
    g(                     x    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dS )	    )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dS )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|| _        || _        |                                 | _        |                                 | _        | 	                                | _
        |                                 | _        |                                 | _        d | _        d S )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      `/var/www/html/ai-engine/env/lib/python3.11/site-packages/sympy/physics/mechanics/jointsmethod.py__init__zJointsMethod.__init__^   s    ! &,'J	
 	
 	
 	
 i** 	#"DJJ"DJ..0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        w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     z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 ]H}|j        |vr|                    |j                   |j        |vr|                    |j                   I|S N)r   childappendparent)r    r(   joints      r#   r   zJointsMethod._generate_bodylist   s`    \ 	, 	,E{&((ek***|6))el+++r%   c                 |    g }| j         D ]1}t          |t                    r|                    |j                   2|S r?   )r(   r   r   extendr+   )r    	load_listbodys      r#   r   zJointsMethod._generate_loadlist   sG    	K 	- 	-D$%% -  ,,,r%   c                     g }| j         D ]4}|j        D ]*}||v rt          d          |                    |           +5t	          |          S )Nz'Coordinates of joints should be unique.)r   coordinates
ValueErrorrA   r   )r    q_indrC   
coordinates       r#   r   zJointsMethod._generate_q   sl    \ 	) 	)E#/ ) )
&&$%NOOOZ(((() e}}r%   c                     g }| j         D ]4}|j        D ]*}||v rt          d          |                    |           +5t	          |          S )Nz"Speeds of joints should be unique.)r   speedsrJ   rA   r   )r    u_indrC   speeds       r#   r   zJointsMethod._generate_u   si    \ 	$ 	$E $ $E>>$%IJJJU####$ e}}r%   c                 z    t          ddg           j        }| j        D ]}|                    |j                  }|S )N   r   )r   Tr   col_joinr3   )r    kd_indrC   s      r#   r   zJointsMethod._generate_kdes   sA    1b!!#\ 	1 	1E__UZ00FFr%   c           	         g }| j         D ]}t          |t                    s|                    |           -|j        rUt          |j        |j        |j        |j	        |j
        |j        f          }|j        |_        |                    |           t          |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    K 	& 	&DdD)) %%%  &ty$/4:ty)4?;= =&*&;#####	4?DIFF(,(=%%%%%r%   c                 T   |                                  }t          |t                    r6t          | j        g|R  } ||| j        | j        || j                  | _        n/ || 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.. 	K4:1111A!6!TVTZ4:NNDLL!6$*DF$&QUQZ.2jK K KDL{%%''r%   Nc                 8    | 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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 Pd  .   X   X   X   X   X ( ( X( , , X, ' ' X' # # X#   X            $  + @ @ @ @D6 6 6 6 6 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      s   9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 6 6 6 6 6 6 3 3 3 3 3 3       @ @ @ @ @ @
s6 s6 s6 s6 s68 s6 s6 s6 s6 s6r%   