
    sgu                     0   d Z ddlZddlmZmZmZmZmZmZ ddl	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZ  ed      Z ed      Z G d d	      Z G d
 d      Z  G d d      Z! G d d      Z" G d d      Z# G d d      Z$ G d d      Z%y)z=Tests for the ``sympy.physics.mechanics.actuator.py`` module.    N)SMatrixSymbolSympifyErrorsqrtAbs)ActuatorBaseForceForceActuatorKanesMethodLinearDamperLinearPathwayLinearSpringParticlePinJointPointReferenceFrame	RigidBodyTorqueActuatorVectordynamicsymbolsDuffingSpring)Exprtargetreactionc                   t   e Zd Z ej                  d      d        Zd Zej                  j                  dde	j                  fe	j                  e	j                  f ed       ed      f ed       ed      f ed      dz   ed      z    ed      dz   ed      z   fg      d	        Zej                  j                  d
ddg      d        Zej                  j                  d e ed       ed            g      d        Zd Zej                  j                  dddg      d        Zd Zd Zd Zd Zy)TestForceActuatorTautousec                    t        d      | _        t        d      | _        t        d      | _        t        | j                  | j                        | _        t        d      | _        t        d      | _	        t        d      | _
        t        dd      | _        t        dd      | _        t        dd      | _        t        d      | _        y )	NFpApBq1q2q3   N)r   forcer   r"   r#   r   pathwayr   r$   r%   r&   q1dq2dq3dr   r(   selfs    ^/var/www/html/venv/lib/python3.12/site-packages/sympy/physics/mechanics/tests/test_actuator.py_linear_pathway_fixturez)TestForceActuator._linear_pathway_fixture(   s    C[
++$TWWdgg6 & & &!$*!$*!$*$    c                 0    t        t        t              sJ y N)
issubclassr   r	   r.   s    r0   test_is_actuator_base_subclassz0TestForceActuator.test_is_actuator_base_subclass6       -666r2   zforce, expected_forcer'   r!      c                     t        || j                        }t        |t               sJ t        |d      sJ t        |j                  t
              sJ |j                  |k(  sJ y )Nr)   )r   r*   
isinstancehasattrr)   ExprType)r/   r)   expected_forceinstances       r0   test_valid_constructor_forcez.TestForceActuator.test_valid_constructor_force9   sZ     !5(M222x)))(..(333~~///r2   r)   Nc                     t        j                  t              5  t        || j                        }d d d        y # 1 sw Y   y xY wr4   )pytestraisesr   r   r*   )r/   r)   _s      r0   .test_invalid_constructor_force_not_sympifyablez@TestForceActuator.test_invalid_constructor_force_not_sympifyableJ   s3    ]]<( 	3eT\\2A	3 	3 	3	   :Ar*   r"   r#   c                     t        | j                  |      }t        |t               sJ t        |d      sJ t        |j                  t
              sJ |j                  |k(  sJ y )Nr*   )r   r)   r:   r;   r*   r   )r/   r*   r>   s      r0   test_valid_constructor_pathwayz0TestForceActuator.test_valid_constructor_pathwayO   s^     !W5(M222x+++(**M:::7***r2   c                     t        j                  t              5  t        | j                  d       }d d d        y # 1 sw Y   y xY wr4   )rA   rB   	TypeErrorr   r)   r/   rC   s     r0   1test_invalid_constructor_pathway_not_pathway_basezCTestForceActuator.test_invalid_constructor_pathway_not_pathway_base\   s3    ]]9% 	0djj$/A	0 	0 	0rE    property_name, fixture_attr_name)r)   r)   r*   r*   c                     t        | j                  | j                        }t        | |      }t	        j
                  t              5  t        |||       d d d        y # 1 sw Y   y xY wr4   )r   r)   r*   getattrrA   rB   AttributeErrorsetattr)r/   property_namefixture_attr_namer>   values        r0   test_properties_are_immutablez/TestForceActuator.test_properties_are_immutable`   sR     !T\\:/0]]>* 	4HmU3	4 	4 	4   AA&c                 h    t        | j                  | j                        }d}t        |      |k(  sJ y )Nz'ForceActuator(F, LinearPathway(pA, pB)))r   r)   r*   reprr/   actuatorexpecteds      r0   	test_reprzTestForceActuator.test_reprm   s-     T\\:<H~)))r2   c                    | j                   j                  | j                  d| j                  j                  z         t        | j                  | j                        }| j                  | j                   | j                  j                  z  f| j                   | j                  | j                  j                  z  fg}|j                         |k(  sJ y Nr8   )	r#   set_posr"   r(   xr   r)   r*   to_loadsrY   s      r0   test_to_loads_static_pathwayz.TestForceActuator.test_to_loads_static_pathwayr   s    46688, T\\:WW

l46688+,WWdjj)*
   "h...r2   c                 X   | j                   j                  | j                  d| j                  z  | j                  j
                  z         t        | j                  | j                        }| j                  | j                   | j                  t        | j                  dz        z  z  | j                  j
                  z  f| j                   | j                  | j                  t        | j                  dz        z  z  | j                  j
                  z  fg}|j                         |k(  sJ y r^   )r#   r_   r"   r$   r(   r`   r   r)   r*   r   ra   rY   s      r0   test_to_loads_2D_pathwayz*TestForceActuator.test_to_loads_2D_pathway{   s    47746688!34 T\\:WW

lDGGD!,<$<=dffhhFGWWdjj$''$twwz*:":;DFFHHDE
   "h...r2   c                    | j                   j                  | j                  | j                  | j                  j
                  z  | j                  | j                  j                  z  z
  d| j                  z  | j                  j                  z  z          t        | j                  | j                        }t        | j                  dz  | j                  dz  z   d| j                  dz  z  z         }| j                   | j                  z  | j                  j
                  z  |z  | j                  | j                  z  | j                  j                  z  |z  z   d| j                  z  | j                  z  | j                  j                  z  |z  z
  }| j                  | j                  z  | j                  j
                  z  |z  | j                  | j                  z  | j                  j                  z  |z  z
  d| j                  z  | j                  z  | j                  j                  z  |z  z   }| j                  |f| j                   |fg}|j                         |k(  sJ y )Nr8      )r#   r_   r"   r$   r(   r`   r%   yr&   zr   r)   r*   r   ra   )r/   rZ   lengthpO_forcepI_forcer[   s         r0   test_to_loads_3D_pathwayz*TestForceActuator.test_to_loads_3D_pathway   s   GGGGDFFHHtwwtvvxx//!DGG)DFFHH2DD	
 !T\\:dggqj477A:-$''1*<=jjL )&0jj )&01

l477"46688+F23 	 JJtwwtvvxx'.jj )&01

l477"46688+F23 	 WWhWWh
   "h...r2   )__name__
__module____qualname__rA   fixturer1   r6   markparametrizer   Oner   r   r?   rD   r   r   rG   rK   rU   r\   rb   rd   rl    r2   r0   r   r   &   se   V^^D!% "%7 [[JUUAEENC[&+&C ."56C[!^fSk)6#;>F3K+GH	
	0	0 [[WtSk23 33 [[%+uT{3	
++0 [[*"	
44*
///r2   r   c                      e Zd Z ej                  d      d        Zd Zd Zej                  j                  dde
j                  de
j                   e ed	      d
z         f ed       ed      de
j                   ed        e ed	      d
z        z  f ed       ed      e
j                  e
j                   ed        e ed	      d
z        z  f ed       ed       ed       ed       ed        e ed	      d
z         ed      z
  z  fg      d        Zej                  j                  dddg      d        Zd Zej                  j                  dddg      d        Zej                  j                  dg d      d        Zej                  j                  de
j                  df ed      dfg      d        Zd Zy)TestLinearSpringTr   c                    t        d      | _        t        d      | _        t        d      | _        t        d      | _        t        | j                  | j
                        | _        t        d      | _	        t        d      | _        y )Nklr"   r#   qr(   )r   	stiffnessry   r   r"   r#   r   r*   r   rz   r   r(   r.   s    r0   _linear_spring_fixturez'TestLinearSpring._linear_spring_fixture   s\    ++$TWWdgg6$$r2   c                 0    t        t        t              sJ y r4   )r5   r   r   r.   s    r0   test_is_force_actuator_subclassz0TestLinearSpring.test_is_force_actuator_subclass       ,666r2   c                 0    t        t        t              sJ y r4   )r5   r   r	   r.   s    r0   r6   z/TestLinearSpring.test_is_actuator_base_subclass       ,555r2   zUstiffness, expected_stiffness, equilibrium_length, expected_equilibrium_length, forcer'   r   rz   r8   rx   ry   c                    | j                   j                  | j                  | j                  | j                  j
                  z         t        || j                  |      }t        |t              sJ t        |d      sJ t        |j                  t              sJ |j                  |k(  sJ t        |d      sJ t        |j                  t              sJ |j                  | j                  k(  sJ t        |d      sJ t        |j                  t              sJ |j                  |k(  sJ t        |d      sJ t        |j                  t              sJ |j                  |k(  sJ y )Nr{   r*   equilibrium_lengthr)   )r#   r_   r"   rz   r(   r`   r   r*   r:   r;   r{   r<   r   r   r)   )r/   r{   expected_stiffnessr   expected_equilibrium_lengthr)   springs          r0   test_valid_constructorz'TestLinearSpring.test_valid_constructor   s5   ^ 	1i7IJ&,///v{+++&**H555#5555vy)))&..-888~~---v3444&33X>>>((,GGGGvw'''&,,111||u$$$r2   r{   Nc                     t        j                  t              5  t        || j                  | j
                        }d d d        y # 1 sw Y   y xY wr4   )rA   rB   r   r   r*   ry   )r/   r{   rC   s      r0   2test_invalid_constructor_stiffness_not_sympifyablezCTestLinearSpring.test_invalid_constructor_stiffness_not_sympifyable   s9    ]]<( 	>Ydff=A	> 	> 	>   "AAc                     t        j                  t              5  t        | j                  d | j
                        }d d d        y # 1 sw Y   y xY wr4   )rA   rB   rI   r   r{   ry   rJ   s     r0   rK   zBTestLinearSpring.test_invalid_constructor_pathway_not_pathway_base   s9    ]]9% 	;T^^T466:A	; 	; 	;r   r   c                     t        j                  t              5  t        | j                  | j
                  |      }d d d        y # 1 sw Y   y xY wr4   )rA   rB   r   r   r{   r*   r/   r   rC   s      r0   ;test_invalid_constructor_equilibrium_length_not_sympifyablezLTestLinearSpring.test_invalid_constructor_equilibrium_length_not_sympifyable   s@    
 ]]<( 	OT^^T\\;MNA	O 	O 	Or   rL   ))r{   r{   rM   )r   ry   c                     t        | j                  | j                  | j                        }t	        | |      }t        j                  t              5  t        |||       d d d        y # 1 sw Y   y xY wr4   )	r   r{   r*   ry   rO   rA   rB   rP   rQ   )r/   rR   rS   r   rT   s        r0   rU   z.TestLinearSpring.test_properties_are_immutable  sX     dnndllDFFC/0]]>* 	2FM51	2 	2 	2s   A((A1equilibrium_length, expectedz&LinearSpring(k, LinearPathway(pA, pB))z<LinearSpring(k, LinearPathway(pA, pB), equilibrium_length=l)c                     | j                   j                  | j                  | j                  | j                  j
                  z         t        | j                  | j                  |      }t        |      |k(  sJ y r4   )
r#   r_   r"   rz   r(   r`   r   r{   r*   rX   r/   r   r[   r   s       r0   r\   zTestLinearSpring.test_repr  sS     	1dnndll<NOF|x'''r2   c                 f   | j                   j                  | j                  | j                  | j                  j
                  z         t        | j                  | j                  | j                        }| j                  t        | j                  dz        z  | j                  j
                  z  }| j                  t        | j                  dz        | j                  z
  z  |z  }| j                   t        | j                  dz        | j                  z
  z  |z  }t        | j                  |      t        | j                   |      g}|j                         }t        ||      D ]M  \  }\  }}	t        |t              sJ |j                  |k(  sJ |j                   |	z
  j#                         dk(  rMJ  y )Nr8   r   )r#   r_   r"   rz   r(   r`   r   r{   r*   ry   r   r
   ra   zipr:   pointvectorsimplify)
r/   r   normalpA_forcepB_forcer[   loadsloadr   r   s
             r0   test_to_loadszTestLinearSpring.test_to_loads   sH   1dnndllDFFCTVVQY'0>>4	?TVV#;<VCNN?DOdff$<=fD$''8,eDGGX.FG!%(%9 	:!D/5&dE***::&&&KK&(224999	:r2   )rm   rn   ro   rA   rp   r|   r~   r6   rq   rr   r   rs   Zeror   r   r   r   r   rK   r   rU   r\   r   rt   r2   r0   rv   rv      s    V^^D!% "%76 [[ nS)1,-- ssT."5q"899 ssT."5q"899 ssssd>##6#9:VC[HI-	
&N%O&N%: [[[4+6> 7>; [[1D#;?O @O [[*	
22 [[&VV=>sN	
	(	(
:r2   rv   c                       e Zd Z ej                  d      d        Zd Zd Zd Zd Z	ej                  j                  dd	d
g      d        Zd Zej                  j                  dddg      d        Zd Zd Zy	)TestLinearDamperTr   c                 P   t        d      | _        t        d      | _        t        d      | _        t        d      | _        t        | j                  | j
                        | _        t        d      | _	        t        dd      | _
        t        d      | _        t        d      | _        y )	Ncry   r"   r#   rz   r'   ur(   )r   dampingry   r   r"   r#   r   r*   r   rz   dqr   r   r(   r.   s    r0   _linear_damper_fixturez'TestLinearDamper._linear_damper_fixture1  sv    c{++$TWWdgg6$ a($$r2   c                 0    t        t        t              sJ y r4   )r5   r   r   r.   s    r0   r~   z0TestLinearDamper.test_is_force_actuator_subclass=  r   r2   c                 0    t        t        t              sJ y r4   )r5   r   r	   r.   s    r0   r6   z/TestLinearDamper.test_is_actuator_base_subclass@  r   r2   c                 
   | j                   j                  | j                  | j                  | j                  j
                  z         t        | j                  | j                        }t        |t              sJ t        |d      sJ t        |j                  t              sJ |j                  | j                  k(  sJ t        |d      sJ t        |j                  t              sJ |j                  | j                  k(  sJ y )Nr   r*   )r#   r_   r"   rz   r(   r`   r   r   r*   r:   r;   r<   r   )r/   dampers     r0   r   z'TestLinearDamper.test_valid_constructorC  s    1dllDLL9&,///vy)))&..(333~~---vy)))&..-888~~---r2   c                    | j                   j                  | j                  | j                  | j                  j
                  z         t        | j                  | j                        }| j                   t        | j                  dz        z  | j                  z  | j                  z  }t        |d      sJ t        |j                  t              sJ |j                  |k(  sJ y )Nr8   r)   )r#   r_   r"   rz   r(   r`   r   r   r*   r   r   r;   r:   r)   r<   )r/   r   r=   s      r0   r?   z-TestLinearDamper.test_valid_constructor_forceQ  s    1dllDLL9,,tDFFAI6tww>tvvEvw'''&,,111||~---r2   r   Nr   c                     t        j                  t              5  t        || j                        }d d d        y # 1 sw Y   y xY wr4   )rA   rB   r   r   r*   )r/   r   rC   s      r0   0test_invalid_constructor_damping_not_sympifyablezATestLinearDamper.test_invalid_constructor_damping_not_sympifyableZ  s3    ]]<( 	4Wdll3A	4 	4 	4rE   c                     t        j                  t              5  t        | j                  d       }d d d        y # 1 sw Y   y xY wr4   )rA   rB   rI   r   r   rJ   s     r0   rK   zBTestLinearDamper.test_invalid_constructor_pathway_not_pathway_base_  s3    ]]9% 	1T\\40A	1 	1 	1rE   rL   )r   r   rM   c                     t        | j                  | j                        }t        | |      }t	        j
                  t              5  t        |||       d d d        y # 1 sw Y   y xY wr4   )r   r   r*   rO   rA   rB   rP   rQ   )r/   rR   rS   r   rT   s        r0   rU   z.TestLinearDamper.test_properties_are_immutablec  sR     dllDLL9/0]]>* 	2FM51	2 	2 	2rV   c                     | j                   j                  | j                  | j                  | j                  j
                  z         t        | j                  | j                        }d}t        |      |k(  sJ y )Nz&LinearDamper(c, LinearPathway(pA, pB)))
r#   r_   r"   rz   r(   r`   r   r   r*   rX   )r/   r   r[   s      r0   r\   zTestLinearDamper.test_reprp  sS    1dllDLL9;F|x'''r2   c                 2   | j                   j                  | j                  | j                  | j                  j
                  z         t        | j                  | j                        }| j                  dz  | j                  dz  z  | j                  j
                  z  }| j                  | j                  z  |z  }| j                   | j                  z  |z  }t        | j                  |      t        | j                   |      g}|j                         |k(  sJ y r^   )r#   r_   r"   rz   r(   r`   r   r   r*   r   r
   ra   )r/   r   	directionr   r   r[   s         r0   r   zTestLinearDamper.test_to_loadsv  s    1dllDLL9FFAIdffai'0	<<'	1LL=(2$''8,eDGGX.FG H,,,r2   )rm   rn   ro   rA   rp   r   r~   r6   r   r?   rq   rr   r   rK   rU   r\   r   rt   r2   r0   r   r   /  s    V^^D!	% "	%76.. [[Ys44 541 [[*""	
22(-r2   r   c                   N    e Zd ZdZ ej
                  d      d        Zd Zd Zy)TestForcedMassSpringDamperModela  A single degree of freedom translational forced mass-spring-damper.

    Notes
    =====

    This system is well known to have the governing equation:

    .. math::
        m \ddot{x} = F - k x - c \dot{x}

    where $F$ is an externally applied force, $m$ is the mass of the particle
    to which the spring and damper are attached, $k$ is the spring's stiffness,
    $c$ is the dampers damping coefficient, and $x$ is the generalized
    coordinate representing the system's single (translational) degree of
    freedom.

    Tr   c                 J   t        d      | _        t        d      | _        t        d      | _        t        d      | _        t        d      | _        t        dd      | _        t        d      | _        t        d      | _
        t        d	      | _        | j                  j                  | j                  d
       t        d      | _        | j                  j                  | j                  | j                  | j                  j                   z         t#        d| j                  | j                        | _        t'        | j                  | j                        | _        t+        | j                  | j                  g| j                  g| j                  | j                  z
  g      | _        | j$                  g| _        t1        | j                  gg      | _        t1        | j                  | j                  | j                  z  z
  | j                  | j                  z  z
  gg      | _        y )Nmrx   r   r!   rz   r'   r   r(   pOr   r"   mass)q_indu_indkd_eqs)r   r   rx   r   r!   r   rz   r   r   r   framer   originset_vel
attachmentr_   r`   r   r   r   r*   r   kanes_methodbodiesr   mass_matrixforcingr.   s    r0   '_force_mass_spring_damper_model_fixturezGTestForcedMassSpringDamperModel._force_mass_spring_damper_model_fixture  sz   $ a($#C(
DkDJJ*+TVVDJJLL-@AVT__dff=	$T[[$//B'JJ66(66(GGdff$%	
 yyk!DFF8*- 6 FGHIr2   c                 l   | j                    | j                  j                  z  }t        || j                        }| j                   | j                  j
                  z  }t        || j                        }| j                  | j                  | j                  j                  z  fg|j                         |j                         }| j                  j                  | j                  |       | j                  j                  | j                  k(  sJ | j                  j                  | j                  k(  sJ y r4   )rx   r*   ri   r   r   extension_velocityr   r!   r   r`   ra   r   kanes_equationsr   r   r   )r/   r{   r   r   r   r   s         r0   test_force_acuatorz2TestForcedMassSpringDamperModel.test_force_acuator  s    VVGDLL///	y$,,766'$,,999w5 __dffTZZ\\12
__
 __

 	))$++u=  ,,0@0@@@@  ((DLL888r2   c                    t        | j                  | j                        }t        | j                  | j                        }| j
                  | j                  | j                  j                  z  fg|j                         |j                         }| j                  j                  | j                  |       | j                  j                  | j                  k(  sJ | j                  j                  | j                  k(  sJ y r4   )r   rx   r*   r   r   r   r!   r   r`   ra   r   r   r   r   r   )r/   r   r   r   s       r0    test_linear_spring_linear_damperz@TestForcedMassSpringDamperModel.test_linear_spring_linear_damper  s    dffdll3dffdll3 __dffTZZ\\12
__
 __

 	))$++u=  ,,0@0@@@@  ((DLL888r2   N)	rm   rn   ro   __doc__rA   rp   r   r   r   rt   r2   r0   r   r     s2    $ V^^D!J "J>9 9r2   r   c            	          e Zd Z ej                  d      d        Zd Zej                  j                  d e	d       e
d       e	d      dz   e	d      z   g      ej                  j                  dej                  ej                  feej                  fej                  efeefg      d	               Zej                  j                  d e	d       e
d       e	d      dz   e	d      z   g      ej                  j                  d
ej                  eg      d               Zej                  j                  dddg      d        Zej                  j                  d e	d       e
d      g      d        Zej                  j                  dd ed      f ed      dfd ed      f ed      dfg      d        Zej                  j                  dg d      d        Zd Zd Zd Zd Zd Zd Zy)TestTorqueActuatorTr   c                 
   t        d      | _        t        d      | _        t        d      | _        | j                  j
                  | _        t        d| j                        | _        t        d| j                        | _	        y )NTr(   Ar   )r   r   )
r   torquer   r(   r   rh   axisr   r   r   r.   s    r0   _torque_actuator_fixturez+TestTorqueActuator._torque_actuator_fixture  sX    Sk$$FFHH	7!*DFF;r2   c                 0    t        t        t              sJ y r4   )r5   r   r	   r.   s    r0   r6   z1TestTorqueActuator.test_is_actuator_base_subclass  s    .,777r2   r   r   r8   ztarget_frame, reaction_framec                 |   t        || j                  ||      }t        |t               sJ t        |d      sJ t        |j                  t
              sJ |j                  |k(  sJ t        |d      sJ t        |j                  t              sJ |j                  | j                  k(  sJ t        |d      sJ t        |j                  t              sJ |j                  t        j                  k(  sJ t        |d      sJ t        |j                  t              sJ |j                  t        j                  k(  sJ y Nr   r   target_framereaction_frame)r   r   r:   r;   r   r<   r   r   r   r   r   r   r   )r/   r   r   r   r>   s        r0   $test_valid_constructor_with_reactionz7TestTorqueActuator.test_valid_constructor_with_reaction  s   . "II	
 (N333x***(//8444&(((x((((--000}}		)))x000(//@@@$$444x!1222(11>BBB&&(..888r2   r   c                     t        || j                  |      }t        |t               sJ t        |d      sJ t        |j                  t
              sJ |j                  |k(  sJ t        |d      sJ t        |j                  t              sJ |j                  | j                  k(  sJ t        |d      sJ t        |j                  t              sJ |j                  t        j                  k(  sJ t        |d      sJ |j                  J y r   )r   r   r:   r;   r   r<   r   r   r   r   r   r   )r/   r   r   r>   s       r0   'test_valid_constructor_without_reactionz:TestTorqueActuator.test_valid_constructor_without_reaction  s     "&$))\B(N333x***(//8444&(((x((((--000}}		)))x000(//@@@$$444x!1222&&...r2   Nc                     t        j                  t              5  t        || j                  | j
                        }d d d        y # 1 sw Y   y xY wr4   )rA   rB   r   r   r   r   )r/   r   rC   s      r0   /test_invalid_constructor_torque_not_sympifyablezBTestTorqueActuator.test_invalid_constructor_torque_not_sympifyable+  s9    ]]<( 	?vtyy$++>A	? 	? 	?r   r   ac                     t        j                  t              5  t        | j                  || j
                  | j                        }d d d        y # 1 sw Y   y xY wr4   )rA   rB   rI   r   r   r   r   )r/   r   rC   s      r0   (test_invalid_constructor_axis_not_vectorz;TestTorqueActuator.test_invalid_constructor_axis_not_vector0  sC    ]]9% 	Nt{{D$++t}}MA	N 	N 	N   -AAframeschildparentc                     t        j                  t              5  t        | j                  | j
                  g| }d d d        y # 1 sw Y   y xY wr4   )rA   rB   rI   r   r   r   )r/   r   rC   s      r0   )test_invalid_constructor_frames_not_framez<TestTorqueActuator.test_invalid_constructor_frames_not_frame5  sB     ]]9% 	@t{{DII??A	@ 	@ 	@r   rL   ))r   r   )r   r   )r   r   )r   r   c                     t        | j                  | j                  | j                  | j                        }t        | |      }t        j                  t              5  t        |||       d d d        y # 1 sw Y   y xY wr4   )
r   r   r   r   r   rO   rA   rB   rP   rQ   )r/   rR   rS   rZ   rT   s        r0   rU   z0TestTorqueActuator.test_properties_are_immutableB  sf     "KKIIKKMM	
 /0]]>* 	4HmU3	4 	4 	4s   A33A<c                 ~    t        | j                  | j                  | j                        }d}t	        |      |k(  sJ y )Nz+TorqueActuator(T, axis=N.z, target_frame=N))r   r   r   r   rX   rY   s      r0   test_repr_without_reactionz-TestTorqueActuator.test_repr_without_reactionV  s3    !$++tyy$++F@H~)))r2   c                     t        | j                  | j                  | j                  | j                        }d}t        |      |k(  sJ y )Nz=TorqueActuator(T, axis=N.z, target_frame=N, reaction_frame=A))r   r   r   r   r   rX   rY   s      r0   test_repr_with_reactionz*TestTorqueActuator.test_repr_with_reaction[  sB    !KKIIKKMM	
 SH~)))r2   c           	      (   t        d| j                  | j                  t        d      t        d      | j                  | j
                        }t        j                  | j                  |      }t        |t              sJ t        |d      sJ t        |j                  t              sJ |j                  | j                  k(  sJ t        |d      sJ t        |j
                  t              sJ |j
                  | j
                  k(  sJ t        |d      sJ t        |j                  t              sJ |j                  | j                  k(  sJ t        |d      sJ t        |j                   t              sJ |j                   | j                  k(  sJ y )	Npinrz   r   )coordinatesspeedsparent_interframe
joint_axisr   r   r   r   )r   r   r   r   r(   r   r   at_pin_jointr   r:   r;   r<   r   r   r   r   r   )r/   	pin_jointr>   s      r0   test_at_pin_joint_constructorz0TestTorqueActuator.test_at_pin_joint_constructore  sT   KKMM&s+!#&"ffyy
	 "..t{{IF(N333x***(//8444$++---x((((--000}}		)))x000(//@@@$$...x!1222(11>BBB&&$&&000r2   c                     t        j                  t              5  t        j                  | j
                  t        d            }d d d        y # 1 sw Y   y xY w)Nr   )rA   rB   rI   r   r   r   r   rJ   s     r0   1test_at_pin_joint_pin_joint_not_pin_joint_invalidzDTestTorqueActuator.test_at_pin_joint_pin_joint_not_pin_joint_invalid  sA    ]]9% 	H++DKKGA	H 	H 	Hs   *AAc                     t        | j                  | j                  | j                        }| j                  | j                  | j                  z  fg}|j                         |k(  sJ y r4   )r   r   r   r   r(   ra   rY   s      r0   test_to_loads_without_reactionz1TestTorqueActuator.test_to_loads_without_reaction  sU    !$++tyy$++FVVT[[*+
   "h...r2   c                 0   t        | j                  | j                  | j                  | j                        }| j
                  | j                  | j                  z  f| j                  | j                   | j                  z  fg}|j                         |k(  sJ y r4   )r   r   r   r   r   r(   r   ra   rY   s      r0   test_to_loads_with_reactionz.TestTorqueActuator.test_to_loads_with_reaction  s~    !KKIIKKMM	
 VVT[[*+VVt{{]499,-
   "h...r2   )rm   rn   ro   rA   rp   r   r6   rq   rr   r   r   r   r   r   r   r   r   r   r   r   r   rU   r   r   r   r   r   r   rt   r2   r0   r   r     s@   V^^D!< "<8 [[3K33KNVC[(	
 [[&\\8>>*X^^$\\8$X		
9"9< [[3K33KNVC[(	
 [[^fllF-CD/ E/& [[Xc{3? 4? [[VfSk>#3F%GHN IN [[>'*+H%t,9W%&x $'		
@@ [[*	
	4	4*
*1:H//r2   r   c                       e Zd Zy)NonSympifyableN)rm   rn   ro   rt   r2   r0   r   r     s    r2   r   c                   H   e Zd Z ej                  d      d        Zd Zd Zej                  j                  dde
j                  de
j                  de
j                   e ed	      d
z          e ed	      d
z        dz  z
  f ed       ed       ed       ed      de
j                   ed        e ed	      d
z        z   ed       e ed	      d
z        dz  z  z
  f ed       ed       ed       ed      e
j                  e
j                   ed        e ed	      d
z        z   ed       e ed	      d
z        dz  z  z
  f ed       ed       ed       ed       ed       ed       ed        e ed	      d
z         ed      z
  z   ed       e ed	      d
z         ed      z
  dz  z  z
  fg      d        Zej                  j                  dd e       g      d        Zej                  j                  dd e       g      d        Zd Zej                  j                  dd e       g      d        Zej                  j                  dg d      d        Zej                  j                  dd ed      dfg      d        Zd Zy) TestDuffingSpringTr   c                 .   t        d      | _        t        d      | _        t        d      | _        t	        d      | _        t	        d      | _        t        | j
                  | j                        | _        t        d      | _
        t        d      | _        y )Nbetaalphary   r"   r#   rz   r(   )r   linear_stiffnessnonlinear_stiffnessr   r   r"   r#   r   r*   r   rz   r   r(   r.   s    r0   _duffing_spring_fixturez)TestDuffingSpring._duffing_spring_fixture  sl     !'v#)'? "(+++$TWWdgg6$$r2   c                 0    t        t        t              sJ y r4   )r5   r   r   r.   s    r0   r~   z1TestDuffingSpring.test_is_force_actuator_subclass  s    -777r2   c                 0    t        t        t              sJ y r4   )r5   r   r	   r.   s    r0   r6   z0TestDuffingSpring.test_is_actuator_base_subclass  r7   r2   zlinear_stiffness,  expected_linear_stiffness,  nonlinear_stiffness,   expected_nonlinear_stiffness,  equilibrium_length,    expected_equilibrium_length,   forcer'   r   rz   r8      r   r  ry   c                 H   | j                   j                  | j                  | j                  | j                  j
                  z         t        ||| j                  |      }t        |t              sJ t        |d      sJ t        |j                  t              sJ |j                  |k(  sJ t        |d      sJ t        |j                  t              sJ |j                  |k(  sJ t        |d      sJ t        |j                  t              sJ |j                  | j                  k(  sJ t        |d      sJ t        |j                  t              sJ |j                  |k(  sJ t        |d      sJ t        |j                  t              sJ |j                  |k(  sJ y )Nr  r  r*   r   r)   )r#   r_   r"   rz   r(   r`   r   r*   r:   r;   r  r<   r  r   r   r)   )	r/   r  expected_linear_stiffnessr  expected_nonlinear_stiffnessr   r   r)   r   s	            r0   r   z(TestDuffingSpring.test_valid_constructor  sv   ~ 	1/1DdllTfg&-000v1222&118<<<&&*CCCCv4555&44h???))-IIIIvy)))&..-888~~---v3444&33X>>>((,GGGGvw'''&,,111||u$$$r2   r  Nc                     t        j                  t              5  t        || j                  | j
                  | j                        }d d d        y # 1 sw Y   y xY wr4   )rA   rB   r   r   r  r*   r   )r/   r  rC   s      r0   9test_invalid_constructor_linear_stiffness_not_sympifyablezKTestDuffingSpring.test_invalid_constructor_linear_stiffness_not_sympifyable  sI    ]]<( 	q.0H0H$,,X\XoXopA	q 	q 	qr   r  c                     t        j                  t              5  t        | j                  || j
                  | j                        }d d d        y # 1 sw Y   y xY wr4   )rA   rB   r   r   r  r*   r   )r/   r  rC   s      r0   <test_invalid_constructor_nonlinear_stiffness_not_sympifyablezNTestDuffingSpring.test_invalid_constructor_nonlinear_stiffness_not_sympifyable  sI    ]]<( 	qd335H$,,X\XoXopA	q 	q 	qr   c                     t        j                  t              5  t        | j                  | j
                  t               | j                        }d d d        y # 1 sw Y   y xY wr4   )rA   rB   rI   r   r  r  r   r   rJ   s     r0   rK   zCTestDuffingSpring.test_invalid_constructor_pathway_not_pathway_base  sM    ]]9% 	zd33T5M5M~O_aeaxaxyA	z 	z 	zs   5AA!r   c                     t        j                  t              5  t        | j                  | j
                  | j                  |      }d d d        y # 1 sw Y   y xY wr4   )rA   rB   r   r   r  r  r*   r   s      r0   r   zMTestDuffingSpring.test_invalid_constructor_equilibrium_length_not_sympifyable  sH    ]]<( 	qd33T5M5Mt||]opA	q 	q 	qr   rL   ))r  r  )r  r  rM   )r   r   c           	          t        | j                  | j                  | j                  | j                        }t        j                  t              5  t        ||t        | |             d d d        y # 1 sw Y   y xY wr4   )
r   r  r  r*   r   rA   rB   rP   rQ   rO   )r/   rR   rS   r   s       r0   rU   z/TestDuffingSpring.test_properties_are_immutable  sg     t44d6N6NPTP\P\^b^u^uv]]>* 	MFM749J+KL	M 	M 	Ms   A11A:r   )r   zGDuffingSpring(beta, alpha, LinearPathway(pA, pB), equilibrium_length=0)zGDuffingSpring(beta, alpha, LinearPathway(pA, pB), equilibrium_length=l)c                 |    t        | j                  | j                  | j                  |      }t	        |      |k(  sJ y r4   )r   r  r  r*   rX   r   s       r0   r\   zTestDuffingSpring.test_repr.  s:     t44d6N6NPTP\P\^pqF|x'''r2   c                 
   | j                   j                  | j                  | j                  | j                  j
                  z         t        | j                  | j                  | j                  | j                        }| j                  | j                  z
  }| j                   |z  | j                  |dz  z  z
  }t        | j                  || j                  j
                  z        t        | j                   | | j                  j
                  z        g}|j                         }t        ||      D ]  \  }}|j                  |j                  k(  sJ | j                  D ]  }|j                  j!                  |      }	|j                  j!                  |      }
| j                  dt#        d      dt#        d      dt#        d      di}|	|
z
  j%                  |      j'                         }t)        |      dk  rJ d|          y )Nr  r'   ry   r  r   g&.>z%The forces do not match. Difference: )r#   r_   r"   rz   r(   r`   r   r  r  r*   r   r
   ra   r   r   r   dotr   subsevalfr   )r/   r   displacementr)   expected_loadscalculated_loads
calculatedr[   dimcalculated_componentexpected_componentsubstitutionsdiffs                r0   r   zTestDuffingSpring.test_to_loads;  s   1t44d6N6NPTP\P\^b^u^uv vv 7 77 &&&58P8PS_abSb8bb  )9:E$''E6TXTZTZT\T\K\<]^ "??,$'(8.$I 		X J##x~~555vv X'1'8'8'<'<S'A$%-__%8%8%="!%F3KF7OQPVW]P^`a b,/AAGGV\\^4y4'W+PQUPV)WW'X		Xr2   )rm   rn   ro   rA   rp   r  r~   r6   rq   rr   r   rs   r   r   r   r   r   r   r  r  rK   r   rU   r\   r   rt   r2   r0   r   r     sH   V^^D!% "%87 [[	 nS)1,--tN34G4J/Ka.OO vvww^C%8!%; <<VG_dSabeSfhiSiNjmnMn=nn vvww^C%8!%; <<VG_dSabeSfhiSiNjmnMn=nn vvwwss4s(;Q(>#?&+#MNQWX_Q`dhiwx{i|~i  eA  DJ  KN  DO  eO  RS  dS  RS  S9%
1j!%k1j!%F [[/$8H1IJq Kq [[2T>;K4LMq Nqz [[1D.:J3KLq Mq [[*	
MM
 [[&ZC[cd	
((Xr2   r   )&r   rA   sympyr   r   r   r   r   r   sympy.physics.mechanicsr	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   sympy.core.exprr   r<   r   r   r   rv   r   r   r   r   r   rt   r2   r0   <module>r#     s    C      & -	8	Z s/ s/lP: P:fN- N-bO9 O9dF/ F/R	 	tX tXr2   