Add acceleration to a simple pendulum

53 views
Skip to first unread message

Raphael Timbó

unread,
Aug 30, 2016, 7:29:28 PM8/30/16
to PyDy


Hi,

I saw the example for the simple pendulum on pydy's github repository (https://github.com/pydy/pydy/blob/master/examples/simple_pendulum/run.py).

I wanted to go from the simple pendulum shown in figure below case (a) to the pendulum with the acceleration on u2, case(b).

Looking at the code, I thought that the solution was adding acceleration to point 'O':

 (O.set_acc(N, att * N.y)

But this does not seem to work.

Can someone point me in the right direction?


Thank you!




Att,
Raphael

Jason Moore

unread,
Aug 30, 2016, 11:06:54 PM8/30/16
to py...@googlegroups.com
Raphael,

Can you share your code and the resulting equations of motion?

--
You received this message because you are subscribed to the Google Groups "PyDy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pydy+unsubscribe@googlegroups.com.
To post to this group, send email to py...@googlegroups.com.
Visit this group at https://groups.google.com/group/pydy.
For more options, visit https://groups.google.com/d/optout.

Raphael Timbó

unread,
Aug 31, 2016, 4:33:36 PM8/31/16
to py...@googlegroups.com
Hi Jason!
So, I took the code from the example and added the symbol a and the following two lines of code:


# This code requires sympy 1.0 to run
from sympy import *
from sympy.physics.mechanics import LagrangesMethod, Lagrangian
from sympy.physics.mechanics import ReferenceFrame, Particle, Point
from sympy.physics.mechanics import dynamicsymbols
# System state variables
theta = dynamicsymbols('theta')
thetad = dynamicsymbols('theta', 1)
# Other system variables
m, l, g, a = symbols('m l g a')
# Set up the reference frames
# Reference frame A set up in the plane perpendicular to the page containing
# segment OP
N = ReferenceFrame('N')
A = N.orientnew('A', 'Axis', [theta, N.z])
# Set up the points and particles
O = Point('O')
P = O.locatenew('P', l * A.x)
Pa = Particle('Pa', P, m)
# Set up velocities
A.set_ang_vel(N, thetad * N.z)
O.set_vel(N, 0) O.set_acc(N, a * N.y) # ----------------------------------------------------------------> Added line
P.v2pt_theory(O, N, A) P.a2pt_theory(O, N, A) # ----------------------------------------------------------------> Added line
# Set up the lagrangian
L = Lagrangian(N, Pa)
# Create the list of forces acting on the system
fl = [(P, g * m * N.x)]
# Create the equations of motion using lagranges method
l = LagrangesMethod(L, [theta], forcelist=fl, frame=N)
pprint(l.form_lagranges_equations())

As a result I am getting:

Matrix([[g*l*m*sin(theta(t)) + l**2*m*Derivative(theta(t), t, t)]])

Which is the simple pendulum's equation of motion, so nothing has changed (was expecting an extra term - m*a* l*cos𝜃)

I thought that maybe I had to change something with the reference frame, but I could not find a solution.

Thanks for the help!

Att, 
Raphael


--
You received this message because you are subscribed to a topic in the Google Groups "PyDy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pydy/MQOcTJqd1VI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pydy+unsubscribe@googlegroups.com.

To post to this group, send email to py...@googlegroups.com.
Visit this group at https://groups.google.com/group/pydy.
For more options, visit https://groups.google.com/d/optout.



--
Att,
Raphael Timbó
Mechanical Engineer at Petrobras

Jason Moore

unread,
Aug 31, 2016, 5:22:40 PM8/31/16
to py...@googlegroups.com
Lagrange's method uses the velocities of particles and rigidbodies to compute the equations of motion. As it stands you have the velocity of the base set to 0 and the acceleration you set is never used internally in LagrangesMethod.

Raphael Timbó

unread,
Aug 31, 2016, 6:41:52 PM8/31/16
to py...@googlegroups.com
I got it. Thought I could go to the acceleration directly...
Since the acceleration in the problem that I have is (a/2)*t**2, I have set the velocity as 'a*t' and now I am getting the expected result. 

Thank you very much!!!

Raphael Timbó

unread,
Aug 31, 2016, 7:35:21 PM8/31/16
to py...@googlegroups.com
I got it. Thought I could go to the acceleration directly...
Since the displacement in the problem that I have is (a/2)*t**2, I have set the velocity as 'a*t' and now I am getting the expected result. 

Thank you very much!!!

On Wed, Aug 31, 2016 at 6:22 PM, Jason Moore <moore...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages