What follows is a short rundown of the commands used in PyDy. All commands that
you would type in an interactive session are preceded by ‘’>>> ‘’. This imports all of the classes and functions in the ‘’SymPy’’ package. Now we
can do some symbolic math: This creates 3 symbols, x, y, and z, and illustrates how to form a SymPy
expression and take its derivative. What follows is a list of objects you can create, and functions you can run.
The first step is to import the functions and classes related to mechanics: Here is a list of classes: ReferenceFrame Point Vector - not created directly Dyadic - not created directly Particle RigidBody KanesMethod You can call ‘’help(class)’’ to see the help entry for ‘’class’’. For example,
‘’help(ReferenceFrame)’’ to see the help entry for ‘’ReferenceFrame’’. Here are some brief usage examples of common functions and classes. Creates two time varying symbols, ‘’q1’’ and ‘’q2’’ This creates a new reference frame named N. Access to the ‘’x’’ basis vector in the ‘’N’’ reference frame Creates a new vector, ‘’a’’, which is the sum of the ‘’x’’ and ‘’y’’ basis
vectors in the ‘’N’’ reference frame. Creates a point named P. FIXME Creates a new ‘’KanesMethod’’ object, used to generate \(F_r +
F_r^*\), with ‘’N’’ as the inertial reference frame. Creates a rigid body container and defines the center of mass location, the
body fixed frame, the mass and the inertia. Creates a new particle container. Here is a list of functions: mprint inertia mprint mpprint mlatex cross dot outer kinematic equations On each of them, you can call ‘’help(function)’’ to see the help entry for
‘’function’’. For example, ‘’help(inertia)’’ will describe what the ‘’inertia’’
function is and how to use it. Sets the default printing to use the mechanics printing. Prints ‘’q1’’ using the mechanics printer; use if mechanics_printing is not on. Creates an inertia dyadic in the frame N with principle measure numbers of 1,
2, and 3. Prints out kinematic differential equations which relate the body fixed angular
velocity measure numbers ‘’u1, u2, u3’’ to the time derivatives of the
coordinates ‘’q1, q2, q3’’, assuming a 313 (ZXZ) body fixed rotations.Commands¶
SymPy Commands¶
>>> from sympy import *
>>> x, y, z = symbols('x y z')
>>> e = x**2 + y**2 + z**2
>>> print(e)
x**2 + y**2 + z**2
>>> diff(e, x)
2*x
Mechanics commands¶
>>> from sympy.physics.mechanics import *
Classes¶
Code Snippets¶
>>> q1, q2 = dynamicsymbols('q1 q2')
>>> N = ReferenceFrame('N')
>>> N.x
>>> a = N.x + N.y
>>> P = Point('P')
>>> K = KanesMethod(N)
>>> D = RigidBody('BodyD', masscenter=P, frame=N, mass=2, inertia=I)
>>> Par = Particle()
Functions¶
Code Snippets¶
>>> mechanics_printing()
>>> mprint(q1)
>>> I = inertia(N, 1, 2, 3)
>>> mprint(kinematic_equations([u1,u2,u3], [q1,q2,q3], 'body', '313'))