o
    oh                     @   s  d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	m
Z
 ddlmZmZ ddlmZmZ ddlmZ dd	lmZ g d
ZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZeddG dd dZdS ) zBImplementations of characteristic curves for musculotendon models.    )	dataclass)UnevaluatedExpr)ArgumentIndexErrorFunction)FloatInteger)explog)coshsinh)sqrt)
PRECEDENCE)	CharacteristicCurveCollectionCharacteristicCurveFunction"FiberForceLengthActiveDeGroote2016#FiberForceLengthPassiveDeGroote2016*FiberForceLengthPassiveInverseDeGroote2016FiberForceVelocityDeGroote2016%FiberForceVelocityInverseDeGroote2016TendonForceLengthDeGroote2016$TendonForceLengthInverseDeGroote2016c                   @   sP   e Zd ZdZedd Zdd ZeZeZeZ	eZ
eZeZeZeZeZeZeZdS )r   z@Base class for all musculotendon characteristic curve functions.c                 C   s   d| j d}t|)NzCannot directly instantiate zD, instances of characteristic curves must be of a concrete subclass.)__name__	TypeError)clsmsg r   t/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/sympy/physics/biomechanics/curve.pyeval   s   z CharacteristicCurveFunction.evalc                 C   s    | || jdddtd S )a8  Print code for the function defining the curve using a printer.

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

        The order of operations may need to be controlled as constant folding
        the numeric terms within the equations of a musculotendon
        characteristic curve can sometimes results in a numerically-unstable
        expression.

        Parameters
        ==========

        printer : Printer
            The printer to be used to print a string representation of the
            characteristic curve as valid code in the target language.

        FdeepevaluateAtom)_printparenthesizedoitr   )selfprinterr   r   r   _print_code'   s   z'CharacteristicCurveFunction._print_codeN)r   
__module____qualname____doc__classmethodr   r'   _ccode	_cupycode_cxxcode_fcode_jaxcode_lambdacode_mpmathcode_octave_pythoncode
_numpycode
_scipycoder   r   r   r   r      s     
r   c                   @   V   e Zd ZdZedd Zedd Zdd Zdd	d
ZdddZ	dddZ
dd ZdS )r   a{  Tendon force-length curve based on De Groote et al., 2016 [1]_.

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

    Gives the normalized tendon force produced as a function of normalized
    tendon length.

    The function is defined by the equation:

    $fl^T = c_0 \exp{c_3 \left( \tilde{l}^T - c_1 \right)} - c_2$

    with constant values of $c_0 = 0.2$, $c_1 = 0.995$, $c_2 = 0.25$, and
    $c_3 = 33.93669377311689$.

    While it is possible to change the constant values, these were carefully
    selected in the original publication to give the characteristic curve
    specific and required properties. For example, the function produces no
    force when the tendon is in an unstrained state. It also produces a force
    of 1 normalized unit when the tendon is under a 5% strain.

    Examples
    ========

    The preferred way to instantiate :class:`TendonForceLengthDeGroote2016` is using
    the :meth:`~.with_defaults` constructor because this will automatically
    populate the constants within the characteristic curve equation with the
    floating point values from the original publication. This constructor takes
    a single argument corresponding to normalized tendon length. We'll create a
    :class:`~.Symbol` called ``l_T_tilde`` to represent this.

    >>> from sympy import Symbol
    >>> from sympy.physics.biomechanics import TendonForceLengthDeGroote2016
    >>> l_T_tilde = Symbol('l_T_tilde')
    >>> fl_T = TendonForceLengthDeGroote2016.with_defaults(l_T_tilde)
    >>> fl_T
    TendonForceLengthDeGroote2016(l_T_tilde, 0.2, 0.995, 0.25,
    33.93669377311689)

    It's also possible to populate the four constants with your own values too.

    >>> from sympy import symbols
    >>> c0, c1, c2, c3 = symbols('c0 c1 c2 c3')
    >>> fl_T = TendonForceLengthDeGroote2016(l_T_tilde, c0, c1, c2, c3)
    >>> fl_T
    TendonForceLengthDeGroote2016(l_T_tilde, c0, c1, c2, c3)

    You don't just have to use symbols as the arguments, it's also possible to
    use expressions. Let's create a new pair of symbols, ``l_T`` and
    ``l_T_slack``, representing tendon length and tendon slack length
    respectively. We can then represent ``l_T_tilde`` as an expression, the
    ratio of these.

    >>> l_T, l_T_slack = symbols('l_T l_T_slack')
    >>> l_T_tilde = l_T/l_T_slack
    >>> fl_T = TendonForceLengthDeGroote2016.with_defaults(l_T_tilde)
    >>> fl_T
    TendonForceLengthDeGroote2016(l_T/l_T_slack, 0.2, 0.995, 0.25,
    33.93669377311689)

    To inspect the actual symbolic expression that this function represents,
    we can call the :meth:`~.doit` method on an instance. We'll use the keyword
    argument ``evaluate=False`` as this will keep the expression in its
    canonical form and won't simplify any constants.

    >>> fl_T.doit(evaluate=False)
    -0.25 + 0.2*exp(33.93669377311689*(l_T/l_T_slack - 0.995))

    The function can also be differentiated. We'll differentiate with respect
    to l_T using the ``diff`` method on an instance with the single positional
    argument ``l_T``.

    >>> fl_T.diff(l_T)
    6.787338754623378*exp(33.93669377311689*(l_T/l_T_slack - 0.995))/l_T_slack

    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

    c                 C   0   t d}t d}t d}t d}| |||||S )a  Recommended constructor that will use the published constants.

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

        Returns a new instance of the tendon force-length function using the
        four constant values specified in the original publication.

        These have the values:

        $c_0 = 0.2$
        $c_1 = 0.995$
        $c_2 = 0.25$
        $c_3 = 33.93669377311689$

        Parameters
        ==========

        l_T_tilde : Any (sympifiable)
            Normalized tendon length.

        0.20.9950.2533.93669377311689r   r   	l_T_tildec0c1c2c3r   r   r   with_defaults   
   z+TendonForceLengthDeGroote2016.with_defaultsc                 C      dS )a  Evaluation of basic inputs.

        Parameters
        ==========

        l_T_tilde : Any (sympifiable)
            Normalized tendon length.
        c0 : Any (sympifiable)
            The first constant in the characteristic equation. The published
            value is ``0.2``.
        c1 : Any (sympifiable)
            The second constant in the characteristic equation. The published
            value is ``0.995``.
        c2 : Any (sympifiable)
            The third constant in the characteristic equation. The published
            value is ``0.25``.
        c3 : Any (sympifiable)
            The fourth constant in the characteristic equation. The published
            value is ``33.93669377311689``.

        Nr   r>   r   r   r   r         z"TendonForceLengthDeGroote2016.evalc                 C      | j ddd|S z4Evaluate the expression numerically using ``evalf``.Fr   r$   _eval_evalfr%   precr   r   r   rK         z)TendonForceLengthDeGroote2016._eval_evalfTc           
         s   | j ^}} r$|d< |jdd i} fdd|D \}}}}	n|\}}}}	|r8|t|	||   | S |t|	t||   | S )  Evaluate the expression defining the function.

        Parameters
        ==========

        deep : bool
            Whether ``doit`` should be recursively called. Default is ``True``.
        evaluate : bool.
            Whether the SymPy expression should be evaluated as it is
            constructed. If ``False``, then no constant folding will be
            conducted which will leave the expression in a more numerically-
            stable for values of ``l_T_tilde`` that correspond to a sensible
            operating range for a musculotendon. Default is ``True``.
        **kwargs : dict[str, Any]
            Additional keyword argument pairs to be recursively passed to
            ``doit``.

        r    r   c                        g | ]}|j dd  iqS r   r   r$   .0cr   hintsr   r   
<listcomp>        z6TendonForceLengthDeGroote2016.doit.<locals>.<listcomp>Nr   argsr$   r   r   )
r%   r   r    rW   r?   	constantsr@   rA   rB   rC   r   rV   r   r$         
z"TendonForceLengthDeGroote2016.doit   c                 C   s   | j \}}}}}|dkr|| t|t||   S |dkr(t|t||  S |dkr;| | t|t||   S |dkrCtdS |dkrW|||  t|t||   S t| |9  Derivative of the function with respect to a single argument.

        Parameters
        ==========

        argindex : int
            The index of the function's arguments with respect to which the
            derivative should be taken. Argument indexes start at ``1``.
            Default is ``1``.

        r^               )r[   r   r   r   r   )r%   argindexr?   r@   rA   rB   rC   r   r   r   fdiff   s    
z#TendonForceLengthDeGroote2016.fdiffc                 C      t S zInverse function.

        Parameters
        ==========

        argindex : int
            Value to start indexing the arguments at. Default is ``1``.

        )r   r%   rf   r   r   r   inverse     
z%TendonForceLengthDeGroote2016.inversec                 C      | j d }||}d| S )Print a LaTeX representation of the function defining the curve.

        Parameters
        ==========

        printer : Printer
            The printer to be used to print the LaTeX string representation.

        r   z%\operatorname{fl}^T \left( %s \right)r[   r"   )r%   r&   r?   
_l_T_tilder   r   r   _latex"     


z$TendonForceLengthDeGroote2016._latexNTTr^   r   r(   r)   r*   r+   rD   r   rK   r$   rg   rk   rq   r   r   r   r   r   K   s    U



 
r   c                   @   r7   )r   a  Inverse tendon force-length curve based on De Groote et al., 2016 [1]_.

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

    Gives the normalized tendon length that produces a specific normalized
    tendon force.

    The function is defined by the equation:

    ${fl^T}^{-1} = frac{\log{\frac{fl^T + c_2}{c_0}}}{c_3} + c_1$

    with constant values of $c_0 = 0.2$, $c_1 = 0.995$, $c_2 = 0.25$, and
    $c_3 = 33.93669377311689$. This function is the exact analytical inverse
    of the related tendon force-length curve ``TendonForceLengthDeGroote2016``.

    While it is possible to change the constant values, these were carefully
    selected in the original publication to give the characteristic curve
    specific and required properties. For example, the function produces no
    force when the tendon is in an unstrained state. It also produces a force
    of 1 normalized unit when the tendon is under a 5% strain.

    Examples
    ========

    The preferred way to instantiate :class:`TendonForceLengthInverseDeGroote2016` is
    using the :meth:`~.with_defaults` constructor because this will automatically
    populate the constants within the characteristic curve equation with the
    floating point values from the original publication. This constructor takes
    a single argument corresponding to normalized tendon force-length, which is
    equal to the tendon force. We'll create a :class:`~.Symbol` called ``fl_T`` to
    represent this.

    >>> from sympy import Symbol
    >>> from sympy.physics.biomechanics import TendonForceLengthInverseDeGroote2016
    >>> fl_T = Symbol('fl_T')
    >>> l_T_tilde = TendonForceLengthInverseDeGroote2016.with_defaults(fl_T)
    >>> l_T_tilde
    TendonForceLengthInverseDeGroote2016(fl_T, 0.2, 0.995, 0.25,
    33.93669377311689)

    It's also possible to populate the four constants with your own values too.

    >>> from sympy import symbols
    >>> c0, c1, c2, c3 = symbols('c0 c1 c2 c3')
    >>> l_T_tilde = TendonForceLengthInverseDeGroote2016(fl_T, c0, c1, c2, c3)
    >>> l_T_tilde
    TendonForceLengthInverseDeGroote2016(fl_T, c0, c1, c2, c3)

    To inspect the actual symbolic expression that this function represents,
    we can call the :meth:`~.doit` method on an instance. We'll use the keyword
    argument ``evaluate=False`` as this will keep the expression in its
    canonical form and won't simplify any constants.

    >>> l_T_tilde.doit(evaluate=False)
    c1 + log((c2 + fl_T)/c0)/c3

    The function can also be differentiated. We'll differentiate with respect
    to l_T using the ``diff`` method on an instance with the single positional
    argument ``l_T``.

    >>> l_T_tilde.diff(fl_T)
    1/(c3*(c2 + fl_T))

    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

    c                 C   r8   )a  Recommended constructor that will use the published constants.

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

        Returns a new instance of the inverse tendon force-length function
        using the four constant values specified in the original publication.

        These have the values:

        $c_0 = 0.2$
        $c_1 = 0.995$
        $c_2 = 0.25$
        $c_3 = 33.93669377311689$

        Parameters
        ==========

        fl_T : Any (sympifiable)
            Normalized tendon force as a function of tendon length.

        r9   r:   r;   r<   r=   r   fl_Tr@   rA   rB   rC   r   r   r   rD   |  rE   z2TendonForceLengthInverseDeGroote2016.with_defaultsc                 C   rF   )a  Evaluation of basic inputs.

        Parameters
        ==========

        fl_T : Any (sympifiable)
            Normalized tendon force as a function of tendon length.
        c0 : Any (sympifiable)
            The first constant in the characteristic equation. The published
            value is ``0.2``.
        c1 : Any (sympifiable)
            The second constant in the characteristic equation. The published
            value is ``0.995``.
        c2 : Any (sympifiable)
            The third constant in the characteristic equation. The published
            value is ``0.25``.
        c3 : Any (sympifiable)
            The fourth constant in the characteristic equation. The published
            value is ``33.93669377311689``.

        Nr   rv   r   r   r   r     rG   z)TendonForceLengthInverseDeGroote2016.evalc                 C   rH   rI   rJ   rL   r   r   r   rK     rN   z0TendonForceLengthInverseDeGroote2016._eval_evalfTc           
         s   | j ^}} r$|d< |jdd i} fdd|D \}}}}	n|\}}}}	|r8t|| | |	 | S tt|| | |	 | S )rO   r    r   c                    rP   rQ   rR   rS   rV   r   r   rX     rY   z=TendonForceLengthInverseDeGroote2016.doit.<locals>.<listcomp>Nr   )r[   r$   r	   r   )
r%   r   r    rW   rw   r\   r@   rA   rB   rC   r   rV   r   r$     r]   z)TendonForceLengthInverseDeGroote2016.doitr^   c                 C   s   | j \}}}}}|dkrd|||   S |dkrd||  S |dkr&tdS |dkr2d|||   S |dkrEtt|| |  |d  S t| |)r`   r^   ra   rd   rb   rc   re   )r[   r   r	   r   r   )r%   rf   rw   r@   rA   rB   rC   r   r   r   rg     s   
z*TendonForceLengthInverseDeGroote2016.fdiffc                 C   rh   ri   )r   rj   r   r   r   rk     rl   z,TendonForceLengthInverseDeGroote2016.inversec                 C   rm   )rn   r   z9\left( \operatorname{fl}^T \right)^{-1} \left( %s \right)ro   )r%   r&   rw   _fl_Tr   r   r   rq     rr   z+TendonForceLengthInverseDeGroote2016._latexNrs   rt   ru   r   r   r   r   r   1  s    J



 
r   c                   @   r7   )r   a  Passive muscle fiber force-length curve based on De Groote et al., 2016
    [1]_.

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

    The function is defined by the equation:

    $fl^M_{pas} = \frac{\frac{\exp{c_1 \left(\tilde{l^M} - 1\right)}}{c_0} - 1}{\exp{c_1} - 1}$

    with constant values of $c_0 = 0.6$ and $c_1 = 4.0$.

    While it is possible to change the constant values, these were carefully
    selected in the original publication to give the characteristic curve
    specific and required properties. For example, the function produces a
    passive fiber force very close to 0 for all normalized fiber lengths
    between 0 and 1.

    Examples
    ========

    The preferred way to instantiate :class:`FiberForceLengthPassiveDeGroote2016` is
    using the :meth:`~.with_defaults` constructor because this will automatically
    populate the constants within the characteristic curve equation with the
    floating point values from the original publication. This constructor takes
    a single argument corresponding to normalized muscle fiber length. We'll
    create a :class:`~.Symbol` called ``l_M_tilde`` to represent this.

    >>> from sympy import Symbol
    >>> from sympy.physics.biomechanics import FiberForceLengthPassiveDeGroote2016
    >>> l_M_tilde = Symbol('l_M_tilde')
    >>> fl_M = FiberForceLengthPassiveDeGroote2016.with_defaults(l_M_tilde)
    >>> fl_M
    FiberForceLengthPassiveDeGroote2016(l_M_tilde, 0.6, 4.0)

    It's also possible to populate the two constants with your own values too.

    >>> from sympy import symbols
    >>> c0, c1 = symbols('c0 c1')
    >>> fl_M = FiberForceLengthPassiveDeGroote2016(l_M_tilde, c0, c1)
    >>> fl_M
    FiberForceLengthPassiveDeGroote2016(l_M_tilde, c0, c1)

    You don't just have to use symbols as the arguments, it's also possible to
    use expressions. Let's create a new pair of symbols, ``l_M`` and
    ``l_M_opt``, representing muscle fiber length and optimal muscle fiber
    length respectively. We can then represent ``l_M_tilde`` as an expression,
    the ratio of these.

    >>> l_M, l_M_opt = symbols('l_M l_M_opt')
    >>> l_M_tilde = l_M/l_M_opt
    >>> fl_M = FiberForceLengthPassiveDeGroote2016.with_defaults(l_M_tilde)
    >>> fl_M
    FiberForceLengthPassiveDeGroote2016(l_M/l_M_opt, 0.6, 4.0)

    To inspect the actual symbolic expression that this function represents,
    we can call the :meth:`~.doit` method on an instance. We'll use the keyword
    argument ``evaluate=False`` as this will keep the expression in its
    canonical form and won't simplify any constants.

    >>> fl_M.doit(evaluate=False)
    0.0186573603637741*(-1 + exp(6.66666666666667*(l_M/l_M_opt - 1)))

    The function can also be differentiated. We'll differentiate with respect
    to l_M using the ``diff`` method on an instance with the single positional
    argument ``l_M``.

    >>> fl_M.diff(l_M)
    0.12438240242516*exp(6.66666666666667*(l_M/l_M_opt - 1))/l_M_opt

    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

    c                 C      t d}t d}| |||S )a  Recommended constructor that will use the published constants.

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

        Returns a new instance of the muscle fiber passive force-length
        function using the four constant values specified in the original
        publication.

        These have the values:

        $c_0 = 0.6$
        $c_1 = 4.0$

        Parameters
        ==========

        l_M_tilde : Any (sympifiable)
            Normalized muscle fiber length.

        0.64.0r=   r   	l_M_tilder@   rA   r   r   r   rD   ]  s   z1FiberForceLengthPassiveDeGroote2016.with_defaultsc                 C   rF   )a  Evaluation of basic inputs.

        Parameters
        ==========

        l_M_tilde : Any (sympifiable)
            Normalized muscle fiber length.
        c0 : Any (sympifiable)
            The first constant in the characteristic equation. The published
            value is ``0.6``.
        c1 : Any (sympifiable)
            The second constant in the characteristic equation. The published
            value is ``4.0``.

        Nr   r|   r   r   r   r   x     z(FiberForceLengthPassiveDeGroote2016.evalc                 C   rH   rI   rJ   rL   r   r   r   rK     rN   z/FiberForceLengthPassiveDeGroote2016._eval_evalfTc                    s   | j ^}} r"|d< |jdd i} fdd|D \}}n|\}}|r:t||d  | d t|d  S t|t|d  | d t|d  S )rO   r    r   c                    rP   rQ   rR   rS   rV   r   r   rX     rY   z<FiberForceLengthPassiveDeGroote2016.doit.<locals>.<listcomp>r^   Nr   rZ   )r%   r   r    rW   r}   r\   r@   rA   r   rV   r   r$        
$(z(FiberForceLengthPassiveDeGroote2016.doitr^   c                 C   s   | j \}}}|dkr |t|t|d  |  |t|d   S |dkrC| t|t|d  |  t|d  |d t|d   S |dkrzt| dt|t|d  |   t|d d  t|t|d  | |d  |t|d    S t| |)r`   r^   ra   rb   rd   )r[   r   r   r   )r%   rf   r}   r@   rA   r   r   r   rg     s    ,
4.
z)FiberForceLengthPassiveDeGroote2016.fdiffc                 C   rh   ri   )r   rj   r   r   r   rk     rl   z+FiberForceLengthPassiveDeGroote2016.inversec                 C   rm   )rn   r   z+\operatorname{fl}^M_{pas} \left( %s \right)ro   r%   r&   r}   
_l_M_tilder   r   r   rq     rr   z*FiberForceLengthPassiveDeGroote2016._latexNrs   rt   ru   r   r   r   r   r     s    P



 
r   c                   @   r7   )r   a  Inverse passive muscle fiber force-length curve based on De Groote et
    al., 2016 [1]_.

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

    Gives the normalized muscle fiber length that produces a specific normalized
    passive muscle fiber force.

    The function is defined by the equation:

    ${fl^M_{pas}}^{-1} = \frac{c_0 \log{\left(\exp{c_1} - 1\right)fl^M_pas + 1}}{c_1} + 1$

    with constant values of $c_0 = 0.6$ and $c_1 = 4.0$. This function is the
    exact analytical inverse of the related tendon force-length curve
    ``FiberForceLengthPassiveDeGroote2016``.

    While it is possible to change the constant values, these were carefully
    selected in the original publication to give the characteristic curve
    specific and required properties. For example, the function produces a
    passive fiber force very close to 0 for all normalized fiber lengths
    between 0 and 1.

    Examples
    ========

    The preferred way to instantiate
    :class:`FiberForceLengthPassiveInverseDeGroote2016` is using the
    :meth:`~.with_defaults` constructor because this will automatically populate the
    constants within the characteristic curve equation with the floating point
    values from the original publication. This constructor takes a single
    argument corresponding to the normalized passive muscle fiber length-force
    component of the muscle fiber force. We'll create a :class:`~.Symbol` called
    ``fl_M_pas`` to represent this.

    >>> from sympy import Symbol
    >>> from sympy.physics.biomechanics import FiberForceLengthPassiveInverseDeGroote2016
    >>> fl_M_pas = Symbol('fl_M_pas')
    >>> l_M_tilde = FiberForceLengthPassiveInverseDeGroote2016.with_defaults(fl_M_pas)
    >>> l_M_tilde
    FiberForceLengthPassiveInverseDeGroote2016(fl_M_pas, 0.6, 4.0)

    It's also possible to populate the two constants with your own values too.

    >>> from sympy import symbols
    >>> c0, c1 = symbols('c0 c1')
    >>> l_M_tilde = FiberForceLengthPassiveInverseDeGroote2016(fl_M_pas, c0, c1)
    >>> l_M_tilde
    FiberForceLengthPassiveInverseDeGroote2016(fl_M_pas, c0, c1)

    To inspect the actual symbolic expression that this function represents,
    we can call the :meth:`~.doit` method on an instance. We'll use the keyword
    argument ``evaluate=False`` as this will keep the expression in its
    canonical form and won't simplify any constants.

    >>> l_M_tilde.doit(evaluate=False)
    c0*log(1 + fl_M_pas*(exp(c1) - 1))/c1 + 1

    The function can also be differentiated. We'll differentiate with respect
    to fl_M_pas using the ``diff`` method on an instance with the single positional
    argument ``fl_M_pas``.

    >>> l_M_tilde.diff(fl_M_pas)
    c0*(exp(c1) - 1)/(c1*(fl_M_pas*(exp(c1) - 1) + 1))

    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

    c                 C   ry   )a  Recommended constructor that will use the published constants.

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

        Returns a new instance of the inverse muscle fiber passive force-length
        function using the four constant values specified in the original
        publication.

        These have the values:

        $c_0 = 0.6$
        $c_1 = 4.0$

        Parameters
        ==========

        fl_M_pas : Any (sympifiable)
            Normalized passive muscle fiber force as a function of muscle fiber
            length.

        rz   r{   r=   r   fl_M_pasr@   rA   r   r   r   rD   2  s   z8FiberForceLengthPassiveInverseDeGroote2016.with_defaultsc                 C   rF   )a  Evaluation of basic inputs.

        Parameters
        ==========

        fl_M_pas : Any (sympifiable)
            Normalized passive muscle fiber force.
        c0 : Any (sympifiable)
            The first constant in the characteristic equation. The published
            value is ``0.6``.
        c1 : Any (sympifiable)
            The second constant in the characteristic equation. The published
            value is ``4.0``.

        Nr   r   r   r   r   r   N  r~   z/FiberForceLengthPassiveInverseDeGroote2016.evalc                 C   rH   rI   rJ   rL   r   r   r   rK   a  rN   z6FiberForceLengthPassiveInverseDeGroote2016._eval_evalfTc                    s   | j ^}} r"|d< |jdd i} fdd|D \}}n|\}}|r:|t|t|d  d  | d S |tt|t|d  d  | d S )rO   r    r   c                    rP   rQ   rR   rS   rV   r   r   rX   |  rY   zCFiberForceLengthPassiveInverseDeGroote2016.doit.<locals>.<listcomp>r^   Nr   )r[   r$   r	   r   r   )r%   r   r    rW   r   r\   r@   rA   r   rV   r   r$   e  r   z/FiberForceLengthPassiveInverseDeGroote2016.doitr^   c                 C   s   | j \}}}|dkr|t|d  ||t|d  d   S |dkr0t|t|d  d | S |dkrZ|| t| ||t|d  d   |t|t|d  d  |d   S t| |)r`   r^   ra   rb   )r[   r   r	   r   )r%   rf   r   r@   rA   r   r   r   rg     s   (&"
z0FiberForceLengthPassiveInverseDeGroote2016.fdiffc                 C   rh   ri   )r   rj   r   r   r   rk     rl   z2FiberForceLengthPassiveInverseDeGroote2016.inversec                 C   rm   )rn   r   z?\left( \operatorname{fl}^M_{pas} \right)^{-1} \left( %s \right)ro   )r%   r&   r   	_fl_M_pasr   r   r   rq     rr   z1FiberForceLengthPassiveInverseDeGroote2016._latexNrs   rt   ru   r   r   r   r   r     s    K



 
r   c                   @   sL   e Zd ZdZedd Zedd Zdd Zdd	d
ZdddZ	dd Z
dS )r   aB  Active muscle fiber force-length curve based on De Groote et al., 2016
    [1]_.

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

    The function is defined by the equation:

    $fl_{\text{act}}^M = c_0 \exp\left(-\frac{1}{2}\left(\frac{\tilde{l}^M - c_1}{c_2 + c_3 \tilde{l}^M}\right)^2\right)
    + c_4 \exp\left(-\frac{1}{2}\left(\frac{\tilde{l}^M - c_5}{c_6 + c_7 \tilde{l}^M}\right)^2\right)
    + c_8 \exp\left(-\frac{1}{2}\left(\frac{\tilde{l}^M - c_9}{c_{10} + c_{11} \tilde{l}^M}\right)^2\right)$

    with constant values of $c0 = 0.814$, $c1 = 1.06$, $c2 = 0.162$,
    $c3 = 0.0633$, $c4 = 0.433$, $c5 = 0.717$, $c6 = -0.0299$, $c7 = 0.2$,
    $c8 = 0.1$, $c9 = 1.0$, $c10 = 0.354$, and $c11 = 0.0$.

    While it is possible to change the constant values, these were carefully
    selected in the original publication to give the characteristic curve
    specific and required properties. For example, the function produces a
    active fiber force of 1 at a normalized fiber length of 1, and an active
    fiber force of 0 at normalized fiber lengths of 0 and 2.

    Examples
    ========

    The preferred way to instantiate :class:`FiberForceLengthActiveDeGroote2016` is
    using the :meth:`~.with_defaults` constructor because this will automatically
    populate the constants within the characteristic curve equation with the
    floating point values from the original publication. This constructor takes
    a single argument corresponding to normalized muscle fiber length. We'll
    create a :class:`~.Symbol` called ``l_M_tilde`` to represent this.

    >>> from sympy import Symbol
    >>> from sympy.physics.biomechanics import FiberForceLengthActiveDeGroote2016
    >>> l_M_tilde = Symbol('l_M_tilde')
    >>> fl_M = FiberForceLengthActiveDeGroote2016.with_defaults(l_M_tilde)
    >>> fl_M
    FiberForceLengthActiveDeGroote2016(l_M_tilde, 0.814, 1.06, 0.162, 0.0633,
    0.433, 0.717, -0.0299, 0.2, 0.1, 1.0, 0.354, 0.0)

    It's also possible to populate the two constants with your own values too.

    >>> from sympy import symbols
    >>> c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 = symbols('c0:12')
    >>> fl_M = FiberForceLengthActiveDeGroote2016(l_M_tilde, c0, c1, c2, c3,
    ...     c4, c5, c6, c7, c8, c9, c10, c11)
    >>> fl_M
    FiberForceLengthActiveDeGroote2016(l_M_tilde, c0, c1, c2, c3, c4, c5, c6,
    c7, c8, c9, c10, c11)

    You don't just have to use symbols as the arguments, it's also possible to
    use expressions. Let's create a new pair of symbols, ``l_M`` and
    ``l_M_opt``, representing muscle fiber length and optimal muscle fiber
    length respectively. We can then represent ``l_M_tilde`` as an expression,
    the ratio of these.

    >>> l_M, l_M_opt = symbols('l_M l_M_opt')
    >>> l_M_tilde = l_M/l_M_opt
    >>> fl_M = FiberForceLengthActiveDeGroote2016.with_defaults(l_M_tilde)
    >>> fl_M
    FiberForceLengthActiveDeGroote2016(l_M/l_M_opt, 0.814, 1.06, 0.162, 0.0633,
    0.433, 0.717, -0.0299, 0.2, 0.1, 1.0, 0.354, 0.0)

    To inspect the actual symbolic expression that this function represents,
    we can call the :meth:`~.doit` method on an instance. We'll use the keyword
    argument ``evaluate=False`` as this will keep the expression in its
    canonical form and won't simplify any constants.

    >>> fl_M.doit(evaluate=False)
    0.814*exp(-19.0519737844841*(l_M/l_M_opt
    - 1.06)**2/(0.390740740740741*l_M/l_M_opt + 1)**2)
    + 0.433*exp(-12.5*(l_M/l_M_opt - 0.717)**2/(l_M/l_M_opt - 0.1495)**2)
    + 0.1*exp(-3.98991349867535*(l_M/l_M_opt - 1.0)**2)

    The function can also be differentiated. We'll differentiate with respect
    to l_M using the ``diff`` method on an instance with the single positional
    argument ``l_M``.

    >>> fl_M.diff(l_M)
    ((-0.79798269973507*l_M/l_M_opt
    + 0.79798269973507)*exp(-3.98991349867535*(l_M/l_M_opt - 1.0)**2)
    + (10.825*(-l_M/l_M_opt + 0.717)/(l_M/l_M_opt - 0.1495)**2
    + 10.825*(l_M/l_M_opt - 0.717)**2/(l_M/l_M_opt
    - 0.1495)**3)*exp(-12.5*(l_M/l_M_opt - 0.717)**2/(l_M/l_M_opt - 0.1495)**2)
    + (31.0166133211401*(-l_M/l_M_opt + 1.06)/(0.390740740740741*l_M/l_M_opt
    + 1)**2 + 13.6174190361677*(0.943396226415094*l_M/l_M_opt
    - 1)**2/(0.390740740740741*l_M/l_M_opt
    + 1)**3)*exp(-21.4067977442463*(0.943396226415094*l_M/l_M_opt
    - 1)**2/(0.390740740740741*l_M/l_M_opt + 1)**2))/l_M_opt

    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

    c                 C   s   t d}t d}t d}t d}t d}t d}t d}t d}	t d	}
t d
}t d}t d}| |||||||||	|
|||S )a  Recommended constructor that will use the published constants.

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

        Returns a new instance of the inverse muscle fiber act force-length
        function using the four constant values specified in the original
        publication.

        These have the values:

        $c0 = 0.814$
        $c1 = 1.06$
        $c2 = 0.162$
        $c3 = 0.0633$
        $c4 = 0.433$
        $c5 = 0.717$
        $c6 = -0.0299$
        $c7 = 0.2$
        $c8 = 0.1$
        $c9 = 1.0$
        $c10 = 0.354$
        $c11 = 0.0$

        Parameters
        ==========

        fl_M_act : Any (sympifiable)
            Normalized passive muscle fiber force as a function of muscle fiber
            length.

        z0.814z1.06z0.162z0.0633z0.433z0.717z-0.0299r9   z0.1z1.0z0.354z0.0r=   r   r}   r@   rA   rB   rC   c4c5c6c7c8c9c10c11r   r   r   rD     s   " z0FiberForceLengthActiveDeGroote2016.with_defaultsc                 C   rF   )a5  Evaluation of basic inputs.

        Parameters
        ==========

        l_M_tilde : Any (sympifiable)
            Normalized muscle fiber length.
        c0 : Any (sympifiable)
            The first constant in the characteristic equation. The published
            value is ``0.814``.
        c1 : Any (sympifiable)
            The second constant in the characteristic equation. The published
            value is ``1.06``.
        c2 : Any (sympifiable)
            The third constant in the characteristic equation. The published
            value is ``0.162``.
        c3 : Any (sympifiable)
            The fourth constant in the characteristic equation. The published
            value is ``0.0633``.
        c4 : Any (sympifiable)
            The fifth constant in the characteristic equation. The published
            value is ``0.433``.
        c5 : Any (sympifiable)
            The sixth constant in the characteristic equation. The published
            value is ``0.717``.
        c6 : Any (sympifiable)
            The seventh constant in the characteristic equation. The published
            value is ``-0.0299``.
        c7 : Any (sympifiable)
            The eighth constant in the characteristic equation. The published
            value is ``0.2``.
        c8 : Any (sympifiable)
            The ninth constant in the characteristic equation. The published
            value is ``0.1``.
        c9 : Any (sympifiable)
            The tenth constant in the characteristic equation. The published
            value is ``1.0``.
        c10 : Any (sympifiable)
            The eleventh constant in the characteristic equation. The published
            value is ``0.354``.
        c11 : Any (sympifiable)
            The tweflth constant in the characteristic equation. The published
            value is ``0.0``.

        Nr   r   r   r   r   r   N  s   /z'FiberForceLengthActiveDeGroote2016.evalc                 C   rH   rI   rJ   rL   r   r   r   rK     rN   z.FiberForceLengthActiveDeGroote2016._eval_evalfTc                    sN  | j ^}} r|d< |jdd i} fdd|D }|\}}}}	}
}}}}}}}|rh|t|| ||	|   d  d  |
t|| |||   d  d   |t|| |||   d  d   S |tt|| ||	|   d  d  |
tt|| |||   d  d   |tt|| |||   d  d   S )a  Evaluate the expression defining the function.

        Parameters
        ==========

        deep : bool
            Whether ``doit`` should be recursively called. Default is ``True``.
        evaluate : bool.
            Whether the SymPy expression should be evaluated as it is
            constructed. If ``False``, then no constant folding will be
            conducted which will leave the expression in a more numerically-
            stable for values of ``l_M_tilde`` that correspond to a sensible
            operating range for a musculotendon. Default is ``True``.
        **kwargs : dict[str, Any]
            Additional keyword argument pairs to be recursively passed to
            ``doit``.

        r    r   c                    rP   rQ   rR   rS   rV   r   r   rX     rY   z;FiberForceLengthActiveDeGroote2016.doit.<locals>.<listcomp>ra   Nr   rZ   )r%   r   r    rW   r}   r\   r@   rA   rB   rC   r   r   r   r   r   r   r   r   r   rV   r   r$     s&   
$$$(((z'FiberForceLengthActiveDeGroote2016.doitr^   c                 C   s  | j \}}}}}}}}	}
}}}}|dkr|||| d  |||  d  || |||  d    t|| d  d|||  d    ||
|| d  |	|
|  d  || |	|
|  d    t|| d  d|	|
|  d     |||| d  |||  d  || |||  d    t|| d  d|||  d     S |dkrt|| d  d|||  d   S |dkr|||  |||  d  t|| d  d|||  d    S |dkr||| d  |||  d  t|| d  d|||  d    S |dkr5|| || d  |||  d  t|| d  d|||  d    S |dkrMt|| d  d|	|
|  d   S |dkrs|||  |	|
|  d  t|| d  d|	|
|  d    S |dkr||| d  |	|
|  d  t|| d  d|	|
|  d    S |d	kr|| || d  |	|
|  d  t|| d  d|	|
|  d    S |d
krt|| d  d|||  d   S |dkr|||  |||  d  t|| d  d|||  d    S |dkr+||| d  |||  d  t|| d  d|||  d    S |dkrU|| || d  |||  d  t|| d  d|||  d    S t| |)r`   r^   ra   rb   rc   re            	   
            )r[   r   r   )r%   rf   r}   r@   rA   rB   rC   r   r   r   r   r   r   r   r   r   r   r   rg     s    $$$&$
$
"$
&
$
$
"$
&
$
$
"$
z(FiberForceLengthActiveDeGroote2016.fdiffc                 C   rm   )rn   r   z+\operatorname{fl}^M_{act} \left( %s \right)ro   r   r   r   r   rq     rr   z)FiberForceLengthActiveDeGroote2016._latexNrs   rt   )r   r(   r)   r*   r+   rD   r   rK   r$   rg   rq   r   r   r   r   r     s    d
/
0

'Rr   c                   @   r7   )r   a  Muscle fiber force-velocity curve based on De Groote et al., 2016 [1]_.

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

    Gives the normalized muscle fiber force produced as a function of
    normalized tendon velocity.

    The function is defined by the equation:

    $fv^M = c_0 \log{\left(c_1 \tilde{v}_m + c_2\right) + \sqrt{\left(c_1 \tilde{v}_m + c_2\right)^2 + 1}} + c_3$

    with constant values of $c_0 = -0.318$, $c_1 = -8.149$, $c_2 = -0.374$, and
    $c_3 = 0.886$.

    While it is possible to change the constant values, these were carefully
    selected in the original publication to give the characteristic curve
    specific and required properties. For example, the function produces a
    normalized muscle fiber force of 1 when the muscle fibers are contracting
    isometrically (they have an extension rate of 0).

    Examples
    ========

    The preferred way to instantiate :class:`FiberForceVelocityDeGroote2016` is using
    the :meth:`~.with_defaults` constructor because this will automatically populate
    the constants within the characteristic curve equation with the floating
    point values from the original publication. This constructor takes a single
    argument corresponding to normalized muscle fiber extension velocity. We'll
    create a :class:`~.Symbol` called ``v_M_tilde`` to represent this.

    >>> from sympy import Symbol
    >>> from sympy.physics.biomechanics import FiberForceVelocityDeGroote2016
    >>> v_M_tilde = Symbol('v_M_tilde')
    >>> fv_M = FiberForceVelocityDeGroote2016.with_defaults(v_M_tilde)
    >>> fv_M
    FiberForceVelocityDeGroote2016(v_M_tilde, -0.318, -8.149, -0.374, 0.886)

    It's also possible to populate the four constants with your own values too.

    >>> from sympy import symbols
    >>> c0, c1, c2, c3 = symbols('c0 c1 c2 c3')
    >>> fv_M = FiberForceVelocityDeGroote2016(v_M_tilde, c0, c1, c2, c3)
    >>> fv_M
    FiberForceVelocityDeGroote2016(v_M_tilde, c0, c1, c2, c3)

    You don't just have to use symbols as the arguments, it's also possible to
    use expressions. Let's create a new pair of symbols, ``v_M`` and
    ``v_M_max``, representing muscle fiber extension velocity and maximum
    muscle fiber extension velocity respectively. We can then represent
    ``v_M_tilde`` as an expression, the ratio of these.

    >>> v_M, v_M_max = symbols('v_M v_M_max')
    >>> v_M_tilde = v_M/v_M_max
    >>> fv_M = FiberForceVelocityDeGroote2016.with_defaults(v_M_tilde)
    >>> fv_M
    FiberForceVelocityDeGroote2016(v_M/v_M_max, -0.318, -8.149, -0.374, 0.886)

    To inspect the actual symbolic expression that this function represents,
    we can call the :meth:`~.doit` method on an instance. We'll use the keyword
    argument ``evaluate=False`` as this will keep the expression in its
    canonical form and won't simplify any constants.

    >>> fv_M.doit(evaluate=False)
    0.886 - 0.318*log(-8.149*v_M/v_M_max - 0.374 + sqrt(1 + (-8.149*v_M/v_M_max
    - 0.374)**2))

    The function can also be differentiated. We'll differentiate with respect
    to v_M using the ``diff`` method on an instance with the single positional
    argument ``v_M``.

    >>> fv_M.diff(v_M)
    2.591382*(1 + (-8.149*v_M/v_M_max - 0.374)**2)**(-1/2)/v_M_max

    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

    c                 C   r8   )a  Recommended constructor that will use the published constants.

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

        Returns a new instance of the muscle fiber force-velocity function
        using the four constant values specified in the original publication.

        These have the values:

        $c_0 = -0.318$
        $c_1 = -8.149$
        $c_2 = -0.374$
        $c_3 = 0.886$

        Parameters
        ==========

        v_M_tilde : Any (sympifiable)
            Normalized muscle fiber extension velocity.

        -0.318-8.149-0.3740.886r=   r   	v_M_tilder@   rA   rB   rC   r   r   r   rD   `  rE   z,FiberForceVelocityDeGroote2016.with_defaultsc                 C   rF   )a  Evaluation of basic inputs.

        Parameters
        ==========

        v_M_tilde : Any (sympifiable)
            Normalized muscle fiber extension velocity.
        c0 : Any (sympifiable)
            The first constant in the characteristic equation. The published
            value is ``-0.318``.
        c1 : Any (sympifiable)
            The second constant in the characteristic equation. The published
            value is ``-8.149``.
        c2 : Any (sympifiable)
            The third constant in the characteristic equation. The published
            value is ``-0.374``.
        c3 : Any (sympifiable)
            The fourth constant in the characteristic equation. The published
            value is ``0.886``.

        Nr   r   r   r   r   r   ~  rG   z#FiberForceVelocityDeGroote2016.evalc                 C   rH   rI   rJ   rL   r   r   r   rK     rN   z*FiberForceVelocityDeGroote2016._eval_evalfTc           
         s   | j ^}} r$|d< |jdd i} fdd|D \}}}}	n|\}}}}	|rD|t|| | t|| | d d   |	 S |t|| | tt|| | d d   |	 S )	a  Evaluate the expression defining the function.

        Parameters
        ==========

        deep : bool
            Whether ``doit`` should be recursively called. Default is ``True``.
        evaluate : bool.
            Whether the SymPy expression should be evaluated as it is
            constructed. If ``False``, then no constant folding will be
            conducted which will leave the expression in a more numerically-
            stable for values of ``v_M_tilde`` that correspond to a sensible
            operating range for a musculotendon. Default is ``True``.
        **kwargs : dict[str, Any]
            Additional keyword argument pairs to be recursively passed to
            ``doit``.

        r    r   c                    rP   rQ   rR   rS   rV   r   r   rX     rY   z7FiberForceVelocityDeGroote2016.doit.<locals>.<listcomp>ra   r^   Nr   )r[   r$   r	   r   r   )
r%   r   r    rW   r   r\   r@   rA   rB   rC   r   rV   r   r$     s   
04z#FiberForceVelocityDeGroote2016.doitr^   c                 C   s   | j \}}}}}|dkr|| tt|| | d d  S |dkr8t|| | tt|| | d d  S |dkrN|| tt|| | d d  S |dkrb|tt|| | d d  S |dkrjtdS t| |)r`   r^   ra   rb   rc   re   )r[   r   r   r	   r   r   )r%   rf   r   r@   rA   rB   rC   r   r   r   rg     s    $
$ 
z$FiberForceVelocityDeGroote2016.fdiffc                 C   rh   ri   )r   rj   r   r   r   rk     rl   z&FiberForceVelocityDeGroote2016.inversec                 C   rm   )rn   r   z%\operatorname{fv}^M \left( %s \right)ro   )r%   r&   r   
_v_M_tilder   r   r   rq     rr   z%FiberForceVelocityDeGroote2016._latexNrs   rt   ru   r   r   r   r   r     s    T



 
r   c                   @   r7   )r   a  Inverse muscle fiber force-velocity curve based on De Groote et al.,
    2016 [1]_.

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

    Gives the normalized muscle fiber velocity that produces a specific
    normalized muscle fiber force.

    The function is defined by the equation:

    ${fv^M}^{-1} = \frac{\sinh{\frac{fv^M - c_3}{c_0}} - c_2}{c_1}$

    with constant values of $c_0 = -0.318$, $c_1 = -8.149$, $c_2 = -0.374$, and
    $c_3 = 0.886$. This function is the exact analytical inverse of the related
    muscle fiber force-velocity curve ``FiberForceVelocityDeGroote2016``.

    While it is possible to change the constant values, these were carefully
    selected in the original publication to give the characteristic curve
    specific and required properties. For example, the function produces a
    normalized muscle fiber force of 1 when the muscle fibers are contracting
    isometrically (they have an extension rate of 0).

    Examples
    ========

    The preferred way to instantiate :class:`FiberForceVelocityInverseDeGroote2016`
    is using the :meth:`~.with_defaults` constructor because this will automatically
    populate the constants within the characteristic curve equation with the
    floating point values from the original publication. This constructor takes
    a single argument corresponding to normalized muscle fiber force-velocity
    component of the muscle fiber force. We'll create a :class:`~.Symbol` called
    ``fv_M`` to represent this.

    >>> from sympy import Symbol
    >>> from sympy.physics.biomechanics import FiberForceVelocityInverseDeGroote2016
    >>> fv_M = Symbol('fv_M')
    >>> v_M_tilde = FiberForceVelocityInverseDeGroote2016.with_defaults(fv_M)
    >>> v_M_tilde
    FiberForceVelocityInverseDeGroote2016(fv_M, -0.318, -8.149, -0.374, 0.886)

    It's also possible to populate the four constants with your own values too.

    >>> from sympy import symbols
    >>> c0, c1, c2, c3 = symbols('c0 c1 c2 c3')
    >>> v_M_tilde = FiberForceVelocityInverseDeGroote2016(fv_M, c0, c1, c2, c3)
    >>> v_M_tilde
    FiberForceVelocityInverseDeGroote2016(fv_M, c0, c1, c2, c3)

    To inspect the actual symbolic expression that this function represents,
    we can call the :meth:`~.doit` method on an instance. We'll use the keyword
    argument ``evaluate=False`` as this will keep the expression in its
    canonical form and won't simplify any constants.

    >>> v_M_tilde.doit(evaluate=False)
    (-c2 + sinh((-c3 + fv_M)/c0))/c1

    The function can also be differentiated. We'll differentiate with respect
    to fv_M using the ``diff`` method on an instance with the single positional
    argument ``fv_M``.

    >>> v_M_tilde.diff(fv_M)
    cosh((-c3 + fv_M)/c0)/(c0*c1)

    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

    c                 C   r8   )a  Recommended constructor that will use the published constants.

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

        Returns a new instance of the inverse muscle fiber force-velocity
        function using the four constant values specified in the original
        publication.

        These have the values:

        $c_0 = -0.318$
        $c_1 = -8.149$
        $c_2 = -0.374$
        $c_3 = 0.886$

        Parameters
        ==========

        fv_M : Any (sympifiable)
            Normalized muscle fiber extension velocity.

        r   r   r   r   r=   r   fv_Mr@   rA   rB   rC   r   r   r   rD   >  s
   z3FiberForceVelocityInverseDeGroote2016.with_defaultsc                 C   rF   )a  Evaluation of basic inputs.

        Parameters
        ==========

        fv_M : Any (sympifiable)
            Normalized muscle fiber force as a function of muscle fiber
            extension velocity.
        c0 : Any (sympifiable)
            The first constant in the characteristic equation. The published
            value is ``-0.318``.
        c1 : Any (sympifiable)
            The second constant in the characteristic equation. The published
            value is ``-8.149``.
        c2 : Any (sympifiable)
            The third constant in the characteristic equation. The published
            value is ``-0.374``.
        c3 : Any (sympifiable)
            The fourth constant in the characteristic equation. The published
            value is ``0.886``.

        Nr   r   r   r   r   r   ]  s   z*FiberForceVelocityInverseDeGroote2016.evalc                 C   rH   rI   rJ   rL   r   r   r   rK   w  rN   z1FiberForceVelocityInverseDeGroote2016._eval_evalfTc           
         s   | j ^}} r$|d< |jdd i} fdd|D \}}}}	n|\}}}}	|r8t||	 | | | S tt||	 | | | S )a  Evaluate the expression defining the function.

        Parameters
        ==========

        deep : bool
            Whether ``doit`` should be recursively called. Default is ``True``.
        evaluate : bool.
            Whether the SymPy expression should be evaluated as it is
            constructed. If ``False``, then no constant folding will be
            conducted which will leave the expression in a more numerically-
            stable for values of ``fv_M`` that correspond to a sensible
            operating range for a musculotendon. Default is ``True``.
        **kwargs : dict[str, Any]
            Additional keyword argument pairs to be recursively passed to
            ``doit``.

        r    r   c                    rP   rQ   rR   rS   rV   r   r   rX     rY   z>FiberForceVelocityInverseDeGroote2016.doit.<locals>.<listcomp>Nr   )r[   r$   r   r   )
r%   r   r    rW   r   r\   r@   rA   rB   rC   r   rV   r   r$   {  r]   z*FiberForceVelocityInverseDeGroote2016.doitr^   c                 C   s   | j \}}}}}|dkrt|| | ||  S |dkr.|| t|| |  |d |  S |dkr@|t|| |  |d  S |dkrHd| S |dkrYt|| |  ||  S t| |r_   )r[   r
   r   r   )r%   rf   r   r@   rA   rB   rC   r   r   r   rg     s   $
z+FiberForceVelocityInverseDeGroote2016.fdiffc                 C   rh   ri   )r   rj   r   r   r   rk     rl   z-FiberForceVelocityInverseDeGroote2016.inversec                 C   rm   )rn   r   z9\left( \operatorname{fv}^M \right)^{-1} \left( %s \right)ro   )r%   r&   r   _fv_Mr   r   r   rq     rr   z,FiberForceVelocityInverseDeGroote2016._latexNrs   rt   ru   r   r   r   r   r     s    J



 
r   T)frozenc                   @   sR   e Zd ZU dZeed< eed< eed< eed< eed< eed< eed< d	d
 ZdS )r   zFSimple data container to group together related characteristic curves.tendon_force_lengthtendon_force_length_inversefiber_force_length_passive"fiber_force_length_passive_inversefiber_force_length_activefiber_force_velocityfiber_force_velocity_inversec                 c   s>    | j V  | jV  | jV  | jV  | jV  | jV  | jV  dS )z7Iterator support for ``CharacteristicCurveCollection``.N)r   r   r   r   r   r   r   )r%   r   r   r   __iter__  s   z&CharacteristicCurveCollection.__iter__N)r   r(   r)   r*   r   __annotations__r   r   r   r   r   r     s   
 r   N)r*   dataclassesr   sympy.core.exprr   sympy.core.functionr   r   sympy.core.numbersr   r   &sympy.functions.elementary.exponentialr   r	   %sympy.functions.elementary.hyperbolicr
   r   (sympy.functions.elementary.miscellaneousr   sympy.printing.precedencer   __all__r   r   r   r   r   r   r   r   r   r   r   r   r   <module>   s8    0 g \ [ T  T i ^