including external forces with KanesMethod of LagrangesMethod

33 views
Skip to first unread message

Kevin Bockstael

unread,
Apr 22, 2014, 4:11:39 AM4/22/14
to sy...@googlegroups.com

Hi

I would like to include a periodic external force into a multiple mass damper-system. My first thought was to include it in the forcelist (using KanesMethod)
which would then become something like in the code below. (where b is the frequency of the periodic force)
This however, returns an error whenever i want to integrate the dynamical equations.
Does anyone know how to include the external force f(t) = sin(b*t), so i can integrate the dynamical equations? 

Thanks

q1,u1,q2,u2 = dynamicsymbols('q1 u1 q2 u2')
q1d, q2d = dynamicsymbols('q1 q2',1)
m1,c1,k1, m2,c2,k2, g,t,b = symbols('m1 c1 k1 m2 c2 k2 g t b')
N = ReferenceFrame('N')
O=Point('O')
O.set_vel(N,0)
P = Point('P')
P.set_vel(N,-u1*N.y)
Q=Point('Q')
Q.set_vel(N,-(u2+u1)*N.y)
kd=[q1d-u1,q2d-u2]
FL = [(P,(2*k1*q1-k1*q2+c1*u1)*N.y),(Q,((k1+k2)*q2-k1*q1+c2*u2+sin(b*t))*N.y)]

Jason Moore

unread,
Apr 22, 2014, 8:00:57 AM4/22/14
to sy...@googlegroups.com
Kevin,

You are correct, you should include the force, sin(b*t), in the force list. Then KanesMethod, for example will give you:

Mx' = f(x, t)

The force, sin(b*t), will be explicitly in the f(x, t) portion. You can then think of it as:

Mx' = f_(x) + u(t)

where u(t) = sin(b * t)

Then when you want to integrate the equations you must make sure that t is available for the ode right hand side.

def rhs(x, t, ...)

return solve(M, f_(x) + u(t))

Something like that. If you show a more complete piece of code that I can run, then I can give you more specific advice.

--
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+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/b1b1fd3f-196f-4151-a3c1-c94e82ef18c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason Moore

unread,
Apr 22, 2014, 3:38:06 PM4/22/14
to sy...@googlegroups.com
Kevin,

Here is another example of doing that:

https://github.com/pydy/pydy#usage-1

Kevin Bockstael

unread,
Apr 23, 2014, 7:49:49 AM4/23/14
to sy...@googlegroups.com
Jason,

The problem was indeed that 't' was not available as a variable for odeint. 

Thanks a lot!



Op dinsdag 22 april 2014 21:38:06 UTC+2 schreef Jason Moore:

Jason Moore

unread,
Apr 23, 2014, 9:24:04 AM4/23/14
to sy...@googlegroups.com
Great! If you get a nice example problem working, we'd love to have it added to the examples directory in the pydy repository. It will help others with issues like this.
Reply all
Reply to author
Forward
0 new messages