For what it is worth: With *KM.auxiliary_eqs* one gets the forces acting on, say, the point where some multi body system is attached to. I tried to see, if one could also get the forces needed to make a particle move in on predetermined path. In the simple example attached (where the result is obvious), it gives the correct result.
-- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/d81cd643-85ac-47d6-abab-52a41d12a26an%40googlegroups.com.
#!/usr/bin/env python # coding: utf-8 # In[2]: from sympy.physics.mechanics import * import sympy as sm from sympy import symbols, Matrix, solve # simple example to see whether with KM.auxiliary_eqs one can also get the forces needed to move a body # in a predefined way. At least in the example the result is what one would expect. #select body or particle koerper = True # True = body M = ReferenceFrame('M') P0 = Point('P0') P0.set_vel(M, 0) q1, q2, u1, u2 = dynamicsymbols('q1, q2, u1, u2') qd1, qd2 = dynamicsymbols('q1, q2', 1) aux, f1 = dynamicsymbols('aux f1') iXX, iYY, iZZ = symbols('iXX, iYY, iZZ') m, g, l, reibung = symbols('m g l reibung') t = symbols('t') func = sm.Function('func') #This is the 'forced' position of P1 as a function if time. f1 needed to func = sm.S(1) - sm.cos(t) #realise this path is the goal. A = M.orientnew('A', 'Axis', [q1, M.y]) A.set_ang_vel(M, u1*M.y) hilfs = P0.locatenew('hilfs', l*A.x) #needed to get the correct speed of P1 hilfs.v2pt_theory(P0, M, A) P1 = hilfs.locatenew('P1', func*A.x) P1.set_vel(M, hilfs.vel(M) + u2*A.x + aux*A.x) if koerper: I = inertia(A, iXX, iYY, iZZ) P1a = RigidBody('P1a', P1, A, m, (I, P1)) BODY = [P1a] else: P1a = Particle('P1a', P1, m) BODY = [P1a] FL = [(P1, -m*g*M.y -reibung*u2*A.x + f1*A.x)] q = [q1, q2] u = [u1] u_dep = [u2] speed_constr = [u2 - func.diff(t)] kd = [u1 - qd1, u2 - qd2] aux = [aux] KM = KanesMethod(M, q_ind=q, u_ind=u, u_dependent=u_dep, kd_eqs=kd, u_auxiliary=aux, velocity_constraints=speed_constr) fr, frstar = KM.kanes_equations(BODY, FL) MM = KM.mass_matrix_full force = KM.forcing_full print('det(MM) = ', sm.det(MM)) rhs = KM.rhs() eingepraegt = KM.auxiliary_eqs eingepraegt = sm.solve(eingepraegt, f1)[f1].subs({u2.diff(t): rhs[3]}) print('force to ensure given motion of P1:', eingepraegt, '\n') print('rhs:') rhs # In[ ]: