In [1]:
#from sage.all import *
from numpy import *
from sympy import *
from __future__ import division
init_printing()
#v0 is v_i-1
#v is v_i
#phi is in radians
d_theta = .01
g = 9.81
r = 4
v_0, m, phi, mu, k = var('v_0 m phi mu k')
In [2]:
def wt(m, g, phi):
"""Calculate the weight force in the tangent direction."""
w = m*g*cos(phi)
return w
def wn(m,g,phi):
"""Calculate the weight force in the normal direction"""
w = m*g*sin(phi)
return w
def B(phi):
"""The angle beta, in terms of phi"""
b = atan( (2+4*cos(phi))/(4*sin(phi)) ) - ((pi/2)-phi)
return b
def Fsn(phi,k,B):
"""The force of the spring in the normal direction"""
f = k*cos(B(phi))*( sqrt(20+16*cos(phi)) - sqrt(20) )
return f
def Fst(phi,k,B):
"""The force of the spring in the tangent direction"""
f = k*sin(B(phi))*( sqrt(20+16*cos(phi)) - sqrt(20) )
return f
In [3]:
v = sqrt( (wt(m,g,phi)-(m*v_0**2)/(2*r*d_theta)+mu*(Fsn(phi,k,B)-wn(m,g,phi)-Fst(phi,k,B)))/((m*mu)/(r)-(m)/(2*r*d_theta)) )
v
Out[3]:
In [4]:
yodog = v.subs(k,100)
yodog = yodog.subs(m,15).subs(phi,90).subs(v_0,15).subs(mu,0)
print '%.6f' %yodog
In [5]:
v0 = 15
theta = pi/2
v = v.subs(k,500).subs(m,15).subs(mu,.25)
while theta > 0:
v0 = v.subs(phi,theta).subs(v_0,v0)
theta=theta-d_theta
In [6]:
print "%.10f" %v0
In [7]:
v0 = 15
theta = pi/2
while theta > 0:
v0 = v.subs(k,1000).subs(m,15).subs(phi,theta).subs(v_0,v0).subs(mu,.25)
theta=theta-d_theta
In [8]:
print "%.10f" %v0
In [8]: