I've done it!!!!
but using python + vpython
All i need to do now is how to display the forces.
I think i need them in vector form with magnitude and direction.
Would you be able to help please?
[code]import visual as v
from math import sin, cos, pi, sqrt
from sys import *
''' Curve radius extended by radius of curve-frame + radius of ball
so that the ball slides along the curve, not through it :P '''
r = 5 + 0.1
t = v.arange(pi, 3*pi/2, 0.0001)
c = v.curve(x = r * v.cos(t), y = r * v.sin(t) + 5, z = 0, radius=0)
# ball starts at -5,5
mass = v.sphere(pos=(-5,5), radius=0.1, color=v.color.red)
def rk4(t0, h, s0, f):
# From http://doswa.com/blog/2009/04/21/improved-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]
''' theta' = omega
omega' = theta'' = -g/R sin(theta) = angular acceleration '''
theta = s
''' angle at time t = s
omega at time t = s
alpha at time t = (-g/R)*sin(s) '''
g = 9.80665
R = 5
g = 9.80665 # accel due to gravity
t = 0 # initial t is 0
h = 0.0001 # dt
s = [3*pi/2, 0] # initial position and initial angular velocity
while (s <= 2*pi): # phi <= pi/2
alpha = (-g/5)*sin(s)
phi = s-3*pi/2
x = -5*cos(phi)
y = 5-5*sin(phi)
mass.pos = v.vector(x,y)
t, s = rk4(t, h, s, pendulum_angular_accel)
print "Final velocity: r*omega = v = ", str(5*s), "m/s"
print "Final velocity: sqrt(2*g*h) = v = ", str(sqrt(10*g)), "m/s"
print "Total travel time: t = ", str(t), "s"[/code]