Re: Digest for pydy@googlegroups.com - 1 Message in 1 Topic

3 views
Skip to first unread message

Luke

unread,
Dec 6, 2009, 5:46:32 PM12/6/09
to py...@googlegroups.com
Alberto,
Could you post the rest of your code? From what you show, things
look correct, but my guess is that the way you obtained q1 might not
be correct.
~Luke

On Sun, Dec 6, 2009 at 11:22 AM, <py...@googlegroups.com> wrote:
>   Today's Topic Summary
>
> Group: http://groups.google.com/group/pydy/topics
>
> Starting with PyDy [1 Update]
>
>  Topic: Starting with PyDy
>
> Albertus <icem...@wanadoo.es> Dec 06 12:55AM +0100
>
> Hi to all!
>
> I'm an engineering student from Spain. I'm working in a project (the
> design of an Stirling's engine) and I'm trying to use PyDy to get the
> motion equations to calculate forces, etc.
> I'm very new to Python and also to PyDy.
> I'm trying to define a solid who rotates around the y axis of the
> newtonian reference with this sentence:
>
>
> C = N.rotate("C", 2, q1, I=(Ixc, Iyc, Izc, Jxyc, Jyzc, Jxzc))
>
> But I get an error message:
>
> Traceback (most recent call last):
> File "motor.py", line 17, in <module>
> C = N.rotate("C", 2, q1, I=(Ixc, Iyc, Izc, Jxyc, Jyzc, Jxzc))
> File "/media/AL_USB/Documentos/ENGLOBE_Stirling/python/pydy.py", line
> 1298, in rotate
> length 3")
> NotImplementedError: angle must be a list/tuple
> of length 3
>
>
> What's wrong? I don't understand this error because I have seen in the
> examples a lot of similar expressions.
> I hope you could help me.
>
> Thank You very much.
>
> Alberto
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "PyDy" group.
> To post to this group, send email to py...@googlegroups.com.
> To unsubscribe from this group, send email to
> pydy+uns...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pydy?hl=en.
>

Iceman_5

unread,
Dec 7, 2009, 3:17:59 AM12/7/09
to PyDy
Here is the code:

# coding=utf8



#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('D1G', (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))

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


On 6 dic, 23:46, Luke <hazelnu...@gmail.com> wrote:
> Alberto,
>   Could you post the rest of your code?  From what you show, things
> look correct, but my guess is that the way you obtained q1 might not
> be correct.
> ~Luke
>
> On Sun, Dec 6, 2009 at 11:22 AM,  <py...@googlegroups.com> wrote:
> >   Today's Topic Summary
>
> > Group:http://groups.google.com/group/pydy/topics
>
> > Starting with PyDy [1 Update]
>
> >  Topic: Starting with PyDy
>
> > Albertus <icema...@wanadoo.es> Dec 06 12:55AM +0100

Luke

unread,
Dec 7, 2009, 3:42:25 AM12/7/09
to PyDy
The default behavior of the declare_coords and declare speeds methods
are to return lists. So in the case of a single coordinate (q1) in
your case, this method is returning two lists, each of length 1. This
is useful if you have lots of coordinates and you want to have a
single list which can be used to index each of the generalized
coordinates or generalized speeds (or their time derivatives). If you
change these:

q1, qd1 = N.declare_coords('q', 1)
u1, ud1 = N.declare_speeds('u', 1)

to this:
(q1,), (qd1,) = N.declare_coords('q', 1)
(u1,), (ud1,) = N.declare_speeds('u', 1)

Then, your code should run fine.

I know this seems a little annoying to have to do, but for any system
with 2 or more coordinates, you would just do:
q, qd = N.declare_coords('q', 500)
u, ud = N.declare_speeds('u', 500)

and then you could access the 300th generalized coordinate by:
q[299]
which is easier than having to type out each of the 500 coordinates.

Let me know if this make more sense now.

Thanks,
~Luke
Reply all
Reply to author
Forward
0 new messages