I think i've got it now:

import visual as v

from math import sin, cos, pi, sqrt

m = 2.1 # mass of mass in kg

r = 5 # radius of circle in m

g = 9.80665 # accel due to gravity

t = 0 # initial t is 0

dt = 0.0001 # time increment

v_max = sqrt(2*r*g) # max velocity

rate = 2500

scene = v.display(title='Mass Sliding Down a Smooth Curve',

width=600,

height=600,

center=(-2.5,2.5),

uniform=1,

range=4,

userzoom = 0,

userspin = 0)

''' Curve radius extended by radius of curve-frame + radius of ball

so that the ball slides along the curve, not through it :P '''

mass_radius = 0.1

curve_radius = 5 + mass_radius

vect_length = 1 # so mg is 1 vect_length

legend_mass = v.sphere(pos=(-1,4.5),

radius=mass_radius,

color=v.color.red)

mass_label = v.label(pos=legend_mass.pos,

text='Mass, 2.1kg', xoffset=-20,

yoffset=12, space=0.1,

height=10, border=6,

font='sans')

legend_mg = v.arrow(pos=legend_mass.pos,

axis=(0,-1),

shaftwidth=0.05,

color=v.color.green)

mg_label = v.label(pos=legend_mass.pos+(legend_mg.axis/2),

text='Force due to gravity', xoffset=-20,

yoffset=12, space=0.1,

height=10, border=6,

font='sans')

legend_radial = v.arrow(pos=legend_mass.pos,

axis=(0.5,0.5),

shaftwidth=0.05,

color=v.color.yellow)

radial_label = v.label(pos=legend_mass.pos+(legend_radial.axis/2),

text='Radial Force', xoffset=-36,

yoffset=32, space=0.1,

height=10, border=6,

font='sans')

legend_transverse = v.arrow(pos=legend_mass.pos,

axis=(0.25,-0.25),

shaftwidth=0.05,

color=v.color.blue)

transverse_label = v.label(pos=legend_mass.pos+(legend_transverse.axis/2),

text='Transverse Force', xoffset=30,

yoffset=12, space=0.1,

height=10, border=6,

font='sans')

xystart_label = v.label(pos=(-5.1,5),

text='(-5,5)', xoffset=-20,

yoffset=0, space=0.1,

height=10, border=6,

font='sans')

xyend_label = v.label(pos=(0,-0.1),

text='(0,0)', xoffset=-0.1,

yoffset=-20, space=0.1,

height=10, border=6,

font='sans')

start_label = v.text(pos=(-2.5,2.5),

text='Click to\nStart', align='center', font='sans', depth = 0.1, width = 1)

# makes a quarter circle radius 5 from (-5,5) to (0,0) centre (0,5)

curve_angle = v.arange(pi,

3*pi/2,

0.0001)

curve = v.curve(x = curve_radius * v.cos(curve_angle),

y = curve_radius * v.sin(curve_angle) + 5,

z = 0,

radius=0)

curve2 = v.curve(x = v.arange(0,10,1),

y = -0.1,

z = 0,

radius=0)

# ball starts at -5,5

mass = v.sphere(pos=(-5,5),

radius=mass_radius,

color=v.color.red)

mg = v.arrow(pos=mass.pos,

axis=-vect_length*(v.vector(0,1)),

shaftwidth=0.05,

color=v.color.green)

radial = v.arrow(pos=mass.pos,

axis=(0,0),

shaftwidth=0.05,

color=v.color.yellow)

transverse = v.arrow(pos=mass.pos,

axis=(0,0),

shaftwidth=0.05,

color=v.color.blue)

def rk4(t0, h, s0, f):

# From http://doswa.com/blog/2009/04/21/improved-rk4-implementation/

'''RK4 implementation.

t = current value of the independent variable

h = amount to increase the independent variable (step size)

s0 = initial state as a list. ex.: [initial_position, initial_velocity]

f = function(state, t) to integrate'''

r = range(len(s0))

s1 = s0 + [f(t0, s0)]

s2 = [s0[i] + 0.5*s1[i+1]*h for i in r]

s2 += [f(t0+0.5*h, s2)]

s3 = [s0[i] + 0.5*s2[i+1]*h for i in r]

s3 += [f(t0+0.5*h, s3)]

s4 = [s0[i] + s3[i+1]*h for i in r]

s4 += [f(t0+h, s4)]

return t+h, [s0[i] + (s1[i+1] + 2*(s2[i+1]+s3[i+1]) + s4[i+1])*h/6.0 for i in r]

def pendulum_angular_accel(t,s):

''' theta' = omega

omega' = theta'' = -g/R sin(theta) = alpha '''

theta = s[0]

''' angle at time t = s[0]

omega at time t = s[1]

alpha at time t = (-g/R)*sin(s[0]) '''

g = 9.80665

R = 5

return (-g/R)*sin(theta)

x = -5

y = 5

s = [-pi/2, 0] # initial angle measured from the line x=0

# and initial angular velocity '''

#f = open('csv.csv', 'w')

#f.write("t,phi,omega,alpha,x,y\n")

# While

while True:

if scene.mouse.clicked:

start_label.visible=False

while (x <= 0): # phi <= pi/2

v.rate(rate)

# alpha + (-g/5)*sin(s[0]) # uncomment if you want to calculate angular accelerarion

phi = s[0]+pi/2 # angle from the line y=5 to the mass

x = -5*cos(phi)

y = 5-5*sin(phi)

# move mass and force arrows to new location

mass.pos = v.vector(x,y)

radial.pos = mass.pos

transverse.pos = mass.pos

mg.pos = mass.pos

# calculate forces

rhat = v.norm(v.vector(-x/25, (5-y)/25))

radial_max = ((m*v_max**2)/r)+(m*g) # max radial force

radial.axis = (vect_length/radial_max)*(((m*r*s[1]**2)+(m*g*cos(s[0])))*rhat)

thetahat = v.norm(v.vector(radial.axis.y,-radial.axis.x)) # theta hat is at right angles to radial

transverse.axis = (vect_length/(2*m*g))*(-(m*g*sin(s[0]))*thetahat)

t, s = rk4(t, dt, s, pendulum_angular_accel)

curve_t = t

while (mass.pos.x <= 1.6):

v.rate(rate)

#speed = distance/time

#distance = speed * time

mass.pos = mass.pos + v.vector(5*s[1]*dt,0)

radial.pos = mass.pos

transverse.pos = mass.pos

mg.pos = mass.pos

t += dt

break

print "Final velocity from model:"

print " r*omega = v = ", str(5*s[1]), "m/s"

print "Final velocity using conservation of energy:"

print " sqrt(2*g*h) = v = ", str(v_max), "m/s"

print "Total time to travel down the curve:"

print "t = ", str(curve_t), "s"

compile it using python (32bit) and vpython