物理学/力学中的质量、惯性、粒子和刚体#

This document will describe how to represent masses and inertias in sympy.physics.mechanics and use of the RigidBody and Particle classes.

假设读者熟悉这些主题的基础知识,例如找到粒子系统的质心,如何操纵惯性张量,以及粒子和刚体的定义。任何高级动态文本都可以为这些详细信息提供参考。

质量#

质量的唯一要求是它必须是 sympify -能干的表达。请记住,质量可以随时间变化。

微粒#

Particles are created with the class Particle in sympy.physics.mechanics. A Particle object has an associated point and an associated mass which are the only two attributes of the object.:

>>> from sympy.physics.mechanics import Particle, Point
>>> from sympy import Symbol
>>> m = Symbol('m')
>>> po = Point('po')
>>> # create a particle container
>>> pa = Particle('pa', po, m)

关联点包含粒子的位置、速度和加速度。 sympy.physics.mechanics 允许执行与质量关联的点的运动分析。

惯性#

Inertia consists out of two parts: a quantity and a reference. The quantity is expressed as a Dyadic and the reference is a Point. The Dyadic can be defined as the outer product between two vectors, which returns the juxtaposition of these vectors. For further information, please refer to the 并矢 section in the advanced documentation of the sympy.physics.vector module. Another more intuitive method to define the Dyadic is to use the inertia() function as described below in the section 'Inertia (Dyadics)'. The Point about which the Dyadic is specified can be any point, as long as it is defined with respect to the center of mass. The most common reference point is of course the center of mass itself.

The inertia of a body can be specified using either an Inertia object or a tuple. If a tuple is used, then it should have a length of two, with the first entry being a Dyadic and the second entry being a Point about which the inertia dyadic is defined. Internally this tuple gets converted to an Inertia object. An example of using a tuple about the center of mass is given below in the 'Rigid Body' section. The Inertia object can be created as follows.:

>>> from sympy.physics.mechanics import ReferenceFrame, Point, outer, Inertia
>>> A = ReferenceFrame('A')
>>> P = Point('P')
>>> Inertia(P, outer(A.x, A.x))
((A.x|A.x), P)

惯性(并矢)#

A dyadic tensor is a second order tensor formed by the juxtaposition of a pair of vectors. There are various operations defined with respect to dyadics, which have been implemented in vector in the form of class Dyadic. To know more, refer to the sympy.physics.vector.dyadic.Dyadic and sympy.physics.vector.vector.Vector class APIs. Dyadics are used to define the inertia of bodies within sympy.physics.mechanics. Inertia dyadics can be defined explicitly using the outer product, but the inertia() function is typically much more convenient for the user.:

>>> from sympy.physics.mechanics import ReferenceFrame, inertia
>>> N = ReferenceFrame('N')

Supply a reference frame and the moments of inertia if the object
is symmetrical:

>>> inertia(N, 1, 2, 3)
(N.x|N.x) + 2*(N.y|N.y) + 3*(N.z|N.z)

Supply a reference frame along with the products and moments of inertia
for a general object:

>>> inertia(N, 1, 2, 3, 4, 5, 6)
(N.x|N.x) + 4*(N.x|N.y) + 6*(N.x|N.z) + 4*(N.y|N.x) + 2*(N.y|N.y) + 5*(N.y|N.z) + 6*(N.z|N.x) + 5*(N.z|N.y) + 3*(N.z|N.z)

Notice that the inertia() function returns a dyadic with each component represented as two unit vectors separated by a | (outer product). Refer to the sympy.physics.vector.dyadic.Dyadic section for more information about dyadics.

惯性常以矩阵或张量的形式表示,特别是在数值计算中。由于矩阵形式不包含定义惯性并矢的参考坐标系的任何信息,因此必须提供一个或两个参考坐标系以从并矢中提取测量值。有一个方便的函数可以完成此操作:

>>> inertia(N, 1, 2, 3, 4, 5, 6).to_matrix(N)
Matrix([
[1, 4, 6],
[4, 2, 5],
[6, 5, 3]])

刚体#

Rigid bodies are created in a similar fashion as particles. The RigidBody class generates objects with four attributes: mass, center of mass, a reference frame, and an Inertia (a tuple can be passed as well).:

>>> 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)
>>> # create a rigid body
>>> B = RigidBody('B', P, A, m, (I, P))

The mass is specified exactly as is in a particle. Similar to the Particle's .point, the RigidBody's center of mass, .masscenter must be specified. The reference frame is stored in an analogous fashion and holds information about the body's orientation and angular velocity.

Loads#

In sympy.physics.mechanics loads can either be represented with tuples or with the dedicated classes Force and Torque. Generally the first argument (or item in the case of a tuple) is the location of the load. The second argument is the vector. In the case of a force the first argument is a point and the second a vector.

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

The location of a torque, on the other hand, is a frame.

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

Optionally, one can also pass the body when using dedicated classes. If so, the force will use the center of mass and the torque will use the associated frame.

>>> from sympy.physics.mechanics import RigidBody
>>> rb = RigidBody('rb')
>>> Force(rb, 3 * N.x)
(rb_masscenter, 3*N.x)
>>> Torque(rb, 4 * N.x)
(rb_frame, 4*N.x)

线性动量#

粒子P的线性动量定义为:

\[P=m\mathbf{v}\]

在哪里? \(m\) 是粒子的质量P和 \(\mathbf{{v}}\) 是质点在惯性系中的速度 frame.[Likins1973]_.

同样,刚体的线性动量定义为:

\[L\u B=m\mathbf{v^*}\]

在哪里? \(m\) 是刚体的质量,B,和 \(\mathbf{{v^*}}\) 是B在惯性系中质心的速度。

角动量#

在惯性系N中,粒子P绕任意点O的角动量定义为:

\[^N\mathbf{H}^{P/O}=\mathbf{r}\times m\mathbf{v}\]

在哪里? \(\mathbf{{r}}\) 是从点O到质点的位置向量 \(m\)\(\mathbf{{v}}\) 是质点在惯性系中的速度。

同样地,刚体B关于惯性系N中点O的角动量定义为:

\[^N \mathbf{H} ^ {B/O} = ^N \mathbf{H} ^ {B/B^*} + ^N \mathbf{H} ^ {B^*/O}\]

其中物体围绕其质心的角动量为:

\[^N \mathbf{H} ^ {B/B^*} = \mathbf{I^*} \cdot \omega\]

质量中心关于O的角动量是:

\[^N \mathbf{H} ^ {B^*/O} = \mathbf{r^*} \times m \mathbf{v^*}\]

在哪里? \(\mathbf{{I^*}}\) 是刚体B的中心惯性并矢, \(\omega\) 是B的惯性角速度, \(\mathbf{{r^*}}\) 是从点O到B质心的位置向量, \(m\) 是B和的质量 \(\mathbf{{v^*}}\) 是质心在惯性系中的速度。

动量函数在力学中的应用#

下面的示例演示如何在中使用momenta函数 sympy.physics.mechanics .

首先要创造必要的符号来描述系统。然后建立参考坐标系并进行运动学分析。:

>>> from sympy import symbols
>>> from sympy.physics.mechanics import dynamicsymbols, ReferenceFrame
>>> from sympy.physics.mechanics import RigidBody, Particle, Point, outer
>>> from sympy.physics.mechanics import linear_momentum, angular_momentum
>>> from sympy.physics.vector import init_vprinting
>>> init_vprinting(pretty_print=False)
>>> m, M, l1 = symbols('m M l1')
>>> q1d = dynamicsymbols('q1d')
>>> N = ReferenceFrame('N')
>>> O = Point('O')
>>> O.set_vel(N, 0 * N.x)
>>> Ac = O.locatenew('Ac', l1 * N.x)
>>> P = Ac.locatenew('P', l1 * N.x)
>>> a = ReferenceFrame('a')
>>> a.set_ang_vel(N, q1d * N.z)
>>> Ac.v2pt_theory(O, N, a)
l1*q1d*N.y
>>> P.v2pt_theory(O, N, a)
2*l1*q1d*N.y

最后,组成系统的实体被创建。在这种情况下,系统由粒子Pa和刚体a组成:

>>> Pa = Particle('Pa', P, m)
>>> I = outer(N.z, N.z)
>>> A = RigidBody('A', Ac, a, M, (I, Ac))

然后你可以选择评估系统中单个组件的动量,也可以选择评估整个系统本身的动量。:

>>> linear_momentum(N,A)
M*l1*q1d*N.y
>>> angular_momentum(O, N, Pa)
4*l1**2*m*q1d*N.z
>>> linear_momentum(N, A, Pa)
(M*l1*q1d + 2*l1*m*q1d)*N.y
>>> angular_momentum(O, N, A, Pa)
(M*l1**2*q1d + 4*l1**2*m*q1d + q1d)*N.z

需要注意的是,用户可以在 sympy.physics.mechanics 因为用户可以在调用函数时指定参考帧。换言之,用户不仅限于确定惯性线动量和角动量。请参阅每个函数的docstrings以了解有关每个函数如何精确工作的更多信息。

动能#

粒子P的动能定义为

\[P=\frac{1}{2}m\mathbf{v^2}\]

在哪里? \(m\) 是粒子的质量P和 \(\mathbf{{v}}\) 是质点在惯性系中的速度。

同样,刚体B的动能定义为

\[T\u B=T\T+T\r\]

其中平动动能由下式得出:

\[T_t = \frac{1}{2} m \mathbf{v^*} \cdot \mathbf{v^*}\]

旋转动能由下式得出:

\[T\u r=\frac{1}{2}\omega\cdot\mathbf{I^*}\cdot\omega\]

在哪里? \(m\) 是刚体的质量, \(\mathbf{{v^*}}\) 是质心在惯性系中的速度, \(\omega\) 是物体的惯性角速度 \(\mathbf{{I^*}}\) 是中心惯性并矢。

势能#

势能是指物体或系统因其位置或排列而具有的能量。

由于势能有各种定义,因此这里没有进一步讨论。在任何关于动力学的基本教科书中,都可以了解更多有关这一点的信息。

拉格朗日#

物体或物体系统的拉格朗日函数定义为:

\[\数学{L}=T-V\]

在哪里? \(T\)\(V\) 分别是动能和势能。

在力学中使用能量函数#

下面的示例演示如何在中使用能量函数 sympy.physics.mechanics .

正如上面在动量函数中讨论的那样,首先通过执行相同的程序创建系统。:

>>> from sympy import symbols
>>> from sympy.physics.mechanics import dynamicsymbols, ReferenceFrame, outer
>>> from sympy.physics.mechanics import RigidBody, Particle
>>> from sympy.physics.mechanics import kinetic_energy, potential_energy, Point
>>> from sympy.physics.vector import init_vprinting
>>> init_vprinting(pretty_print=False)
>>> m, M, l1, g, h, H = symbols('m M l1 g h H')
>>> omega = dynamicsymbols('omega')
>>> N = ReferenceFrame('N')
>>> O = Point('O')
>>> O.set_vel(N, 0 * N.x)
>>> Ac = O.locatenew('Ac', l1 * N.x)
>>> P = Ac.locatenew('P', l1 * N.x)
>>> a = ReferenceFrame('a')
>>> a.set_ang_vel(N, omega * N.z)
>>> Ac.v2pt_theory(O, N, a)
l1*omega*N.y
>>> P.v2pt_theory(O, N, a)
2*l1*omega*N.y
>>> Pa = Particle('Pa', P, m)
>>> I = outer(N.z, N.z)
>>> A = RigidBody('A', Ac, a, M, (I, Ac))

然后用户可以确定系统中任意数量实体的动能:::

>>> kinetic_energy(N, Pa)
2*l1**2*m*omega**2
>>> kinetic_energy(N, Pa, A)
M*l1**2*omega**2/2 + 2*l1**2*m*omega**2 + omega**2/2

需要注意的是,用户可以确定相对于任何帧的动能 sympy.physics.mechanics 因为用户可以在调用函数时指定参考帧。换言之,用户不仅限于确定惯性动能。

对于势能,用户必须首先使用 sympy.physics.mechanics.rigidbody.RigidBody.potential_energy 财产。组成这个系统的任何数量的实体的势能可以确定:::

>>> Pa.potential_energy = m * g * h
>>> A.potential_energy = M * g * H
>>> potential_energy(A, Pa)
H*M*g + g*h*m

我们也可以确定这个系统的拉格朗日:::

>>> from sympy.physics.mechanics import Lagrangian
>>> from sympy.physics.vector import init_vprinting
>>> init_vprinting(pretty_print=False)
>>> Lagrangian(N, Pa, A)
-H*M*g + M*l1**2*omega**2/2 - g*h*m + 2*l1**2*m*omega**2 + omega**2/2

请参考docstrings以了解有关每个函数的更多信息。