I am new to using SymPy mechanics and hope to use it extensively for my work. However, I am having trouble understanding some of the basics of the notation. Therefore, I have tried to create a simple example to validate if I implemented things correctly in the framework.
Unfortunately, however, I was not able to validate the equations. I completely recognize that this may be due to my ignorance of the toolbox, but I want to get a second opinion.
Could someone look at this code and let me know if there is an issue with my implementation?
# %%
# import
import sympy as sp
import sympy.physics.mechanics as sm
# %%
# define the symbols
q,u,f = sm.dynamicsymbols("x,xd,f") # position and velocity
m,k,l = sp.symbols("m,k,l") # physical parameters
# %%
# define the inertial frame
F_Inertia = sm.ReferenceFrame("F_I")
P_Origin = sm.Point("P_O")
P_Origin.set_vel(F_Inertia,0) # set the relative velocity of the point to frame as zero
# %%
# define the bodies
P_M = sm.Point("P_M")
# %%
# define the position vectors
r_F_M = q * F_Inertia.z
# set the positions of each body
P_M.set_pos(P_Origin, r_F_M)
# set the velocity of this point
P_M.set_vel(F_Inertia,u * F_Inertia.z)
# %%
# define the particle
p1 = sm.Particle("p1",P_M,m)
# %%
# apply the driving load
L_f = (P_M,f*F_Inertia.z)
# create force list
flist = [L_f]
# %%
# form lagrangian
T = sm.kinetic_energy(F_Inertia,p1)
V = -1/2*k*r_F_M.dot(r_F_M)
L = T - V
L
# %%
# compute EOMs
LM = sm.LagrangesMethod(L,[q,u],forcelist=flist,frame=F_Inertia)
LM.form_lagranges_equations()
# %%
LM.mass_matrix
# %%
LM.forcing
# %% [markdown]
# Putting these outputs together, SymPy gives us the following equations of motion (based on the [structure of equations](https://docs.sympy.org/latest/modules/physics/mechanics/lagrange.html#structure-of-equations))
# $$
# begin{split}
# 0 &= k x(t) \
# 0 & = m dot{x}(t)
# end{split}
# $$
# %% [markdown]
# # Validation
# The above equations do not match the appropriate equations provided in the beginning. Therefore, the validation failed.