
    \h                     >   S r SSKJr  SSKJrJr  SSKJrJr  SSK	J
r
Jr  SSKJr  SSKJrJr  SSKJrJrJrJr  SS	KJr  SS
KJrJrJrJrJrJrJ r J!r!  SSK"J#r#  SSK$J%r%  SSK&J'r'  / SQr(\ " S S\5      5       r)\)RT                  r+ " S S\%\#5      r, " S S\,5      r-g)a   Implementations of musculotendon models.

Musculotendon models are a critical component of biomechanical models, one that
differentiates them from pure multibody systems. Musculotendon models produce a
force dependent on their level of activation, their length, and their
extension velocity. Length- and extension velocity-dependent force production
are governed by force-length and force-velocity characteristics.
These are normalized functions that are dependent on the musculotendon's state
and are specific to a given musculotendon model.

    )abstractmethod)IntEnumunique)FloatInteger)Symbolsymbols)sqrt)cossin)MutableDenseMatrixdiageyezeros)ActivationBase)CharacteristicCurveCollection"FiberForceLengthActiveDeGroote2016#FiberForceLengthPassiveDeGroote2016*FiberForceLengthPassiveInverseDeGroote2016FiberForceVelocityDeGroote2016%FiberForceVelocityInverseDeGroote2016TendonForceLengthDeGroote2016$TendonForceLengthInverseDeGroote2016)_NamedMixin)ForceActuator)dynamicsymbols)MusculotendonBaseMusculotendonDeGroote2016MusculotendonFormulationc                   2    \ rS rSrSrSrSrSrSrSr	S r
S	rg
)r   ,   a{  Enumeration of types of musculotendon dynamics formulations.

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

An (integer) enumeration is used as it allows for clearer selection of the
different formulations of musculotendon dynamics.

Members
=======

RIGID_TENDON : 0
    A rigid tendon model.
FIBER_LENGTH_EXPLICIT : 1
    An explicit elastic tendon model with the muscle fiber length (l_M) as
    the state variable.
TENDON_FORCE_EXPLICIT : 2
    An explicit elastic tendon model with the tendon force (F_T) as the
    state variable.
FIBER_LENGTH_IMPLICIT : 3
    An implicit elastic tendon model with the muscle fiber length (l_M) as
    the state variable and the muscle fiber velocity as an additional input
    variable.
TENDON_FORCE_IMPLICIT : 4
    An implicit elastic tendon model with the tendon force (F_T) as the
    state variable as the muscle fiber velocity as an additional input
    variable.

r               c                 ,    [        U R                  5      $ )a  Returns a string representation of the enumeration value.

Notes
=====

This hard coding is required due to an incompatibility between the
``IntEnum`` implementations in Python 3.10 and Python 3.11
(https://github.com/python/cpython/issues/84247). From Python 3.11
onwards, the ``__str__`` method uses ``int.__str__``, whereas prior it
used ``Enum.__str__``. Once Python 3.11 becomes the minimum version
supported by SymPy, this method override can be removed.

)strvalueselfs    `/var/www/auris/envauris/lib/python3.13/site-packages/sympy/physics/biomechanics/musculotendon.py__str__ MusculotendonFormulation.__str__R   s     4::     N)__name__
__module____qualname____firstlineno____doc__RIGID_TENDONFIBER_LENGTH_EXPLICITTENDON_FORCE_EXPLICITFIBER_LENGTH_IMPLICITTENDON_FORCE_IMPLICITr,   __static_attributes__r/   r.   r+   r   r   ,   s+    < Lr.   r   c            
       j  ^  \ rS rSrSr\SSSSSSSS.U 4S jjr\\SSS\" S5      \" S5      \" S	5      S
.S j5       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 5       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 5       r\S 5       rS rS  r S! r!S" r"S# 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- r-S. r.S/r/U =r0$ )0r   f   a  Abstract base class for all musculotendon classes to inherit from.

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

A musculotendon generates a contractile force based on its activation,
length, and shortening velocity. This abstract base class is to be inherited
by all musculotendon subclasses that implement different characteristic
musculotendon curves. Characteristic musculotendon curves are required for
the tendon force-length, passive fiber force-length, active fiber force-
length, and fiber force-velocity relationships.

Parameters
==========

name : str
    The name identifier associated with the musculotendon. This name is used
    as a suffix when automatically generated symbols are instantiated. It
    must be a string of nonzero length.
pathway : PathwayBase
    The pathway that the actuator follows. This must be an instance of a
    concrete subclass of ``PathwayBase``, e.g. ``LinearPathway``.
activation_dynamics : ActivationBase
    The activation dynamics that will be modeled within the musculotendon.
    This must be an instance of a concrete subclass of ``ActivationBase``,
    e.g. ``FirstOrderActivationDeGroote2016``.
musculotendon_dynamics : MusculotendonFormulation | int
    The formulation of musculotendon dynamics that should be used
    internally, i.e. rigid or elastic tendon model, the choice of
    musculotendon state etc. This must be a member of the integer
    enumeration ``MusculotendonFormulation`` or an integer that can be cast
    to a member. To use a rigid tendon formulation, set this to
    ``MusculotendonFormulation.RIGID_TENDON`` (or the integer value ``0``,
    which will be cast to the enumeration member). There are four possible
    formulations for an elastic tendon model. To use an explicit formulation
    with the fiber length as the state, set this to
    ``MusculotendonFormulation.FIBER_LENGTH_EXPLICIT`` (or the integer value
    ``1``). To use an explicit formulation with the tendon force as the
    state, set this to ``MusculotendonFormulation.TENDON_FORCE_EXPLICIT``
    (or the integer value ``2``). To use an implicit formulation with the
    fiber length as the state, set this to
    ``MusculotendonFormulation.FIBER_LENGTH_IMPLICIT`` (or the integer value
    ``3``). To use an implicit formulation with the tendon force as the
    state, set this to ``MusculotendonFormulation.TENDON_FORCE_IMPLICIT``
    (or the integer value ``4``). The default is
    ``MusculotendonFormulation.RIGID_TENDON``, which corresponds to a rigid
    tendon formulation.
tendon_slack_length : Expr | None
    The length of the tendon when the musculotendon is in its unloaded
    state. In a rigid tendon model the tendon length is the tendon slack
    length. In all musculotendon models, tendon slack length is used to
    normalize tendon length to give
    :math:`\tilde{l}^T = \frac{l^T}{l^T_{slack}}`.
peak_isometric_force : Expr | None
    The maximum force that the muscle fiber can produce when it is
    undergoing an isometric contraction (no lengthening velocity). In all
    musculotendon models, peak isometric force is used to normalized tendon
    and muscle fiber force to give
    :math:`\tilde{F}^T = \frac{F^T}{F^M_{max}}`.
optimal_fiber_length : Expr | None
    The muscle fiber length at which the muscle fibers produce no passive
    force and their maximum active force. In all musculotendon models,
    optimal fiber length is used to normalize muscle fiber length to give
    :math:`\tilde{l}^M = \frac{l^M}{l^M_{opt}}`.
maximal_fiber_velocity : Expr | None
    The fiber velocity at which, during muscle fiber shortening, the muscle
    fibers are unable to produce any active force. In all musculotendon
    models, maximal fiber velocity is used to normalize muscle fiber
    extension velocity to give :math:`\tilde{v}^M = \frac{v^M}{v^M_{max}}`.
optimal_pennation_angle : Expr | None
    The pennation angle when muscle fiber length equals the optimal fiber
    length.
fiber_damping_coefficient : Expr | None
    The coefficient of damping to be used in the damping element in the
    muscle fiber model.
with_defaults : bool
    Whether ``with_defaults`` alternate constructors should be used when
    automatically constructing child classes. Default is ``False``.

NF)musculotendon_dynamicstendon_slack_lengthpeak_isometric_forceoptimal_fiber_lengthmaximal_fiber_velocityoptimal_pennation_anglefiber_damping_coefficientwith_defaultsc                  > Xl         [        TU ]	  [        S5      U5        [	        U[
        5      (       d  SU S[        U5       S3n[        U5      eX0l        U R                  4U l	        Ub  XPl
        O[        SU R                    35      U l
        Ub  X`l        O[        SU R                    35      U l        Ub  Xpl        O[        SU R                    35      U l        Ub  Xl        O[        SU R                    35      U l        U	b  Xl        O[        S	U R                    35      U l        U
b  Xl        O[        S
U R                    35      U l        Xl        U["        R$                  :X  a  U R'                  5         OU["        R(                  :X  a  U R+                  5         OU["        R,                  :X  a  U R/                  5         OwU["        R0                  :X  a  U R3                  5         ORU["        R4                  :X  a  U R7                  5         O-S[9        U5       S[        U5       S["         S3n[        U5      eX@l        U R<                  * U l        g )NFz-Can't set attribute `activation_dynamics` to z- as it must be of type `ActivationBase`, not .
l_T_slack_F_M_max_l_M_opt_v_M_max_
alpha_opt_beta_zMusculotendon dynamics z0 passed to `musculotendon_dynamics` was of type z
, must be ) namesuper__init__r   
isinstancer   type	TypeError_activation_dynamics_child_objects
_l_T_slack_F_M_max_l_M_opt_v_M_max
_alpha_opt_beta_with_defaultsr   r5   $_rigid_tendon_musculotendon_dynamicsr6   -_fiber_length_explicit_musculotendon_dynamicsr7   -_tendon_force_explicit_musculotendon_dynamicsr8   -_fiber_length_implicit_musculotendon_dynamicsr9   -_tendon_force_implicit_musculotendon_dynamicsrepr_musculotendon_dynamics_F_T_force)r*   rN   pathwayactivation_dynamicsr=   r>   r?   r@   rA   rB   rC   rD   msg	__class__s                r+   rP   MusculotendonBase.__init__   s.    	 	g. -~>>@&' ())-.A)B(C1F 
 C. $7!#88; *1O$z$))%=>DO+0M"Xdii[#9:DM+0M"Xdii[#9:DM!-2M"Xdii[#9:DM".5O$z$))%=>DO$02J%		{ 34DJ ,!%=%J%JJ557#'?'U'UU>>@#'?'U'UU>>@#'?'U'UU>>@#'?'U'UU>>@ *$/E*F)G HB./0
+,A/  C. '=$ yyjr.   z10.0z0.0z0.1)r=   r>   r?   r@   rA   rB   rC   c                "    U " UUUUUUUUU	U
SS9$ )a  Recommended constructor that will use the published constants.

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

Returns a new instance of the musculotendon class using recommended
values for ``v_M_max``, ``alpha_opt``, and ``beta``. The values are:

    :math:`v^M_{max} = 10`
    :math:`\alpha_{opt} = 0`
    :math:`\beta = \frac{1}{10}`

The musculotendon curves are also instantiated using the constants from
the original publication.

Parameters
==========

name : str
    The name identifier associated with the musculotendon. This name is
    used as a suffix when automatically generated symbols are
    instantiated. It must be a string of nonzero length.
pathway : PathwayBase
    The pathway that the actuator follows. This must be an instance of a
    concrete subclass of ``PathwayBase``, e.g. ``LinearPathway``.
activation_dynamics : ActivationBase
    The activation dynamics that will be modeled within the
    musculotendon. This must be an instance of a concrete subclass of
    ``ActivationBase``, e.g. ``FirstOrderActivationDeGroote2016``.
musculotendon_dynamics : MusculotendonFormulation | int
    The formulation of musculotendon dynamics that should be used
    internally, i.e. rigid or elastic tendon model, the choice of
    musculotendon state etc. This must be a member of the integer
    enumeration ``MusculotendonFormulation`` or an integer that can be
    cast to a member. To use a rigid tendon formulation, set this to
    ``MusculotendonFormulation.RIGID_TENDON`` (or the integer value
    ``0``, which will be cast to the enumeration member). There are four
    possible formulations for an elastic tendon model. To use an
    explicit formulation with the fiber length as the state, set this to
    ``MusculotendonFormulation.FIBER_LENGTH_EXPLICIT`` (or the integer
    value ``1``). To use an explicit formulation with the tendon force
    as the state, set this to
    ``MusculotendonFormulation.TENDON_FORCE_EXPLICIT`` (or the integer
    value ``2``). To use an implicit formulation with the fiber length
    as the state, set this to
    ``MusculotendonFormulation.FIBER_LENGTH_IMPLICIT`` (or the integer
    value ``3``). To use an implicit formulation with the tendon force
    as the state, set this to
    ``MusculotendonFormulation.TENDON_FORCE_IMPLICIT`` (or the integer
    value ``4``). The default is
    ``MusculotendonFormulation.RIGID_TENDON``, which corresponds to a
    rigid tendon formulation.
tendon_slack_length : Expr | None
    The length of the tendon when the musculotendon is in its unloaded
    state. In a rigid tendon model the tendon length is the tendon slack
    length. In all musculotendon models, tendon slack length is used to
    normalize tendon length to give
    :math:`\tilde{l}^T = \frac{l^T}{l^T_{slack}}`.
peak_isometric_force : Expr | None
    The maximum force that the muscle fiber can produce when it is
    undergoing an isometric contraction (no lengthening velocity). In
    all musculotendon models, peak isometric force is used to normalized
    tendon and muscle fiber force to give
    :math:`\tilde{F}^T = \frac{F^T}{F^M_{max}}`.
optimal_fiber_length : Expr | None
    The muscle fiber length at which the muscle fibers produce no
    passive force and their maximum active force. In all musculotendon
    models, optimal fiber length is used to normalize muscle fiber
    length to give :math:`\tilde{l}^M = \frac{l^M}{l^M_{opt}}`.
maximal_fiber_velocity : Expr | None
    The fiber velocity at which, during muscle fiber shortening, the
    muscle fibers are unable to produce any active force. In all
    musculotendon models, maximal fiber velocity is used to normalize
    muscle fiber extension velocity to give
    :math:`\tilde{v}^M = \frac{v^M}{v^M_{max}}`.
optimal_pennation_angle : Expr | None
    The pennation angle when muscle fiber length equals the optimal
    fiber length.
fiber_damping_coefficient : Expr | None
    The coefficient of damping to be used in the damping element in the
    muscle fiber model.

T)	rg   r=   r>   r?   r@   rA   rB   rC   rD   r/   )clsrN   rf   rg   r=   r>   r?   r@   rA   rB   rC   s              r+   rD   MusculotendonBase.with_defaults  s3    D  3#9 3!5!5#9$;&?
 	
r.   c                     g)zWReturn a ``CharacteristicCurveCollection`` of the curves related to
the specific model.Nr/   )rl   s    r+   curvesMusculotendonBase.curves  s     	r.   c                     U R                   $ )a  Symbol or value corresponding to the tendon slack length constant.

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

The length of the tendon when the musculotendon is in its unloaded
state. In a rigid tendon model the tendon length is the tendon slack
length. In all musculotendon models, tendon slack length is used to
normalize tendon length to give
:math:`\tilde{l}^T = \frac{l^T}{l^T_{slack}}`.

The alias ``l_T_slack`` can also be used to access the same attribute.

rV   r)   s    r+   r>   %MusculotendonBase.tendon_slack_length  s      r.   c                     U R                   $ )a  Symbol or value corresponding to the tendon slack length constant.

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

The length of the tendon when the musculotendon is in its unloaded
state. In a rigid tendon model the tendon length is the tendon slack
length. In all musculotendon models, tendon slack length is used to
normalize tendon length to give
:math:`\tilde{l}^T = \frac{l^T}{l^T_{slack}}`.

The alias ``tendon_slack_length`` can also be used to access the same
attribute.

rr   r)   s    r+   	l_T_slackMusculotendonBase.l_T_slack  s    " r.   c                     U R                   $ )a  Symbol or value corresponding to the peak isometric force constant.

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

The maximum force that the muscle fiber can produce when it is
undergoing an isometric contraction (no lengthening velocity). In all
musculotendon models, peak isometric force is used to normalized tendon
and muscle fiber force to give
:math:`\tilde{F}^T = \frac{F^T}{F^M_{max}}`.

The alias ``F_M_max`` can also be used to access the same attribute.

rW   r)   s    r+   r?   &MusculotendonBase.peak_isometric_force        }}r.   c                     U R                   $ )a  Symbol or value corresponding to the peak isometric force constant.

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

The maximum force that the muscle fiber can produce when it is
undergoing an isometric contraction (no lengthening velocity). In all
musculotendon models, peak isometric force is used to normalized tendon
and muscle fiber force to give
:math:`\tilde{F}^T = \frac{F^T}{F^M_{max}}`.

The alias ``peak_isometric_force`` can also be used to access the same
attribute.

rx   r)   s    r+   F_M_maxMusculotendonBase.F_M_max  s    " }}r.   c                     U R                   $ )a  Symbol or value corresponding to the optimal fiber length constant.

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

The muscle fiber length at which the muscle fibers produce no passive
force and their maximum active force. In all musculotendon models,
optimal fiber length is used to normalize muscle fiber length to give
:math:`\tilde{l}^M = \frac{l^M}{l^M_{opt}}`.

The alias ``l_M_opt`` can also be used to access the same attribute.

rX   r)   s    r+   r@   &MusculotendonBase.optimal_fiber_length       }}r.   c                     U R                   $ )a  Symbol or value corresponding to the optimal fiber length constant.

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

The muscle fiber length at which the muscle fibers produce no passive
force and their maximum active force. In all musculotendon models,
optimal fiber length is used to normalize muscle fiber length to give
:math:`\tilde{l}^M = \frac{l^M}{l^M_{opt}}`.

The alias ``optimal_fiber_length`` can also be used to access the same
attribute.

r   r)   s    r+   l_M_optMusculotendonBase.l_M_opt  rz   r.   c                     U R                   $ )a  Symbol or value corresponding to the maximal fiber velocity constant.

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

The fiber velocity at which, during muscle fiber shortening, the muscle
fibers are unable to produce any active force. In all musculotendon
models, maximal fiber velocity is used to normalize muscle fiber
extension velocity to give :math:`\tilde{v}^M = \frac{v^M}{v^M_{max}}`.

The alias ``v_M_max`` can also be used to access the same attribute.

rY   r)   s    r+   rA   (MusculotendonBase.maximal_fiber_velocity  r   r.   c                     U R                   $ )a  Symbol or value corresponding to the maximal fiber velocity constant.

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

The fiber velocity at which, during muscle fiber shortening, the muscle
fibers are unable to produce any active force. In all musculotendon
models, maximal fiber velocity is used to normalize muscle fiber
extension velocity to give :math:`\tilde{v}^M = \frac{v^M}{v^M_{max}}`.

The alias ``maximal_fiber_velocity`` can also be used to access the same
attribute.

r   r)   s    r+   v_M_maxMusculotendonBase.v_M_max  rz   r.   c                     U R                   $ )zSymbol or value corresponding to the optimal pennation angle
constant.

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

The pennation angle when muscle fiber length equals the optimal fiber
length.

The alias ``alpha_opt`` can also be used to access the same attribute.

rZ   r)   s    r+   rB   )MusculotendonBase.optimal_pennation_angle  s     r.   c                     U R                   $ )a  Symbol or value corresponding to the optimal pennation angle
constant.

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

The pennation angle when muscle fiber length equals the optimal fiber
length.

The alias ``optimal_pennation_angle`` can also be used to access the
same attribute.

r   r)   s    r+   	alpha_optMusculotendonBase.alpha_opt&  s     r.   c                     U R                   $ )zSymbol or value corresponding to the fiber damping coefficient
constant.

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

The coefficient of damping to be used in the damping element in the
muscle fiber model.

The alias ``beta`` can also be used to access the same attribute.

r[   r)   s    r+   rC   +MusculotendonBase.fiber_damping_coefficient7  s     zzr.   c                     U R                   $ )a  Symbol or value corresponding to the fiber damping coefficient
constant.

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

The coefficient of damping to be used in the damping element in the
muscle fiber model.

The alias ``fiber_damping_coefficient`` can also be used to access the
same attribute.

r   r)   s    r+   betaMusculotendonBase.betaG  s     zzr.   c                     U R                   $ )a"  Activation dynamics model governing this musculotendon's activation.

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

Returns the instance of a subclass of ``ActivationBase`` that governs
the relationship between excitation and activation that is used to
represent the activation dynamics of this musculotendon.

)rT   r)   s    r+   rg   %MusculotendonBase.activation_dynamicsX  s     (((r.   c                 .    U R                   R                  $ )zDynamic symbol representing excitation.

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

The alias ``e`` can also be used to access the same attribute.

rT   _er)   s    r+   
excitationMusculotendonBase.excitationf       ((+++r.   c                 .    U R                   R                  $ )zDynamic symbol representing excitation.

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

The alias ``excitation`` can also be used to access the same attribute.

r   r)   s    r+   eMusculotendonBase.er  r   r.   c                 .    U R                   R                  $ )zDynamic symbol representing activation.

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

The alias ``a`` can also be used to access the same attribute.

rT   _ar)   s    r+   
activationMusculotendonBase.activation~  r   r.   c                 .    U R                   R                  $ )zDynamic symbol representing activation.

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

The alias ``activation`` can also be used to access the same attribute.

r   r)   s    r+   aMusculotendonBase.a  r   r.   c                     U R                   $ )aB  The choice of rigid or type of elastic tendon musculotendon dynamics.

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

The formulation of musculotendon dynamics that should be used
internally, i.e. rigid or elastic tendon model, the choice of
musculotendon state etc. This must be a member of the integer
enumeration ``MusculotendonFormulation`` or an integer that can be cast
to a member. To use a rigid tendon formulation, set this to
``MusculotendonFormulation.RIGID_TENDON`` (or the integer value ``0``,
which will be cast to the enumeration member). There are four possible
formulations for an elastic tendon model. To use an explicit formulation
with the fiber length as the state, set this to
``MusculotendonFormulation.FIBER_LENGTH_EXPLICIT`` (or the integer value
``1``). To use an explicit formulation with the tendon force as the
state, set this to ``MusculotendonFormulation.TENDON_FORCE_EXPLICIT``
(or the integer value ``2``). To use an implicit formulation with the
fiber length as the state, set this to
``MusculotendonFormulation.FIBER_LENGTH_IMPLICIT`` (or the integer value
``3``). To use an implicit formulation with the tendon force as the
state, set this to ``MusculotendonFormulation.TENDON_FORCE_IMPLICIT``
(or the integer value ``4``). The default is
``MusculotendonFormulation.RIGID_TENDON``, which corresponds to a rigid
tendon formulation.

)rc   r)   s    r+   r=   (MusculotendonBase.musculotendon_dynamics  s    : +++r.   c                 p   U R                   R                  U l        U R                   R                  U l        U R
                  U l        [        S5      U l        [        U R                  U R                  -
  S-  U R                  [        U R                  5      -  S-  -   5      U l        U R                  U R                  -  U l        U R                  U R                  U R
                  -
  -  U R                  -  U l        U R                  U R                   -  U l        U R$                  (       a  U R&                  R(                  R+                  U R                  5      U l        U R&                  R.                  R+                  U R                  5      U l        U R&                  R2                  R+                  U R                  5      U l        U R&                  R6                  R+                  U R"                  5      U l        GO[;        SU R<                   35      nU R&                  R(                  " U R                  /UQ76 U l        [;        SU R<                   35      nU R&                  R.                  " U R                  /UQ76 U l        [;        SU R<                   35      nU R&                  R2                  " U R                  /UQ76 U l        [;        SU R<                   35      nU R&                  R6                  " U R"                  /UQ76 U l        U R>                  U R4                  -  U R8                  -  U R0                  -   U R@                  U R"                  -  -   U l!        U RB                  U l"        U RB                  U RF                  -  U l$        [K        U R                  5      U l&        U RH                  U RL                  -  U l'        [Q        SS5      U l)        [Q        SS5      U l*        [Q        SS5      U l+        U R$                  (       d  [Y        WW-   W-   W-   5      U l-        g[Q        SS5      U l-        g)	zRigid tendon musculotendon.r"   r#   c_0:4_fl_T_c_0:2_fl_M_pas_c_0:12_fl_M_act_c_0:4_fv_M_r   N).rf   length_l_MTextension_velocity_v_MTrV   _l_Tr   
_l_T_tilder
   rX   r   rZ   _l_M
_l_M_tilde_v_MrY   
_v_M_tilder\   ro   tendon_force_lengthrD   _fl_Tfiber_force_length_passive	_fl_M_pasfiber_force_length_active	_fl_M_actfiber_force_velocity_fv_Mr	   rN   r   r[   
_F_M_tilde
_F_T_tilderW   _F_Mr   
_cos_alphard   r   _state_vars_input_vars_state_eqnsMatrix_curve_constantsr*   fl_T_constantsfl_M_pas_constantsfl_M_act_constantsfv_M_constantss        r+   r]   6MusculotendonBase._rigid_tendon_musculotendon_dynamics  s   \\((
\\44
OO	!!*$**tyy014c$//FZ8Z]^7^^_	))DMM1JJ

T__ <=diiG	))DMM188FFtWDJ![[CCQQRVRaRabDN![[BBPPQUQ`Q`aDN99GGXDJ${499+%>?N88Z>ZDJ!(?499+)F!G![[CCDOOiVhiDN!(+;DII;)G!H![[BB4??hUghDN${499+%>?N99$//[N[DJ&&/

:T^^KdjjY]YhYhNhh//OODMM1	doo.IIdoo-	 !A; A; A; $$ !' ! ! !

 +01+ 	r.   c                    [        SU R                   35      U l        U R                  R                  U l        U R                  R                  U l        U R                  U R                  -  U l	        U R
                  [        U R                  S-  U R                  [        U R                  5      -  S-  -
  5      -
  U l        U R                  U R                  -  U l        U R
                  U R                  -
  U R                  -  U l        U R"                  (       a  U R$                  R&                  R)                  U R                  5      U l        U R$                  R,                  R)                  U R                  5      U l        U R$                  R0                  R)                  U R                  5      U l        O[5        SU R                   35      nU R$                  R&                  " U R                  /UQ76 U l        [5        SU R                   35      nU R$                  R,                  " U R                  /UQ76 U l        [5        SU R                   35      nU R$                  R0                  " U R                  /UQ76 U l        U R*                  U l        U R6                  U R8                  -  U l        U R:                  U R                   -  U l        U R<                  U R8                  -  U l        U R>                  U R.                  -
  U R@                  U R2                  -  -  U l!        U R"                  (       a5  U R$                  RD                  R)                  U RB                  5      U l#        OD[5        SU R                   35      nU R$                  RD                  " U RB                  /UQ76 U l#        U RH                  U R                  -  U RF                  -  U l%        [M        U R                  /5      U l'        [Q        SS5      U l)        [M        U RJ                  /5      U l*        U R"                  (       d  [M        WW-   W-   W-   5      U l+        g	[Q        SS5      U l+        g	)
z:Elastic tendon musculotendon using `l_M_tilde` as a state.
l_M_tilde_r#   r   r   r   r   r   r"   N),r   rN   r   rf   r   r   r   r   rX   r   r
   r   rZ   r   rV   r   r   r\   ro   r   rD   r   r   r   r   r   r	   r   rW   rd   r   r   r   r   fiber_force_velocity_inverser   rY   _dl_M_tilde_dtr   r   r   r   r   r   r   s        r+   r^   ?MusculotendonBase._fiber_length_explicit_musculotendon_dynamics  s8   (:dii[)AB\\((
\\44
OODMM1	JJdiildmmCDX6X[\5\&\!]]	))DOO3::		1499<88FFtWDJ![[CCQQRVRaRabDN![[BBPPQUQ`Q`aDN${499+%>?N88Z>ZDJ!(?499+)F!G![[CCDOOiVhiDN!(+;DII;)G!H![[BB4??hUghDN**OODMM1	IIdoo-	))DMM1oo69NO
"kkFFTTUYU_U_`DO${499+%>?N"kkFFtzzcTbcDO#}}T]]:DOOK!4??"34 A;!4#6#6"78 $$ !' ! ! !

 +01+ 	r.   c                 f   [        SU R                   35      U l        U R                  R                  U l        U R                  R                  U l        U R                  U l        U R                  (       a5  U R                  R                  R                  U R                  5      U l        OD[        SU R                   35      nU R                  R                  " U R                  /UQ76 U l        U R                  U l        U R                  U R                   -  U l        [%        U R
                  U R"                  -
  S-  U R&                  [)        U R*                  5      -  S-  -   5      U l        U R,                  U R&                  -  U l        U R                  (       ai  U R                  R0                  R                  U R.                  5      U l        U R                  R4                  R                  U R.                  5      U l        O[        SU R                   35      nU R                  R0                  " U R.                  /UQ76 U l        [        SU R                   35      nU R                  R4                  " U R.                  /UQ76 U l        U R
                  U R"                  -
  U R,                  -  U l        U R                  U R:                  -  U l        U R<                  U R8                  -  U l        U R>                  U R:                  -  U l         U R@                  U R2                  -
  U RB                  U R6                  -  -  U l"        U R                  (       a5  U R                  RF                  R                  U RD                  5      U l$        OD[        SU R                   35      nU R                  RF                  " U RD                  /UQ76 U l$        U RH                  U l%        U RJ                  U RL                  -  U l'        U R                  U RN                  U R8                  -  -
  U l(        U RP                  U R                   -  U l)        U R                  (       a5  U R                  RT                  R                  U R                  5      U l        O,U R                  RT                  " U R                  /WQ76 U l        U R                  RW                  [         RX                  5      R[                  U R                  RW                  [         RX                  5      U RR                  05      U l.        [_        U R                  /5      U l0        [c        SS5      U l2        [_        U R\                  /5      U l3        U R                  (       d  [_        WW-   W-   W-   5      U l4        g	[c        SS5      U l4        g	)
z:Elastic tendon musculotendon using `F_T_tilde` as a state.
F_T_tilde_r   r#   r   r   r   r   r"   N)5r   rN   r   rf   r   r   r   r   r   r\   ro   tendon_force_length_inverserD   	_fl_T_invr	   r   rV   r   r
   rX   r   rZ   r   r   r   r   r   r   r   rW   rd   r   r   r   r   r   	_fv_M_invr   rY   r   _v_T
_v_T_tilder   diff_tsubs_dF_T_tilde_dtr   r   r   r   r   r   r   s        r+   r_   ?MusculotendonBase._tendon_force_explicit_musculotendon_dynamics  s   (:dii[)AB\\((
\\44
__
![[DDRRSWS]S]^DN${499+%>?N![[DDTZZaR`aDN..OODOO3	$**tyy014c$//FZ8Z]^7^^_	))DMM1![[CCQQRVRaRabDN![[BBPPQUQ`Q`aDN!(?499+)F!G![[CCDOOiVhiDN!(+;DII;)G!H![[BB4??hUghDN::		1499<OODMM1	IIdoo-	))DMM1oo69NO
![[EESSTXT^T^_DN${499+%>?N![[EEdjjbSabDN..OODMM1	JJ$))DOO";<	))DOO388FFtWDJ88Z>ZDJ"jjoon.?.?@EEtG[G[\j\m\mGnptpp  GA  B!4??"34 A;!4#6#6"78 $$ !' ! ! !

 +01+ 	r.   c                     [         eNNotImplementedErrorr)   s    r+   r`   ?MusculotendonBase._fiber_length_implicit_musculotendon_dynamics=      !!r.   c                     [         er   r   r)   s    r+   ra   ?MusculotendonBase._tendon_force_implicit_musculotendon_dynamics@  r   r.   c                     U R                   /nU R                   H  nUR                  UR                  5        M      [        R
                  " U6 $ )zOrdered column matrix of functions of time that represent the state
variables.

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

The alias ``x`` can also be used to access the same attribute.

r   rU   append
state_varsr   vstackr*   r   childs      r+   r   MusculotendonBase.state_varsC  E     &&'
((Ee../ )}}j))r.   c                     U R                   /nU R                   H  nUR                  UR                  5        M      [        R
                  " U6 $ )zOrdered column matrix of functions of time that represent the state
variables.

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

The alias ``state_vars`` can also be used to access the same attribute.

r   r   s      r+   xMusculotendonBase.xS  r   r.   c                     U R                   /nU R                   H  nUR                  UR                  5        M      [        R
                  " U6 $ )zOrdered column matrix of functions of time that represent the input
variables.

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

The alias ``r`` can also be used to access the same attribute.

r   rU   r   
input_varsr   r   r*   r   r   s      r+   r   MusculotendonBase.input_varsc  r   r.   c                     U R                   /nU R                   H  nUR                  UR                  5        M      [        R
                  " U6 $ )zOrdered column matrix of functions of time that represent the input
variables.

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

The alias ``input_vars`` can also be used to access the same attribute.

r   r   s      r+   rMusculotendonBase.rs  r   r.   c                    U R                   U R                  U R                  U R                  U R                  U R
                  /nU Vs/ s H  o"R                  (       a  M  UPM     nnU(       a  [        U5      O[        SS5      /nU R                   H  nUR                  UR                  5        M      UR                  U R                  5        [        R                  " U6 $ s  snf )a"  Ordered column matrix of non-time varying symbols present in ``M``
and ``F``.

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

Only symbolic constants are returned. If a numeric type (e.g. ``Float``)
has been used instead of ``Symbol`` for a constant then that attribute
will not be included in the matrix returned by this property. This is
because the primary use of this property attribute is to provide an
ordered sequence of the still-free symbols that require numeric values
during code generation.

The alias ``p`` can also be used to access the same attribute.

r   r"   rV   rW   rX   rY   rZ   r[   	is_numberr   r   rU   r   	constantsr   r   r*   musculotendon_constantscr  r   s        r+   r  MusculotendonBase.constants      & OOMMMMMMOOJJ#
 /#
.!kkA. 	  #

 ' *+q!
	
 ((EU__- )../}}i((#
   	C$!C$c                    U R                   U R                  U R                  U R                  U R                  U R
                  /nU Vs/ s H  o"R                  (       a  M  UPM     nnU(       a  [        U5      O[        SS5      /nU R                   H  nUR                  UR                  5        M      UR                  U R                  5        [        R                  " U6 $ s  snf )a*  Ordered column matrix of non-time varying symbols present in ``M``
and ``F``.

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

Only symbolic constants are returned. If a numeric type (e.g. ``Float``)
has been used instead of ``Symbol`` for a constant then that attribute
will not be included in the matrix returned by this property. This is
because the primary use of this property attribute is to provide an
ordered sequence of the still-free symbols that require numeric values
during code generation.

The alias ``constants`` can also be used to access the same attribute.

r   r"   r   r  s        r+   pMusculotendonBase.p  r  r  c                     [        [        U R                  5      5      /nU R                   H  nUR	                  UR
                  5        M      [        U6 $ )a  Ordered square matrix of coefficients on the LHS of ``M x' = F``.

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

The square matrix that forms part of the LHS of the linear system of
ordinary differential equations governing the activation dynamics:

``M(x, r, t, p) x' = F(x, r, t, p)``.

As zeroth-order activation dynamics have no state variables, this
linear system has dimension 0 and therefore ``M`` is an empty square
``Matrix`` with shape (0, 0).

)r   lenr   rU   r   Mr   )r*   r  r   s      r+   r  MusculotendonBase.M  sE    " T%%&'(((EHHUWW )Qxr.   c                     U R                   /nU R                   H  nUR                  UR                  5        M      [        R
                  " U6 $ )a  Ordered column matrix of equations on the RHS of ``M x' = F``.

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

The column matrix that forms the RHS of the linear system of ordinary
differential equations governing the activation dynamics:

``M(x, r, t, p) x' = F(x, r, t, p)``.

As zeroth-order activation dynamics have no state variables, this
linear system has dimension 0 and therefore ``F`` is an empty column
``Matrix`` with shape (0, 1).

)r   rU   r   rF   r   r   )r*   rF   r   s      r+   rF   MusculotendonBase.F  sA    " ((EHHUWW )}}a  r.   c                 
   [         R                  [         R                  4nU R                  [         R                  L a<  U R
                   Vs/ s H  o"R                  5       PM     nn[        R                  " U6 $ U R                  U;   aL  U R                  nU R
                   Vs/ s H  o"R                  5       PM     nn[        R                  " U/UQ76 $ U R                  R                  U R                  5      $ s  snf s  snf )a  Ordered column matrix of equations for the solution of ``M x' = F``.

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

The solution to the linear system of ordinary differential equations
governing the activation dynamics:

``M(x, r, t, p) x' = F(x, r, t, p)``.

As zeroth-order activation dynamics have no state variables, this
linear has dimension 0 and therefore this method returns an empty
column ``Matrix`` with shape (0, 1).

)r   r6   r7   r=   r5   rU   rhsr   r   r   r  solverF   )r*   is_explicitr   	child_rhsr  s        r+   r  MusculotendonBase.rhs  s    " %::$::
 &&*B*O*OO262E2EF2E2EIF==),,((K7""C262E2EF2E2EIF==1y11vv||DFF## G Gs   C;$D c                 J   U R                   R                   SU R                  < SU R                  < SU R                  < SU R
                   SU R                  < SU R                  < SU R                  < SU R                  < S	U R                  < S
U R                  < S3$ )z;Returns a string representation to reinstantiate the model.(z
, pathway=z, activation_dynamics=z, musculotendon_dynamics=z, tendon_slack_length=z, peak_isometric_force=z, optimal_fiber_length=z, maximal_fiber_velocity=z, optimal_pennation_angle=z, fiber_damping_coefficient=))ri   r0   rN   rf   rg   r=   rV   rW   rX   rY   rZ   r[   r)   s    r+   __repr__MusculotendonBase.__repr__  s     ~~&&'q 6||& '##'#;#;"> ?&&*&A&A%B C##'??"5 6$$(MM#4 5$$(MM#4 5&&*mm%6 7''+&9 :))-a	9	
r.   c                 ,    [        U R                  5      $ )zJReturns a string representation of the expression for musculotendon
force.)r'   forcer)   s    r+   r,   MusculotendonBase.__str__)  s     4::r.   )'r   rW   r   rd   r   rT   rZ   r[   rU   r   r   r   r   r   r   r   r   re   r   r   r   r   r   rX   r   r   rV   r   rc   r   r   r   r   rY   r   r   r   r\   rN   )1r0   r1   r2   r3   r4   "_DEFAULT_MUSCULOTENDON_FORMULATIONrP   classmethodr   rD   r   ro   propertyr>   ru   r?   r|   r@   r   rA   r   rB   r   rC   r   rg   r   r   r   r   r=   r]   r^   r_   r`   ra   r   r   r   r   r  r
  r  rF   r  r  r,   r:   __classcell__)ri   s   @r+   r   r   f   s   On  B !!# $"&V! V!p   B !!$V} %e"',m
 m
^  
  "  $  "  $     "     "           ) ) 	, 	, 	, 	, 	, 	, 	, 	, , ,<'6R(6T36j"" * * * * * * * * $) $)L $) $)L  * ! !*$:
 r.   r   c            
       0    \ rS rSrSr\" \\\\	\
\\S9rSrg)r   i/  a4  Musculotendon model using the curves of De Groote et al., 2016 [1]_.

Examples
========

This class models the musculotendon actuator parametrized by the
characteristic curves described in De Groote et al., 2016 [1]_. Like all
musculotendon models in SymPy's biomechanics module, it requires a pathway
to define its line of action. We'll begin by creating a simple
``LinearPathway`` between two points that our musculotendon will follow.
We'll create a point ``O`` to represent the musculotendon's origin and
another ``I`` to represent its insertion.

>>> from sympy import symbols
>>> from sympy.physics.mechanics import (LinearPathway, Point,
...     ReferenceFrame, dynamicsymbols)

>>> N = ReferenceFrame('N')
>>> O, I = O, P = symbols('O, I', cls=Point)
>>> q, u = dynamicsymbols('q, u', real=True)
>>> I.set_pos(O, q*N.x)
>>> O.set_vel(N, 0)
>>> I.set_vel(N, u*N.x)
>>> pathway = LinearPathway(O, I)
>>> pathway.attachments
(O, I)
>>> pathway.length
Abs(q(t))
>>> pathway.extension_velocity
sign(q(t))*Derivative(q(t), t)

A musculotendon also takes an instance of an activation dynamics model as
this will be used to provide symbols for the activation in the formulation
of the musculotendon dynamics. We'll use an instance of
``FirstOrderActivationDeGroote2016`` to represent first-order activation
dynamics. Note that a single name argument needs to be provided as SymPy
will use this as a suffix.

>>> from sympy.physics.biomechanics import FirstOrderActivationDeGroote2016

>>> activation = FirstOrderActivationDeGroote2016('muscle')
>>> activation.x
Matrix([[a_muscle(t)]])
>>> activation.r
Matrix([[e_muscle(t)]])
>>> activation.p
Matrix([
[tau_a_muscle],
[tau_d_muscle],
[    b_muscle]])
>>> activation.rhs()
Matrix([[((1/2 - tanh(b_muscle*(-a_muscle(t) + e_muscle(t)))/2)*(3*...]])

The musculotendon class requires symbols or values to be passed to represent
the constants in the musculotendon dynamics. We'll use SymPy's ``symbols``
function to create symbols for the maximum isometric force ``F_M_max``,
optimal fiber length ``l_M_opt``, tendon slack length ``l_T_slack``, maximum
fiber velocity ``v_M_max``, optimal pennation angle ``alpha_opt, and fiber
damping coefficient ``beta``.

>>> F_M_max = symbols('F_M_max', real=True)
>>> l_M_opt = symbols('l_M_opt', real=True)
>>> l_T_slack = symbols('l_T_slack', real=True)
>>> v_M_max = symbols('v_M_max', real=True)
>>> alpha_opt = symbols('alpha_opt', real=True)
>>> beta = symbols('beta', real=True)

We can then import the class ``MusculotendonDeGroote2016`` from the
biomechanics module and create an instance by passing in the various objects
we have previously instantiated. By default, a musculotendon model with
rigid tendon musculotendon dynamics will be created.

>>> from sympy.physics.biomechanics import MusculotendonDeGroote2016

>>> rigid_tendon_muscle = MusculotendonDeGroote2016(
...     'muscle',
...     pathway,
...     activation,
...     tendon_slack_length=l_T_slack,
...     peak_isometric_force=F_M_max,
...     optimal_fiber_length=l_M_opt,
...     maximal_fiber_velocity=v_M_max,
...     optimal_pennation_angle=alpha_opt,
...     fiber_damping_coefficient=beta,
... )

We can inspect the various properties of the musculotendon, including
getting the symbolic expression describing the force it produces using its
``force`` attribute.

>>> rigid_tendon_muscle.force
-F_M_max*(beta*(-l_T_slack + Abs(q(t)))*sign(q(t))*Derivative(q(t), t)...

When we created the musculotendon object, we passed in an instance of an
activation dynamics object that governs the activation within the
musculotendon. SymPy makes a design choice here that the activation dynamics
instance will be treated as a child object of the musculotendon dynamics.
Therefore, if we want to inspect the state and input variables associated
with the musculotendon model, we will also be returned the state and input
variables associated with the child object, or the activation dynamics in
this case. As the musculotendon model that we created here uses rigid tendon
dynamics, no additional states or inputs relating to the musculotendon are
introduces. Consequently, the model has a single state associated with it,
the activation, and a single input associated with it, the excitation. The
states and inputs can be inspected using the ``x`` and ``r`` attributes
respectively. Note that both ``x`` and ``r`` have the alias attributes of
``state_vars`` and ``input_vars``.

>>> rigid_tendon_muscle.x
Matrix([[a_muscle(t)]])
>>> rigid_tendon_muscle.r
Matrix([[e_muscle(t)]])

To see which constants are symbolic in the musculotendon model, we can use
the ``p`` or ``constants`` attribute. This returns a ``Matrix`` populated
by the constants that are represented by a ``Symbol`` rather than a numeric
value.

>>> rigid_tendon_muscle.p
Matrix([
[           l_T_slack],
[             F_M_max],
[             l_M_opt],
[             v_M_max],
[           alpha_opt],
[                beta],
[        tau_a_muscle],
[        tau_d_muscle],
[            b_muscle],
[     c_0_fl_T_muscle],
[     c_1_fl_T_muscle],
[     c_2_fl_T_muscle],
[     c_3_fl_T_muscle],
[ c_0_fl_M_pas_muscle],
[ c_1_fl_M_pas_muscle],
[ c_0_fl_M_act_muscle],
[ c_1_fl_M_act_muscle],
[ c_2_fl_M_act_muscle],
[ c_3_fl_M_act_muscle],
[ c_4_fl_M_act_muscle],
[ c_5_fl_M_act_muscle],
[ c_6_fl_M_act_muscle],
[ c_7_fl_M_act_muscle],
[ c_8_fl_M_act_muscle],
[ c_9_fl_M_act_muscle],
[c_10_fl_M_act_muscle],
[c_11_fl_M_act_muscle],
[     c_0_fv_M_muscle],
[     c_1_fv_M_muscle],
[     c_2_fv_M_muscle],
[     c_3_fv_M_muscle]])

Finally, we can call the ``rhs`` method to return a ``Matrix`` that
contains as its elements the righthand side of the ordinary differential
equations corresponding to each of the musculotendon's states. Like the
method with the same name on the ``Method`` classes in SymPy's mechanics
module, this returns a column vector where the number of rows corresponds to
the number of states. For our example here, we have a single state, the
dynamic symbol ``a_muscle(t)``, so the returned value is a 1-by-1
``Matrix``.

>>> rigid_tendon_muscle.rhs()
Matrix([[((1/2 - tanh(b_muscle*(-a_muscle(t) + e_muscle(t)))/2)*(3*...]])

The musculotendon class supports elastic tendon musculotendon models in
addition to rigid tendon ones. You can choose to either use the fiber length
or tendon force as an additional state. You can also specify whether an
explicit or implicit formulation should be used. To select a formulation,
pass a member of the ``MusculotendonFormulation`` enumeration to the
``musculotendon_dynamics`` parameter when calling the constructor. This
enumeration is an ``IntEnum``, so you can also pass an integer, however it
is recommended to use the enumeration as it is clearer which formulation you
are actually selecting. Below, we'll use the ``FIBER_LENGTH_EXPLICIT``
member to create a musculotendon with an elastic tendon that will use the
(normalized) muscle fiber length as an additional state and will produce
the governing ordinary differential equation in explicit form.

>>> from sympy.physics.biomechanics import MusculotendonFormulation

>>> elastic_tendon_muscle = MusculotendonDeGroote2016(
...     'muscle',
...     pathway,
...     activation,
...     musculotendon_dynamics=MusculotendonFormulation.FIBER_LENGTH_EXPLICIT,
...     tendon_slack_length=l_T_slack,
...     peak_isometric_force=F_M_max,
...     optimal_fiber_length=l_M_opt,
...     maximal_fiber_velocity=v_M_max,
...     optimal_pennation_angle=alpha_opt,
...     fiber_damping_coefficient=beta,
... )

>>> elastic_tendon_muscle.force
-F_M_max*TendonForceLengthDeGroote2016((-sqrt(l_M_opt**2*...
>>> elastic_tendon_muscle.x
Matrix([
[l_M_tilde_muscle(t)],
[        a_muscle(t)]])
>>> elastic_tendon_muscle.r
Matrix([[e_muscle(t)]])
>>> elastic_tendon_muscle.p
Matrix([
[           l_T_slack],
[             F_M_max],
[             l_M_opt],
[             v_M_max],
[           alpha_opt],
[                beta],
[        tau_a_muscle],
[        tau_d_muscle],
[            b_muscle],
[     c_0_fl_T_muscle],
[     c_1_fl_T_muscle],
[     c_2_fl_T_muscle],
[     c_3_fl_T_muscle],
[ c_0_fl_M_pas_muscle],
[ c_1_fl_M_pas_muscle],
[ c_0_fl_M_act_muscle],
[ c_1_fl_M_act_muscle],
[ c_2_fl_M_act_muscle],
[ c_3_fl_M_act_muscle],
[ c_4_fl_M_act_muscle],
[ c_5_fl_M_act_muscle],
[ c_6_fl_M_act_muscle],
[ c_7_fl_M_act_muscle],
[ c_8_fl_M_act_muscle],
[ c_9_fl_M_act_muscle],
[c_10_fl_M_act_muscle],
[c_11_fl_M_act_muscle],
[     c_0_fv_M_muscle],
[     c_1_fv_M_muscle],
[     c_2_fv_M_muscle],
[     c_3_fv_M_muscle]])
>>> elastic_tendon_muscle.rhs()
Matrix([
[v_M_max*FiberForceVelocityInverseDeGroote2016((l_M_opt*...],
[ ((1/2 - tanh(b_muscle*(-a_muscle(t) + e_muscle(t)))/2)*(3*...]])

It is strongly recommended to use the alternate ``with_defaults``
constructor when creating an instance because this will ensure that the
published constants are used in the musculotendon characteristic curves.

>>> elastic_tendon_muscle = MusculotendonDeGroote2016.with_defaults(
...     'muscle',
...     pathway,
...     activation,
...     musculotendon_dynamics=MusculotendonFormulation.FIBER_LENGTH_EXPLICIT,
...     tendon_slack_length=l_T_slack,
...     peak_isometric_force=F_M_max,
...     optimal_fiber_length=l_M_opt,
... )

>>> elastic_tendon_muscle.x
Matrix([
[l_M_tilde_muscle(t)],
[        a_muscle(t)]])
>>> elastic_tendon_muscle.r
Matrix([[e_muscle(t)]])
>>> elastic_tendon_muscle.p
Matrix([
[   l_T_slack],
[     F_M_max],
[     l_M_opt],
[tau_a_muscle],
[tau_d_muscle],
[    b_muscle]])

Parameters
==========

name : str
    The name identifier associated with the musculotendon. This name is used
    as a suffix when automatically generated symbols are instantiated. It
    must be a string of nonzero length.
pathway : PathwayBase
    The pathway that the actuator follows. This must be an instance of a
    concrete subclass of ``PathwayBase``, e.g. ``LinearPathway``.
activation_dynamics : ActivationBase
    The activation dynamics that will be modeled within the musculotendon.
    This must be an instance of a concrete subclass of ``ActivationBase``,
    e.g. ``FirstOrderActivationDeGroote2016``.
musculotendon_dynamics : MusculotendonFormulation | int
    The formulation of musculotendon dynamics that should be used
    internally, i.e. rigid or elastic tendon model, the choice of
    musculotendon state etc. This must be a member of the integer
    enumeration ``MusculotendonFormulation`` or an integer that can be cast
    to a member. To use a rigid tendon formulation, set this to
    ``MusculotendonFormulation.RIGID_TENDON`` (or the integer value ``0``,
    which will be cast to the enumeration member). There are four possible
    formulations for an elastic tendon model. To use an explicit formulation
    with the fiber length as the state, set this to
    ``MusculotendonFormulation.FIBER_LENGTH_EXPLICIT`` (or the integer value
    ``1``). To use an explicit formulation with the tendon force as the
    state, set this to ``MusculotendonFormulation.TENDON_FORCE_EXPLICIT``
    (or the integer value ``2``). To use an implicit formulation with the
    fiber length as the state, set this to
    ``MusculotendonFormulation.FIBER_LENGTH_IMPLICIT`` (or the integer value
    ``3``). To use an implicit formulation with the tendon force as the
    state, set this to ``MusculotendonFormulation.TENDON_FORCE_IMPLICIT``
    (or the integer value ``4``). The default is
    ``MusculotendonFormulation.RIGID_TENDON``, which corresponds to a rigid
    tendon formulation.
tendon_slack_length : Expr | None
    The length of the tendon when the musculotendon is in its unloaded
    state. In a rigid tendon model the tendon length is the tendon slack
    length. In all musculotendon models, tendon slack length is used to
    normalize tendon length to give
    :math:`\tilde{l}^T = \frac{l^T}{l^T_{slack}}`.
peak_isometric_force : Expr | None
    The maximum force that the muscle fiber can produce when it is
    undergoing an isometric contraction (no lengthening velocity). In all
    musculotendon models, peak isometric force is used to normalized tendon
    and muscle fiber force to give
    :math:`\tilde{F}^T = \frac{F^T}{F^M_{max}}`.
optimal_fiber_length : Expr | None
    The muscle fiber length at which the muscle fibers produce no passive
    force and their maximum active force. In all musculotendon models,
    optimal fiber length is used to normalize muscle fiber length to give
    :math:`\tilde{l}^M = \frac{l^M}{l^M_{opt}}`.
maximal_fiber_velocity : Expr | None
    The fiber velocity at which, during muscle fiber shortening, the muscle
    fibers are unable to produce any active force. In all musculotendon
    models, maximal fiber velocity is used to normalize muscle fiber
    extension velocity to give :math:`\tilde{v}^M = \frac{v^M}{v^M_{max}}`.
optimal_pennation_angle : Expr | None
    The pennation angle when muscle fiber length equals the optimal fiber
    length.
fiber_damping_coefficient : Expr | None
    The coefficient of damping to be used in the damping element in the
    muscle fiber model.
with_defaults : bool
    Whether ``with_defaults`` alternate constructors should be used when
    automatically constructing child classes. Default is ``False``.

References
==========

.. [1] De Groote, F., Kinney, A. L., Rao, A. V., & Fregly, B. J., Evaluation
       of direct collocation optimal control problem formulations for
       solving the muscle redundancy problem, Annals of biomedical
       engineering, 44(10), (2016) pp. 2922-2936

)r   r   r   "fiber_force_length_passive_inverser   r   r   r/   N)r0   r1   r2   r3   r4   r   r   r   r   r   r   r   r   ro   r:   r/   r.   r+   r   r   /  s*    Vp
 +9$H#F+U"D;%JFr.   r   N).r4   abcr   enumr   r   sympy.core.numbersr   r   sympy.core.symbolr   r	   (sympy.functions.elementary.miscellaneousr
   (sympy.functions.elementary.trigonometricr   r   sympy.matrices.denser   r   r   r   r   %sympy.physics.biomechanics.activationr    sympy.physics.biomechanics.curver   r   r   r   r   r   r   r   !sympy.physics.biomechanics._mixinr    sympy.physics.mechanics.actuatorr   sympy.physics.vector.functionsr   __all__r   r5   r   r   r   r/   r.   r+   <module>r3     s   
    - - 9 = O O @	 	 	 : : 9 3w 3 3l &>%J%J "F{ FRa 1 ar.   