
    Ed?                     <    d Z ddlmZ ddlmc mZ 	 	 d	dZd
dZ	dS )zOThis module contains some sample symbolic models used for testing and
examples.    )backendN   Fc                 t   t          j        d                    |                     }t          j        d                    |                     }t          j        d                    |                     }t          j        d          }t          j        d                    |                     }t          j        d                    |                     }t          j        d                    |                     }	t          j        d          }
t          j        d	          }|                    |
d
           |g}g }g }g }t          |           D ]}|d         	                    d                    |          ||         |
j
        z            }|                    |
|d                             |
          ||         |
j
        z  z              |                    |           t          j        d                    |          |||                   }|                    ||         ||                                         z
             ||          ||         z  ||         ||         z  z
  }	 |||dz            ||dz            z  ||dz            ||dz            z  z   z  }n# t          $ r Y nw xY w|r|||         |z  z  }|r||	|         z  }|                    |||
j
        z  f           |                    |           t          j        |
|||          }|                    ||           |S )as  Returns a system containing the symbolic equations of motion and
    associated variables for a simple multi-degree of freedom point mass,
    spring, damper system with optional gravitational and external
    specified forces. For example, a two mass system under the influence of
    gravity and external forces looks like:

    ::

        ----------------
         |     |     |   | g
         \    | |    |   V
      k0 /    --- c0 |
         |     |     | x0, v0
        ---------    V
        |  m0   | -----
        ---------    |
         | |   |     |
         \ v  | |    |
      k1 / f0 --- c1 |
         |     |     | x1, v1
        ---------    V
        |  m1   | -----
        ---------
           | f1
           V

    Parameters
    ==========

    n : integer
        The number of masses in the serial chain.
    apply_gravity : boolean
        If true, gravity will be applied to each mass.
    apply_external_forces : boolean
        If true, a time varying external force will be applied to each mass.

    Returns
    =======

    kane : sympy.physics.mechanics.kane.KanesMethod
        A KanesMethod object.

    m:{}zk:{}zc:{}gzx:{}zv:{}zf:{}Noriginr   zcenter{}zblock{}r   q_indu_indkd_eqs)smsymbolsformatmedynamicsymbolsReferenceFramePointset_velrange	locatenewxvelappendParticlediff
IndexErrorKanesMethodkanes_equations)napply_gravityapply_external_forcesmass	stiffnessdampingacceleration_due_to_gravitycoordinatesspeeds
specifiedsceilingr	   pointskinematic_equations	particlesforcesicenterblocktotal_forcekanes                        >lib/python3.11/site-packages/sympy/physics/mechanics/models.pymulti_mass_spring_damperr6   
   s%   \ :fmmA&&''D
6==++,,Ijq))**G"$*S//#FMM!$4$455Kv}}Q//00F"6==#3#344J$$GXhF
NN7AXFIF1XX    %%j&7&7&:&:&1!nwy&@B Bwr
w 7 7ay79,!- 	. 	. 	.fI,,Q//aAA""6!9{1~/B/B/D/D#DEEE!!}{1~5qzF1I-.	Ia!e,{1q5/AA#AENVAE]:; <KK 	 	 	D	  	A47%@@@K  	):a=(Kv{WY67888>'F!46 6 6DF+++Ks   42J''
J43J4Tc                 	   | dk    rt          d          t          j        d                    | dz                       }t          j        d                    | dz                       }|du r*t          j        d                    | dz                       }t	          j        d                    | dz                       }t	          j        d	                    |                     }t	          j        d
          \  }}	t          j        d          }
t          j        d          }|                    |
d           t          j        d          }|	                    ||d         |
j
        z             |                    |
|d         |
j
        z             t          j        d||d                   }|
g}|g}|g}||d          |z  |
j        z  fg}|d                             |	          |d         z
  g}|du s|du rg }nd}t          |           D ]N}|
                    d                    |          d||dz            |
j        g          }|                    |
||dz            |
j        z             |                    |           |d                             d                    |dz             ||         |j        z            }|                    |d         |
|           |                    |           t          j        dt+          |dz             z   |||dz                      }|                    |           |                    |||dz             |z  |
j        z  f           |du r|                    ||                    |dk    r&|                    |
||          |
j        z  f           || dz
  k    r&|                    |||         |
j        z  f           n9|                    |||         |
j        z  ||dz            |
j        z  z
  f           |                    ||dz                                |	          ||dz            z
             P|du rHt          j        d          }|                    |||
j
        z  f           |                    |           t          j        |
|||          }|                    ||           |S )a-  Returns the system containing the symbolic first order equations of
    motion for a 2D n-link pendulum on a sliding cart under the influence of
    gravity.

    ::

                  |
         o    y   v
          \ 0 ^   g
           \  |
          --\-|----
          |  \|   |
      F-> |   o --|---> x
          |       |
          ---------
           o     o

    Parameters
    ==========

    n : integer
        The number of links in the pendulum.
    cart_force : boolean, default=True
        If true an external specified lateral force is applied to the cart.
    joint_torques : boolean, default=False
        If true joint torques will be added as specified inputs at each
        joint.

    Returns
    =======

    kane : sympy.physics.mechanics.kane.KanesMethod
        A KanesMethod object.

    Notes
    =====

    The degrees of freedom of the system are n + 1, i.e. one for each
    pendulum link and one for the lateral motion of the cart.

    M x' = F, where x = [u0, ..., un+1, q0, ..., qn+1]

    The joint angles are all defined relative to the ground where the x axis
    defines the ground line and the y axis points up. The joint torques are
    applied between each adjacent link and the between the cart and the
    lower link where a positive torque corresponds to positive angle.

    r   z/The number of links must be a positive integer.zq:{}r   zu:{}TzT1:{}r   zl:{}zg tIOP0Pa0NzB{}Axisr
   zP{}PaFr   )
ValueErrorr   r   r   r   r   r   r   r   set_posr   r   yr   r   	orientnewzset_ang_velr   r   v2pt_theorystrr   r    )r!   
cart_forcejoint_torquesquTmlr   tr8   r9   r:   r;   framesr,   r.   r/   kindiffs	specifiedr0   BiPiPair>   r4   s                             r5   n_link_pendulum_on_cartrU   p   s   b 	Av LJKKK
&--A..//A
&--A..//A 5gnnQU3344

6==Q''((A

6==##$$A:eDAq
#A
AIIaOOO	$BJJq!A$*JJq!A$*
+eR1
&
&CSFTFIAaD519qs?#$F!		!qt#$HT ]d2 			1XX 5 5[[a&1QU8QS/BB
q!AE(QS.)))bBZ!!%,,q1u"5"5qtbd{CC
vbz1b)))bk$QU+R1q5::rAa!eH9q=13./000D  
	AQqT"""Av 0q1Q4%!#+.///AEz Ar1Q4!#:.////r1Q4!#:!a%13#>?@@@!a%a((1QU834444T c""r1qs7m$$$>!1Ah???DF+++K    )r   FF)r   TF)
__doc__
sympy.corer   r   sympy.physics.mechanicsphysics	mechanicsr   r6   rU    rV   r5   <module>r]      s     % $ $ $ $ $ $ $ $ $ $ $ $ $ $ 1638c c c cLv v v v v vrV   