
    sg(                     p    d dl mZmZmZmZmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ dgZ G d de
      Zy)	    )Body
LagrangianKanesMethodLagrangesMethod	RigidBodyParticle)BodyBase)_Methods)Matrix)sympy_deprecation_warningJointsMethodc                       e Zd ZdZd Zed        Zed        Zed        Zed        Z	ed        Z
ed        Zed	        Zed
        Zed        Zed        Zd Zd Zd Zd Zd Zd ZefdZddZy)r   a
  Method for formulating the equations of motion using a set of interconnected bodies with joints.

    .. deprecated:: 1.13
        The JointsMethod class is deprecated. Its functionality has been
        replaced by the new :class:`~.System` class.

    Parameters
    ==========

    newtonion : Body or ReferenceFrame
        The newtonion(inertial) frame.
    *joints : Joint
        The joints in the system

    Attributes
    ==========

    q, u : iterable
        Iterable of the generalized coordinates and speeds
    bodies : iterable
        Iterable of Body objects in the system.
    loads : iterable
        Iterable of (Point, vector) or (ReferenceFrame, vector) tuples
        describing the forces on the system.
    mass_matrix : Matrix, shape(n, n)
        The system's mass matrix
    forcing : Matrix, shape(n, 1)
        The system's forcing vector
    mass_matrix_full : Matrix, shape(2*n, 2*n)
        The "mass matrix" for the u's and q's
    forcing_full : Matrix, shape(2*n, 1)
        The "forcing vector" for the u's and q's
    method : KanesMethod or Lagrange's method
        Method's object.
    kdes : iterable
        Iterable of kde in they system.

    Examples
    ========

    As Body and JointsMethod have been deprecated, the following examples are
    for illustrative purposes only. The functionality of Body is fully captured
    by :class:`~.RigidBody` and :class:`~.Particle` and the functionality of
    JointsMethod is fully captured by :class:`~.System`. To ignore the
    deprecation warning we can use the ignore_warnings context manager.

    >>> from sympy.utilities.exceptions import ignore_warnings

    This is a simple example for a one degree of freedom translational
    spring-mass-damper.

    >>> from sympy import symbols
    >>> from sympy.physics.mechanics import Body, JointsMethod, PrismaticJoint
    >>> from sympy.physics.vector import dynamicsymbols
    >>> c, k = symbols('c k')
    >>> x, v = dynamicsymbols('x v')
    >>> with ignore_warnings(DeprecationWarning):
    ...     wall = Body('W')
    ...     body = Body('B')
    >>> J = PrismaticJoint('J', wall, body, coordinates=x, speeds=v)
    >>> wall.apply_force(c*v*wall.x, reaction_body=body)
    >>> wall.apply_force(k*x*wall.x, reaction_body=body)
    >>> with ignore_warnings(DeprecationWarning):
    ...     method = JointsMethod(wall, J)
    >>> method.form_eoms()
    Matrix([[-B_mass*Derivative(v(t), t) - c*v(t) - k*x(t)]])
    >>> M = method.mass_matrix_full
    >>> F = method.forcing_full
    >>> rhs = M.LUsolve(F)
    >>> rhs
    Matrix([
    [                     v(t)],
    [(-c*v(t) - k*x(t))/B_mass]])

    Notes
    =====

    ``JointsMethod`` currently only works with systems that do not have any
    configuration or motion constraints.

    c                 `   t        ddd       t        |t              r|j                  | _        n|| _        || _        | j                         | _        | j                         | _        | j                         | _
        | j                         | _        | j                         | _        d | _        y )Nz
            The JointsMethod class is deprecated.
            Its functionality has been replaced by the new System class.
            z1.13z!deprecated-mechanics-jointsmethod)deprecated_since_versionactive_deprecations_target)r   
isinstancer	   frame_joints_generate_bodylist_bodies_generate_loadlist_loads_generate_q_q_generate_u_u_generate_kdes_kdes_method)self	newtonionjointss      W/var/www/html/venv/lib/python3.12/site-packages/sympy/physics/mechanics/jointsmethod.py__init__zJointsMethod.__init__^   s    ! &,'J	
 i*"DJ"DJ..0--/""$""$((*
    c                     | j                   S )zList of bodies in they system.)r   r    s    r#   bodieszJointsMethod.bodiesu        ||r%   c                     | j                   S )zList of loads on the system.)r   r'   s    r#   loadszJointsMethod.loadsz   s     {{r%   c                     | j                   S z$List of the generalized coordinates.)r   r'   s    r#   qzJointsMethod.q        wwr%   c                     | j                   S )zList of the generalized speeds.)r   r'   s    r#   uzJointsMethod.u   r/   r%   c                     | j                   S r-   )r   r'   s    r#   kdeszJointsMethod.kdes   s     zzr%   c                 .    | j                   j                  S )z)The "forcing vector" for the u's and q's.)methodforcing_fullr'   s    r#   r6   zJointsMethod.forcing_full   s     {{'''r%   c                 .    | j                   j                  S )z&The "mass matrix" for the u's and q's.)r5   mass_matrix_fullr'   s    r#   r8   zJointsMethod.mass_matrix_full   s     {{+++r%   c                 .    | j                   j                  S )zThe system's mass matrix.)r5   mass_matrixr'   s    r#   r:   zJointsMethod.mass_matrix   s     {{&&&r%   c                 .    | j                   j                  S )zThe system's forcing vector.)r5   forcingr'   s    r#   r<   zJointsMethod.forcing   s     {{"""r%   c                     | j                   S )z3Object of method used to form equations of systems.)r   r'   s    r#   r5   zJointsMethod.method   r)   r%   c                     g }| j                   D ]U  }|j                  |vr|j                  |j                         |j                  |vs;|j                  |j                         W |S N)r   childappendparent)r    r(   joints      r#   r   zJointsMethod._generate_bodylist   sY    \\ 	,E{{&(ekk*||6)ell+		,
 r%   c                     g }| j                   D ].  }t        |t              s|j                  |j                         0 |S r?   )r(   r   r   extendr+   )r    	load_listbodys      r#   r   zJointsMethod._generate_loadlist   s>    	KK 	-D$%  ,	- r%   c                     g }| j                   D ]3  }|j                  D ]"  }||v rt        d      |j                  |       $ 5 t	        |      S )Nz'Coordinates of joints should be unique.)r   coordinates
ValueErrorrA   r   )r    q_indrC   
coordinates       r#   r   zJointsMethod._generate_q   s[    \\ 	)E#// )
&$%NOOZ()	)
 e}r%   c                     g }| j                   D ]3  }|j                  D ]"  }||v rt        d      |j                  |       $ 5 t	        |      S )Nz"Speeds of joints should be unique.)r   speedsrJ   rA   r   )r    u_indrC   speeds       r#   r   zJointsMethod._generate_u   sX    \\ 	$E $E>$%IJJU#$	$
 e}r%   c                     t        ddg       j                  }| j                  D ]  }|j                  |j                        } |S )N   r   )r   Tr   col_joinr3   )r    kd_indrC   s      r#   r   zJointsMethod._generate_kdes   s@    1b!##\\ 	1E__UZZ0F	1r%   c           	         g }| j                   D ]  }t        |t              s|j                  |       %|j                  rpt        |j                  |j                  |j                  |j                  |j                  |j                  f      }|j                  |_        |j                  |       t        |j                  |j                  |j                        }|j                  |_        |j                  |        |S r?   )r(   r   r   rA   is_rigidbodyr   name
masscenterr   masscentral_inertiapotential_energyr   )r    bodylistrG   rbparts        r#   _convert_bodieszJointsMethod._convert_bodies   s    KK 	&DdD)%  tyy$//4::tyy))4??;=&*&;&;##		4??DIIF(,(=(=%%	& r%   c                    | j                         }t        |t              rFt        | j                  g| } ||| j
                  | j                  || j                        | _        nE || j                  | j
                  | j                  | j                  | j                  |      | _        | j                  j                         }|S )a  Method to form system's equation of motions.

        Parameters
        ==========

        method : Class
            Class name of method.

        Returns
        ========

        Matrix
            Vector of equations of motions.

        Examples
        ========

        As Body and JointsMethod have been deprecated, the following examples
        are for illustrative purposes only. The functionality of Body is fully
        captured by :class:`~.RigidBody` and :class:`~.Particle` and the
        functionality of JointsMethod is fully captured by :class:`~.System`. To
        ignore the deprecation warning we can use the ignore_warnings context
        manager.

        >>> from sympy.utilities.exceptions import ignore_warnings

        This is a simple example for a one degree of freedom translational
        spring-mass-damper.

        >>> from sympy import S, symbols
        >>> from sympy.physics.mechanics import LagrangesMethod, dynamicsymbols, Body
        >>> from sympy.physics.mechanics import PrismaticJoint, JointsMethod
        >>> q = dynamicsymbols('q')
        >>> qd = dynamicsymbols('q', 1)
        >>> m, k, b = symbols('m k b')
        >>> with ignore_warnings(DeprecationWarning):
        ...     wall = Body('W')
        ...     part = Body('P', mass=m)
        >>> part.potential_energy = k * q**2 / S(2)
        >>> J = PrismaticJoint('J', wall, part, coordinates=q, speeds=qd)
        >>> wall.apply_force(b * qd * wall.x, reaction_body=part)
        >>> with ignore_warnings(DeprecationWarning):
        ...     method = JointsMethod(wall, J)
        >>> method.form_eoms(LagrangesMethod)
        Matrix([[b*Derivative(q(t), t) + k*q(t) + m*Derivative(q(t), (t, 2))]])

        We can also solve for the states using the 'rhs' method.

        >>> method.rhs()
        Matrix([
        [                Derivative(q(t), t)],
        [(-b*Derivative(q(t), t) - k*q(t))/m]])

        )rK   rO   kd_eqs	forcelistr(   )r`   
issubclassr   r   r   r.   r+   r   r1   r3   r5   
_form_eoms)r    r5   r]   Lsolns        r#   	form_eomszJointsMethod.form_eoms   s    p '')fo.4::11A!!TVVTZZ4::NDL!$**DFF$&&QUQZQZ.2jjKDL{{%%'r%   Nc                 :    | j                   j                  |      S )az  Returns equations that can be solved numerically.

        Parameters
        ==========

        inv_method : str
            The specific sympy inverse matrix calculation method to use. For a
            list of valid methods, see
            :meth:`~sympy.matrices.matrixbase.MatrixBase.inv`

        Returns
        ========

        Matrix
            Numerically solvable equations.

        See Also
        ========

        sympy.physics.mechanics.kane.KanesMethod.rhs:
            KanesMethod's rhs function.
        sympy.physics.mechanics.lagrange.LagrangesMethod.rhs:
            LagrangesMethod's rhs function.

        )
inv_method)r5   rhs)r    rj   s     r#   rk   zJointsMethod.rhs#  s    6 {{*55r%   r?   )__name__
__module____qualname____doc__r$   propertyr(   r+   r.   r1   r3   r6   r8   r:   r<   r5   r   r   r   r   r   r`   r   rh   rk    r%   r#   r   r      s   Pd.           ( ( , , ' ' # #  $  + @D6r%   N)sympy.physics.mechanicsr   r   r   r   r   r   !sympy.physics.mechanics.body_baser	   sympy.physics.mechanics.methodr
   sympyr   sympy.utilities.exceptionsr   __all__r   rq   r%   r#   <module>rx      s1   9 9 6 3  @
s68 s6r%   