
    \h!                         S SK Jr  S SKJr  S SKJr  S SKJrJr  S SK	J
r
  S SKJr  / SQrS rS	 rS
 rS rS rS rS rg)    )diff)S)	integrate)Vectorexpress)_check_frame)_check_vector)curl
divergencegradientis_conservativeis_solenoidalscalar_potentialscalar_potential_differencec                    [        U 5        U S:X  a  [        S5      $ [        XSS9n U R                  UR                  5      nU R                  UR
                  5      nU R                  UR                  5      n[        S5      nU[        XAS   5      [        X1S   5      -
  UR                  -  -  nU[        X!S   5      [        XAS   5      -
  UR
                  -  -  nU[        X1S   5      [        X!S   5      -
  UR                  -  -  nU$ )a   
Returns the curl of a vector field computed wrt the coordinate
symbols of the given frame.

Parameters
==========

vect : Vector
    The vector operand

frame : ReferenceFrame
    The reference frame to calculate the curl in

Examples
========

>>> from sympy.physics.vector import ReferenceFrame
>>> from sympy.physics.vector import curl
>>> R = ReferenceFrame('R')
>>> v1 = R[1]*R[2]*R.x + R[0]*R[2]*R.y + R[0]*R[1]*R.z
>>> curl(v1, R)
0
>>> v2 = R[0]*R[1]*R[2]*R.x
>>> curl(v2, R)
R_x*R_y*R.y - R_x*R_z*R.z

r   T	variables      )r	   r   r   dotxyzr   )vectframevectxvectyvectzoutvecs         [/var/www/auris/envauris/lib/python3.13/site-packages/sympy/physics/vector/fieldfunctions.pyr
   r
      s    : $qyay4$/DHHUWWEHHUWWEHHUWWEAYF
tE8$tE8'<<GGF
tE8$tE8'<<GGF
tE8$tE8'<<GGFM    c                    [        U 5        U S:X  a  [        R                  $ [        XSS9n U R	                  UR
                  5      nU R	                  UR                  5      nU R	                  UR                  5      n[        R                  nU[        X!S   5      -  nU[        X1S   5      -  nU[        XAS   5      -  nU$ )a  
Returns the divergence of a vector field computed wrt the coordinate
symbols of the given frame.

Parameters
==========

vect : Vector
    The vector operand

frame : ReferenceFrame
    The reference frame to calculate the divergence in

Examples
========

>>> from sympy.physics.vector import ReferenceFrame
>>> from sympy.physics.vector import divergence
>>> R = ReferenceFrame('R')
>>> v1 = R[0]*R[1]*R[2] * (R.x+R.y+R.z)
>>> divergence(v1, R)
R_x*R_y + R_x*R_z + R_y*R_z
>>> v2 = 2*R[1]*R[2]*R.y
>>> divergence(v2, R)
2*R_z

r   Tr   r   r   )	r	   r   Zeror   r   r   r   r   r   )r   r   r   r   r   outs         r    r   r   :   s    : $qyvv4$/DHHUWWEHHUWWEHHUWWE
&&C4Qx  C4Qx  C4Qx  CJr!   c                     [        U5        [        S5      n[        XSS9n [        U5       H  u  p4U[	        XU   5      U-  -  nM     U$ )a5  
Returns the vector gradient of a scalar field computed wrt the
coordinate symbols of the given frame.

Parameters
==========

scalar : sympifiable
    The scalar field to take the gradient of

frame : ReferenceFrame
    The frame to calculate the gradient in

Examples
========

>>> from sympy.physics.vector import ReferenceFrame
>>> from sympy.physics.vector import gradient
>>> R = ReferenceFrame('R')
>>> s1 = R[0]*R[1]*R[2]
>>> gradient(s1, R)
R_y*R_z*R.x + R_x*R_z*R.y + R_x*R_y*R.z
>>> s2 = 5*R[0]**2*R[2]
>>> gradient(s2, R)
10*R_x*R_z*R.x + 5*R_x**2*R.z

r   Tr   )r   r   r   	enumerater   )scalarr   r   ir   s        r    r   r   e   sO    : AYFVd3F% $vQx(1,, !Mr!   c                     U [        S5      :X  a  g[        U R                  5       5      S   n[        X5      R	                  5       [        S5      :H  $ )a  
Checks if a field is conservative.

Parameters
==========

field : Vector
    The field to check for conservative property

Examples
========

>>> from sympy.physics.vector import ReferenceFrame
>>> from sympy.physics.vector import is_conservative
>>> R = ReferenceFrame('R')
>>> is_conservative(R[1]*R[2]*R.x + R[0]*R[2]*R.y + R[0]*R[1]*R.z)
True
>>> is_conservative(R[2] * R.y)
False

r   T)r   listseparater
   simplifyfieldr   s     r    r   r      sF    2 q	!"1%E&&(F1I55r!   c                     U [        S5      :X  a  g[        U R                  5       5      S   n[        X5      R	                  5       [
        R                  L $ )az  
Checks if a field is solenoidal.

Parameters
==========

field : Vector
    The field to check for solenoidal property

Examples
========

>>> from sympy.physics.vector import ReferenceFrame
>>> from sympy.physics.vector import is_solenoidal
>>> R = ReferenceFrame('R')
>>> is_solenoidal(R[1]*R[2]*R.x + R[0]*R[2]*R.y + R[0]*R[1]*R.z)
True
>>> is_solenoidal(R[1] * R.y)
False

r   T)r   r*   r+   r   r,   r   r#   r-   s     r    r   r      sF    2 q	!"1%Ee#,,.!&&88r!   c                    [        U 5      (       d  [        S5      eU [        S5      :X  a  [        R                  $ [        U5        [        XSS9n [        U5      n[        U R                  US   5      US   5      n[        USS 5       H>  u  pE[        X1US-      5      nU R                  U5      U-
  nU[        XaUS-      5      -  nM@     U$ )av  
Returns the scalar potential function of a field in a given frame
(without the added integration constant).

Parameters
==========

field : Vector
    The vector field whose scalar potential function is to be
    calculated

frame : ReferenceFrame
    The frame to do the calculation in

Examples
========

>>> from sympy.physics.vector import ReferenceFrame
>>> from sympy.physics.vector import scalar_potential, gradient
>>> R = ReferenceFrame('R')
>>> scalar_potential(R.z, R) == R[2]
True
>>> scalar_field = 2*R[0]**2*R[1]*R[2]
>>> grad_field = gradient(scalar_field, R)
>>> scalar_potential(grad_field, R)
2*R_x**2*R_y*R_z

zField is not conservativer   Tr   r   N)r   
ValueErrorr   r   r#   r   r   r*   r   r   r&   r   )r.   r   
dimensionstemp_functionr(   dimpartial_diffs          r    r   r      s    > 5!!455q	vv ED1EeJeii
16aAMJqrN+MQ<8yy~4<q1u>> , r!   c                    [        U5        [        U [        5      (       a  [        X5      nOU n[	        UR                  U5      USS9n[	        UR                  U5      USS9n0 n0 n	[        U5       H1  u  pUR                  U5      XU
   '   UR                  U5      XU
   '   M3     UR                  U	5      UR                  U5      -
  $ )a  
Returns the scalar potential difference between two points in a
certain frame, wrt a given field.

If a scalar field is provided, its values at the two points are
considered. If a conservative vector field is provided, the values
of its scalar potential function at the two points are used.

Returns (potential at position 2) - (potential at position 1)

Parameters
==========

field : Vector/sympyfiable
    The field to calculate wrt

frame : ReferenceFrame
    The frame to do the calculations in

point1 : Point
    The initial Point in given frame

position2 : Point
    The second Point in the given frame

origin : Point
    The Point to use as reference point for position vector
    calculation

Examples
========

>>> from sympy.physics.vector import ReferenceFrame, Point
>>> from sympy.physics.vector import scalar_potential_difference
>>> R = ReferenceFrame('R')
>>> O = Point('O')
>>> P = O.locatenew('P', R[0]*R.x + R[1]*R.y + R[2]*R.z)
>>> vectfield = 4*R[0]*R[1]*R.x + 2*R[0]**2*R.y
>>> scalar_potential_difference(vectfield, R, O, P, O)
2*R_x**2*R_y
>>> Q = O.locatenew('O', 3*R.x + R.y + 2*R.z)
>>> scalar_potential_difference(vectfield, R, P, Q, O)
-2*R_x**2*R_y + 18

Tr   )	r   
isinstancer   r   r   pos_fromr&   r   subs)r.   r   point1point2origin	scalar_fn	position1	position2
subs_dict1
subs_dict2r(   r   s               r    r   r      s    ^ %  $U2	 	/$GI/$GIJJ%  uuY/
8 uuY/
8 ! >>*%	z(BBBr!   N)sympy.core.functionr   sympy.core.singletonr   sympy.integrals.integralsr   sympy.physics.vectorr   r   sympy.physics.vector.framer   sympy.physics.vector.vectorr	   __all__r
   r   r   r   r   r   r    r!   r    <module>rJ      sF    $ " / 0 3 5*
)X(V"J6>9>/d?Cr!   