phi is in radians


In [67]:
from sage.all import *

In [68]:
v_n, v, m, phi, mu, r, k = var('v_n v m phi mu r k')

In [69]:
g = 9.81
d_phi = .001

In [70]:
def wt(m, g, phi):
    w = m*g*cos(phi)
    return w

In [71]:
def wn(m, g, phi):
    w = m*g*sin(phi)
    return w

In [72]:
def B(phi):
    """phi in radians"""
    b = arctan( (2+4*cos(phi))/(4*sin(phi)) ) - ( (pi/2) - phi)
    return b

In [73]:
def Fsn(k, phi, B):
    F = k * ( sqrt(20+16*cos(phi)) - sqrt(20))*cos(B(phi))
    return F

In [74]:
def Fst(k, phi, B):
    F = k * ( sqrt(20+16*cos(phi)) - sqrt(20))*sin(B(phi))
    return F

In [75]:
def frict_fun(m,v,r,wn,Fsn,g):
    fn = ((m*v**2)/r)+wn(m, g, phi)+Fsn(k, phi, B)
    return fn

In [76]:
def topOfFunction(wt, mu, frict_fun, Fst, m, g, phi, v, r, wn, Fsn, k, B):
    top = wt(m,g,phi) - mu*fric_fun(m,v,r,wn,Fsn,g)-Fst(k,phi,B)
    return top

In [110]:
v_fun = v == sqrt(v_n**2 - 2* (topOfFunction(wt,mu,frict_fun,Fst,m,g,phi,v,r,wn,Fsn,k,B)/m)*r*d_phi)

assume(v!=0)

solvedFv = v_fun.solve(v)


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-110-d33391eea40d> in <module>()
      1 v_fun = v == sqrt(v_n**2 - 2* (topOfFunction(wt,mu,frict_fun,Fst,m,g,phi,v,r,wn,Fsn,k,B)/m)*r*d_phi)
      2 
----> 3 assume(v!=0)
      4 
      5 solvedFv = v_fun.solve(v)

/opt/sage/local/lib/python2.7/site-packages/sage/symbolic/assumptions.pyc in assume(*args)
    410         else:
    411             try:
--> 412                 x.assume()
    413             except KeyError:
    414                 raise TypeError, "assume not defined for objects of type '%s'"%type(x)

/opt/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.assume (sage/symbolic/expression.cpp:8848)()

ValueError: Assumption is redundant

In [102]:
print solvedFv


[
v == 1/100*sqrt((100*m*mu*v^2 + 50000*m*v_n^2 + 100*sqrt(16*cos(phi) + 20)*(k*mu*sin(phi + arctan(1/2*(2*cos(phi) + 1)/sin(phi))) - k*cos(phi + arctan(1/2*(2*cos(phi) + 1)/sin(phi))))*r - (200*sqrt(5)*k*mu*sin(phi + arctan(1/2*(2*cos(phi) + 1)/sin(phi))) - 981*m*mu*sin(phi) - 200*sqrt(5)*k*cos(phi + arctan(1/2*(2*cos(phi) + 1)/sin(phi))) + 981*m*cos(phi))*r)/m)*sqrt(1/5)
]

solved Fv is the instatanos velocity in terms of phi and the velocity instataneously before it


In [103]:
type(solvedFv)


Out[103]:
sage.structure.sequence.Sequence_generic

In [104]:
solvedF = solvedFv[0]

In [105]:
type(solvedF)


Out[105]:
sage.symbolic.expression.Expression

In [106]:
solvedF.arguments()


Out[106]:
(k, m, mu, phi, r, v, v_n)

In [107]:
solvedF2 = solvedF.subs(k=20,m=15,mu=.25,r=4,v_n=3)

In [108]:
solvedF2.arguments()


Out[108]:
(phi, v)

In [109]:
print solvedF2.subs(phi=pi/2)


v == 1/100*sqrt(25.0*v^2 - 800/3*(-sin(1/2*pi + arctan(1/2)) + 4*cos(1/2*pi + arctan(1/2)))*sqrt(5) - 266.6666666666667*sqrt(5)*sin(1/2*pi + arctan(1/2)) + 3200/3*sqrt(5)*cos(1/2*pi + arctan(1/2)) + 450981.0)*sqrt(1/5)

In [109]:


In [109]:


In [ ]: