
    \hA                     $   S SK Jr  S SKJr  S SKJr  S SKJrJrJ	r	  S SK
Jr  S SKJr  S SKJr  S SKJrJrJr  S S	KJr  S S
KJr  S SKJr  S SKJrJr  S SKJr  S SKJ r   S SK!J"r"J#r#J$r$  S SK%J&r&  S SK'J(r(  SS/r)S r* " S S\5      r+ " S S5      r,g)    wraps)Basic)ImmutableMatrix)Matrixeyezeros
OrderedSet)ActuatorBase)BodyBase)
Lagrangian_validate_coordinatesfind_dynamicsymbols)Joint)KanesMethod)LagrangesMethod)_parse_loadgravity)_Methods)Particle)PointReferenceFramedynamicsymbols)iterable)
filldedentSymbolicSystemSystemc                 0   ^  [        T 5      U 4S j5       nU$ )z;Decorator to reset the eom_method if a property is changed.c                 *   > S U l         T" U /UQ70 UD6$ N_eom_method)selfargskwargsmethods      V/var/www/auris/envauris/lib/python3.13/site-packages/sympy/physics/mechanics/system.pywrapper"_reset_eom_method.<locals>.wrapper   s     d,T,V,,    r   )r'   r)   s   ` r(   _reset_eom_methodr,      s"     6]- - Nr+   c                   P   \ rS rSrSrSES jr\S 5       r\S 5       r	\S 5       r
\S 5       r\S	 5       r\S
 5       r\S 5       r\R                  \S 5       5       r\S 5       r\R                  \S 5       5       r\S 5       r\R                  \S 5       5       r\S 5       r\R                  \S 5       5       r\S 5       r\S 5       r\S 5       r\R                  \S 5       5       r\S 5       r\R                  \S 5       5       r\S 5       r\R                  \S 5       5       r\S 5       r\R                  \S 5       5       r\S 5       r\R                  \S 5       5       r\S 5       r\R                  \S  5       5       r\S! 5       r\R                  \S" 5       5       r\S# 5       r\R                  \S$ 5       5       r\S% 5       r\R                  \S& 5       5       r\S' 5       r\ S( 5       r!\ S) 5       r" SFS* jr#\  SGS, j5       r$\S-S..S/ j5       r%\S-S..S0 j5       r&\S1 5       r'\S2 5       r(\S3 5       r)\S4 5       r*\S5 5       r+\S6 5       r,\S7 5       r-\S8 5       r.\S9 5       r/S: r0S; r1S< r2\34S= jr4SHS> jr5\S? 5       r6\S@ 5       r7\SA 5       r8\SB 5       r9\3S+4SC jr:SDr;g)Ir   #   a  Class to define a multibody system and form its equations of motion.

Explanation
===========

A ``System`` instance stores the different objects associated with a model,
including bodies, joints, constraints, and other relevant information. With
all the relationships between components defined, the ``System`` can be used
to form the equations of motion using a backend, such as ``KanesMethod``.
The ``System`` has been designed to be compatible with third-party
libraries for greater flexibility and integration with other tools.

Attributes
==========

frame : ReferenceFrame
    Inertial reference frame of the system.
fixed_point : Point
    A fixed point in the inertial reference frame.
x : Vector
    Unit vector fixed in the inertial reference frame.
y : Vector
    Unit vector fixed in the inertial reference frame.
z : Vector
    Unit vector fixed in the inertial reference frame.
q : ImmutableMatrix
    Matrix of all the generalized coordinates, i.e. the independent
    generalized coordinates stacked upon the dependent.
u : ImmutableMatrix
    Matrix of all the generalized speeds, i.e. the independent generealized
    speeds stacked upon the dependent.
q_ind : ImmutableMatrix
    Matrix of the independent generalized coordinates.
q_dep : ImmutableMatrix
    Matrix of the dependent generalized coordinates.
u_ind : ImmutableMatrix
    Matrix of the independent generalized speeds.
u_dep : ImmutableMatrix
    Matrix of the dependent generalized speeds.
u_aux : ImmutableMatrix
    Matrix of auxiliary generalized speeds.
kdes : ImmutableMatrix
    Matrix of the kinematical differential equations as expressions equated
    to the zero matrix.
bodies : tuple of BodyBase subclasses
    Tuple of all bodies that make up the system.
joints : tuple of Joint
    Tuple of all joints that connect bodies in the system.
loads : tuple of LoadBase subclasses
    Tuple of all loads that have been applied to the system.
actuators : tuple of ActuatorBase subclasses
    Tuple of all actuators present in the system.
holonomic_constraints : ImmutableMatrix
    Matrix with the holonomic constraints as expressions equated to the zero
    matrix.
nonholonomic_constraints : ImmutableMatrix
    Matrix with the nonholonomic constraints as expressions equated to the
    zero matrix.
velocity_constraints : ImmutableMatrix
    Matrix with the velocity constraints as expressions equated to the zero
    matrix. These are by default derived as the time derivatives of the
    holonomic constraints extended with the nonholonomic constraints.
eom_method : subclass of KanesMethod or LagrangesMethod
    Backend for forming the equations of motion.

Examples
========

In the example below a cart with a pendulum is created. The cart moves along
the x axis of the rail and the pendulum rotates about the z axis. The length
of the pendulum is ``l`` with the pendulum represented as a particle. To
move the cart a time dependent force ``F`` is applied to the cart.

We first need to import some functions and create some of our variables.

>>> from sympy import symbols, simplify
>>> from sympy.physics.mechanics import (
...     mechanics_printing, dynamicsymbols, RigidBody, Particle,
...     ReferenceFrame, PrismaticJoint, PinJoint, System)
>>> mechanics_printing(pretty_print=False)
>>> g, l = symbols('g l')
>>> F = dynamicsymbols('F')

The next step is to create bodies. It is also useful to create a frame for
locating the particle with respect to the pin joint later on, as a particle
does not have a body-fixed frame.

>>> rail = RigidBody('rail')
>>> cart = RigidBody('cart')
>>> bob = Particle('bob')
>>> bob_frame = ReferenceFrame('bob_frame')

Initialize the system, with the rail as the Newtonian reference. The body is
also automatically added to the system.

>>> system = System.from_newtonian(rail)
>>> print(system.bodies[0])
rail

Create the joints, while immediately also adding them to the system.

>>> system.add_joints(
...     PrismaticJoint('slider', rail, cart, joint_axis=rail.x),
...     PinJoint('pin', cart, bob, joint_axis=cart.z,
...              child_interframe=bob_frame,
...              child_point=l * bob_frame.y)
... )
>>> system.joints
(PrismaticJoint: slider  parent: rail  child: cart,
PinJoint: pin  parent: cart  child: bob)

While adding the joints, the associated generalized coordinates, generalized
speeds, kinematic differential equations and bodies are also added to the
system.

>>> system.q
Matrix([
[q_slider],
[   q_pin]])
>>> system.u
Matrix([
[u_slider],
[   u_pin]])
>>> system.kdes
Matrix([
[u_slider - q_slider'],
[      u_pin - q_pin']])
>>> [body.name for body in system.bodies]
['rail', 'cart', 'bob']

With the kinematics established, we can now apply gravity and the cart force
``F``.

>>> system.apply_uniform_gravity(-g * system.y)
>>> system.add_loads((cart.masscenter, F * rail.x))
>>> system.loads
((rail_masscenter, - g*rail_mass*rail_frame.y),
 (cart_masscenter, - cart_mass*g*rail_frame.y),
 (bob_masscenter, - bob_mass*g*rail_frame.y),
 (cart_masscenter, F*rail_frame.x))

With the entire system defined, we can now form the equations of motion.
Before forming the equations of motion, one can also run some checks that
will try to identify some common errors.

>>> system.validate_system()
>>> system.form_eoms()
Matrix([
[bob_mass*l*u_pin**2*sin(q_pin) - bob_mass*l*cos(q_pin)*u_pin'
 - (bob_mass + cart_mass)*u_slider' + F],
[                   -bob_mass*g*l*sin(q_pin) - bob_mass*l**2*u_pin'
 - bob_mass*l*cos(q_pin)*u_slider']])
>>> simplify(system.mass_matrix)
Matrix([
[ bob_mass + cart_mass, bob_mass*l*cos(q_pin)],
[bob_mass*l*cos(q_pin),         bob_mass*l**2]])
>>> system.forcing
Matrix([
[bob_mass*l*u_pin**2*sin(q_pin) + F],
[          -bob_mass*g*l*sin(q_pin)]])

The complexity of the above example can be increased if we add a constraint
to prevent the particle from moving in the horizontal (x) direction. This
can be done by adding a holonomic constraint. After which we should also
redefine what our (in)dependent generalized coordinates and speeds are.

>>> system.add_holonomic_constraints(
...     bob.masscenter.pos_from(rail.masscenter).dot(system.x)
... )
>>> system.q_ind = system.get_joint('pin').coordinates
>>> system.q_dep = system.get_joint('slider').coordinates
>>> system.u_ind = system.get_joint('pin').speeds
>>> system.u_dep = system.get_joint('slider').speeds

With the updated system the equations of motion can be formed again.

>>> system.validate_system()
>>> system.form_eoms()
Matrix([[-bob_mass*g*l*sin(q_pin)
         - bob_mass*l**2*u_pin'
         - bob_mass*l*cos(q_pin)*u_slider'
         - l*(bob_mass*l*u_pin**2*sin(q_pin)
         - bob_mass*l*cos(q_pin)*u_pin'
         - (bob_mass + cart_mass)*u_slider')*cos(q_pin)
         - l*F*cos(q_pin)]])
>>> simplify(system.mass_matrix)
Matrix([
[bob_mass*l**2*sin(q_pin)**2, -cart_mass*l*cos(q_pin)],
[               l*cos(q_pin),                       1]])
>>> simplify(system.forcing)
Matrix([
[-l*(bob_mass*g*sin(q_pin) + bob_mass*l*u_pin**2*sin(2*q_pin)/2
 + F*cos(q_pin))],
[
l*u_pin**2*sin(q_pin)]])

Nc                 8   Uc  [        S5      nO [        U[         5      (       d  [        S5      eXl        Uc  [	        S5      nO [        U[        5      (       d  [        S5      eX l        U R
                  R                  U R                  S5        [        SS/ 5      R                  U l	        [        SS/ 5      R                  U l
        [        SS/ 5      R                  U l        [        SS/ 5      R                  U l        [        SS/ 5      R                  U l        [        SS/ 5      R                  U l        [        SS/ 5      R                  U l        [        SS/ 5      R                  U l        SU l        / U l        / U l        / U l        / U l        SU l        g)a:  Initialize the system.

Parameters
==========

frame : ReferenceFrame, optional
    The inertial frame of the system. If none is supplied, a new frame
    will be created.
fixed_point : Point, optional
    A fixed point in the inertial reference frame. If none is supplied,
    a new fixed_point will be created.

Ninertial_framez,Frame must be an instance of ReferenceFrame.inertial_pointz)Fixed point must be an instance of Point.r      )r   
isinstance	TypeError_framer   _fixed_pointset_velr   T_q_ind_q_dep_u_ind_u_dep_u_aux_kdes_hol_coneqs_nonhol_coneqs_vel_constrs_bodies_joints_loads
_actuatorsr#   )r$   framefixed_points      r(   __init__System.__init__   sZ    ="#34EE>22JKK 01KK//GHH'!!$++q1%aB/11%aB/11%aB/11%aB/11%aB/11$Q2.00
*1a466-aB799 r+   c                     [        U[        5      (       a  [        S5      eU " UR                  UR                  S9nUR                  U5        U$ )z7Constructs the system with respect to a Newtonian body.z7A Particle has no frame so cannot act as the Newtonian.)rF   rG   )r3   r   r4   rF   
masscenter
add_bodies)cls	newtoniansystems      r(   from_newtonianSystem.from_newtonian  sL     i** - . .9??	8L8LM)$r+   c                     U R                   $ )z,Fixed point in the inertial reference frame.)r6   r$   s    r(   rG   System.fixed_point  s        r+   c                     U R                   $ )z'Inertial reference frame of the system.)r5   rS   s    r(   rF   System.frame!       {{r+   c                 .    U R                   R                  $ z2Unit vector fixed in the inertial reference frame.)r5   xrS   s    r(   rZ   System.x&       {{}}r+   c                 .    U R                   R                  $ rY   )r5   yrS   s    r(   r^   System.y+  r\   r+   c                 .    U R                   R                  $ rY   )r5   zrS   s    r(   ra   System.z0  r\   r+   c                 ,    [        U R                  5      $ )z7Tuple of all bodies that have been added to the system.)tuplerB   rS   s    r(   bodiesSystem.bodies5       T\\""r+   c                 d    U R                  U5      nU R                  U/ [        SS5        Xl        g )NBodiesre   )_objects_to_list_check_objectsr   rB   r$   re   s     r(   re   rf   :  s/     &&v.FB(HEr+   c                 ,    [        U R                  5      $ )z7Tuple of all joints that have been added to the system.)rd   rC   rS   s    r(   jointsSystem.jointsA  rg   r+   c                     U R                  U5      nU R                  U/ [        SS5        / U l        U R                  " U6   g )NJointsrn   )rj   rk   r   rC   
add_joints)r$   rn   s     r(   rn   ro   F  s=     &&v.FBxB r+   c                 ,    [        U R                  5      $ )z4Tuple of loads that have been applied on the system.)rd   rD   rS   s    r(   loadsSystem.loadsN  s     T[[!!r+   c                 r    U R                  U5      nU Vs/ s H  n[        U5      PM     snU l        g s  snf r!   )rj   r   rD   r$   rt   loads      r(   rt   ru   S  s2     %%e,5:;UT{4(U;;s   4c                 ,    [        U R                  5      $ )z)Tuple of actuators present in the system.)rd   rE   rS   s    r(   	actuatorsSystem.actuatorsY  s     T__%%r+   c                 d    U R                  U5      nU R                  U/ [        SS5        Xl        g )N	Actuatorsrz   )rj   rk   r   rE   r$   rz   s     r(   rz   r{   ^  s2     )))4	Ir<'	)#r+   c                 L    U R                   R                  U R                  5      $ )zZMatrix of all the generalized coordinates with the independent
stacked upon the dependent.)r9   col_joinr:   rS   s    r(   qSystem.qf       {{##DKK00r+   c                 L    U R                   R                  U R                  5      $ )zUMatrix of all the generalized speeds with the independent stacked
upon the dependent.)r;   r   r<   rS   s    r(   uSystem.ul  r   r+   c                     U R                   $ )z2Matrix of the independent generalized coordinates.)r9   rS   s    r(   q_indSystem.q_indr  rW   r+   c                 z    U R                  U R                  U5      S/ U R                  S5      u  U l        U l        g )NTcoordinates)_parse_coordinatesrj   q_depr9   r:   )r$   r   s     r(   r   r   w  s8     $(#:#:!!%($DJJ$O T[r+   c                     U R                   $ )z0Matrix of the dependent generalized coordinates.)r:   rS   s    r(   r   System.q_dep}  rW   r+   c                 z    U R                  U R                  U5      SU R                  / S5      u  U l        U l        g )NFr   )r   rj   r   r9   r:   )r$   r   s     r(   r   r     s8     $(#:#:!!%(%R$P T[r+   c                     U R                   $ )z-Matrix of the independent generalized speeds.)r;   rS   s    r(   u_indSystem.u_ind  rW   r+   c                 z    U R                  U R                  U5      S/ U R                  S5      u  U l        U l        g )NTspeeds)r   rj   u_depr;   r<   )r$   r   s     r(   r   r     s8     $(#:#:!!%($DJJ$J T[r+   c                     U R                   $ )z+Matrix of the dependent generalized speeds.)r<   rS   s    r(   r   System.u_dep  rW   r+   c                 z    U R                  U R                  U5      SU R                  / S5      u  U l        U l        g )NFr   )r   rj   r   r;   r<   )r$   r   s     r(   r   r     s8     $(#:#:!!%(%R$K T[r+   c                     U R                   $ )z'Matrix of auxiliary generalized speeds.)r=   rS   s    r(   u_auxSystem.u_aux  rW   r+   c                 \    U R                  U R                  U5      S/ / S5      S   U l        g )NTu_auxiliaryr   )r   rj   r=   )r$   r   s     r(   r   r     s6     --!!%($BGGHJr+   c                     U R                   $ )zKinematical differential equations as expressions equated to the zero
matrix. These equations describe the coupling between the generalized
coordinates and the generalized speeds.)r>   rS   s    r(   kdesSystem.kdes  s    
 zzr+   c                 V    U R                  U5      nU R                  U/ S5      U l        g )N kinematic differential equations)rj   _parse_expressionsr>   r$   r   s     r(   r   r     s.     $$T*,,"8:
r+   c                     U R                   $ )zPMatrix with the holonomic constraints as expressions equated to the
zero matrix.)r?   rS   s    r(   holonomic_constraintsSystem.holonomic_constraints  s     r+   c                 V    U R                  U5      nU R                  U/ S5      U l        g )Nholonomic constraints)rj   r   r?   r$   constraintss     r(   r   r     s/     ++K82246r+   c                     U R                   $ )zSMatrix with the nonholonomic constraints as expressions equated to
the zero matrix.)r@   rS   s    r(   nonholonomic_constraintsSystem.nonholonomic_constraints  s     """r+   c                 V    U R                  U5      nU R                  U/ S5      U l        g )Nnonholonomic constraints)rj   r   r@   r   s     r(   r   r     s/     ++K8"5579r+   c                     U R                   cB  U R                  R                  [        R                  5      R                  U R                  5      $ U R                   $ )zMatrix with the velocity constraints as expressions equated to the
zero matrix. The velocity constraints are by default derived from the
holonomic and nonholonomic constraints unless they are explicitly set.
)rA   r   diffr   _tr   r   rS   s    r(   velocity_constraintsSystem.velocity_constraints  sO     $--22>3D3DENN--/ /   r+   c                 l    Uc  S U l         g U R                  U5      nU R                  U/ S5      U l         g )Nzvelocity constraints)rA   rj   r   r   s     r(   r   r     s@      $D++K8 3335r+   c                     U R                   $ )z,Backend for forming the equations of motion.r"   rS   s    r(   
eom_methodSystem.eom_method  s     r+   c                 D    [        U 5      (       d  U /$ [        U SS 5      $ )z+Helper to convert passed objects to a list.N)r   list)lsts    r(   rj   System._objects_to_list  s"     }}5LCF|r+   c                 N   [        U5      n[        5       n[        5       nU  HM  n[        X5      (       d  UR                  U5        X;   a  UR                  U5        M<  UR                  U5        MO     U(       a  [        U SU SU S35      eU(       a  [	        U SU S35      eg)a*  Helper to check the objects that are being added to the system.

Explanation
===========
This method checks that the objects that are being added to the system
are of the correct type and have not already been added. If any of the
objects are not of the correct type or have already been added, then
an error is raised.

Parameters
==========
objects : iterable
    The objects that would be added to the system.
obj_lst : list
    The list of objects that are already in the system.
expected_type : type
    The type that the objects should be.
obj_name : str
    The name of the category of objects. This string is used to
    formulate the error message for the user.
type_name : str
    The name of the type that the objects should be. This string is used
    to formulate the error message for the user.

 z	 are not .z' have already been added to the system.N)setr3   addr4   
ValueError)	objectsobj_lstexpected_typeobj_name	type_nameseen
duplicateswrong_typesobjs	            r(   rk   System._check_objects  s    6 7|U
eCc11${s#  xj+i	{!LMMz:, 7. / 0 0 r+   c           	         USS USS pv[        U5      (       d  U/[        U5      -  n[        X5       H0  u  pU	(       a  UR                  U5        M  UR                  U5        M2     SU R                  SS U R
                  SS -   SU R                  SS U R                  SS -   SU R                  SS XVU-   0n
[        S0 U
D6  [        S[        U5      U5      R                  [        S[        U5      U5      R                  4$ )z'Helper to parse coordinates and speeds.Nr   r   r   r2    )r   lenzipappendr   r   r   r   r=   r   r   r8   )r$   
new_coordsindependentold_coords_indold_coords_dep
coord_type
coords_ind
coords_depcoordindepcurrents              r(   r   System._parse_coordinates  s     "0!2N14EJ$$&-#j/9K
8LE!!%(!!%(	 9 !$**Q-$**Q-"?TZZ]TZZ]: $++a.J68 	((3z?J?AA3z?J?AAC 	Cr+   Fc                 :   USS n[        U 5      n U(       a  X Vs/ s H  oD* PM     sn-   nOUn[        R                  X[        US5        U  H  nUS:X  d  M  [	        SU S35      e   [        S[        U5      [        U 5      -   X-   5      R                  $ s  snf )z-Helper to parse expressions like constraints.Nexpressionsr   zParsed z
 are zero.r2   )r   r   rk   r   r   r   r   r8   )new_expressionsold_expressionsnamecheck_negativesexprcheck_exprss         r(   r   System._parse_expressions2  s     *!,/),OtU,OOK)KoE4+	-#Dqy 74&
!;<< $ q#o"6_9M"M.@BBC!	D -Ps   BT)r   c                n    U R                  X!U R                  U R                  S5      u  U l        U l        g)ag  Add generalized coordinate(s) to the system.

Parameters
==========

*coordinates : dynamicsymbols
    One or more generalized coordinates to be added to the system.
independent : bool or list of bool, optional
    Boolean whether a coordinate is dependent or independent. The
    default is True, so the coordinates are added as independent by
    default.

r   N)r   r   r   r9   r:   )r$   r   r   s      r(   add_coordinatesSystem.add_coordinatesD  s/     $(#:#:djj$**m$M T[r+   c                n    U R                  X!U R                  U R                  S5      u  U l        U l        g)aJ  Add generalized speed(s) to the system.

Parameters
==========

*speeds : dynamicsymbols
    One or more generalized speeds to be added to the system.
independent : bool or list of bool, optional
    Boolean whether a speed is dependent or independent. The default is
    True, so the speeds are added as independent by default.

r   N)r   r   r   r;   r<   )r$   r   r   s      r(   
add_speedsSystem.add_speedsV  s/     $(#:#:TZZ$C T[r+   c                 R    U R                  USU R                  / S5      S   U l        g)zAdd auxiliary speed(s) to the system.

Parameters
==========

*speeds : dynamicsymbols
    One or more auxiliary speeds to be added to the system.

Tr   r   N)r   r=   )r$   r   s     r(   add_auxiliary_speedsSystem.add_auxiliary_speedsg  s-     --D$++r=::;=r+   c                 D    U R                  XR                  SSS9U l        g)zAdd kinematic differential equation(s) to the system.

Parameters
==========

*kdes : Expr
    One or more kinematic differential equations.

r   Tr   N)r   r   r>   r   s     r(   add_kdesSystem.add_kdesu  s(     ,,))?  - "
r+   c                 D    U R                  XR                  SSS9U l        g)zAdd holonomic constraint(s) to the system.

Parameters
==========

*constraints : Expr
    One or more holonomic constraints, which are expressions that should
    be zero.

r   Tr   N)r   r?   r   s     r(   add_holonomic_constraints System.add_holonomic_constraints  s+      22))+B  3 "r+   c                 D    U R                  XR                  SSS9U l        g)zAdd nonholonomic constraint(s) to the system.

Parameters
==========

*constraints : Expr
    One or more nonholonomic constraints, which are expressions that
    should be zero.

r   Tr   N)r   r@   r   s     r(   add_nonholonomic_constraints#System.add_nonholonomic_constraints  s+     #55,,.H  6 "r+   c                 ~    U R                  XR                  [        SS5        U R                  R	                  U5        g)zmAdd body(ies) to the system.

Parameters
==========

bodies : Particle or RigidBody
    One or more bodies.

ri   re   N)rk   re   r   rB   extendrl   s     r(   rL   System.add_bodies  s.     	FKK8XNF#r+   c                 z    U Vs/ s H  n[        U5      PM     nnU R                  R                  U5        gs  snf )zdAdd load(s) to the system.

Parameters
==========

*loads : Force or Torque
    One or more loads.

N)r   rD   r   rw   s      r(   	add_loadsSystem.add_loads  s4     055utT"u55! 6s   8c                 J    U R                   " [        U/U R                  Q76 6   g)zApply uniform gravity to all bodies in the system by adding loads.

Parameters
==========

acceleration : Vector
    The acceleration due to gravity.

N)r   r   re   )r$   accelerations     r(   apply_uniform_gravitySystem.apply_uniform_gravity  s     	;t{{;<r+   c                 ~    U R                  XR                  [        SS5        U R                  R	                  U5        g)zyAdd actuator(s) to the system.

Parameters
==========

*actuators : subclass of ActuatorBase
    One or more actuators.

r}   rz   N)rk   rz   r   rE   r   r~   s     r(   add_actuatorsSystem.add_actuators  s1     	I~~|'	6y)r+   c                 x   U R                  XR                  [        SS5        U R                  R	                  U5        S [        S5       5       u  p#pEU H{  nUR                  UR                  5        UR                  UR                  5        UR                  UR                  5        UR                  UR                  UR                  45        M}     UR                  U R                  5      nUR                  U R                  5      nUR                  U R                  SS U R                  * SS -   5      nUR                  U R                  5      nU R                   " [#        U5      6   U R$                  " [#        U5      6   U R&                  " S [#        U5       5       6   U R(                  " [#        U5      6   g)ay  Add joint(s) to the system.

Explanation
===========

This methods adds one or more joints to the system including its
associated objects, i.e. generalized coordinates, generalized speeds,
kinematic differential equations and the bodies.

Parameters
==========

*joints : subclass of Joint
    One or more joints.

Notes
=====

For the generalized coordinates, generalized speeds and bodies it is
checked whether they are already known by the system instance. If they
are, then they are not added. The kinematic differential equations are
however always added to the system, so you should not also manually add
those on beforehand.

rq   rn   c              3   6   #    U  H  n[        5       v   M     g 7fr!   r
   ).0_s     r(   	<genexpr>$System.add_joints.<locals>.<genexpr>  s     ,L8aZ\\8s      Nc              3   4   #    U  H  oS :X  a  M
  Uv   M     g7f)r   Nr   )r
  kdes     r(   r  r    s     C{({s   		)rk   rn   r   rC   r   rangeupdater   r   r   parentchild
differencer   r   re   r   rd   r   r   rL   )r$   rn   r   r   r   re   joints          r(   rr   System.add_joints  sD   6 	FKK(KF#,L58,L)TEu001MM%,,'KK

#MM5<<56	 
 ",,TVV4""466*tyy|		z1o=>""4;;/eK01v'CuT{CDv'r+   c                 R    U R                    H  nUR                  U:X  d  M  Us  $    g)zRetrieve a body from the system by name.

Parameters
==========

name : str
    The name of the body to retrieve.

Returns
=======

RigidBody or Particle
    The body with the given name, or None if no such body exists.

N)rB   r   )r$   r   bodys      r(   get_bodySystem.get_body  s#      LLDyyD  !r+   c                 R    U R                    H  nUR                  U:X  d  M  Us  $    g)zRetrieve a joint from the system by name.

Parameters
==========

name : str
    The name of the joint to retrieve.

Returns
=======

subclass of Joint
    The joint with the given name, or None if no such joint exists.

N)rC   r   )r$   r   r  s      r(   	get_jointSystem.get_joint  s#      \\EzzT! "r+   c                 "    U R                  5       $ r!   )	form_eomsrS   s    r(   
_form_eomsSystem._form_eoms0  s    ~~r+   c                    U R                   [        S U R                   5       5      -   nU(       a  UOSn[        U[        5      (       a  1 SknUR                  U5      nU(       a  [        SUR                   SU S35      eU R                  U R                  U R                  U R                  U R                  U R                  U R                  U R                  U R                   X0R"                  SS.UEnU" S0 UD6U l        O[        U[&        5      (       a  1 S	knUR                  U5      nU(       a  [        SUR                   SU S35      eU R                  U R(                  UU R"                  U R                  U R*                  S
.UEnSU;  a  [-        US   /US   Q76 US'   U" S0 UD6U l        O[/        U S35      eU R0                  R3                  5       $ )a  Form the equations of motion of the system.

Parameters
==========

eom_method : subclass of KanesMethod or LagrangesMethod
    Backend class to be used for forming the equations of motion. The
    default is ``KanesMethod``.

Returns
========

ImmutableMatrix
    Vector of equations of motions.

Examples
========

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, PrismaticJoint, Particle,
...     RigidBody, System)
>>> q = dynamicsymbols('q')
>>> qd = dynamicsymbols('q', 1)
>>> m, k, b = symbols('m k b')
>>> wall = RigidBody('W')
>>> system = System.from_newtonian(wall)
>>> bob = Particle('P', mass=m)
>>> bob.potential_energy = S.Half * k * q**2
>>> system.add_joints(PrismaticJoint('J', wall, bob, q, qd))
>>> system.add_loads((bob.masscenter, b * qd * system.x))
>>> system.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.

>>> system.rhs()
Matrix([
[               Derivative(q(t), t)],
[(b*Derivative(q(t), t) - k*q(t))/m]])

c              3   R   #    U  H  oR                  5         H  o"v   M     M     g 7fr!   )to_loads)r
  actrx   s      r(   r  #System.form_eoms.<locals>.<genexpr>b  s       #G*S||~tD~DNs   %'N>   rF   r   r   re   kd_eqs	forcelistq_dependentr   u_dependentr   configuration_constraintszEThe following keyword arguments are not allowed to be overwritten in z: r   F)rF   r   r   r(  r*  r+  r,  r   r   r)  re   explicit_kinematics>   qsrF   re   r)  r   
hol_coneqsnonhol_coneqs)rF   r.  r)  re   r/  r0  r   rF   re    has not been implemented.r   )rt   rd   rz   
issubclassr   intersectionr   __name__rF   r   r   r   r   r   r   r   r   re   r#   r   r   r   r   NotImplementedErrorr   r!  )r$   r   r&   rt   disallowed_kwargswrong_kwargss         r(   r   System.form_eoms3  s   ^ 

U #G NN#G G GDj+..!? -99&AL &&0&9&9%:"\N!MN N  $zzDJJ#zzTYY%)ZZ

373M3M.2.G.G%)ZZ#(KK-2> 7=>F  *3F3D
O44!/ -99&AL &&0&9&9%:"\N!MN N  $zze $$($>$>'+'D'DP IOPF 6)'1&/ (E39(3C(E|$)3F3D%4N&OPP))++r+   c                 4    U R                   R                  US9$ )a  Compute the equations of motion in the explicit form.

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
========

ImmutableMatrix
    Equations of motion in the explicit form.

See Also
========

sympy.physics.mechanics.kane.KanesMethod.rhs:
    KanesMethod's ``rhs`` function.
sympy.physics.mechanics.lagrange.LagrangesMethod.rhs:
    LagrangesMethod's ``rhs`` function.

)
inv_method)r   rhs)r$   r:  s     r(   r;  
System.rhs  s    4 ""j"99r+   c                 .    U R                   R                  $ )a"  The mass matrix of the system.

Explanation
===========

The mass matrix $M_d$ and the forcing vector $f_d$ of a system describe
the system's dynamics according to the following equations:

.. math::
    M_d \dot{u} = f_d

where $\dot{u}$ is the time derivative of the generalized speeds.

)r   mass_matrixrS   s    r(   r>  System.mass_matrix  s      ***r+   c                 .    U R                   R                  $ )as  The mass matrix of the system, augmented by the kinematic
differential equations in explicit or implicit form.

Explanation
===========

The full mass matrix $M_m$ and the full forcing vector $f_m$ of a system
describe the dynamics and kinematics according to the following
equation:

.. math::
    M_m \dot{x} = f_m

where $x$ is the state vector stacking $q$ and $u$.

)r   mass_matrix_fullrS   s    r(   rA  System.mass_matrix_full  s    $ ///r+   c                 .    U R                   R                  $ )z!The forcing vector of the system.)r   forcingrS   s    r(   rD  System.forcing  s     &&&r+   c                 .    U R                   R                  $ )zqThe forcing vector of the system, augmented by the kinematic
differential equations in explicit or implicit form.)r   forcing_fullrS   s    r(   rG  System.forcing_full  s     +++r+   c           
      	   / nU R                   R                  S   nU R                  R                  S   nU R                  R                  S   U R                  R                  S   pv[        U R                  5      [        U R                  5      p[        U5      [        U	5      pXd:w  a!  UR                  [        SU SU S35      5        [        5       nU R                   H6  nUR                  [        UR                  5      R                  U5      5        M8     U(       a  UR                  [        SU S35      5        [        U[         5      (       Ga~  [        U R"                  5      n[        5       [        5       nnU R                   H  nUR                  [        UR$                  5      R                  U	5      5        UR                  [        UR"                  5      R                  U R"                  SS U R"                  * SS -   5      5        M     U(       a  UR                  [        SU S	35      5        U(       a  UR                  [        S
U S35      5        Xu:w  a!  UR                  [        SU SU S35      5        X:  a!  UR                  [        SU
 SU S35      5        X:w  a!  UR                  [        SU SU S35      5        GO;[        U[&        5      (       Ga  [        U R                  5      R                  U R                  R)                  [*        R,                  5      5      nU R                   H]  nUR                  [        UR$                  5      R                  U R                  R)                  [*        R,                  5      5      5        M_     U(       a  UR                  [        SU S35      5        U R.                  (       a(  UR                  [        SU R.                   S35      5        O[1        U S35      eU(       a  SU R                  4SU R                  4SU R.                  4SU R2                  4SU R                  4/nU Hj  u  nn[        5       nU Vs1 s H#  nUU;   d  UR5                  U5      (       d  M!  UiM%     nnU(       d  MI  UR                  [        SU SU S35      5        Ml     U(       a  [7        SR9                  U5      5      egs  snf )a  Validates the system using some basic checks.

Explanation
===========

This method validates the system based on the following checks:

- The number of dependent generalized coordinates should equal the
  number of holonomic constraints.
- All generalized coordinates defined by the joints should also be known
  to the system.
- If ``KanesMethod`` is used as a ``eom_method``:
    - All generalized speeds and kinematic differential equations
      defined by the joints should also be known to the system.
    - The number of dependent generalized speeds should equal the number
      of velocity constraints.
    - The number of generalized coordinates should be less than or equal
      to the number of generalized speeds.
    - The number of generalized coordinates should equal the number of
      kinematic differential equations.
- If ``LagrangesMethod`` is used as ``eom_method``:
    - There should not be any generalized speeds that are not
      derivatives of the generalized coordinates (this includes the
      generalized speeds defined by the joints).

Parameters
==========

eom_method : subclass of KanesMethod or LagrangesMethod
    Backend class that will be used for forming the equations of motion.
    There are different checks for the different backends. The default
    is ``KanesMethod``.
check_duplicates : bool
    Boolean whether the system should be checked for duplicate
    definitions. The default is False, because duplicates are already
    checked when adding objects to the system.

Notes
=====

This method is not guaranteed to be backwards compatible as it may
improve over time. The method can become both more and less strict in
certain areas. However a well-defined system should always pass all
these tests.

r   z=
            The number of dependent generalized coordinates zD should be
            equal to the number of holonomic constraints r   z)
            The generalized coordinates z8 used in joints are not added
            to the system.Nz(
                The generalized speeds z< used in joints are not added
                to the system.z6
                The kinematic differential equations z< used in
                joints are not added to the system.z<
                The number of dependent generalized speeds zG should be
                equal to the number of velocity constraints z7
                The number of generalized coordinates zR should be less than
                or equal to the number of generalized speeds z2
                The number of generalized speeds zS should be equal to the
                number of kinematic differential equations z are not supported by this
                method. Only derivatives of the generalized coordinates are
                supported. If these symbols are used in your expressions, then
                this will result in wrong equations of motion.z
                This method does not support auxiliary speeds. If these symbols
                are used in your expressions, then this will result in wrong
                equations of motion. The auxiliary speeds are r1  zgeneralized coordinateszgeneralized speedszauxiliary speedsre   rn   z
                    The r   z< exist multiple times within the
                    system.
)r   shaper   r   r   r   r   r   r   r   r   rn   r  r   r  r2  r   r   r   r   r   r   r   r   r5  re   r   r   join)r$   r   check_duplicatesmsgsn_hcn_vcn_q_depn_u_depq_setu_setn_qn_u	missing_qr  n_kdesmissing_kdes	missing_u	not_qdotsduplicates_to_checkr   r   r   rZ   r   s                           r(   validate_systemSystem.validate_system  s   ^ ))//2((..q1::++A.

0@0@0C466{CKuu:s5zS?KK
 (==DI F::>q$D E F E	[[ES!2!23>>uEF !KK
 ())2 4$    j+..^F&)eSU)L  U\\!2!=!=e!DE##C

O$>$>IIaLTYYJ?2%4 5 % J ,((1{ 3(" # $ J ,66B^ D4(7 8 9 J ,<<C9 E==AF!(G H I yJ ,77:e <>>AU!(G H I }J ,225 7<<B81(H I J 
O44DFF..tvv{{>;L;L/MNI  LL""",*TVV[[9J9J-K"LN % J ,((1{ 3?(B C D
 zzJ ,? @Dzzl!(O P Q
 &4N&OPP$=tvv#F$8$&&#A$6

#C$,dkk#:$,dkk#:	#<
 1	cu),IAT	TXXa[a
I:KK
 0a
| ,, !  !	 1 TYYt_--  Js   . S*S*)rE   rB   r#   r6   r5   r?   rC   r>   rD   r@   r:   r9   r=   r<   r;   rA   )NN)r   )Fr!   )<r4  
__module____qualname____firstlineno____doc__rH   classmethodrP   propertyrG   rF   rZ   r^   ra   re   setterr,   rn   rt   rz   r   r   r   r   r   r   r   r   r   r   r   r   staticmethodrj   rk   r   r   r   r   r   r   r   r   rL   r   r  r  rr   r  r  r!  r   r   r;  r>  rA  rD  rG  r]  __static_attributes__r   r+   r(   r   r   #   s+   DL& P   ! !         # # ]]  
 # # ]]!  ! " " \\<  < & & $  $ 1 1
 1 1
   \\O  O   \\P  P   \\J  J   \\K  K   \\J  J   
[[:  :
    
 !!6  "6
 # #
 $$9  %9
 ! !   5  !5       (0 (0V 7DC* +0D D" 8< M M" .2 C C  = = " " " " " " $ $ " " 
= 
= * * )( )(V((  $/ X,t:8 + +" 0 0& ' ' , ,
 *5u .r+   c            	          \ rS rSrSrSSSS0 SSSS4	S jr\S 5       r\S 5       r\S 5       r	\S 5       r
\S	 5       r\S
 5       r\S 5       r\S 5       rS r\S 5       r\S 5       rS rS r\S 5       r\S 5       rSrg)r   i\  a  SymbolicSystem is a class that contains all the information about a
system in a symbolic format such as the equations of motions and the bodies
and loads in the system.

There are three ways that the equations of motion can be described for
Symbolic System:


    [1] Explicit form where the kinematics and dynamics are combined
        x' = F_1(x, t, r, p)

    [2] Implicit form where the kinematics and dynamics are combined
        M_2(x, p) x' = F_2(x, t, r, p)

    [3] Implicit form where the kinematics and dynamics are separate
        M_3(q, p) u' = F_3(q, u, t, r, p)
        q' = G(q, u, t, r, p)

where

x : states, e.g. [q, u]
t : time
r : specified (exogenous) inputs
p : constants
q : generalized coordinates
u : generalized speeds
F_1 : right hand side of the combined equations in explicit form
F_2 : right hand side of the combined equations in implicit form
F_3 : right hand side of the dynamical equations in implicit form
M_2 : mass matrix of the combined equations in implicit form
M_3 : mass matrix of the dynamical equations in implicit form
G : right hand side of the kinematical differential equations

    Parameters
    ==========

    coord_states : ordered iterable of functions of time
        This input will either be a collection of the coordinates or states
        of the system depending on whether or not the speeds are also
        given. If speeds are specified this input will be assumed to
        be the coordinates otherwise this input will be assumed to
        be the states.

    right_hand_side : Matrix
        This variable is the right hand side of the equations of motion in
        any of the forms. The specific form will be assumed depending on
        whether a mass matrix or coordinate derivatives are given.

    speeds : ordered iterable of functions of time, optional
        This is a collection of the generalized speeds of the system. If
        given it will be assumed that the first argument (coord_states)
        will represent the generalized coordinates of the system.

    mass_matrix : Matrix, optional
        The matrix of the implicit forms of the equations of motion (forms
        [2] and [3]). The distinction between the forms is determined by
        whether or not the coordinate derivatives are passed in. If
        they are given form [3] will be assumed otherwise form [2] is
        assumed.

    coordinate_derivatives : Matrix, optional
        The right hand side of the kinematical equations in explicit form.
        If given it will be assumed that the equations of motion are being
        entered in form [3].

    alg_con : Iterable, optional
        The indexes of the rows in the equations of motion that contain
        algebraic constraints instead of differential equations. If the
        equations are input in form [3], it will be assumed the indexes are
        referencing the mass_matrix/right_hand_side combination and not the
        coordinate_derivatives.

    output_eqns : Dictionary, optional
        Any output equations that are desired to be tracked are stored in a
        dictionary where the key corresponds to the name given for the
        specific equation and the value is the equation itself in symbolic
        form

    coord_idxs : Iterable, optional
        If coord_states corresponds to the states rather than the
        coordinates this variable will tell SymbolicSystem which indexes of
        the states correspond to generalized coordinates.

    speed_idxs : Iterable, optional
        If coord_states corresponds to the states rather than the
        coordinates this variable will tell SymbolicSystem which indexes of
        the states correspond to generalized speeds.

    bodies : iterable of Body/Rigidbody objects, optional
        Iterable containing the bodies of the system

    loads : iterable of load instances (described below), optional
        Iterable containing the loads of the system where forces are given
        by (point of application, force vector) and torques are given by
        (reference frame acting upon, torque vector). Ex [(point, force),
        (ref_frame, torque)]

Attributes
==========

coordinates : Matrix, shape(n, 1)
    This is a matrix containing the generalized coordinates of the system

speeds : Matrix, shape(m, 1)
    This is a matrix containing the generalized speeds of the system

states : Matrix, shape(o, 1)
    This is a matrix containing the state variables of the system

alg_con : List
    This list contains the indices of the algebraic constraints in the
    combined equations of motion. The presence of these constraints
    requires that a DAE solver be used instead of an ODE solver.
    If the system is given in form [3] the alg_con variable will be
    adjusted such that it is a representation of the combined kinematics
    and dynamics thus make sure it always matches the mass matrix
    entered.

dyn_implicit_mat : Matrix, shape(m, m)
    This is the M matrix in form [3] of the equations of motion (the mass
    matrix or generalized inertia matrix of the dynamical equations of
    motion in implicit form).

dyn_implicit_rhs : Matrix, shape(m, 1)
    This is the F vector in form [3] of the equations of motion (the right
    hand side of the dynamical equations of motion in implicit form).

comb_implicit_mat : Matrix, shape(o, o)
    This is the M matrix in form [2] of the equations of motion.
    This matrix contains a block diagonal structure where the top
    left block (the first rows) represent the matrix in the
    implicit form of the kinematical equations and the bottom right
    block (the last rows) represent the matrix in the implicit form
    of the dynamical equations.

comb_implicit_rhs : Matrix, shape(o, 1)
    This is the F vector in form [2] of the equations of motion. The top
    part of the vector represents the right hand side of the implicit form
    of the kinemaical equations and the bottom of the vector represents the
    right hand side of the implicit form of the dynamical equations of
    motion.

comb_explicit_rhs : Matrix, shape(o, 1)
    This vector represents the right hand side of the combined equations of
    motion in explicit form (form [1] from above).

kin_explicit_rhs : Matrix, shape(m, 1)
    This is the right hand side of the explicit form of the kinematical
    equations of motion as can be seen in form [3] (the G matrix).

output_eqns : Dictionary
    If output equations were given they are stored in a dictionary where
    the key corresponds to the name given for the specific equation and
    the value is the equation itself in symbolic form

bodies : Tuple
    If the bodies in the system were given they are stored in a tuple for
    future access

loads : Tuple
    If the loads in the system were given they are stored in a tuple for
    future access. This includes forces and torques where forces are given
    by (point of application, force vector) and torques are given by
    (reference frame acted upon, torque vector).

Example
=======

As a simple example, the dynamics of a simple pendulum will be input into a
SymbolicSystem object manually. First some imports will be needed and then
symbols will be set up for the length of the pendulum (l), mass at the end
of the pendulum (m), and a constant for gravity (g). ::

    >>> from sympy import Matrix, sin, symbols
    >>> from sympy.physics.mechanics import dynamicsymbols, SymbolicSystem
    >>> l, m, g = symbols('l m g')

The system will be defined by an angle of theta from the vertical and a
generalized speed of omega will be used where omega = theta_dot. ::

    >>> theta, omega = dynamicsymbols('theta omega')

Now the equations of motion are ready to be formed and passed to the
SymbolicSystem object. ::

    >>> kin_explicit_rhs = Matrix([omega])
    >>> dyn_implicit_mat = Matrix([l**2 * m])
    >>> dyn_implicit_rhs = Matrix([-g * l * m * sin(theta)])
    >>> symsystem = SymbolicSystem([theta], dyn_implicit_rhs, [omega],
    ...                            dyn_implicit_mat)

Notes
=====

m : number of generalized speeds
n : number of generalized coordinates
o : number of states

Nc                    Uco  [        U5      U l        Uc  SU l        O$U Vs/ s H  oU   PM	     nn[        U5      U l        U	c  SU l        OoU	 Vs/ s H  oU   PM	     nn[        U5      U l        OJ[        U5      U l        [        U5      U l        U R                  R	                  U R                  5      U l        Ub(  XPl        X l        X@l        SU l        SU l	        SU l
        OUUb)  SU l        SU l        SU l        X l        X@l	        SU l
        O)SU l        SU l        SU l        SU l        SU l	        X l
        Ub   Ub  U Vs/ s H  o[        U5      -   PM     nnX`l        Xpl        [        U
[        5      (       d  U
b  [        U
5      n
[        U[        5      (       d  Ub  [        U5      nXl        Xl        gs  snf s  snf s  snf )z#Initializes a SymbolicSystem objectN)r   _states_coordinates_speedsr   _kin_explicit_rhs_dyn_implicit_rhs_dyn_implicit_mat_comb_implicit_rhs_comb_implicit_mat_comb_explicit_rhsr   _alg_conoutput_eqnsr3   rd   rB   rD   )r$   coord_statesright_hand_sider   r>  coordinate_derivativesalg_conrt  
coord_idxs
speed_idxsre   rt   icoordsspeeds_inters                  r(   rH   SymbolicSystem.__init__%  s    >!,/DL!$(!3=>:aq/:>$*6N!!#9CDAQD%l3 &| 4D!&>DL,,55dllCDL "-%;"%4"%0"&*D#&*D#&*D#$%)D"%)D"%)D"&5#&1#&*D#%)D"%)D"%)D"&*D#&*D#&5# #9#E@GH13566GH& &%((V-?6]F%''E,=%LEc ?  E@ Is   F?GG	c                 J    U R                   c  [        S5      eU R                   $ )z8Returns the column matrix of the generalized coordinatesz#The coordinates were not specified.)rk  AttributeErrorrS   s    r(   r   SymbolicSystem.coordinatese  s(     $ !FGG$$$r+   c                 J    U R                   c  [        S5      eU R                   $ )z/Returns the column matrix of generalized speedszThe speeds were not specified.)rl  r  rS   s    r(   r   SymbolicSystem.speedsm  s$     << !ABB<<r+   c                     U R                   $ )z0Returns the column matrix of the state variables)rj  rS   s    r(   statesSymbolicSystem.statesu  s     ||r+   c                     U R                   $ )z|Returns a list with the indices of the rows containing algebraic
constraints in the combined form of the equations of motion)rs  rS   s    r(   rx  SymbolicSystem.alg_conz  s     }}r+   c                 J    U R                   c  [        S5      eU R                   $ )zReturns the matrix, M, corresponding to the dynamic equations in
implicit form, M x' = F, where the kinematical equations are not
includedzJdyn_implicit_mat is not specified for equations of motion form [1] or [2].)ro  r  rS   s    r(   dyn_implicit_matSymbolicSystem.dyn_implicit_mat  3    
 !!)  "H I I )))r+   c                 J    U R                   c  [        S5      eU R                   $ )zReturns the column matrix, F, corresponding to the dynamic equations
in implicit form, M x' = F, where the kinematical equations are not
includedzJdyn_implicit_rhs is not specified for equations of motion form [1] or [2].)rn  r  rS   s    r(   dyn_implicit_rhsSymbolicSystem.dyn_implicit_rhs  r  r+   c                    U R                   c  U R                  b  [        U R                  5      n[        U R                  5      n[        X5      n[        X!5      n[        U5      R                  U5      nUR                  U R                  5      nUR                  U5      U l         U R                   $ [        S5      eU R                   $ )zReturns the matrix, M, corresponding to the equations of motion in
implicit form (form [2]), M x' = F, where the kinematical equations are
includedzDcomb_implicit_mat is not specified for equations of motion form [1].)
rq  ro  r   rm  rn  r	   r   row_joinr   r  )r$   num_kin_eqnsnum_dyn_eqnszeros1zeros2inter1inter2s          r(   comb_implicit_mat SymbolicSystem.comb_implicit_mat  s    
 ""*%%1"4#9#9:"4#9#9:|:|:\*33F;)?)?@*0//&*A'...$ &E F F ***r+   c                     U R                   cR  U R                  b:  U R                  nU R                  nUR                  U5      U l         U R                   $ [	        S5      eU R                   $ )zReturns the column matrix, F, corresponding to the equations of
motion in implicit form (form [2]), M x' = F, where the kinematical
equations are includedzGcomb_implicit_mat is not specified for equations of motion in form [1].)rp  rn  rm  r   r  )r$   	kin_inter	dyn_inters      r(   comb_implicit_rhs SymbolicSystem.comb_implicit_rhs  st    
 ""*%%1 22	 22	*3*<*<Y*G'...$ &H I I ***r+   c                    U R                   b  [        S5      e[        U SS5      nUb7  U R                  R	                  U R
                  5      nUR                  U5      nO%U R                  R	                  U R                  5      nX0l         g)zIf the explicit right hand side of the combined equations of motion
is to provided upon initialization, this method will calculate it. This
calculation can potentially take awhile to compute.Nz$comb_explicit_rhs is already formed.kin_explicit_rhs)	rr  r  getattrro  LUsolvern  r   rq  rp  )r$   r  r  outs       r(   compute_explicit_form$SymbolicSystem.compute_explicit_form  s}     "". !GHH148++33D4J4JKF//&)C))11$2I2IJC"%r+   c                 J    U R                   c  [        S5      eU R                   $ )z}Returns the right hand side of the equations of motion in explicit
form, x' = F, where the kinematical equations are includedzPPlease run .combute_explicit_form before attempting to access comb_explicit_rhs.)rr  r  rS   s    r(   comb_explicit_rhs SymbolicSystem.comb_explicit_rhs  s3     ""*  "K L L ***r+   c                 J    U R                   c  [        S5      eU R                   $ )zQReturns the right hand side of the kinematical equations in explicit
form, q' = GzJkin_explicit_rhs is not specified for equations of motion form [1] or [2].)rm  r  rS   s    r(   r  SymbolicSystem.kin_explicit_rhs  s3     !!)  "H I I )))r+   c                     U R                   c   U R                  SS U R                  SS -   nOU R                   SS n[        5       nU H  nUR	                  [        U5      5      nM     UR	                  U R                  5      n[        U5      $ )zWReturns a column matrix containing all of the symbols in the system
that depend on timeN)rr  r  r  r   unionr   rj  rd   )r$   eom_expressionsfunctions_of_timer   s       r(   dynamic_symbolsSymbolicSystem.dynamic_symbols  s     ""*#55a8#55a8 9O  $66q9OE#D 1 7 7#D)!+ $ .33DLLA&''r+   c                 *   U R                   c   U R                  SS U R                  SS -   nOU R                   SS n[        5       nU H  nUR	                  UR
                  5      nM      UR                  [        R                  5        [        U5      $ )z^Returns a column matrix containing all of the symbols in the system
that do not depend on timeN)
rr  r  r  r   r  free_symbolsremover   r   rd   )r$   r  	constantsr   s       r(   constant_symbolsSymbolicSystem.constant_symbols  s     ""*#55a8#55a8 9O  $66q9OE	#D!(9(9:I $**+Yr+   c                 J    U R                   c  [        S5      eU R                   $ )z Returns the bodies in the systemz)bodies were not specified for the system.)rB   r  rS   s    r(   re   SymbolicSystem.bodies  s$     << !LMM<<r+   c                 J    U R                   c  [        S5      eU R                   $ )zReturns the loads in the systemz(loads were not specified for the system.)rD   r  rS   s    r(   rt   SymbolicSystem.loads  s$     ;; !KLL;;r+   )rs  rB   rr  rq  rp  rk  ro  rn  rm  rD   rl  rj  rt  )r4  r_  r`  ra  rb  rH   rd  r   r   r  rx  r  r  r  r  r  r  r  r  r  re   rt   rg  r   r+   r(   r   r   \  s'   FP >B!$DT$>@ % %        
 * * * * + +( + + &  + + * *($ "      r+   N)-	functoolsr   sympy.core.basicr   sympy.matrices.immutabler   sympy.matrices.denser   r   r	   sympy.core.containersr    sympy.physics.mechanics.actuatorr   !sympy.physics.mechanics.body_baser   !sympy.physics.mechanics.functionsr   r   r   sympy.physics.mechanics.jointr   sympy.physics.mechanics.kaner    sympy.physics.mechanics.lagranger   sympy.physics.mechanics.loadsr   r   sympy.physics.mechanics.methodr    sympy.physics.mechanics.particler   sympy.physics.vectorr   r   r   sympy.utilities.iterablesr   sympy.utilities.miscr   __all__r,   r   r   r   r+   r(   <module>r     so     " 4 3 3 , 9 6< < / 4 < > 3 5 F F . +X
&v.X v.r!u ur+   