sympyderivativekinematicscontinuity

SymPy dynamicsymbols, how to set the second derivative to vanish?


enter image description here

N is the inertial reference frame, the telescopic arm is extending along N.x at a constant rate. The disk is spinning with a constant angular velocity theta_dot. I need to find the expression for the inertial acceleration of point P. The problem is I don't know how to set the second derivatives of L and theta to vanish. Now I have to manually simplify the expressions by setting double derivative terms of L and theta to zero. Is there a way to constrain the continuity of dynamicsymbols. Any help is appreciated. TIA

My Code:

import sympy as sym
sym.init_printing(use_latex='mathjax')
from sympy.physics.vector import *
init_vprinting(use_latex='mathjax')

N =  ReferenceFrame('N')
E =  ReferenceFrame('E')

th = dynamicsymbols('theta')
L = dynamicsymbols('L')
t = sym.symbols('t')
r = sym.symbols('r')
p = sym.symbols('p')

E.orient_axis(N, N.z, th)

p = L * N.x + r*E.x
p_vel = p.diff(t,N)
p_acc = p_vel.diff(t,N)
p_acc.simplify()

The output is : enter image description here


Solution

  • One way is to declare the second derivative of these symbols, then create a substitution dictionary and apply it to your expression:

    import sympy as sym
    sym.init_printing(use_latex='mathjax')
    from sympy.physics.vector import *
    init_vprinting(use_latex='mathjax')
    
    N =  ReferenceFrame('N')
    E =  ReferenceFrame('E')
    
    th = dynamicsymbols('theta')
    L = dynamicsymbols('L')
    t = sym.symbols('t')
    r = sym.symbols('r')
    p = sym.symbols('p')
    
    # create second derivatives of L and theta
    Ldd, thdd = dynamicsymbols("L theta", 2)
    # create a substitution dictionary
    subs_dict = {
        Ldd: 0,
        thdd: 0
    }
    
    E.orient_axis(N, N.z, th)
    
    p = L * N.x + r*E.x
    p_vel = p.diff(t,N)
    p_acc = p_vel.diff(t,N)
    p_acc = p_acc.simplify()
    # apply the substitution dictionary
    p_acc.subs(subs_dict)