More problems

7 views
Skip to first unread message

Iceman_5

unread,
Dec 8, 2009, 11:45:46 AM12/8/09
to PyDy
Hi to all!
I continue to try make progresses but it's difficult. After solving
the problem with the generalized coordinates, now I get the next
error:

Traceback (most recent call last):
File "motor.py", line 39, in <module>
kanes_eqns = N.form_kanes_equations()
File "/home/alberto/Documentos/ENGLOBE_Stirling/python/pydy.py",
line 1904, in form_kanes_equations
self.frstar(subs_dict=subs_dict)
File "/home/alberto/Documentos/ENGLOBE_Stirling/python/pydy.py",
line 1736, in frstar
self.recursive_frstar(self.O, subs_dict=subs_dict)
File "/home/alberto/Documentos/ENGLOBE_Stirling/python/pydy.py",
line 1832, in recursive_frstar
self.recursive_frstar(child, subs_dict=subs_dict)
File "/home/alberto/Documentos/ENGLOBE_Stirling/python/pydy.py",
line 1771, in recursive_frstar
acc = PorF.abs_acc
AttributeError: 'Point' object has no attribute 'abs_acc'

I don't understand the problem. I have to calculate the acceleration
of the important points manually?
Here is my code:

from sympy import *

from pydy import *



# Create a Newtonian reference frame

N = NewtonianReferenceFrame('N')



# Declare parameters, coordinates, and speeds

R, l4, l6, Ixc, Iyc, Izc, Jxyc, Jxzc, Jyzc, Ixd, Iyd, Izd, Jyzd, mc,
md, lgd, betta, F=\

N.declare_parameters('R l4 l6 Ixc Iyc Izc Jxyc Jxzc Jyzc Ixd Iyd Izd
Jyzd mc md lgd betta F')

(q1,),(qd1,) = N.declare_coords('q', 1)

(u1,),(ud1,) = N.declare_speeds('u', 1)



# Orient the three rigid bodies, assign inertias

#Definimos el solido cigüeñal

C = N.rotate("C", 2, q1, I=(Ixc, Iyc, Izc, Jxyc, Jyzc, Jxzc))

#Definimos un sistema de referencia auxiliar en el cigueñal
correspondiente al brazo girado

Caux = N.rotate("Caux", 2, q1+betta)

#Definimos el solido disco 1

D1 = N.rotate('D1', 2, -q1, I=(Ixd, Iyd, Izd, 0, Jyzd, 0))

#Definimos el solido disco 2

D2aux=N.rotate('D2aux', 3, pi)

D2 = D2aux.rotate('D2', 2, -q1-betta, I=(Ixd, Iyd, Izd, 0, Jyzd, 0))



#locate mass centers and assign masses

CG = N.O.locate('CG', 0, C, mc)

D1G= CG.locate('D1G', (-l6/2-l4+lgd)*C[2] + (R/2)*C[3], D1, md)

D2G= CG.locate('D2G', (l6/2+l4-lgd)*Caux[2] + (R/2)*Caux[3], D2, md)



#locate the force application points P and P2

P= D1G.locate('P', -lgd*D1[2] + (R/2)*D1[3], D1, force=F*cos(q1)*N[3])

P2= D2G.locate('P2', -lgd*D2[2] + (R/2)*D2[3], D2, force=-F*sin(q1)*N
[3])

# Define generalized speeds
u_defs = N.define_speeds([Eq(u1, dot(C.ang_vel(), C[2]))])
print u_defs

kanes_eqns = N.form_kanes_equations()
print kanes_eqns

Luke

unread,
Dec 8, 2009, 1:11:26 PM12/8/09
to PyDy
Alberto,
Yes, currently you need to calculate the acceleration of all
important points (points which have mass associated with them). The
same is true for computing the angular acceleration of Reference
Frames which have inertia associated with them. I would recommend
following the rolling torus example, lines 82-89 of rollingtorus.py
illustrate exactly how PyDy needs things to be entered in order for
the .form_kanes_equations() method to work properly.

Here is the link to that file on the github:
http://github.com/hazelnusse/pydy/blob/master/examples/rollingtorus/rollingtorus.py

I played around with having PyDy automatically calculate
accelerations, but ran into some troubles and decided it was better
for the user to be able to have more control than to try to make
everything happen automatically. If it could be implemented in a way
that works reliably and consistently, I'd be up for changing it so the
user doesn't have to manually declare all these things. Having to
manually do it does introduce the risk of a typo or some other error,
but it also forces you to know *exactly* what is needed in order to
form the equations of motion, so there is a trade-off.

~Luke

Iceman_5

unread,
Dec 8, 2009, 2:34:39 PM12/8/09
to PyDy
Ok, I'm understand it.
But, you can use the implemented functions to get the velocities and
after that get the acceleration with the function dt?
For example, I could make something like:

P.abs_vel=P.vel()
P.abs_acc=dt(P.abs_vel, N)

That could work or not?

On 8 dic, 19:11, Luke <hazelnu...@gmail.com> wrote:
> Alberto,
>   Yes, currently you need to calculate the acceleration of all
> important points (points which have mass associated with them).  The
> same is true for computing the angular acceleration of Reference
> Frames which have inertia associated with them.  I would recommend
> following the rolling torus example, lines 82-89 of rollingtorus.py
> illustrate exactly how PyDy needs things to be entered in order for
> the .form_kanes_equations() method to work properly.
>
> Here is the link to that file on the github:http://github.com/hazelnusse/pydy/blob/master/examples/rollingtorus/r...

Luke

unread,
Dec 8, 2009, 6:50:45 PM12/8/09
to PyDy
Alberto,
More or less, yes. The requirement, however, is that the velocity
and angular velocity expressions be expressed using the generalized
speeds (the u's), but not have the time derivative of the coordinates
in those expressions. Instead of what you wrote above, you should do:

P.abs_vel = dt(P.rel(N.O), N).subs({qd1: u1})
P.abs_acc = dt(P.abs_vel, N)

The first statement forms the position of the point P, relative to the
point N.O (the inertial origin), then takes the time derivative of
that position vector relative to the inertial frame N, and then
substitutes any occurrence of qd1 with u1. This substitution is
implying that you are using the standard definition for the
generalized speed:
u1 = d/dt (q1)

This is the typical definition you would introduce when you convert a
single 2nd order differential equations to two first order
differential equations.

The second statement then simply takes the derivative of the absolute
velocity relative to the inertial frame N, which gives the absolute
acceleration.

If you haven't heard of these things called generalized speeds and
want to better understand them, I would recommend looking at the
Dynamics book by Kane that I have posted on the main pydy.org page, it
has a good description of them.

Hope this helps,
~Luke

Iceman_5

unread,
Dec 15, 2009, 11:56:47 AM12/15/09
to PyDy
And what happens when the generalized speeds differ from u1 = d/dt
(q1)? Because in that case is not easy to create a dictionary to make
the substitutions.

Luke

unread,
Dec 18, 2009, 3:16:04 AM12/18/09
to PyDy
In that case, typically all of the u's will be defined to be linear
combinations of the d/dt (q). Solving this linear system for all the
d/dt (q_i) in terms of the u_i's gives the 'kinematic' differential
equations. If you look at the rolling disc example, you will see this
-- the u's are defined to be the components, in the leaned frame of
the disc, of the angular velocity of the disc relative to the inertial
frame.

The advantage to doing it this way is that you often obtain much
simpler dynamic equations at the expense of marginally more
complicated kinematic equations.

~Luke

Reply all
Reply to author
Forward
0 new messages