Bodies, Inertias, Loads & Other Functions (Docstrings)#
Bodies#
- class sympy.physics.mechanics.particle.Particle(name, point=None, mass=None)[源代码]#
一个粒子。
- 参数:
name :结构
粒子名称
点 :点
表示粒子位置、速度和加速度的物理/力学点
mass :可解释
表示粒子质量的同调表达式
potential_energy : Sympifyable
粒子的势能。
解释
粒子的质量不为零,缺乏空间扩展;它们不占用空间。
初始化时需要提供值,但可以稍后更改。
实例
>>> 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)[源代码]#
质点的角动量。
- 参数:
点 :点
粒子的角动量被期望的点。
框架 :参考帧
需要角动量的帧。
解释
关于粒子P的某个点O的角动量H由下式给出:
H = cross(r, m * v)
其中r是从点O到质点P的位置矢量,m是质点的质量,v是质点在惯性系中的速度,N。
实例
>>> 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)[源代码]#
Kinetic energy of the particle.
- 参数:
框架 :参考帧
粒子的速度通常是相对于惯性系来定义的,但是任何已知速度的相关坐标系都可以提供。
解释
The kinetic energy, T, of a particle, P, is given by:
T = 1/2 (dot(m * v, v))
其中m是粒子P的质量,v是粒子在所提供的参考帧中的速度。
实例
>>> 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)[源代码]#
粒子的线性动量。
- 参数:
框架 :参考帧
需要线性动量的帧。
解释
The linear momentum L, of a particle P, with respect to frame N is given by:
L=m*v
其中m是粒子的质量,v是粒子在N帧中的速度。
实例
>>> 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)[源代码]#
返回粒子相对于另一个点和帧的惯性并矢。
- 参数:
点 : sympy.物理.矢量.点
表示惯性并矢的点。
框架 : sympy.物理.矢量.参考框架
用来构造并矢的参考坐标系。
- 返回:
惯性 : sympy.物理.矢量.并矢
质点的惯量并矢表示在给定的点和坐标系上。
- property point#
The body's center of mass.
- property potential_energy#
The potential energy of the body.
实例
>>> 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)[源代码]#
理想化的刚体。
解释
本质上,这是一个容器,其中包含描述刚体的各种组件:名称、质量、质心、参考系和惯性。
所有这些都需要在创建时提供,但可以在以后更改。
实例
>>> 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
属性
名称
(字符串)实体的名称。
质量中心
(点)表示刚体质心的点。
框架
(ReferenceFrame)刚体固定在其中的ReferenceFrame。
群众
(值得同情的)身体的质量。
惯性
(并矢,点)物体对一点的惯性;如上图所示存储在元组中。
potential_energy
(Sympifyable) The potential energy of the RigidBody.
- angular_momentum(point, frame)[源代码]#
返回刚体关于给定帧中某一点的角动量。
- 参数:
点 :点
角动量需要角动量的点。
框架 :参考帧
需要角动量的帧。
解释
刚体B关于框架N中某点O的角动量H由下式给出:
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.
实例
>>> 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#
物体的中心惯性并矢。
- property frame#
The ReferenceFrame fixed to the body.
- property inertia#
The body's inertia about a point; stored as (Dyadic, Point).
- kinetic_energy(frame)[源代码]#
Kinetic energy of the rigid body.
- 参数:
框架 :参考帧
刚体的角速度和质心速度通常是相对于惯性系来定义的,但是任何已知速度的相关坐标系都可以提供。
解释
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.
实例
>>> 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)[源代码]#
刚体的线动量。
- 参数:
框架 :参考帧
需要线性动量的帧。
解释
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.
实例
>>> 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)[源代码]#
返回物体相对于另一点的惯性并矢。
- 参数:
点 : sympy.物理.矢量.点
表示惯性并矢的点。
框架 : sympy.物理.矢量.参考框架
用来构造并矢的参考坐标系。
- 返回:
惯性 : sympy.物理.矢量.并矢
刚体的惯量并矢表示在给定点附近。
- property potential_energy#
The potential energy of the body.
实例
>>> 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)[源代码]#
Inertia object consisting of a Dyadic and a Point of reference.
解释
This is a simple class to store the Point and Dyadic, belonging to an inertia.
实例
>>> 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 methodfrom_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)
属性
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)[源代码]#
Simple way to create an Inertia object based on the tensor values.
- 参数:
点 :点
The reference point of the inertia.
框架 :参考帧
The frame the inertia is defined in.
ixx :可解释
The xx element in the inertia dyadic.
iyy :可解释
The yy element in the inertia dyadic.
izz :可解释
The zz element in the inertia dyadic.
ixy :可解释
The xy element in the inertia dyadic.
iyz :可解释
The yz element in the inertia dyadic.
izx :可解释
The zx element in the inertia dyadic.
解释
This class method uses the :func`~.inertia` to create the Dyadic based on the tensor values.
实例
>>> 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)[源代码]#
创建惯性并矢物体的简单方法。
- 参数:
框架 :参考帧
The frame the inertia is defined in.
ixx :可解释
The xx element in the inertia dyadic.
iyy :可解释
The yy element in the inertia dyadic.
izz :可解释
The zz element in the inertia dyadic.
ixy :可解释
The xy element in the inertia dyadic.
iyz :可解释
The yz element in the inertia dyadic.
izx :可解释
The zx element in the inertia dyadic.
解释
Creates an inertia Dyadic based on the given tensor values and a body-fixed reference frame.
实例
>>> 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)[源代码]#
点质量相对于点O的惯性并矢。
- 参数:
mass :可解释
点质量的质量
pos_vec :矢量
从点O到点质量的位置
框架 :参考帧
表示并矢的参考坐标系
实例
>>> 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)[源代码]#
Force acting upon a point.
解释
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.
实例
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)[源代码]#
Torque acting upon a frame.
解释
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.
实例
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)[源代码]#
Returns the position vector from the given point to the center of mass of the given bodies(particles or rigidbodies).
例子
>>> 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)[源代码]#
系统的线性动量。
- 参数:
框架 :参考帧
需要线性动量的帧。
身体1,身体2,身体3。。。 :粒子和/或刚体
需要线性动量的物体。
解释
此函数返回粒子和/或刚体系统的线性动量。系统的线性动量等于其组成部分的线性动量的矢量和。考虑一个由刚体a和质点P组成的系统S。系统的线动量L等于质点的线动量L1和刚体的线动量L2的矢量和,即。
L=L1+L2
实例
>>> 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)[源代码]#
Angular momentum of a system.
- 参数:
点 :点
角动量系统的角动量所期望的点。
框架 :参考帧
需要角动量的帧。
身体1,身体2,身体3。。。 :粒子和/或刚体
需要角动量的物体。
解释
此函数返回粒子和/或刚体系统的角动量。该系统的角动量等于其组成部分的角动量的矢量和。考虑一个由刚体a和质点P组成的系统S。系统的角动量H等于质点角动量H1和刚体角动量H2的矢量和,即。
H=H1+H2
实例
>>> 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)[源代码]#
多体系统的动能。
- 参数:
框架 :参考帧
定义物体速度或角速度的帧。
身体1,身体2,身体3。。。 :粒子和/或刚体
需要动能的物体。
解释
这个函数返回粒子和/或刚体系统的动能。这个系统的动能等于其组成部分的动能之和。考虑一个系统,S,包括一个刚体a和一个粒子P。系统的动能T等于粒子动能T1和刚体动能T2的矢量和,即。
T=T1+T2
动能是标量。
实例
>>> 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)[源代码]#
多体系统的势能。
- 参数:
身体1,身体2,身体3。。。 :粒子和/或刚体
需要势能的物体。
解释
这个函数返回粒子和/或刚体系统的势能。这样一个系统的势能等于其组成部分的势能之和。考虑一个系统,S,包括一个刚体a和一个粒子P。系统的势能V等于粒子势能V1和刚体势能V2的矢量和,即。
V=V1+V2
势能是标量。
实例
>>> 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)[源代码]#
多体系统的拉格朗日。
- 参数:
框架 :参考帧
定义物体速度或角速度以确定动能的框架。
身体1,身体2,身体3。。。 :粒子和/或刚体
需要拉格朗日的物体。
解释
这个函数返回粒子和/或刚体系统的拉格朗日。这样一个系统的拉格朗日等于其组成部分的动能和势能之差。如果T和V是系统的动能和势能,那么它的拉格朗日,L,定义为
L=T-V
拉格朗日是标量。
实例
>>> 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)[源代码]#
在表达式中查找所有动态符号。
- 参数:
expression : SymPy expression
排除 :iterable of dynamicsymbols,可选
reference_frame :ReferenceFrame,可选
确定给定向量的动态符号的帧。
解释
If the optional
exclude
kwarg is used, only dynamicsymbols not in the iterableexclude
are returned. If we intend to apply this function on a vector, the optionalreference_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.实例
>>> 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)}