
    \h?                     >    S r SSKJr  SSKJs  Jr    SS jrSS jr	g)zOThis module contains some sample symbolic models used for testing and
examples.    )backendNc                    [         R                  " SR                  U 5      5      n[         R                  " SR                  U 5      5      n[         R                  " SR                  U 5      5      n[         R                  " S5      n[        R                  " SR                  U 5      5      n[        R                  " SR                  U 5      5      n[        R                  " SR                  U 5      5      n	[        R
                  " S5      n
[        R                  " S	5      nUR                  U
S
5        U/n/ n/ n/ n[        U 5       GHb  nUS   R                  SR                  U5      UU   U
R                  -  5      nUR                  XS   R                  U
5      UU   U
R                  -  -   5        UR                  U5        [        R                  " SR                  U5      UUU   5      nUR                  UU   UU   R                  5       -
  5        UU   * UU   -  UU   UU   -  -
  n UUUS-      UUS-      -  UUS-      UUS-      -  -   -  nU(       a  UUU   U-  -  nU(       a  UU	U   -  nUR                  UUU
R                  -  45        UR                  U5        GMe     [        R                   " XUUS9nUR#                  X5        U$ ! [         a     Nf = f)a  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{}   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                        V/var/www/auris/envauris/lib/python3.13/site-packages/sympy/physics/mechanics/models.pymulti_mass_spring_damperr6   
   s   \ ::fmmA&'D

6==+,Ijjq)*G"$**S/##FMM!$45Kv}}Q/0F""6==#34J$GXXhF
NN7AXFIF1X%%j&7&7&:&1!nwyy&@Bwr
w 7ay799,!- 	.fI,,Q/aA""6!9{1~/B/B/D#DE!!}{1~5qzF1I-.	Ia!e,{1q5/AA#AENVAE]:; <K
 47%@@@K :a=(Kv{WYY6789 < >>'F!46D+K#  		s   1&K
K$#K$c                    U S::  a  [        S5      e[        R                  " SR                  U S-   5      5      n[        R                  " SR                  U S-   5      5      nUSL a(  [        R                  " SR                  U S-   5      5      n[        R
                  " SR                  U S-   5      5      n[        R
                  " S	R                  U 5      5      n[        R
                  " S
5      u  p[        R                  " S5      n
[        R                  " S5      nUR                  U
S5        [        R                  " S5      nUR                  XS   U
R                  -  5        UR                  XS   U
R                  -  5        [        R                  " SXS   5      nU
/nU/nU/nXS   * U-  U
R                  -  4/nUS   R                  U	5      US   -
  /nUSL d  USL a  / nOSn[        U 5       GH
  nU
R                  SR                  U5      SUUS-      U
R                   /5      nUR#                  XUS-      U
R                   -  5        UR%                  U5        US   R'                  SR                  US-   5      UU   UR                  -  5      nUR)                  US   U
U5        UR%                  U5        [        R                  " S[+        US-   5      -   UUUS-      5      nUR%                  U5        UR%                  UUUS-      * U-  U
R                  -  45        USL a  UR%                  WU   5        US:X  a#  UR%                  XU   * U
R                   -  45        UU S-
  :X  a$  UR%                  UUU   U
R                   -  45        O9UR%                  UUU   U
R                   -  UUS-      U
R                   -  -
  45        UR%                  UUS-      R                  U	5      UUS-      -
  5        GM     USL aG  [        R                  " S5      nUR%                  UUU
R                  -  45        UR%                  U5        [        R,                  " XUUS9nUR/                  UU5        U$ )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JKK
&--A./A
&--A./AgnnQU34


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


6==#$A::eDA
#A
AIIaO	$BJJqA$*JJqA$*
++eR1
&CSFTFIaD519qss?#$F!		!qt#$HT]d2		1X[[a&1QU8QSS/B
qAE(QSS.)bBZ!!%,,q1u"5qtbdd{C
vbz1b)bkk$QU+R1q5:rAa!eH9q=133./0D QqT"AvqQ4%!##+./AEzr1Q4!##:./r1Q4!##:!a%133#>?@!a%a(1QU8345 8 Tc"r1qss7m$>>!Ah?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LvrV   