Masses, Inertias & Particles, RigidBodys (Docstrings)
Contents
Masses, Inertias & Particles, RigidBodys (Docstrings)¶
Particle¶
- class sympy.physics.mechanics.particle.Particle(name, point, mass)[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
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 = r x 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 m v^2’
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¶
Mass of the particle.
- 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¶
Point of the particle.
- property potential_energy¶
The potential energy of the Particle.
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
RigidBody¶
- class sympy.physics.mechanics.rigidbody.RigidBody(name, masscenter, frame, mass, inertia)[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.
- 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 = I . w + r x Mv
where I is the central inertia dyadic of 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.
- 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 (I omega^2 + m v^2)’
where I and m are the central inertia dyadic and mass of rigid body B, respectively, omega 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
- parallel_axis(point)[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.
- 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 RigidBody.
Examples
>>> from sympy.physics.mechanics import RigidBody, Point, outer, ReferenceFrame >>> from sympy import symbols >>> M, g, h = symbols('M g h') >>> b = ReferenceFrame('b') >>> P = Point('P') >>> I = outer (b.x, b.x) >>> Inertia_tuple = (I, P) >>> B = RigidBody('B', P, b, M, Inertia_tuple) >>> B.potential_energy = M * g * h >>> B.potential_energy M*g*h
inertia¶
- sympy.physics.mechanics.functions.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
If you don’t know what a Dyadic is, just treat this like the inertia tensor. Then, do the easy thing and define it in a body-fixed 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)
inertia_of_point_mass¶
- sympy.physics.mechanics.functions.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)
linear_momentum¶
- 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
angular_momentum¶
- 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
kinetic_energy¶
- 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
potential_energy¶
- 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
Lagrangian¶
- 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