K i:'dZdgZddlmZddlmZddlmZmZddl m Z m Z m Z ddl mZddlmZmZdd lmZmZdd lmZdd lmZdd lmZmZmZdd lmZmZm Z ejBee z Z"GddeZ#y)zb This module has all the classes and functions related to waves in optics. **Contains** * TWave TWave)Basic)Expr) DerivativeFunction)NumberpiI)S)Symbolsymbols)_sympifysympify)exp)sqrt)atan2cossin)speed_of_lightmetersecondceZdZdZdej dedfdZedZ edZ edZ edZ ed Z ed Zed Zed Zed ZdZeZdZdZdZdZdZdZdZdZdZdZdZy)ra4 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. Explanation =========== 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 frequency, :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*sin(phi1) + A2*sin(phi2), A1*cos(phi1) + A2*cos(phi2)), 1/f, n) >>> w3.amplitude sqrt(A1**2 + 2*A1*A2*cos(phi1 - phi2) + A2**2) >>> w3.phase atan2(A1*sin(phi1) + A2*sin(phi2), A1*cos(phi1) + A2*cos(phi2)) >>> w3.speed 299792458*meter/(second*n) >>> w3.angular_velocity 2*pi*f Nncp|t|}tj|z }|At|}tj|z }|!|tj|z k7r td| | td|}|}t|}t|}t |}t j ||||||}|S)Nz/frequency and time_period should be consistent.z*Either frequency or time period is needed.)rr One ValueErrorrr__new__) cls amplitude frequencyphase time_periodr _frequency _time_periodobjs `/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/physics/optics/waves.pyrz TWave.__new__Ys  "";/K{*J   +I55?L&k 11$%VWW  !4IJ J  "I  &KY'  AJmmCIuk1M c |jdS)a! 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 rargsselfs r&rzTWave.amplitudevsyy|r'c |jdS)a? 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+s r&r zTWave.frequency yy|r'c |jdS)a5 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+s r&r!z TWave.phaser/r'c |jdS)aI 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+s r&r"zTWave.time_periodr/r'c |jdS)z< Returns the refractive index of the medium r)r+s r&rzTWave.ns yy|r'cBt|j|jzz S)a 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) )cr rr+s r& wavelengthzTWave.wavelengths"$..'((r'c4|j|jzS)a 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) )r8r r+s r&speedz TWave.speeds"t~~--r'c.dtz|jzS)aS 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 r1)r r r+s r&angular_velocityzTWave.angular_velocitys tDNN""r'c.dtz|jz S)a_ 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) r1)r r8r+s r& wavenumberzTWave.wavenumbers tDOO##r'c^ddlm}t|j||jzS)z!String representation of a TWave.r)sstr)sympy.printingr@type__name__r*)r,r@s r&__str__z TWave.__str__s"'Dz""T$))_44r'c t|trL|j|jk(r'|j|jk(r tt |j dz|j dzzd|j z|j zt |j|jz zz|jt|j t|jz|j t|jzz|j t |jz|j t |jzzStdtt|jdz)z Addition of two waves will result in their superposition. The type of interference will depend on their phase angles. r1zJInterference of waves with different frequencies has not been implemented.z# and TWave objects cannot be added.) isinstancerr r8rrrr!rrNotImplementedError TypeErrorrBrCr,others r&__add__z TWave.__add__sA eU #~~0T__HXHX5XT$..!"3eooq6H"H1"&..L116LAAD&*jj5;;&>B@L@#@A"^^"4>>#djj/#A$s5;;/??$@!^^C O;$s5;;/??@A *+122DK003XXY Yr'ct|}t|tr&t|j|zg|j ddSt t|jdz)zT Multiplying a wave by a scalar rescales the amplitude of the wave. r.Nz( and TWave objects cannot be multiplied.) rrFrrrr*rHrBrCrIs r&__mul__z TWave.__mul__,sU eV $-> !" > >DK003]]^ ^r'c*|jd|zSNrKrIs r&__sub__z TWave.__sub__6s||BuH%%r'c$|jdSrOrMr+s r&__neg__z TWave.__neg__9s||Br'c$|j|SNrQrIs r&__radd__zTWave.__radd__<||E""r'c$|j|SrWrTrIs r&__rmul__zTWave.__rmul__?rYr'c&| j|SrW)rXrIs r&__rsub__zTWave.__rsub__Bs&&r'c|jt|jtdz|jtdzz |j zt dz zdzS)Nxtr1F)evaluate)rrr>r r<r!r r,r*kwargss r&_eval_rewrite_as_sinzTWave._eval_rewrite_as_sinEs_~~c$//&+"=##F3K/#026**#=?A!t#DNSUU Ur'c|jt|jtdz|jtdzz |j zzSNr_r`)rrr>r r<r!rbs r&_eval_rewrite_as_coszTWave._eval_rewrite_as_cosIsL~~c$//&+"=##F3K/#026**#=>> >r'ctd\}}}}td}t||||d||zt||||dzzS)Nzmu, epsilon, x, tEr1)r rr)r,r*rcmuepsilonr_r`ris r&_eval_rewrite_as_pdezTWave._eval_rewrite_as_pdeMsQ#$78GQ SM!Aq'1a(2g:j1a!Q6O+OOOr'c |jtt|jt dz|j t dzz |j zzzSrf)rrr r>r r<r!rbs r&_eval_rewrite_as_expzTWave._eval_rewrite_as_expRsS~~c!T__VC[%@##F3K/&026**&=#>?? ?r')rC __module__ __qualname____doc__r Zeror rpropertyrr r!r"rr8r:r<r>rD__repr__rKrMrRrUrXr[r]rdrgrlrnr'r&rrs:~&&Sk : """ ))&..$##"$$"5 HZ,_& ##'U>P ?r'N)$rq__all__sympy.core.basicrsympy.core.exprrsympy.core.functionrrsympy.core.numbersrr r sympy.core.singletonr sympy.core.symbolr r sympy.core.sympifyrr&sympy.functions.elementary.exponentialr(sympy.functions.elementary.miscellaneousr(sympy.functions.elementary.trigonometricrrrsympy.physics.unitsrrr convert_tor7rrur'r&rsc )" 4.."/069FF==NeFl+y?Dy?r'