K i(pddlmZmZmZmZmZmZddlmZddl m Z ddl m Z ddl mZdgZGdde Zy) )Body Lagrangian KanesMethodLagrangesMethod RigidBodyParticle)BodyBase)_Methods)Matrix)sympy_deprecation_warning JointsMethodceZdZdZdZedZedZedZedZ edZ edZ ed Z ed Z ed Zed Zd ZdZdZdZdZdZefdZddZy)r a Method for formulating the equations of motion using a set of interconnected bodies with joints. .. deprecated:: 1.13 The JointsMethod class is deprecated. Its functionality has been replaced by the new :class:`~.System` class. Parameters ========== newtonion : Body or ReferenceFrame The newtonion(inertial) frame. *joints : Joint The joints in the system Attributes ========== q, u : iterable Iterable of the generalized coordinates and speeds bodies : iterable Iterable of Body objects in the system. loads : iterable Iterable of (Point, vector) or (ReferenceFrame, vector) tuples describing the forces on the system. mass_matrix : Matrix, shape(n, n) The system's mass matrix forcing : Matrix, shape(n, 1) The system's forcing vector mass_matrix_full : Matrix, shape(2*n, 2*n) The "mass matrix" for the u's and q's forcing_full : Matrix, shape(2*n, 1) The "forcing vector" for the u's and q's method : KanesMethod or Lagrange's method Method's object. kdes : iterable Iterable of kde in they system. Examples ======== As Body and JointsMethod have been deprecated, the following examples are for illustrative purposes only. The functionality of Body is fully captured by :class:`~.RigidBody` and :class:`~.Particle` and the functionality of JointsMethod is fully captured by :class:`~.System`. To ignore the deprecation warning we can use the ignore_warnings context manager. >>> from sympy.utilities.exceptions import ignore_warnings This is a simple example for a one degree of freedom translational spring-mass-damper. >>> from sympy import symbols >>> from sympy.physics.mechanics import Body, JointsMethod, PrismaticJoint >>> from sympy.physics.vector import dynamicsymbols >>> c, k = symbols('c k') >>> x, v = dynamicsymbols('x v') >>> with ignore_warnings(DeprecationWarning): ... wall = Body('W') ... body = Body('B') >>> J = PrismaticJoint('J', wall, body, coordinates=x, speeds=v) >>> wall.apply_force(c*v*wall.x, reaction_body=body) >>> wall.apply_force(k*x*wall.x, reaction_body=body) >>> with ignore_warnings(DeprecationWarning): ... method = JointsMethod(wall, J) >>> method.form_eoms() Matrix([[-B_mass*Derivative(v(t), t) - c*v(t) - k*x(t)]]) >>> M = method.mass_matrix_full >>> F = method.forcing_full >>> rhs = M.LUsolve(F) >>> rhs Matrix([ [ v(t)], [(-c*v(t) - k*x(t))/B_mass]]) Notes ===== ``JointsMethod`` currently only works with systems that do not have any configuration or motion constraints. c`tdddt|tr|j|_n||_||_|j |_|j|_|j|_ |j|_ |j|_d|_y)Nz The JointsMethod class is deprecated. Its functionality has been replaced by the new System class. z1.13z!deprecated-mechanics-jointsmethod)deprecated_since_versionactive_deprecations_target)r isinstancer frame_joints_generate_bodylist_bodies_generate_loadlist_loads _generate_q_q _generate_u_u_generate_kdes_kdes_method)self newtonionjointss j/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/physics/mechanics/jointsmethod.py__init__zJointsMethod.__init__^s! &,'J   i *"DJ"DJ ..0 --/ ""$""$((*  c|jS)zList of bodies in they system.)rr s r#bodieszJointsMethod.bodiesu||r%c|jS)zList of loads on the system.)rr's r#loadszJointsMethod.loadszs{{r%c|jSz$List of the generalized coordinates.)rr's r#qzJointsMethod.q wwr%c|jS)zList of the generalized speeds.)rr's r#uzJointsMethod.ur/r%c|jSr-)rr's r#kdeszJointsMethod.kdesszzr%c.|jjS)z)The "forcing vector" for the u's and q's.)method forcing_fullr's r#r6zJointsMethod.forcing_fulls{{'''r%c.|jjS)z&The "mass matrix" for the u's and q's.)r5mass_matrix_fullr's r#r8zJointsMethod.mass_matrix_fulls{{+++r%c.|jjS)zThe system's mass matrix.)r5 mass_matrixr's r#r:zJointsMethod.mass_matrixs{{&&&r%c.|jjS)zThe system's forcing vector.)r5forcingr's r#r<zJointsMethod.forcings{{"""r%c|jS)z3Object of method used to form equations of systems.)rr's r#r5zJointsMethod.methodr)r%cg}|jD]U}|j|vr|j|j|j|vs;|j|jW|SN)rchildappendparent)r r(joints r#rzJointsMethod._generate_bodylistsY\\ ,E{{&( ekk*||6) ell+  ,  r%cg}|jD].}t|ts|j|j0|Sr?)r(rrextendr+)r load_listbodys r#rzJointsMethod._generate_loadlists> KK -D$%  , -r%cg}|jD]3}|jD]"}||vr td|j|$5t |S)Nz'Coordinates of joints should be unique.)r coordinates ValueErrorrAr )r q_indrC coordinates r#rzJointsMethod._generate_qs[\\ )E#// ) &$%NOO Z( ) ) e}r%cg}|jD]3}|jD]"}||vr td|j|$5t |S)Nz"Speeds of joints should be unique.)rspeedsrJrAr )r u_indrCspeeds r#rzJointsMethod._generate_usX\\ $E $E>$%IJJ U# $ $ e}r%ctddgj}|jD]}|j|j}|S)Nr)r Trcol_joinr3)r kd_indrCs r#rzJointsMethod._generate_kdess@1b!##\\ 1E__UZZ0F 1 r%c g}|jD]}t|ts|j|%|jrpt |j |j|j|j|j|jf}|j|_ |j|t|j |j|j}|j|_ |j||Sr?) r(rrrA is_rigidbodyrname masscenterrmasscentral_inertiapotential_energyr)r bodylistrGrbparts r#_convert_bodieszJointsMethod._convert_bodiessKK &DdD)%  tyy$//4::tyy))4??;=&*&;&;## 4??DIIF(,(=(=%% &r%c|j}t|trFt|jg|}|||j |j ||j|_nE||j|j |j|j|j ||_|jj}|S)aMethod to form system's equation of motions. Parameters ========== method : Class Class name of method. Returns ======== Matrix Vector of equations of motions. Examples ======== As Body and JointsMethod have been deprecated, the following examples are for illustrative purposes only. The functionality of Body is fully captured by :class:`~.RigidBody` and :class:`~.Particle` and the functionality of JointsMethod is fully captured by :class:`~.System`. To ignore the deprecation warning we can use the ignore_warnings context manager. >>> from sympy.utilities.exceptions import ignore_warnings This is a simple example for a one degree of freedom translational spring-mass-damper. >>> from sympy import S, symbols >>> from sympy.physics.mechanics import LagrangesMethod, dynamicsymbols, Body >>> from sympy.physics.mechanics import PrismaticJoint, JointsMethod >>> q = dynamicsymbols('q') >>> qd = dynamicsymbols('q', 1) >>> m, k, b = symbols('m k b') >>> with ignore_warnings(DeprecationWarning): ... wall = Body('W') ... part = Body('P', mass=m) >>> part.potential_energy = k * q**2 / S(2) >>> J = PrismaticJoint('J', wall, part, coordinates=q, speeds=qd) >>> wall.apply_force(b * qd * wall.x, reaction_body=part) >>> with ignore_warnings(DeprecationWarning): ... method = JointsMethod(wall, J) >>> method.form_eoms(LagrangesMethod) Matrix([[b*Derivative(q(t), t) + k*q(t) + m*Derivative(q(t), (t, 2))]]) We can also solve for the states using the 'rhs' method. >>> method.rhs() Matrix([ [ Derivative(q(t), t)], [(-b*Derivative(q(t), t) - k*q(t))/m]]) )rKrOkd_eqs forcelistr() r` issubclassrrrr.r+rr1r3r5 _form_eoms)r r5r]Lsolns r# form_eomszJointsMethod.form_eomssp'') fo .4::11A!!TVVTZZ4::NDL!$**DFF$&&QUQZQZ.2jjKDL{{%%' r%Nc:|jj|S)azReturns equations that can be solved numerically. Parameters ========== inv_method : str The specific sympy inverse matrix calculation method to use. For a list of valid methods, see :meth:`~sympy.matrices.matrixbase.MatrixBase.inv` Returns ======== Matrix Numerically solvable equations. See Also ======== sympy.physics.mechanics.kane.KanesMethod.rhs: KanesMethod's rhs function. sympy.physics.mechanics.lagrange.LagrangesMethod.rhs: LagrangesMethod's rhs function. ) inv_method)r5rhs)r rjs r#rkzJointsMethod.rhs#s6{{*55r%r?)__name__ __module__ __qualname____doc__r$propertyr(r+r.r1r3r6r8r:r<r5rrrrrr`rrhrkr%r#r r sPd.((,,''## $ +@D6r%N)sympy.physics.mechanicsrrrrrr!sympy.physics.mechanics.body_baser sympy.physics.mechanics.methodr sympyr sympy.utilities.exceptionsr __all__r rqr%r#rxs19963@  s68s6r%