Most welcome! On Mon 4. Apr 2022 at 15:45, n doherty <[email protected]> wrote:
> Thanks very much Peter - that worked > > On Monday, 4 April 2022 at 14:33:22 UTC+1 [email protected] wrote: > >> In addition, you probably have a typo in this: >> >> P1.set_ang_vel(A, omega1 * A.z) >> P2.set_ang_vel(P1, omega*1* * P1.z) >> >> It should probably be >> >> P2.set_ang_vel(P1, omega*2* * P1.z) >> >> With this change, it would calculate some rhs, like: >> >> rhs = kanes.rhs() >> >> Peter >> >> >> On Mon 4. Apr 2022 at 15:25 Peter Stahlecker <[email protected]> >> wrote: >> >>> Your loads were incorrect: >>> >>> Try this: >>> >>> loads = [ (p1, F_grav_1), (p2, F_grav_2) ] >>> >>> When I changed this in your program, it worked, or at least there was no >>> error. >>> >>> You have to give the points where the forces ‚attack‘, as tuples. >>> Otherwise, hwo would sympy.physics.mechanics ‚know‘, where the forces act? >>> >>> Peter >>> >>> On Mon 4. Apr 2022 at 14:57 n doherty <[email protected]> wrote: >>> >> Thanks very much Peter. >>>> >>>> I hope I'm not making an error but would welcome you finding one if I >>>> am. I'm getting the same error in tutorial examples so suspect it's an >>>> error with a new version of sympy or python, or something specific to my >>>> setup. I'm using python 3.8 and sympy 1.8. I get the same error on 2 >>>> different machines although the same versions of sympy/python. >>>> >>>> Code is below. It's when executing the final line that the error comes >>>> up - everything else is fine. Thanks again. >>>> _____________________________________ >>>> import sympy as sm >>>> import sympy.physics.mechanics as me >>>> >>>> ## REFERENCE FRAMES >>>> >>>> A = me.ReferenceFrame("A") # earth reference frame >>>> P1 = me.ReferenceFrame("P1") # 1st pendulum arm reference frame >>>> P2 = me.ReferenceFrame("P2") # 2nd pendulum arm reference frame >>>> >>>> ## ORIENTATION >>>> >>>> theta1, theta2 = me.dynamicsymbols("theta1 theta2") # generalised >>>> coordinates >>>> >>>> P1.orient(A, "Axis", (theta1, A.z)) >>>> P2.orient(P1, "Axis", (theta2, P1.z)) >>>> >>>> ## KINEMATICS >>>> ### Points and Locations >>>> >>>> m1, m2, L1, L2 = sm.symbols("m1 m2 L1 L2") >>>> >>>> O = me.Point("O") >>>> p1 = me.Point("p1") >>>> p2 = me.Point("p2") >>>> >>>> p1.set_pos(O, L1 * P1.x) >>>> p2.set_pos(p1, L2 * P2.x) >>>> >>>> >>>> ### Kinematical Differential Equations >>>> >>>> omega1, omega2 = me.dynamicsymbols("omega1 omega2") >>>> >>>> kinematical_differential_equations = [omega1 - theta1.diff(), >>>> omega2 - theta2.diff()] >>>> >>>> >>>> ### Angular Velocities >>>> >>>> P1.set_ang_vel(A, omega1 * A.z) >>>> P2.set_ang_vel(P1, omega1 * P1.z) >>>> >>>> >>>> >>>> ### Linear Velocities >>>> >>>> O.set_vel(A, 0) # point O has zero velocity >>>> >>>> p1.v2pt_theory(O, A, P1) >>>> p2.v2pt_theory(p1, A, P2) >>>> >>>> >>>> ## KINETICS >>>> >>>> g = sm.symbols("g") >>>> >>>> F_grav_1 = m1 * g * A.x >>>> F_grav_2 = m2 * g * A.x >>>> >>>> B1 = me.Particle("B1", p1, m1) >>>> B2 = me.Particle("B2", p2, m2) >>>> >>>> >>>> ## EQUATIONS OF MOTION >>>> >>>> coordinates = [theta1, theta2] >>>> speeds = [omega1, omega2] >>>> loads = [F_grav_1, F_grav_2] >>>> bodies = [B1, B2] >>>> >>>> >>>> ### Kane's Method >>>> >>>> kane = me.KanesMethod(A, coordinates, speeds, >>>> kinematical_differential_equations) >>>> >>>> fr, frstar = kane.kanes_equations(loads, bodies) >>>> >>>> _________________________________________ >>>> >>>> On Monday, 4 April 2022 at 12:12:29 UTC+1 [email protected] wrote: >>>> >>>>> I have done all sorts of pendulae, single, double, triple..... >>>>> If you could send your code, maybe I could find a mistake. >>>>> Peter >>>>> >>>>> On Mon 4. Apr 2022 at 13:00, n doherty <[email protected]> wrote: >>>>> >>>>>> Hi, >>>>>> Looking for some help if possible. I was recently trying to get the >>>>>> equations of motion of a double pendulum via SymPy. When I used >>>>>> "kanes_equations" to obtain Fr and Fr* I got the above TypeError message. >>>>>> >>>>>> I have the loads and the bodies contained in lists which are input >>>>>> into the kanes_equation method, which I think is causing the problem >>>>>> here? >>>>>> If I apply the method for a single pendulum with a single body (not >>>>>> contained in a list or array) kanes_equations works fine. >>>>>> >>>>>> I suspect it's a newer version of sympy or python which is causing >>>>>> the issue. If I try to perform the same method on the human standing >>>>>> tutorial I get the same error but for the bodies being RigidBody instead >>>>>> of >>>>>> Particle. I've run this tutorial and numerous other examples in the past >>>>>> without this error occurring. >>>>>> >>>>>> Is there a known workaround to this issue? >>>>>> >>>>>> Thanks, >>>>>> Nick >>>>>> >>>>>> -- >>>>>> 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 [email protected]. >>>>>> To view this discussion on the web visit >>>>>> https://groups.google.com/d/msgid/sympy/0a4cea0a-8050-4765-873f-7a0a0857b606n%40googlegroups.com >>>>>> <https://groups.google.com/d/msgid/sympy/0a4cea0a-8050-4765-873f-7a0a0857b606n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>> . >>>>>> >>>>> -- >>>>> Best regards, >>>>> >>>>> Peter Stahlecker >>>>> >>>> -- >>>> 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 [email protected]. >>>> >>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/sympy/15ac5e54-8a4f-4ffc-83c7-24d6c21c94f3n%40googlegroups.com >>>> <https://groups.google.com/d/msgid/sympy/15ac5e54-8a4f-4ffc-83c7-24d6c21c94f3n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- >>> Best regards, >>> >>> Peter Stahlecker >>> >> -- >> Best regards, >> >> Peter Stahlecker >> > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/baac9f4b-fd32-4335-a692-6b12b84c9e85n%40googlegroups.com > <https://groups.google.com/d/msgid/sympy/baac9f4b-fd32-4335-a692-6b12b84c9e85n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Best regards, Peter Stahlecker -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CABKqA0ZXMOSySjEbFe1MDZwC3dXxpnjMo3uPMX8SZEB5hOXucQ%40mail.gmail.com.
