o
    hu                     @   s   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	 d	ZG d
d dZ G dd dZ!G dd dZ"G dd dZ#G dd dZ$G dd dZ%dS )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                   @   s  e Zd Zejdddd Zdd Zejdde	j
fe	j
e	j
fed	ed	fed	ed	fed	d
 ed	 ed	d
 ed	 fgdd Zejddd	gdd Zejdeededgdd Zdd Zejdddgdd Zdd Zdd  Zd!d" Zd#d$ ZdS )%TestForceActuatorTautousec                 C   s~   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| _d S )	NFpApBq1q2q3   N)r   forcer   r   r    r   pathwayr   r!   r"   r#   q1dq2dq3dr   r%   self r-   _/var/www/vscode/kcb/lib/python3.10/site-packages/sympy/physics/mechanics/tests/test_actuator.py_linear_pathway_fixture(   s   





z)TestForceActuator._linear_pathway_fixturec                 C      t ttsJ d S N)
issubclassr
   r   r+   r-   r-   r.   test_is_actuator_base_subclass6      z0TestForceActuator.test_is_actuator_base_subclasszforce, expected_forcer$   r      c                 C   sJ   t || j}t|t sJ t|dsJ t|jtsJ |j|ks#J d S )Nr&   )r
   r'   
isinstancehasattrr&   ExprType)r,   r&   expected_forceinstancer-   r-   r.   test_valid_constructor_force9   s
   z.TestForceActuator.test_valid_constructor_forcer&   Nc                 C   <   t t t|| j}W d    d S 1 sw   Y  d S r1   )pytestraisesr   r
   r'   )r,   r&   _r-   r-   r.   .test_invalid_constructor_force_not_sympifyableJ      "z@TestForceActuator.test_invalid_constructor_force_not_sympifyabler'   r   r    c                 C   sJ   t | j|}t|t sJ t|dsJ t|jtsJ |j|ks#J d S )Nr'   )r
   r&   r6   r7   r'   r   )r,   r'   r:   r-   r-   r.   test_valid_constructor_pathwayO   s
   z0TestForceActuator.test_valid_constructor_pathwayc                 C   <   t t t| jd }W d    d S 1 sw   Y  d S r1   )r=   r>   	TypeErrorr
   r&   r,   r?   r-   r-   r.   1test_invalid_constructor_pathway_not_pathway_base\      "zCTestForceActuator.test_invalid_constructor_pathway_not_pathway_base property_name, fixture_attr_name)r&   r&   r'   r'   c                 C   T   t | j| j}t| |}tt t||| W d    d S 1 s#w   Y  d S r1   )r
   r&   r'   getattrr=   r>   AttributeErrorsetattr)r,   property_namefixture_attr_namer:   valuer-   r-   r.   test_properties_are_immutable`   
   
"z/TestForceActuator.test_properties_are_immutablec                 C   s&   t | j| j}d}t||ksJ d S )Nz'ForceActuator(F, LinearPathway(pA, pB)))r
   r&   r'   reprr,   actuatorexpectedr-   r-   r.   	test_reprm   s   zTestForceActuator.test_reprc                 C   sd   | j | jd| jj  t| j| j}| j| j | jj f| j | j| jj fg}| |ks0J d S Nr5   )	r    set_posr   r%   xr
   r&   r'   to_loadsrT   r-   r-   r.   test_to_loads_static_pathwayr   s   z.TestForceActuator.test_to_loads_static_pathwayc                 C   s   | j | jd| j | jj  t| j| j}| j| j | jt	| jd   | jj f| j | j| jt	| jd   | jj fg}|
 |ksGJ d S rX   )r    rY   r   r!   r%   rZ   r
   r&   r'   r   r[   rT   r-   r-   r.   test_to_loads_2D_pathway{   s   (&z*TestForceActuator.test_to_loads_2D_pathwayc                 C   s0  | j | j| j| jj | j| jj  d| j | jj	   t
| j| j}t| jd | jd  d| jd   }| j | j | jj | | j| j | jj |  d| j | j | jj	 |  }| j| j | jj | | j| j | jj |  d| j | j | jj	 |  }| j|f| j |fg}| |ksJ d S )Nr5      )r    rY   r   r!   r%   rZ   r"   yr#   zr
   r&   r'   r   r[   )r,   rU   lengthpO_forcepI_forcerV   r-   r-   r.   test_to_loads_3D_pathway   s,   ,&z*TestForceActuator.test_to_loads_3D_pathway)__name__
__module____qualname__r=   fixturer/   r3   markparametrizer   Oner   r   r;   r@   r   r   rB   rF   rQ   rW   r\   r]   rd   r-   r-   r-   r.   r   &   sD    


&




		r   c                   @   s~  e Zd Zejdddd Zdd Zdd Zej	d	d
e
jde
jeedd  fededde
jed eedd  fedede
je
jed eedd  fededededed eedd ed  fgdd Zej	dddgdd Zdd Zej	dddgdd Zej	dg ddd Zej	de
jd fedd!fgd"d# Zd$d% ZdS )&TestLinearSpringTr   c                 C   sP   t d| _t d| _td| _td| _t| j| j| _td| _	t
d| _d S )Nklr   r    qr%   )r   	stiffnessrn   r   r   r    r   r'   r   ro   r   r%   r+   r-   r-   r.   _linear_spring_fixture   s   




z'TestLinearSpring._linear_spring_fixturec                 C   r0   r1   )r2   r   r
   r+   r-   r-   r.   test_is_force_actuator_subclass   r4   z0TestLinearSpring.test_is_force_actuator_subclassc                 C   r0   r1   )r2   r   r   r+   r-   r-   r.   r3      r4   z/TestLinearSpring.test_is_actuator_base_subclasszUstiffness, expected_stiffness, equilibrium_length, expected_equilibrium_length, forcer$   r   ro   r5   rm   rn   c                 C   s   | j | j| j| jj  t|| j|}t|tsJ t	|ds"J t|j
ts*J |j
|ks1J t	|ds8J t|jts@J |j| jksHJ t	|dsOJ t|jtsWJ |j|ks^J t	|dseJ t|jtsmJ |j|kstJ d S )Nrp   r'   equilibrium_lengthr&   )r    rY   r   ro   r%   rZ   r   r'   r6   r7   rp   r8   r   rs   r&   )r,   rp   expected_stiffnessrs   expected_equilibrium_lengthr&   springr-   r-   r.   test_valid_constructor   s   /z'TestLinearSpring.test_valid_constructorrp   Nc                 C   @   t t t|| j| j}W d    d S 1 sw   Y  d S r1   )r=   r>   r   r   r'   rn   )r,   rp   r?   r-   r-   r.   2test_invalid_constructor_stiffness_not_sympifyable      "zCTestLinearSpring.test_invalid_constructor_stiffness_not_sympifyablec                 C   s@   t t t| jd | j}W d    d S 1 sw   Y  d S r1   )r=   r>   rD   r   rp   rn   rE   r-   r-   r.   rF      s   "zBTestLinearSpring.test_invalid_constructor_pathway_not_pathway_basers   c                 C   s@   t t t| j| j|}W d    d S 1 sw   Y  d S r1   )r=   r>   r   r   rp   r'   r,   rs   r?   r-   r-   r.   ;test_invalid_constructor_equilibrium_length_not_sympifyable   s   "zLTestLinearSpring.test_invalid_constructor_equilibrium_length_not_sympifyablerH   ))rp   rp   rI   )rs   rn   c                 C   sX   t | j| j| j}t| |}tt t||| W d    d S 1 s%w   Y  d S r1   )	r   rp   r'   rn   rK   r=   r>   rL   rM   )r,   rN   rO   rv   rP   r-   r-   r.   rQ     s
   	
"z.TestLinearSpring.test_properties_are_immutableequilibrium_length, expectedz&LinearSpring(k, LinearPathway(pA, pB))z<LinearSpring(k, LinearPathway(pA, pB), equilibrium_length=l)c                 C   s>   | j | j| j| jj  t| j| j|}t	||ksJ d S r1   )
r    rY   r   ro   r%   rZ   r   rp   r'   rS   r,   rs   rV   rv   r-   r-   r.   rW     s   zTestLinearSpring.test_reprc           
      C   s   | j | j| j| jj  t| j| j| j	}| jt
| jd  | jj }| jt
| jd | j	  | }| j t
| jd | j	  | }t| j|t| j |g}| }t||D ]\}\}}	t|tseJ |j|kslJ |j|	  dkswJ qXd S )Nr5   r   )r    rY   r   ro   r%   rZ   r   rp   r'   rn   r   r	   r[   zipr6   pointvectorsimplify)
r,   rv   normalpA_forcepB_forcerV   loadsloadr   r   r-   r-   r.   test_to_loads   s    zTestLinearSpring.test_to_loads)re   rf   rg   r=   rh   rq   rr   r3   ri   rj   r   rk   Zeror   r   r   rw   ry   rF   r|   rQ   rW   r   r-   r-   r-   r.   rl      sl    

	 
'




rl   c                   @   s   e Zd Zejdddd Zdd Zdd Zd	d
 Zdd Z	ej
dddgdd Zdd Zej
dddgdd Zdd Zdd ZdS )TestLinearDamperTr   c                 C   sf   t d| _t d| _td| _td| _t| j| j| _td| _	tdd| _
td| _td| _d S )	Ncrn   r   r    ro   r$   ur%   )r   dampingrn   r   r   r    r   r'   r   ro   dqr   r   r%   r+   r-   r-   r.   _linear_damper_fixture1  s   





z'TestLinearDamper._linear_damper_fixturec                 C   r0   r1   )r2   r   r
   r+   r-   r-   r.   rr   =  r4   z0TestLinearDamper.test_is_force_actuator_subclassc                 C   r0   r1   )r2   r   r   r+   r-   r-   r.   r3   @  r4   z/TestLinearDamper.test_is_actuator_base_subclassc                 C   s   | j | j| j| jj  t| j| j}t	|tsJ t
|ds"J t	|jts*J |j| jks2J t
|ds9J t	|jtsAJ |j| jksIJ d S )Nr   r'   )r    rY   r   ro   r%   rZ   r   r   r'   r6   r7   r8   r   )r,   damperr-   r-   r.   rw   C  s   z'TestLinearDamper.test_valid_constructorc                 C   sz   | j | j| j| jj  t| j| j}| j t	| jd  | j
 | j }t|ds,J t|jts4J |j|ks;J d S )Nr5   r&   )r    rY   r   ro   r%   rZ   r   r   r'   r   r   r7   r6   r&   r8   )r,   r   r9   r-   r-   r.   r;   Q  s   "z-TestLinearDamper.test_valid_constructor_forcer   Nr   c                 C   r<   r1   )r=   r>   r   r   r'   )r,   r   r?   r-   r-   r.   0test_invalid_constructor_damping_not_sympifyableZ  rA   zATestLinearDamper.test_invalid_constructor_damping_not_sympifyablec                 C   rC   r1   )r=   r>   rD   r   r   rE   r-   r-   r.   rF   _  rG   zBTestLinearDamper.test_invalid_constructor_pathway_not_pathway_baserH   )r   r   rI   c                 C   rJ   r1   )r   r   r'   rK   r=   r>   rL   rM   )r,   rN   rO   r   rP   r-   r-   r.   rQ   c  rR   z.TestLinearDamper.test_properties_are_immutablec                 C   s@   | j | j| j| jj  t| j| j}d}t	||ksJ d S )Nz&LinearDamper(c, LinearPathway(pA, pB)))
r    rY   r   ro   r%   rZ   r   r   r'   rS   )r,   r   rV   r-   r-   r.   rW   p  s   zTestLinearDamper.test_reprc                 C   s   | j | j| j| jj  t| j| j}| jd | jd  | jj }| j| j	 | }| j | j	 | }t
| j|t
| j |g}| |ksGJ d S rX   )r    rY   r   ro   r%   rZ   r   r   r'   r   r	   r[   )r,   r   	directionr   r   rV   r-   r-   r.   r   v  s   zTestLinearDamper.test_to_loads)re   rf   rg   r=   rh   r   rr   r3   rw   r;   ri   rj   r   rF   rQ   rW   r   r-   r-   r-   r.   r   /  s&    

	

r   c                   @   s4   e Zd ZdZejdddd Zdd Zdd	 Zd
S )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                 C   s  t d| _t d| _t d| _t d| _td| _tdd| _td| _t	d| _
td	| _| j| j
d
 td| _| j| j| j| j
j  td| j| j| _t| j| j| _t| j
| jg| jg| j| j gd| _| jg| _t| jgg| _t| j| j| j  | j| j  gg| _d S )Nmrm   r   r   ro   r$   r   r%   pOr   r   mass)q_indu_indkd_eqs)r   r   rm   r   r   r   ro   r   r   r   framer   originset_vel
attachmentrY   rZ   r   r   r   r'   r   kanes_methodbodiesr   mass_matrixforcingr+   r-   r-   r.   '_force_mass_spring_damper_model_fixture  s.   









,zGTestForcedMassSpringDamperModel._force_mass_spring_damper_model_fixturec                 C   s   | j  | jj }t|| j}| j | jj }t|| j}| j| j| jj	 fg|
 |
 }| j| j| | jj| jks@J | jj| jksIJ d S r1   )rm   r'   ra   r
   r   extension_velocityr   r   r   rZ   r[   r   kanes_equationsr   r   r   )r,   rp   rv   r   r   r   r-   r-   r.   test_force_acuator  s   z2TestForcedMassSpringDamperModel.test_force_acuatorc                 C   sz   t | j| j}t| j| j}| j| j| jj fg|	 |	 }| j
| j| | j
j| jks2J | j
j| jks;J d S r1   )r   rm   r'   r   r   r   r   r   rZ   r[   r   r   r   r   r   )r,   rv   r   r   r-   r-   r.    test_linear_spring_linear_damper  s   z@TestForcedMassSpringDamperModel.test_linear_spring_linear_damperN)	re   rf   rg   __doc__r=   rh   r   r   r   r-   r-   r-   r.   r     s    

r   c                	   @   s  e Zd Zejdddd Zdd Zejde	de
de	dd	 e	d gejd
ejejfeejfejefeefgdd Zejde	de
de	dd	 e	d gejdejegdd Zejdddgdd Zejde	de
dgdd Zejddedfeddfdedfeddfgdd Zejdg ddd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ ZdS ),TestTorqueActuatorTr   c                 C   sL   t d| _td| _td| _| jj| _td| jd| _td| jd| _	d S )NTr%   Ar   )r   r   )
r   torquer   r%   r   r`   axisr   r   r   r+   r-   r-   r.   _torque_actuator_fixture  s   



z+TestTorqueActuator._torque_actuator_fixturec                 C   r0   r1   )r2   r   r   r+   r-   r-   r.   r3     r4   z1TestTorqueActuator.test_is_actuator_base_subclassr   r   r5   ztarget_frame, reaction_framec                 C   s   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s4J |j| jks<J t|dsCJ t|jtsKJ |jt	j
ksSJ t|dsZJ t|jtsbJ |jtj
ksjJ d S Nr   r   target_framereaction_frame)r   r   r6   r7   r   r8   r   r   r   r   r   r   r   )r,   r   r   r   r:   r-   r-   r.   $test_valid_constructor_with_reaction  s&   z7TestTorqueActuator.test_valid_constructor_with_reactionr   c                 C   s   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s3J |j| jks;J t|dsBJ t|jtsJJ |jt	j
ksRJ t|dsYJ |jd u s`J d S r   )r   r   r6   r7   r   r8   r   r   r   r   r   r   )r,   r   r   r:   r-   r-   r.   'test_valid_constructor_without_reaction  s   
z:TestTorqueActuator.test_valid_constructor_without_reactionNc                 C   rx   r1   )r=   r>   r   r   r   r   )r,   r   r?   r-   r-   r.   /test_invalid_constructor_torque_not_sympifyable+  rz   zBTestTorqueActuator.test_invalid_constructor_torque_not_sympifyabler   ac                 C   D   t t t| j|| j| j}W d    d S 1 sw   Y  d S r1   )r=   r>   rD   r   r   r   r   )r,   r   r?   r-   r-   r.   (test_invalid_constructor_axis_not_vector0     "z;TestTorqueActuator.test_invalid_constructor_axis_not_vectorframeschildparentc                 C   sF   t t t| j| jg|R  }W d    d S 1 sw   Y  d S r1   )r=   r>   rD   r   r   r   )r,   r   r?   r-   r-   r.   )test_invalid_constructor_frames_not_frame5  s   
"z<TestTorqueActuator.test_invalid_constructor_frames_not_framerH   ))r   r   )r   r   )r   r   )r   r   c                 C   s\   t | j| j| j| j}t| |}tt t	||| W d    d S 1 s'w   Y  d S r1   )
r   r   r   r   r   rK   r=   r>   rL   rM   )r,   rN   rO   rU   rP   r-   r-   r.   rQ   B  s   

"z0TestTorqueActuator.test_properties_are_immutablec                 C   s*   t | j| j| j}d}t||ksJ d S )Nz+TorqueActuator(T, axis=N.z, target_frame=N))r   r   r   r   rS   rT   r-   r-   r.   test_repr_without_reactionV  s   z-TestTorqueActuator.test_repr_without_reactionc                 C   s.   t | j| j| j| j}d}t||ksJ d S )Nz=TorqueActuator(T, axis=N.z, target_frame=N, reaction_frame=A))r   r   r   r   r   rS   rT   r-   r-   r.   test_repr_with_reaction[  s   z*TestTorqueActuator.test_repr_with_reactionc              	   C   s   t d| j| jtdtd| j| jd}t| j|}t	|ts!J t
|ds(J t	|jts0J |j| jks8J t
|ds?J t	|jtsGJ |j| jksOJ t
|dsVJ t	|jts^J |j| jksfJ t
|dsmJ t	|jtsuJ |j| jks}J d S )	Npinro   r   )coordinatesspeedsparent_interframe
joint_axisr   r   r   r   )r   r   r   r   r%   r   r   at_pin_jointr   r6   r7   r8   r   r   r   r   r   )r,   	pin_jointr:   r-   r-   r.   test_at_pin_joint_constructore  s.   	z0TestTorqueActuator.test_at_pin_joint_constructorc                 C   sB   t t t| jtd}W d    d S 1 sw   Y  d S )Nr   )r=   r>   rD   r   r   r   r   rE   r-   r-   r.   1test_at_pin_joint_pin_joint_not_pin_joint_invalid  s   "zDTestTorqueActuator.test_at_pin_joint_pin_joint_not_pin_joint_invalidc                 C   s:   t | j| j| j}| j| j| j fg}| |ksJ d S r1   )r   r   r   r   r%   r[   rT   r-   r-   r.   test_to_loads_without_reaction  s   z1TestTorqueActuator.test_to_loads_without_reactionc                 C   sP   t | j| j| j| j}| j| j| j f| j| j | j fg}| |ks&J d S r1   )r   r   r   r   r   r%   r   r[   rT   r-   r-   r.   test_to_loads_with_reaction  s   z.TestTorqueActuator.test_to_loads_with_reaction)re   rf   rg   r=   rh   r   r3   ri   rj   r   r   r   r   r   r   r   r   r   r   r   r   rQ   r   r   r   r   r   r   r-   r-   r-   r.   r     sj    


	






	
	
r   c                   @   s   e Zd ZdS )NonSympifyableN)re   rf   rg   r-   r-   r-   r.   r     s    r   c                   @   s2  e Zd Zejdddd Zdd Zdd Zej	d	d
e
jd
e
jde
jeedd  eedd d  fededededde
jed eedd  edeedd d   fedededede
je
jed eedd  edeedd d   fededededededed eedd ed  edeedd ed d   fgdd Zej	dde gdd Zej	dde gdd Zdd Zej	dde gdd Zej	d g d!d"d# Zej	d$d%edd&fgd'd( Zd)d* ZdS )+TestDuffingSpringTr   c                 C   sZ   t d| _t d| _t d| _td| _td| _t| j| j| _t	d| _
td| _d S )Nbetaalpharn   r   r    ro   r%   )r   linear_stiffnessnonlinear_stiffnessrs   r   r   r    r   r'   r   ro   r   r%   r+   r-   r-   r.   _duffing_spring_fixture  s   





z)TestDuffingSpring._duffing_spring_fixturec                 C   r0   r1   )r2   r   r
   r+   r-   r-   r.   rr     r4   z1TestDuffingSpring.test_is_force_actuator_subclassc                 C   r0   r1   )r2   r   r   r+   r-   r-   r.   r3     r4   z0TestDuffingSpring.test_is_actuator_base_subclasszlinear_stiffness,  expected_linear_stiffness,  nonlinear_stiffness,   expected_nonlinear_stiffness,  equilibrium_length,    expected_equilibrium_length,   forcer$   r   ro   r5      r   r   rn   c           	      C   s  | j | j| j| jj  t||| j|}t|tsJ t	|ds#J t|j
ts+J |j
|ks2J t	|ds9J t|jtsAJ |j|ksHJ t	|dsOJ t|jtsWJ |j| jks_J t	|dsfJ t|jtsnJ |j|ksuJ t	|ds|J t|jtsJ |j|ksJ d S )Nr   r   r'   rs   r&   )r    rY   r   ro   r%   rZ   r   r'   r6   r7   r   r8   r   r   rs   r&   )	r,   r   expected_linear_stiffnessr   expected_nonlinear_stiffnessrs   ru   r&   rv   r-   r-   r.   rw     s$   ?z(TestDuffingSpring.test_valid_constructorr   Nc                 C   sD   t t t|| j| j| j}W d    d S 1 sw   Y  d S r1   )r=   r>   r   r   r   r'   rs   )r,   r   r?   r-   r-   r.   9test_invalid_constructor_linear_stiffness_not_sympifyable  r   zKTestDuffingSpring.test_invalid_constructor_linear_stiffness_not_sympifyabler   c                 C   r   r1   )r=   r>   r   r   r   r'   rs   )r,   r   r?   r-   r-   r.   <test_invalid_constructor_nonlinear_stiffness_not_sympifyable  r   zNTestDuffingSpring.test_invalid_constructor_nonlinear_stiffness_not_sympifyablec                 C   sF   t t t| j| jt | j}W d    d S 1 sw   Y  d S r1   )r=   r>   rD   r   r   r   r   rs   rE   r-   r-   r.   rF     s   "zCTestDuffingSpring.test_invalid_constructor_pathway_not_pathway_basers   c                 C   sD   t t t| j| j| j|}W d    d S 1 sw   Y  d S r1   )r=   r>   r   r   r   r   r'   r{   r-   r-   r.   r|     r   zMTestDuffingSpring.test_invalid_constructor_equilibrium_length_not_sympifyablerH   ))r   r   )r   r   rI   )rs   rs   c                 C   sX   t | j| j| j| j}tt t||t	| | W d    d S 1 s%w   Y  d S r1   )
r   r   r   r'   rs   r=   r>   rL   rM   rK   )r,   rN   rO   rv   r-   r-   r.   rQ     s   "z/TestDuffingSpring.test_properties_are_immutabler}   )r   zGDuffingSpring(beta, alpha, LinearPathway(pA, pB), equilibrium_length=0)zGDuffingSpring(beta, alpha, LinearPathway(pA, pB), equilibrium_length=l)c                 C   s(   t | j| j| j|}t||ksJ d S r1   )r   r   r   r'   rS   r~   r-   r-   r.   rW   .  s   
zTestDuffingSpring.test_reprc              
   C   s"  | j | j| j| jj  t| j| j| j	| j
}| j| j
 }| j | | j|d   }t| j|| jj t| j | | jj g}| }t||D ]E\}}|j|jksUJ | jD ]5}|j|}	|j|}
| jdtddtddtddi}|	|
 | }t|dk sJ d| qXqId S )Nr   r$   rn   r   r   g&.>z%The forces do not match. Difference: )r    rY   r   ro   r%   rZ   r   r   r   r'   rs   r	   r[   r   r   r   dotr   subsevalfr   )r,   rv   displacementr&   expected_loadscalculated_loads
calculatedrV   dimcalculated_componentexpected_componentsubstitutionsdiffr-   r-   r.   r   ;  s    *
"zTestDuffingSpring.test_to_loads)re   rf   rg   r=   rh   r   rr   r3   ri   rj   r   rk   r   r   r   r   rw   r   r   r   rF   r|   rQ   rW   r   r-   r-   r-   r.   r     s|    


$
4
4
D
5#





	r   )&r   r=   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   r8   r   r   r   rl   r   r   r   r   r   r-   r-   r-   r.   <module>   s      Hv QR J