U
    9%e                     @   s<   d dl mZ d dlmZ d dlmZ dgZG dd dZdS )    )sympify)Point)sympy_deprecation_warningParticlec                   @   s   e Zd ZdZdd Zdd Zdd Zedd	 Zej	d
d	 Zedd Z
e
j	dd Z
dd Zdd Zdd Zedd Zej	dd Zdd Zdd ZdS )r   a  A particle.

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

    Particles have a non-zero mass and lack spatial extension; they take up no
    space.

    Values need to be supplied on initialization, but can be changed later.

    Parameters
    ==========

    name : str
        Name of particle
    point : Point
        A physics/mechanics Point which represents the position, velocity, and
        acceleration of this Particle
    mass : sympifyable
        A SymPy expression representing the Particle's mass

    Examples
    ========

    >>> from sympy.physics.mechanics import Particle, Point
    >>> from sympy import Symbol
    >>> po = Point('po')
    >>> m = Symbol('m')
    >>> pa = Particle('pa', po, m)
    >>> # Or you could change these later
    >>> pa.mass = m
    >>> pa.point = po

    c                 C   s.   t |tstd|| _|| _|| _d| _d S )NzSupply a valid name.r   )
isinstancestr	TypeError_namemasspointpotential_energy)selfnamer   r
    r   _/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/sympy/physics/mechanics/particle.py__init__-   s    
zParticle.__init__c                 C   s   | j S N)r	   r   r   r   r   __str__5   s    zParticle.__str__c                 C   s   |   S r   )r   r   r   r   r   __repr__8   s    zParticle.__repr__c                 C   s   | j S )zMass of the particle.)_massr   r   r   r   r
   ;   s    zParticle.massc                 C   s   t || _d S r   )r   r   )r   valuer   r   r   r
   @   s    c                 C   s   | j S )zPoint of the particle.)_pointr   r   r   r   r   D   s    zParticle.pointc                 C   s   t |tstd|| _d S )Nz0Particle point attribute must be a Point object.)r   r   r   r   )r   pr   r   r   r   I   s    
c                 C   s   | j | j| S )a  Linear momentum of the particle.

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

        The linear momentum L, of a particle P, with respect to frame N is
        given by:

        L = m * v

        where m is the mass of the particle, and v is the velocity of the
        particle in the frame N.

        Parameters
        ==========

        frame : ReferenceFrame
            The frame in which linear momentum is desired.

        Examples
        ========

        >>> from sympy.physics.mechanics import Particle, Point, ReferenceFrame
        >>> from sympy.physics.mechanics import dynamicsymbols
        >>> from sympy.physics.vector import init_vprinting
        >>> init_vprinting(pretty_print=False)
        >>> m, v = dynamicsymbols('m v')
        >>> N = ReferenceFrame('N')
        >>> P = Point('P')
        >>> A = Particle('A', P, m)
        >>> P.set_vel(N, v * N.x)
        >>> A.linear_momentum(N)
        m*v*N.x

        )r
   r   velr   framer   r   r   linear_momentumO   s    %zParticle.linear_momentumc                 C   s   | j || j| j | A S )a  Angular momentum of the particle about the point.

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

        The angular momentum H, about some point O of a particle, P, is given
        by:

        ``H = cross(r, m * v)``

        where r is the position vector from point O to the particle P, m is
        the mass of the particle, and v is the velocity of the particle in
        the inertial frame, N.

        Parameters
        ==========

        point : Point
            The point about which angular momentum of the particle is desired.

        frame : ReferenceFrame
            The frame in which angular momentum is desired.

        Examples
        ========

        >>> from sympy.physics.mechanics import Particle, Point, ReferenceFrame
        >>> from sympy.physics.mechanics import dynamicsymbols
        >>> from sympy.physics.vector import init_vprinting
        >>> init_vprinting(pretty_print=False)
        >>> m, v, r = dynamicsymbols('m v r')
        >>> N = ReferenceFrame('N')
        >>> O = Point('O')
        >>> A = O.locatenew('A', r * N.x)
        >>> P = Particle('P', A, m)
        >>> P.point.set_vel(N, v * N.y)
        >>> P.angular_momentum(O, N)
        m*r*v*N.z

        )r   pos_fromr
   r   )r   r   r   r   r   r   angular_momentumv   s    *zParticle.angular_momentumc                 C   s&   | j td | j| | j|@ S )a  Kinetic energy of the particle.

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

        The kinetic energy, T, of a particle, P, is given by:

        ``T = 1/2 (dot(m * v, v))``

        where m is the mass of particle P, and v is the velocity of the
        particle in the supplied ReferenceFrame.

        Parameters
        ==========

        frame : ReferenceFrame
            The Particle's velocity is typically defined with respect to
            an inertial frame but any relevant frame in which the velocity is
            known can be supplied.

        Examples
        ========

        >>> from sympy.physics.mechanics import Particle, Point, ReferenceFrame
        >>> from sympy import symbols
        >>> m, v, r = symbols('m v r')
        >>> N = ReferenceFrame('N')
        >>> O = Point('O')
        >>> P = Particle('P', O, m)
        >>> P.point.set_vel(N, v * N.y)
        >>> P.kinetic_energy(N)
        m*v**2/2

           )r
   r   r   r   r   r   r   r   kinetic_energy   s    $
zParticle.kinetic_energyc                 C   s   | j S )aw  The potential energy of the Particle.

        Examples
        ========

        >>> from sympy.physics.mechanics import Particle, Point
        >>> from sympy import symbols
        >>> m, g, h = symbols('m g h')
        >>> O = Point('O')
        >>> P = Particle('P', O, m)
        >>> P.potential_energy = m * g * h
        >>> P.potential_energy
        g*h*m

        )_per   r   r   r   r      s    zParticle.potential_energyc                 C   s   t || _dS )a  Used to set the potential energy of the Particle.

        Parameters
        ==========

        scalar : Sympifyable
            The potential energy (a scalar) of the Particle.

        Examples
        ========

        >>> from sympy.physics.mechanics import Particle, Point
        >>> from sympy import symbols
        >>> m, g, h = symbols('m g h')
        >>> O = Point('O')
        >>> P = Particle('P', O, m)
        >>> P.potential_energy = m * g * h

        N)r   r"   r   Zscalarr   r   r   r      s    c                 C   s   t dddd || _d S )Nz
The sympy.physics.mechanics.Particle.set_potential_energy()
method is deprecated. Instead use

    P.potential_energy = scalar
            z1.5zdeprecated-set-potential-energy)Zdeprecated_since_versionZactive_deprecations_target)r   r   r#   r   r   r   set_potential_energy   s    
zParticle.set_potential_energyc                 C   s"   ddl m} || j| j||S )a  Returns an inertia dyadic of the particle with respect to another
        point and frame.

        Parameters
        ==========

        point : sympy.physics.vector.Point
            The point to express the inertia dyadic about.
        frame : sympy.physics.vector.ReferenceFrame
            The reference frame used to construct the dyadic.

        Returns
        =======

        inertia : sympy.physics.vector.Dyadic
            The inertia dyadic of the particle expressed about the provided
            point and frame.

        r   )inertia_of_point_mass)Zsympy.physics.mechanicsr%   r
   r   r   )r   r   r   r%   r   r   r   parallel_axis  s    zParticle.parallel_axisN)__name__
__module____qualname____doc__r   r   r   propertyr
   setterr   r   r   r!   r   r$   r&   r   r   r   r   r   	   s*   #



','

N)Zsympy.core.backendr   Zsympy.physics.vectorr   Zsympy.utilities.exceptionsr   __all__r   r   r   r   r   <module>   s   