Bodies, Inertias, Loads & Other Functions (Docstrings)

Bodies

class sympy.physics.mechanics.particle.Particle(name, point=None, mass=None)[source]

A particle.

Parameters:

name : str

Name of particle

point : Point

A physics/mechanics Point which represents the position, velocity, and acceleration of this Particle

mass : Sympifyable

A SymPy expression representing the Particle’s mass

potential_energy : Sympifyable

The potential energy of the Particle.

Explanation

Particles have a non-zero mass and lack spatial extension; they take up no space.

Values need to be supplied on initialization, but can be changed later.

Examples

>>> from sympy.physics.mechanics import Particle, Point
>>> from sympy import Symbol
>>> po = Point('po')
>>> m = Symbol('m')
>>> pa = Particle('pa', po, m)
>>> # Or you could change these later
>>> pa.mass = m
>>> pa.point = po
angular_momentum(point, frame)[source]

Angular momentum of the particle about the point.

Parameters:

point : Point

The point about which angular momentum of the particle is desired.

frame : ReferenceFrame

The frame in which angular momentum is desired.

Explanation

The angular momentum H, about some point O of a particle, P, is given by:

H = cross(r, m * v)

where r is the position vector from point O to the particle P, m is the mass of the particle, and v is the velocity of the particle in the inertial frame, N.

Examples

>>> from sympy.physics.mechanics import Particle, Point, ReferenceFrame
>>> from sympy.physics.mechanics import dynamicsymbols
>>> from sympy.physics.vector import init_vprinting
>>> init_vprinting(pretty_print=False)
>>> m, v, r = dynamicsymbols('m v r')
>>> N = ReferenceFrame('N')
>>> O = Point('O')
>>> A = O.locatenew('A', r * N.x)
>>> P = Particle('P', A, m)
>>> P.point.set_vel(N, v * N.y)
>>> P.angular_momentum(O, N)
m*r*v*N.z
kinetic_energy(frame)[source]

Kinetic energy of the particle.

Parameters:

frame : ReferenceFrame

The Particle’s velocity is typically defined with respect to an inertial frame but any relevant frame in which the velocity is known can be supplied.

Explanation

The kinetic energy, T, of a particle, P, is given by:

T = 1/2 (dot(m * v, v))

where m is the mass of particle P, and v is the velocity of the particle in the supplied ReferenceFrame.

Examples

>>> from sympy.physics.mechanics import Particle, Point, ReferenceFrame
>>> from sympy import symbols
>>> m, v, r = symbols('m v r')
>>> N = ReferenceFrame('N')
>>> O = Point('O')
>>> P = Particle('P', O, m)
>>> P.point.set_vel(N, v * N.y)
>>> P.kinetic_energy(N)
m*v**2/2
linear_momentum(frame)[source]

Linear momentum of the particle.

Parameters:

frame : ReferenceFrame

The frame in which linear momentum is desired.

Explanation

The linear momentum L, of a particle P, with respect to frame N is given by:

L = m * v

where m is the mass of the particle, and v is the velocity of the particle in the frame N.

Examples

>>> from sympy.physics.mechanics import Particle, Point, ReferenceFrame
>>> from sympy.physics.mechanics import dynamicsymbols
>>> from sympy.physics.vector import init_vprinting
>>> init_vprinting(pretty_print=False)
>>> m, v = dynamicsymbols('m v')
>>> N = ReferenceFrame('N')
>>> P = Point('P')
>>> A = Particle('A', P, m)
>>> P.set_vel(N, v * N.x)
>>> A.linear_momentum(N)
m*v*N.x
property mass

The body’s mass.

property masscenter

The body’s center of mass.

property name

The name of the body.

parallel_axis(point, frame)[source]

Returns an inertia dyadic of the particle with respect to another point and frame.

Parameters:

point : sympy.physics.vector.Point

The point to express the inertia dyadic about.

frame : sympy.physics.vector.ReferenceFrame

The reference frame used to construct the dyadic.

Returns:

inertia : sympy.physics.vector.Dyadic

The inertia dyadic of the particle expressed about the provided point and frame.

property point

The body’s center of mass.

property potential_energy

The potential energy of the body.

Examples

>>> from sympy.physics.mechanics import Particle, Point
>>> from sympy import symbols
>>> m, g, h = symbols('m g h')
>>> O = Point('O')
>>> P = Particle('P', O, m)
>>> P.potential_energy = m * g * h
>>> P.potential_energy
g*h*m
class sympy.physics.mechanics.rigidbody.RigidBody(name, masscenter=None, frame=None, mass=None, inertia=None)[source]

An idealized rigid body.

Explanation

This is essentially a container which holds the various components which describe a rigid body: a name, mass, center of mass, reference frame, and inertia.

All of these need to be supplied on creation, but can be changed afterwards.

Examples

>>> from sympy import Symbol
>>> from sympy.physics.mechanics import ReferenceFrame, Point, RigidBody
>>> from sympy.physics.mechanics import outer
>>> m = Symbol('m')
>>> A = ReferenceFrame('A')
>>> P = Point('P')
>>> I = outer (A.x, A.x)
>>> inertia_tuple = (I, P)
>>> B = RigidBody('B', P, A, m, inertia_tuple)
>>> # Or you could change them afterwards
>>> m2 = Symbol('m2')
>>> B.mass = m2

Attributes

name

(string) The body’s name.

masscenter

(Point) The point which represents the center of mass of the rigid body.

frame

(ReferenceFrame) The ReferenceFrame which the rigid body is fixed in.

mass

(Sympifyable) The body’s mass.

inertia

((Dyadic, Point)) The body’s inertia about a point; stored in a tuple as shown above.

potential_energy

(Sympifyable) The potential energy of the RigidBody.

angular_momentum(point, frame)[source]

Returns the angular momentum of the rigid body about a point in the given frame.

Parameters:

point : Point

The point about which angular momentum is desired.

frame : ReferenceFrame

The frame in which angular momentum is desired.

Explanation

The angular momentum H of a rigid body B about some point O in a frame N is given by:

H = dot(I, w) + cross(r, m * v)

where I and m are the central inertia dyadic and mass of rigid body B, w is the angular velocity of body B in the frame N, r is the position vector from point O to the mass center of B, and v is the velocity of the mass center in the frame N.

Examples

>>> from sympy.physics.mechanics import Point, ReferenceFrame, outer
>>> from sympy.physics.mechanics import RigidBody, dynamicsymbols
>>> from sympy.physics.vector import init_vprinting
>>> init_vprinting(pretty_print=False)
>>> m, v, r, omega = dynamicsymbols('m v r omega')
>>> N = ReferenceFrame('N')
>>> b = ReferenceFrame('b')
>>> b.set_ang_vel(N, omega * b.x)
>>> P = Point('P')
>>> P.set_vel(N, 1 * N.x)
>>> I = outer(b.x, b.x)
>>> B = RigidBody('B', P, b, m, (I, P))
>>> B.angular_momentum(P, N)
omega*b.x
property central_inertia

The body’s central inertia dyadic.

property frame

The ReferenceFrame fixed to the body.

property inertia

The body’s inertia about a point; stored as (Dyadic, Point).

kinetic_energy(frame)[source]

Kinetic energy of the rigid body.

Parameters:

frame : ReferenceFrame

The RigidBody’s angular velocity and the velocity of it’s mass center are typically defined with respect to an inertial frame but any relevant frame in which the velocities are known can be supplied.

Explanation

The kinetic energy, T, of a rigid body, B, is given by:

T = 1/2 * (dot(dot(I, w), w) + dot(m * v, v))

where I and m are the central inertia dyadic and mass of rigid body B respectively, w is the body’s angular velocity, and v is the velocity of the body’s mass center in the supplied ReferenceFrame.

Examples

>>> from sympy.physics.mechanics import Point, ReferenceFrame, outer
>>> from sympy.physics.mechanics import RigidBody
>>> from sympy import symbols
>>> m, v, r, omega = symbols('m v r omega')
>>> N = ReferenceFrame('N')
>>> b = ReferenceFrame('b')
>>> b.set_ang_vel(N, omega * b.x)
>>> P = Point('P')
>>> P.set_vel(N, v * N.x)
>>> I = outer (b.x, b.x)
>>> inertia_tuple = (I, P)
>>> B = RigidBody('B', P, b, m, inertia_tuple)
>>> B.kinetic_energy(N)
m*v**2/2 + omega**2/2
linear_momentum(frame)[source]

Linear momentum of the rigid body.

Parameters:

frame : ReferenceFrame

The frame in which linear momentum is desired.

Explanation

The linear momentum L, of a rigid body B, with respect to frame N is given by:

L = m * v

where m is the mass of the rigid body, and v is the velocity of the mass center of B in the frame N.

Examples

>>> from sympy.physics.mechanics import Point, ReferenceFrame, outer
>>> from sympy.physics.mechanics import RigidBody, dynamicsymbols
>>> from sympy.physics.vector import init_vprinting
>>> init_vprinting(pretty_print=False)
>>> m, v = dynamicsymbols('m v')
>>> N = ReferenceFrame('N')
>>> P = Point('P')
>>> P.set_vel(N, v * N.x)
>>> I = outer (N.x, N.x)
>>> Inertia_tuple = (I, P)
>>> B = RigidBody('B', P, N, m, Inertia_tuple)
>>> B.linear_momentum(N)
m*v*N.x
property mass

The body’s mass.

property masscenter

The body’s center of mass.

property name

The name of the body.

parallel_axis(point, frame=None)[source]

Returns the inertia dyadic of the body with respect to another point.

Parameters:

point : sympy.physics.vector.Point

The point to express the inertia dyadic about.

frame : sympy.physics.vector.ReferenceFrame

The reference frame used to construct the dyadic.

Returns:

inertia : sympy.physics.vector.Dyadic

The inertia dyadic of the rigid body expressed about the provided point.

property potential_energy

The potential energy of the body.

Examples

>>> from sympy.physics.mechanics import Particle, Point
>>> from sympy import symbols
>>> m, g, h = symbols('m g h')
>>> O = Point('O')
>>> P = Particle('P', O, m)
>>> P.potential_energy = m * g * h
>>> P.potential_energy
g*h*m
property x

The basis Vector for the body, in the x direction.

property y

The basis Vector for the body, in the y direction.

property z

The basis Vector for the body, in the z direction.

Inertias

class sympy.physics.mechanics.inertia.Inertia(dyadic, point)[source]

Inertia object consisting of a Dyadic and a Point of reference.

Explanation

This is a simple class to store the Point and Dyadic, belonging to an inertia.

Examples

>>> from sympy.physics.mechanics import ReferenceFrame, Point, Inertia
>>> N = ReferenceFrame('N')
>>> Po = Point('Po')
>>> Inertia(N.x.outer(N.x) + N.y.outer(N.y) + N.z.outer(N.z), Po)
((N.x|N.x) + (N.y|N.y) + (N.z|N.z), Po)

In the example above the Dyadic was created manually, one can however also use the inertia function for this or the class method from_tensor as shown below.

>>> Inertia.from_inertia_scalars(Po, N, 1, 1, 1)
((N.x|N.x) + (N.y|N.y) + (N.z|N.z), Po)

Attributes

dyadic

(Dyadic) The dyadic of the inertia.

point

(Point) The reference point of the inertia.

classmethod from_inertia_scalars(point, frame, ixx, iyy, izz, ixy=0, iyz=0, izx=0)[source]

Simple way to create an Inertia object based on the tensor values.

Parameters:

point : Point

The reference point of the inertia.

frame : ReferenceFrame

The frame the inertia is defined in.

ixx : Sympifyable

The xx element in the inertia dyadic.

iyy : Sympifyable

The yy element in the inertia dyadic.

izz : Sympifyable

The zz element in the inertia dyadic.

ixy : Sympifyable

The xy element in the inertia dyadic.

iyz : Sympifyable

The yz element in the inertia dyadic.

izx : Sympifyable

The zx element in the inertia dyadic.

Explanation

This class method uses the :func`~.inertia` to create the Dyadic based on the tensor values.

Examples

>>> from sympy import symbols
>>> from sympy.physics.mechanics import ReferenceFrame, Point, Inertia
>>> ixx, iyy, izz, ixy, iyz, izx = symbols('ixx iyy izz ixy iyz izx')
>>> N = ReferenceFrame('N')
>>> P = Point('P')
>>> I = Inertia.from_inertia_scalars(P, N, ixx, iyy, izz, ixy, iyz, izx)

The tensor values can easily be seen when converting the dyadic to a matrix.

>>> I.dyadic.to_matrix(N)
Matrix([
[ixx, ixy, izx],
[ixy, iyy, iyz],
[izx, iyz, izz]])
sympy.physics.mechanics.inertia.inertia(frame, ixx, iyy, izz, ixy=0, iyz=0, izx=0)[source]

Simple way to create inertia Dyadic object.

Parameters:

frame : ReferenceFrame

The frame the inertia is defined in.

ixx : Sympifyable

The xx element in the inertia dyadic.

iyy : Sympifyable

The yy element in the inertia dyadic.

izz : Sympifyable

The zz element in the inertia dyadic.

ixy : Sympifyable

The xy element in the inertia dyadic.

iyz : Sympifyable

The yz element in the inertia dyadic.

izx : Sympifyable

The zx element in the inertia dyadic.

Explanation

Creates an inertia Dyadic based on the given tensor values and a body-fixed reference frame.

Examples

>>> from sympy.physics.mechanics import ReferenceFrame, inertia
>>> N = ReferenceFrame('N')
>>> inertia(N, 1, 2, 3)
(N.x|N.x) + 2*(N.y|N.y) + 3*(N.z|N.z)
sympy.physics.mechanics.inertia.inertia_of_point_mass(mass, pos_vec, frame)[source]

Inertia dyadic of a point mass relative to point O.

Parameters:

mass : Sympifyable

Mass of the point mass

pos_vec : Vector

Position from point O to point mass

frame : ReferenceFrame

Reference frame to express the dyadic in

Examples

>>> from sympy import symbols
>>> from sympy.physics.mechanics import ReferenceFrame, inertia_of_point_mass
>>> N = ReferenceFrame('N')
>>> r, m = symbols('r m')
>>> px = r * N.x
>>> inertia_of_point_mass(m, px, N)
m*r**2*(N.y|N.y) + m*r**2*(N.z|N.z)

Loads

class sympy.physics.mechanics.loads.Force(point, force)[source]

Force acting upon a point.

Explanation

A force is a vector that is bound to a line of action. This class stores both a point, which lies on the line of action, and the vector. A tuple can also be used, with the location as the first entry and the vector as second entry.

Examples

A force of magnitude 2 along N.x acting on a point Po can be created as follows:

>>> from sympy.physics.mechanics import Point, ReferenceFrame, Force
>>> N = ReferenceFrame('N')
>>> Po = Point('Po')
>>> Force(Po, 2 * N.x)
(Po, 2*N.x)

If a body is supplied, then the center of mass of that body is used.

>>> from sympy.physics.mechanics import Particle
>>> P = Particle('P', point=Po)
>>> Force(P, 2 * N.x)
(Po, 2*N.x)
class sympy.physics.mechanics.loads.Torque(frame, torque)[source]

Torque acting upon a frame.

Explanation

A torque is a free vector that is acting on a reference frame, which is associated with a rigid body. This class stores both the frame and the vector. A tuple can also be used, with the location as the first item and the vector as second item.

Examples

A torque of magnitude 2 about N.x acting on a frame N can be created as follows:

>>> from sympy.physics.mechanics import ReferenceFrame, Torque
>>> N = ReferenceFrame('N')
>>> Torque(N, 2 * N.x)
(N, 2*N.x)

If a body is supplied, then the frame fixed to that body is used.

>>> from sympy.physics.mechanics import RigidBody
>>> rb = RigidBody('rb', frame=N)
>>> Torque(rb, 2 * N.x)
(N, 2*N.x)

Other Functions

sympy.physics.mechanics.functions.center_of_mass(point, *bodies)[source]

Returns the position vector from the given point to the center of mass of the given bodies(particles or rigidbodies).

Example

>>> from sympy import symbols, S
>>> from sympy.physics.vector import Point
>>> from sympy.physics.mechanics import Particle, ReferenceFrame, RigidBody, outer
>>> from sympy.physics.mechanics.functions import center_of_mass
>>> a = ReferenceFrame('a')
>>> m = symbols('m', real=True)
>>> p1 = Particle('p1', Point('p1_pt'), S(1))
>>> p2 = Particle('p2', Point('p2_pt'), S(2))
>>> p3 = Particle('p3', Point('p3_pt'), S(3))
>>> p4 = Particle('p4', Point('p4_pt'), m)
>>> b_f = ReferenceFrame('b_f')
>>> b_cm = Point('b_cm')
>>> mb = symbols('mb')
>>> b = RigidBody('b', b_cm, b_f, mb, (outer(b_f.x, b_f.x), b_cm))
>>> p2.point.set_pos(p1.point, a.x)
>>> p3.point.set_pos(p1.point, a.x + a.y)
>>> p4.point.set_pos(p1.point, a.y)
>>> b.masscenter.set_pos(p1.point, a.y + a.z)
>>> point_o=Point('o')
>>> point_o.set_pos(p1.point, center_of_mass(p1.point, p1, p2, p3, p4, b))
>>> expr = 5/(m + mb + 6)*a.x + (m + mb + 3)/(m + mb + 6)*a.y + mb/(m + mb + 6)*a.z
>>> point_o.pos_from(p1.point)
5/(m + mb + 6)*a.x + (m + mb + 3)/(m + mb + 6)*a.y + mb/(m + mb + 6)*a.z
sympy.physics.mechanics.functions.linear_momentum(frame, *body)[source]

Linear momentum of the system.

Parameters:

frame : ReferenceFrame

The frame in which linear momentum is desired.

body1, body2, body3… : Particle and/or RigidBody

The body (or bodies) whose linear momentum is required.

Explanation

This function returns the linear momentum of a system of Particle’s and/or RigidBody’s. The linear momentum of a system is equal to the vector sum of the linear momentum of its constituents. Consider a system, S, comprised of a rigid body, A, and a particle, P. The linear momentum of the system, L, is equal to the vector sum of the linear momentum of the particle, L1, and the linear momentum of the rigid body, L2, i.e.

L = L1 + L2

Examples

>>> from sympy.physics.mechanics import Point, Particle, ReferenceFrame
>>> from sympy.physics.mechanics import RigidBody, outer, linear_momentum
>>> N = ReferenceFrame('N')
>>> P = Point('P')
>>> P.set_vel(N, 10 * N.x)
>>> Pa = Particle('Pa', P, 1)
>>> Ac = Point('Ac')
>>> Ac.set_vel(N, 25 * N.y)
>>> I = outer(N.x, N.x)
>>> A = RigidBody('A', Ac, N, 20, (I, Ac))
>>> linear_momentum(N, A, Pa)
10*N.x + 500*N.y
sympy.physics.mechanics.functions.angular_momentum(point, frame, *body)[source]

Angular momentum of a system.

Parameters:

point : Point

The point about which angular momentum of the system is desired.

frame : ReferenceFrame

The frame in which angular momentum is desired.

body1, body2, body3… : Particle and/or RigidBody

The body (or bodies) whose angular momentum is required.

Explanation

This function returns the angular momentum of a system of Particle’s and/or RigidBody’s. The angular momentum of such a system is equal to the vector sum of the angular momentum of its constituents. Consider a system, S, comprised of a rigid body, A, and a particle, P. The angular momentum of the system, H, is equal to the vector sum of the angular momentum of the particle, H1, and the angular momentum of the rigid body, H2, i.e.

H = H1 + H2

Examples

>>> from sympy.physics.mechanics import Point, Particle, ReferenceFrame
>>> from sympy.physics.mechanics import RigidBody, outer, angular_momentum
>>> N = ReferenceFrame('N')
>>> O = Point('O')
>>> O.set_vel(N, 0 * N.x)
>>> P = O.locatenew('P', 1 * N.x)
>>> P.set_vel(N, 10 * N.x)
>>> Pa = Particle('Pa', P, 1)
>>> Ac = O.locatenew('Ac', 2 * N.y)
>>> Ac.set_vel(N, 5 * N.y)
>>> a = ReferenceFrame('a')
>>> a.set_ang_vel(N, 10 * N.z)
>>> I = outer(N.z, N.z)
>>> A = RigidBody('A', Ac, a, 20, (I, Ac))
>>> angular_momentum(O, N, Pa, A)
10*N.z
sympy.physics.mechanics.functions.kinetic_energy(frame, *body)[source]

Kinetic energy of a multibody system.

Parameters:

frame : ReferenceFrame

The frame in which the velocity or angular velocity of the body is defined.

body1, body2, body3… : Particle and/or RigidBody

The body (or bodies) whose kinetic energy is required.

Explanation

This function returns the kinetic energy of a system of Particle’s and/or RigidBody’s. The kinetic energy of such a system is equal to the sum of the kinetic energies of its constituents. Consider a system, S, comprising a rigid body, A, and a particle, P. The kinetic energy of the system, T, is equal to the vector sum of the kinetic energy of the particle, T1, and the kinetic energy of the rigid body, T2, i.e.

T = T1 + T2

Kinetic energy is a scalar.

Examples

>>> from sympy.physics.mechanics import Point, Particle, ReferenceFrame
>>> from sympy.physics.mechanics import RigidBody, outer, kinetic_energy
>>> N = ReferenceFrame('N')
>>> O = Point('O')
>>> O.set_vel(N, 0 * N.x)
>>> P = O.locatenew('P', 1 * N.x)
>>> P.set_vel(N, 10 * N.x)
>>> Pa = Particle('Pa', P, 1)
>>> Ac = O.locatenew('Ac', 2 * N.y)
>>> Ac.set_vel(N, 5 * N.y)
>>> a = ReferenceFrame('a')
>>> a.set_ang_vel(N, 10 * N.z)
>>> I = outer(N.z, N.z)
>>> A = RigidBody('A', Ac, a, 20, (I, Ac))
>>> kinetic_energy(N, Pa, A)
350
sympy.physics.mechanics.functions.potential_energy(*body)[source]

Potential energy of a multibody system.

Parameters:

body1, body2, body3… : Particle and/or RigidBody

The body (or bodies) whose potential energy is required.

Explanation

This function returns the potential energy of a system of Particle’s and/or RigidBody’s. The potential energy of such a system is equal to the sum of the potential energy of its constituents. Consider a system, S, comprising a rigid body, A, and a particle, P. The potential energy of the system, V, is equal to the vector sum of the potential energy of the particle, V1, and the potential energy of the rigid body, V2, i.e.

V = V1 + V2

Potential energy is a scalar.

Examples

>>> from sympy.physics.mechanics import Point, Particle, ReferenceFrame
>>> from sympy.physics.mechanics import RigidBody, outer, potential_energy
>>> from sympy import symbols
>>> M, m, g, h = symbols('M m g h')
>>> N = ReferenceFrame('N')
>>> O = Point('O')
>>> O.set_vel(N, 0 * N.x)
>>> P = O.locatenew('P', 1 * N.x)
>>> Pa = Particle('Pa', P, m)
>>> Ac = O.locatenew('Ac', 2 * N.y)
>>> a = ReferenceFrame('a')
>>> I = outer(N.z, N.z)
>>> A = RigidBody('A', Ac, a, M, (I, Ac))
>>> Pa.potential_energy = m * g * h
>>> A.potential_energy = M * g * h
>>> potential_energy(Pa, A)
M*g*h + g*h*m
sympy.physics.mechanics.functions.Lagrangian(frame, *body)[source]

Lagrangian of a multibody system.

Parameters:

frame : ReferenceFrame

The frame in which the velocity or angular velocity of the body is defined to determine the kinetic energy.

body1, body2, body3… : Particle and/or RigidBody

The body (or bodies) whose Lagrangian is required.

Explanation

This function returns the Lagrangian of a system of Particle’s and/or RigidBody’s. The Lagrangian of such a system is equal to the difference between the kinetic energies and potential energies of its constituents. If T and V are the kinetic and potential energies of a system then it’s Lagrangian, L, is defined as

L = T - V

The Lagrangian is a scalar.

Examples

>>> from sympy.physics.mechanics import Point, Particle, ReferenceFrame
>>> from sympy.physics.mechanics import RigidBody, outer, Lagrangian
>>> from sympy import symbols
>>> M, m, g, h = symbols('M m g h')
>>> N = ReferenceFrame('N')
>>> O = Point('O')
>>> O.set_vel(N, 0 * N.x)
>>> P = O.locatenew('P', 1 * N.x)
>>> P.set_vel(N, 10 * N.x)
>>> Pa = Particle('Pa', P, 1)
>>> Ac = O.locatenew('Ac', 2 * N.y)
>>> Ac.set_vel(N, 5 * N.y)
>>> a = ReferenceFrame('a')
>>> a.set_ang_vel(N, 10 * N.z)
>>> I = outer(N.z, N.z)
>>> A = RigidBody('A', Ac, a, 20, (I, Ac))
>>> Pa.potential_energy = m * g * h
>>> A.potential_energy = M * g * h
>>> Lagrangian(N, Pa, A)
-M*g*h - g*h*m + 350
sympy.physics.mechanics.functions.find_dynamicsymbols(expression, exclude=None, reference_frame=None)[source]

Find all dynamicsymbols in expression.

Parameters:

expression : SymPy expression

exclude : iterable of dynamicsymbols, optional

reference_frame : ReferenceFrame, optional

The frame with respect to which the dynamic symbols of the given vector is to be determined.

Explanation

If the optional exclude kwarg is used, only dynamicsymbols not in the iterable exclude are returned. If we intend to apply this function on a vector, the optional reference_frame is also used to inform about the corresponding frame with respect to which the dynamic symbols of the given vector is to be determined.

Examples

>>> from sympy.physics.mechanics import dynamicsymbols, find_dynamicsymbols
>>> from sympy.physics.mechanics import ReferenceFrame
>>> x, y = dynamicsymbols('x, y')
>>> expr = x + x.diff()*y
>>> find_dynamicsymbols(expr)
{x(t), y(t), Derivative(x(t), t)}
>>> find_dynamicsymbols(expr, exclude=[x, y])
{Derivative(x(t), t)}
>>> a, b, c = dynamicsymbols('a, b, c')
>>> A = ReferenceFrame('A')
>>> v = a * A.x + b * A.y + c * A.z
>>> find_dynamicsymbols(v, reference_frame=A)
{a(t), b(t), c(t)}