ó
”¼\c           @  sÄ   d  Z  d d l m Z m Z d g Z d d l m Z m Z m Z m	 Z	 m
 Z
 m Z m Z m Z m Z m Z d d l m Z d d l m Z m Z m Z e j e e  Z d e f d     YZ d S(	   sb   
This module has all the classes and functions related to waves in optics.

**Contains**

* TWave
i’’’’(   t   print_functiont   divisiont   TWave(
   t   sympifyt   pit   sint   cost   sqrtt   Symbolt   St   symbolst
   Derivativet   atan2(   t   Expr(   t   speed_of_lightt   metert   secondc           B  są   e  Z d  Z d e j d e d  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 e Z d   Z d   Z d   Z d   Z d   Z RS(   s
  
    This is a simple transverse sine wave travelling in a one-dimensional space.
    Basic properties are required at the time of creation of the object,
    but they can be changed later with respective methods provided.

    It is represented as :math:`A \times cos(k*x - \omega \times t + \phi )`,
    where :math:`A` is the amplitude, :math:`\omega` is the angular velocity,
    :math:`k` is the wavenumber (spatial frequency), :math:`x` is a spatial variable
    to represent the position on the dimension on which the wave propagates,
    and :math:`\phi` is the phase angle of the wave.


    Arguments
    =========

    amplitude : Sympifyable
        Amplitude of the wave.
    frequency : Sympifyable
        Frequency of the wave.
    phase : Sympifyable
        Phase angle of the wave.
    time_period : Sympifyable
        Time period of the wave.
    n : Sympifyable
        Refractive index of the medium.

    Raises
    =======

    ValueError : When neither frequency nor time period is provided
        or they are not consistent.
    TypeError : When anything other than TWave objects is added.


    Examples
    ========

    >>> from sympy import symbols
    >>> from sympy.physics.optics import TWave
    >>> A1, phi1, A2, phi2, f = symbols('A1, phi1, A2, phi2, f')
    >>> w1 = TWave(A1, f, phi1)
    >>> w2 = TWave(A2, f, phi2)
    >>> w3 = w1 + w2  # Superposition of two waves
    >>> w3
    TWave(sqrt(A1**2 + 2*A1*A2*cos(phi1 - phi2) + A2**2), f,
        atan2(A1*cos(phi1) + A2*cos(phi2), A1*sin(phi1) + A2*sin(phi2)))
    >>> w3.amplitude
    sqrt(A1**2 + 2*A1*A2*cos(phi1 - phi2) + A2**2)
    >>> w3.phase
    atan2(A1*cos(phi1) + A2*cos(phi2), A1*sin(phi1) + A2*sin(phi2))
    >>> w3.speed
    299792458*meter/(second*n)
    >>> w3.angular_velocity
    2*pi*f

    t   nc         C  s   t  |  } t  |  } t  |  } t  |  } t  |  } | |  _ | |  _ | |  _ | |  _ | |  _ | d  k	 r d |  j |  _ n  | d  k	 rÕ d |  j |  _ | d  k	 rÕ | d | k rŅ t d   qŅ qÕ n  | d  k rü | d  k rü t d   n  d  S(   Ni   s/   frequency and time_period should be consistent.s*   Either frequency or time period is needed.(   R   t
   _frequencyt
   _amplitudet   _phaset   _time_periodt   _nt   Nonet
   ValueError(   t   selft	   amplitudet	   frequencyt   phaset   time_periodR   (    (    s9   lib/python2.7/site-packages/sympy/physics/optics/waves.pyt   __init__Q   s&    					c         C  s   |  j  S(   s?  
        Returns the frequency of the wave,
        in cycles per second.

        Examples
        ========

        >>> from sympy import symbols
        >>> from sympy.physics.optics import TWave
        >>> A, phi, f = symbols('A, phi, f')
        >>> w = TWave(A, f, phi)
        >>> w.frequency
        f
        (   R   (   R   (    (    s9   lib/python2.7/site-packages/sympy/physics/optics/waves.pyR   l   s    c         C  s   |  j  S(   sI  
        Returns the temporal period of the wave,
        in seconds per cycle.

        Examples
        ========

        >>> from sympy import symbols
        >>> from sympy.physics.optics import TWave
        >>> A, phi, f = symbols('A, phi, f')
        >>> w = TWave(A, f, phi)
        >>> w.time_period
        1/f
        (   R   (   R   (    (    s9   lib/python2.7/site-packages/sympy/physics/optics/waves.pyR   ~   s    c         C  s   t  |  j |  j S(   s  
        Returns the wavelength (spatial period) of the wave,
        in meters per cycle.
        It depends on the medium of the wave.

        Examples
        ========

        >>> from sympy import symbols
        >>> from sympy.physics.optics import TWave
        >>> A, phi, f = symbols('A, phi, f')
        >>> w = TWave(A, f, phi)
        >>> w.wavelength
        299792458*meter/(second*f*n)
        (   t   cR   R   (   R   (    (    s9   lib/python2.7/site-packages/sympy/physics/optics/waves.pyt
   wavelength   s    c         C  s   |  j  S(   s!  
        Returns the amplitude of the wave.

        Examples
        ========

        >>> from sympy import symbols
        >>> from sympy.physics.optics import TWave
        >>> A, phi, f = symbols('A, phi, f')
        >>> w = TWave(A, f, phi)
        >>> w.amplitude
        A
        (   R   (   R   (    (    s9   lib/python2.7/site-packages/sympy/physics/optics/waves.pyR   £   s    c         C  s   |  j  S(   s5  
        Returns the phase angle of the wave,
        in radians.

        Examples
        ========

        >>> from sympy import symbols
        >>> from sympy.physics.optics import TWave
        >>> A, phi, f = symbols('A, phi, f')
        >>> w = TWave(A, f, phi)
        >>> w.phase
        phi
        (   R   (   R   (    (    s9   lib/python2.7/site-packages/sympy/physics/optics/waves.pyR   “   s    c         C  s   |  j  |  j S(   s  
        Returns the propagation speed of the wave,
        in meters per second.
        It is dependent on the propagation medium.

        Examples
        ========

        >>> from sympy import symbols
        >>> from sympy.physics.optics import TWave
        >>> A, phi, f = symbols('A, phi, f')
        >>> w = TWave(A, f, phi)
        >>> w.speed
        299792458*meter/(second*n)
        (   R    R   (   R   (    (    s9   lib/python2.7/site-packages/sympy/physics/optics/waves.pyt   speedĘ   s    c         C  s   d t  |  j S(   sS  
        Returns the angular velocity of the wave,
        in radians per second.

        Examples
        ========

        >>> from sympy import symbols
        >>> from sympy.physics.optics import TWave
        >>> A, phi, f = symbols('A, phi, f')
        >>> w = TWave(A, f, phi)
        >>> w.angular_velocity
        2*pi*f
        i   (   R   R   (   R   (    (    s9   lib/python2.7/site-packages/sympy/physics/optics/waves.pyt   angular_velocityŁ   s    c         C  s   d t  |  j S(   s_  
        Returns the wavenumber of the wave,
        in radians per meter.

        Examples
        ========

        >>> from sympy import symbols
        >>> from sympy.physics.optics import TWave
        >>> A, phi, f = symbols('A, phi, f')
        >>> w = TWave(A, f, phi)
        >>> w.wavenumber
        pi*second*f*n/(149896229*meter)
        i   (   R   R    (   R   (    (    s9   lib/python2.7/site-packages/sympy/physics/optics/waves.pyt
   wavenumberė   s    c         C  s*   d d l  m } t |   j | |  j  S(   s!   String representation of a TWave.i’’’’(   t   sstr(   t   sympy.printingR$   t   typet   __name__t   args(   R   R$   (    (    s9   lib/python2.7/site-packages/sympy/physics/optics/waves.pyt   __str__ż   s    c      	   C  s  t  | t  rä |  j | j k rÕ |  j | j k rÕ t t |  j d | j d d |  j | j t |  j | j	   |  j
 t |  j t |  j  | j t | j  |  j t |  j  | j t | j    St d   n t t |  j d   d S(   s   
        Addition of two waves will result in their superposition.
        The type of interference will depend on their phase angles.
        i   sJ   Interference of waves with different frequencies has not been implemented.s"    and TWave objects can't be added.N(   t
   isinstanceR   R   R    R   R   R   R   R   R   R   R   R   t   NotImplementedErrort	   TypeErrorR&   R'   (   R   t   other(    (    s9   lib/python2.7/site-packages/sympy/physics/optics/waves.pyt   __add__  s    $c         O  sD   |  j  t |  j t d  |  j t d  |  j t d d t S(   Nt   xt   ti   t   evaluate(   R   R   R#   R   R"   R   R   t   False(   R   R(   t   kwargs(    (    s9   lib/python2.7/site-packages/sympy/physics/optics/waves.pyt   _eval_rewrite_as_sin  s    	c         O  s6   |  j  t |  j t d  |  j t d  |  j  S(   NR/   R0   (   R   R   R#   R   R"   R   (   R   R(   R3   (    (    s9   lib/python2.7/site-packages/sympy/physics/optics/waves.pyt   _eval_rewrite_as_cos  s    	c   	      O  sn   d d l  m } t d  \ } } } } | d  } t | | |  | d  | | t | | |  | d  S(   Ni’’’’(   t   Functions   mu, epsilon, x, tt   Ei   (   t   sympyR6   R
   R   (	   R   R(   R3   R6   t   mut   epsilonR/   R0   R7   (    (    s9   lib/python2.7/site-packages/sympy/physics/optics/waves.pyt   _eval_rewrite_as_pde"  s    c         O  sP   d d l  m } m } |  j | | |  j t d  |  j t d  |  j  S(   Ni’’’’(   t   expt   IR/   R0   (   R8   R<   R=   R   R#   R   R"   R   (   R   R(   R3   R<   R=   (    (    s9   lib/python2.7/site-packages/sympy/physics/optics/waves.pyt   _eval_rewrite_as_exp(  s    N(   R'   t
   __module__t   __doc__R   R	   t   ZeroR   R   t   propertyR   R   R    R   R   R!   R"   R#   R)   t   __repr__R.   R4   R5   R;   R>   (    (    (    s9   lib/python2.7/site-packages/sympy/physics/optics/waves.pyR      s(   9					N(   R@   t
   __future__R    R   t   __all__R8   R   R   R   R   R   R   R	   R
   R   R   t   sympy.core.exprR   t   sympy.physics.unitsR   R   R   t
   convert_toR   R   (    (    (    s9   lib/python2.7/site-packages/sympy/physics/optics/waves.pyt   <module>   s   	F