Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- ckpts/universal/global_step80/zero/12.post_attention_layernorm.weight/exp_avg_sq.pt +3 -0
- ckpts/universal/global_step80/zero/12.post_attention_layernorm.weight/fp32.pt +3 -0
- venv/lib/python3.10/site-packages/sympy/physics/optics/__init__.py +38 -0
- venv/lib/python3.10/site-packages/sympy/physics/optics/gaussopt.py +923 -0
- venv/lib/python3.10/site-packages/sympy/physics/optics/medium.py +253 -0
- venv/lib/python3.10/site-packages/sympy/physics/optics/polarization.py +732 -0
- venv/lib/python3.10/site-packages/sympy/physics/optics/tests/__init__.py +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/optics/tests/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/optics/tests/__pycache__/test_gaussopt.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/optics/tests/__pycache__/test_medium.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/optics/tests/__pycache__/test_polarization.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/optics/tests/test_gaussopt.py +102 -0
- venv/lib/python3.10/site-packages/sympy/physics/optics/tests/test_medium.py +48 -0
- venv/lib/python3.10/site-packages/sympy/physics/optics/tests/test_polarization.py +57 -0
- venv/lib/python3.10/site-packages/sympy/physics/optics/tests/test_utils.py +202 -0
- venv/lib/python3.10/site-packages/sympy/physics/optics/tests/test_waves.py +82 -0
- venv/lib/python3.10/site-packages/sympy/physics/optics/utils.py +698 -0
- venv/lib/python3.10/site-packages/sympy/physics/optics/waves.py +340 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_boson.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_cartesian.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_circuitplot.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_constants.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_density.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_fermion.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_grover.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_hilbert.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_identitysearch.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_innerproduct.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_matrixutils.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_operator.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_operatorordering.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_operatorset.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_piab.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_qapply.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_qasm.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_qexpr.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_qubit.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_represent.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_sho1d.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_shor.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_spin.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_state.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_trace.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/vector/__init__.py +36 -0
- venv/lib/python3.10/site-packages/sympy/physics/vector/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/vector/__pycache__/dyadic.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/vector/__pycache__/fieldfunctions.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/vector/__pycache__/frame.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/vector/__pycache__/functions.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/sympy/physics/vector/__pycache__/point.cpython-310.pyc +0 -0
ckpts/universal/global_step80/zero/12.post_attention_layernorm.weight/exp_avg_sq.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5249306b6c88a8b0f7e183856e76e85d5314fad1a0ea18a293c4b77df960ec67
|
3 |
+
size 9387
|
ckpts/universal/global_step80/zero/12.post_attention_layernorm.weight/fp32.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:888bb28c5de66a00fdc5566bb8fdd0815a3efd1a22060ccfeb266189d7298f2a
|
3 |
+
size 9293
|
venv/lib/python3.10/site-packages/sympy/physics/optics/__init__.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
__all__ = [
|
2 |
+
'TWave',
|
3 |
+
|
4 |
+
'RayTransferMatrix', 'FreeSpace', 'FlatRefraction', 'CurvedRefraction',
|
5 |
+
'FlatMirror', 'CurvedMirror', 'ThinLens', 'GeometricRay', 'BeamParameter',
|
6 |
+
'waist2rayleigh', 'rayleigh2waist', 'geometric_conj_ab',
|
7 |
+
'geometric_conj_af', 'geometric_conj_bf', 'gaussian_conj',
|
8 |
+
'conjugate_gauss_beams',
|
9 |
+
|
10 |
+
'Medium',
|
11 |
+
|
12 |
+
'refraction_angle', 'deviation', 'fresnel_coefficients', 'brewster_angle',
|
13 |
+
'critical_angle', 'lens_makers_formula', 'mirror_formula', 'lens_formula',
|
14 |
+
'hyperfocal_distance', 'transverse_magnification',
|
15 |
+
|
16 |
+
'jones_vector', 'stokes_vector', 'jones_2_stokes', 'linear_polarizer',
|
17 |
+
'phase_retarder', 'half_wave_retarder', 'quarter_wave_retarder',
|
18 |
+
'transmissive_filter', 'reflective_filter', 'mueller_matrix',
|
19 |
+
'polarizing_beam_splitter',
|
20 |
+
]
|
21 |
+
from .waves import TWave
|
22 |
+
|
23 |
+
from .gaussopt import (RayTransferMatrix, FreeSpace, FlatRefraction,
|
24 |
+
CurvedRefraction, FlatMirror, CurvedMirror, ThinLens, GeometricRay,
|
25 |
+
BeamParameter, waist2rayleigh, rayleigh2waist, geometric_conj_ab,
|
26 |
+
geometric_conj_af, geometric_conj_bf, gaussian_conj,
|
27 |
+
conjugate_gauss_beams)
|
28 |
+
|
29 |
+
from .medium import Medium
|
30 |
+
|
31 |
+
from .utils import (refraction_angle, deviation, fresnel_coefficients,
|
32 |
+
brewster_angle, critical_angle, lens_makers_formula, mirror_formula,
|
33 |
+
lens_formula, hyperfocal_distance, transverse_magnification)
|
34 |
+
|
35 |
+
from .polarization import (jones_vector, stokes_vector, jones_2_stokes,
|
36 |
+
linear_polarizer, phase_retarder, half_wave_retarder,
|
37 |
+
quarter_wave_retarder, transmissive_filter, reflective_filter,
|
38 |
+
mueller_matrix, polarizing_beam_splitter)
|
venv/lib/python3.10/site-packages/sympy/physics/optics/gaussopt.py
ADDED
@@ -0,0 +1,923 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Gaussian optics.
|
3 |
+
|
4 |
+
The module implements:
|
5 |
+
|
6 |
+
- Ray transfer matrices for geometrical and gaussian optics.
|
7 |
+
|
8 |
+
See RayTransferMatrix, GeometricRay and BeamParameter
|
9 |
+
|
10 |
+
- Conjugation relations for geometrical and gaussian optics.
|
11 |
+
|
12 |
+
See geometric_conj*, gauss_conj and conjugate_gauss_beams
|
13 |
+
|
14 |
+
The conventions for the distances are as follows:
|
15 |
+
|
16 |
+
focal distance
|
17 |
+
positive for convergent lenses
|
18 |
+
object distance
|
19 |
+
positive for real objects
|
20 |
+
image distance
|
21 |
+
positive for real images
|
22 |
+
"""
|
23 |
+
|
24 |
+
__all__ = [
|
25 |
+
'RayTransferMatrix',
|
26 |
+
'FreeSpace',
|
27 |
+
'FlatRefraction',
|
28 |
+
'CurvedRefraction',
|
29 |
+
'FlatMirror',
|
30 |
+
'CurvedMirror',
|
31 |
+
'ThinLens',
|
32 |
+
'GeometricRay',
|
33 |
+
'BeamParameter',
|
34 |
+
'waist2rayleigh',
|
35 |
+
'rayleigh2waist',
|
36 |
+
'geometric_conj_ab',
|
37 |
+
'geometric_conj_af',
|
38 |
+
'geometric_conj_bf',
|
39 |
+
'gaussian_conj',
|
40 |
+
'conjugate_gauss_beams',
|
41 |
+
]
|
42 |
+
|
43 |
+
|
44 |
+
from sympy.core.expr import Expr
|
45 |
+
from sympy.core.numbers import (I, pi)
|
46 |
+
from sympy.core.sympify import sympify
|
47 |
+
from sympy.functions.elementary.complexes import (im, re)
|
48 |
+
from sympy.functions.elementary.miscellaneous import sqrt
|
49 |
+
from sympy.functions.elementary.trigonometric import atan2
|
50 |
+
from sympy.matrices.dense import Matrix, MutableDenseMatrix
|
51 |
+
from sympy.polys.rationaltools import together
|
52 |
+
from sympy.utilities.misc import filldedent
|
53 |
+
|
54 |
+
###
|
55 |
+
# A, B, C, D matrices
|
56 |
+
###
|
57 |
+
|
58 |
+
|
59 |
+
class RayTransferMatrix(MutableDenseMatrix):
|
60 |
+
"""
|
61 |
+
Base class for a Ray Transfer Matrix.
|
62 |
+
|
63 |
+
It should be used if there is not already a more specific subclass mentioned
|
64 |
+
in See Also.
|
65 |
+
|
66 |
+
Parameters
|
67 |
+
==========
|
68 |
+
|
69 |
+
parameters :
|
70 |
+
A, B, C and D or 2x2 matrix (Matrix(2, 2, [A, B, C, D]))
|
71 |
+
|
72 |
+
Examples
|
73 |
+
========
|
74 |
+
|
75 |
+
>>> from sympy.physics.optics import RayTransferMatrix, ThinLens
|
76 |
+
>>> from sympy import Symbol, Matrix
|
77 |
+
|
78 |
+
>>> mat = RayTransferMatrix(1, 2, 3, 4)
|
79 |
+
>>> mat
|
80 |
+
Matrix([
|
81 |
+
[1, 2],
|
82 |
+
[3, 4]])
|
83 |
+
|
84 |
+
>>> RayTransferMatrix(Matrix([[1, 2], [3, 4]]))
|
85 |
+
Matrix([
|
86 |
+
[1, 2],
|
87 |
+
[3, 4]])
|
88 |
+
|
89 |
+
>>> mat.A
|
90 |
+
1
|
91 |
+
|
92 |
+
>>> f = Symbol('f')
|
93 |
+
>>> lens = ThinLens(f)
|
94 |
+
>>> lens
|
95 |
+
Matrix([
|
96 |
+
[ 1, 0],
|
97 |
+
[-1/f, 1]])
|
98 |
+
|
99 |
+
>>> lens.C
|
100 |
+
-1/f
|
101 |
+
|
102 |
+
See Also
|
103 |
+
========
|
104 |
+
|
105 |
+
GeometricRay, BeamParameter,
|
106 |
+
FreeSpace, FlatRefraction, CurvedRefraction,
|
107 |
+
FlatMirror, CurvedMirror, ThinLens
|
108 |
+
|
109 |
+
References
|
110 |
+
==========
|
111 |
+
|
112 |
+
.. [1] https://en.wikipedia.org/wiki/Ray_transfer_matrix_analysis
|
113 |
+
"""
|
114 |
+
|
115 |
+
def __new__(cls, *args):
|
116 |
+
|
117 |
+
if len(args) == 4:
|
118 |
+
temp = ((args[0], args[1]), (args[2], args[3]))
|
119 |
+
elif len(args) == 1 \
|
120 |
+
and isinstance(args[0], Matrix) \
|
121 |
+
and args[0].shape == (2, 2):
|
122 |
+
temp = args[0]
|
123 |
+
else:
|
124 |
+
raise ValueError(filldedent('''
|
125 |
+
Expecting 2x2 Matrix or the 4 elements of
|
126 |
+
the Matrix but got %s''' % str(args)))
|
127 |
+
return Matrix.__new__(cls, temp)
|
128 |
+
|
129 |
+
def __mul__(self, other):
|
130 |
+
if isinstance(other, RayTransferMatrix):
|
131 |
+
return RayTransferMatrix(Matrix.__mul__(self, other))
|
132 |
+
elif isinstance(other, GeometricRay):
|
133 |
+
return GeometricRay(Matrix.__mul__(self, other))
|
134 |
+
elif isinstance(other, BeamParameter):
|
135 |
+
temp = self*Matrix(((other.q,), (1,)))
|
136 |
+
q = (temp[0]/temp[1]).expand(complex=True)
|
137 |
+
return BeamParameter(other.wavelen,
|
138 |
+
together(re(q)),
|
139 |
+
z_r=together(im(q)))
|
140 |
+
else:
|
141 |
+
return Matrix.__mul__(self, other)
|
142 |
+
|
143 |
+
@property
|
144 |
+
def A(self):
|
145 |
+
"""
|
146 |
+
The A parameter of the Matrix.
|
147 |
+
|
148 |
+
Examples
|
149 |
+
========
|
150 |
+
|
151 |
+
>>> from sympy.physics.optics import RayTransferMatrix
|
152 |
+
>>> mat = RayTransferMatrix(1, 2, 3, 4)
|
153 |
+
>>> mat.A
|
154 |
+
1
|
155 |
+
"""
|
156 |
+
return self[0, 0]
|
157 |
+
|
158 |
+
@property
|
159 |
+
def B(self):
|
160 |
+
"""
|
161 |
+
The B parameter of the Matrix.
|
162 |
+
|
163 |
+
Examples
|
164 |
+
========
|
165 |
+
|
166 |
+
>>> from sympy.physics.optics import RayTransferMatrix
|
167 |
+
>>> mat = RayTransferMatrix(1, 2, 3, 4)
|
168 |
+
>>> mat.B
|
169 |
+
2
|
170 |
+
"""
|
171 |
+
return self[0, 1]
|
172 |
+
|
173 |
+
@property
|
174 |
+
def C(self):
|
175 |
+
"""
|
176 |
+
The C parameter of the Matrix.
|
177 |
+
|
178 |
+
Examples
|
179 |
+
========
|
180 |
+
|
181 |
+
>>> from sympy.physics.optics import RayTransferMatrix
|
182 |
+
>>> mat = RayTransferMatrix(1, 2, 3, 4)
|
183 |
+
>>> mat.C
|
184 |
+
3
|
185 |
+
"""
|
186 |
+
return self[1, 0]
|
187 |
+
|
188 |
+
@property
|
189 |
+
def D(self):
|
190 |
+
"""
|
191 |
+
The D parameter of the Matrix.
|
192 |
+
|
193 |
+
Examples
|
194 |
+
========
|
195 |
+
|
196 |
+
>>> from sympy.physics.optics import RayTransferMatrix
|
197 |
+
>>> mat = RayTransferMatrix(1, 2, 3, 4)
|
198 |
+
>>> mat.D
|
199 |
+
4
|
200 |
+
"""
|
201 |
+
return self[1, 1]
|
202 |
+
|
203 |
+
|
204 |
+
class FreeSpace(RayTransferMatrix):
|
205 |
+
"""
|
206 |
+
Ray Transfer Matrix for free space.
|
207 |
+
|
208 |
+
Parameters
|
209 |
+
==========
|
210 |
+
|
211 |
+
distance
|
212 |
+
|
213 |
+
See Also
|
214 |
+
========
|
215 |
+
|
216 |
+
RayTransferMatrix
|
217 |
+
|
218 |
+
Examples
|
219 |
+
========
|
220 |
+
|
221 |
+
>>> from sympy.physics.optics import FreeSpace
|
222 |
+
>>> from sympy import symbols
|
223 |
+
>>> d = symbols('d')
|
224 |
+
>>> FreeSpace(d)
|
225 |
+
Matrix([
|
226 |
+
[1, d],
|
227 |
+
[0, 1]])
|
228 |
+
"""
|
229 |
+
def __new__(cls, d):
|
230 |
+
return RayTransferMatrix.__new__(cls, 1, d, 0, 1)
|
231 |
+
|
232 |
+
|
233 |
+
class FlatRefraction(RayTransferMatrix):
|
234 |
+
"""
|
235 |
+
Ray Transfer Matrix for refraction.
|
236 |
+
|
237 |
+
Parameters
|
238 |
+
==========
|
239 |
+
|
240 |
+
n1 :
|
241 |
+
Refractive index of one medium.
|
242 |
+
n2 :
|
243 |
+
Refractive index of other medium.
|
244 |
+
|
245 |
+
See Also
|
246 |
+
========
|
247 |
+
|
248 |
+
RayTransferMatrix
|
249 |
+
|
250 |
+
Examples
|
251 |
+
========
|
252 |
+
|
253 |
+
>>> from sympy.physics.optics import FlatRefraction
|
254 |
+
>>> from sympy import symbols
|
255 |
+
>>> n1, n2 = symbols('n1 n2')
|
256 |
+
>>> FlatRefraction(n1, n2)
|
257 |
+
Matrix([
|
258 |
+
[1, 0],
|
259 |
+
[0, n1/n2]])
|
260 |
+
"""
|
261 |
+
def __new__(cls, n1, n2):
|
262 |
+
n1, n2 = map(sympify, (n1, n2))
|
263 |
+
return RayTransferMatrix.__new__(cls, 1, 0, 0, n1/n2)
|
264 |
+
|
265 |
+
|
266 |
+
class CurvedRefraction(RayTransferMatrix):
|
267 |
+
"""
|
268 |
+
Ray Transfer Matrix for refraction on curved interface.
|
269 |
+
|
270 |
+
Parameters
|
271 |
+
==========
|
272 |
+
|
273 |
+
R :
|
274 |
+
Radius of curvature (positive for concave).
|
275 |
+
n1 :
|
276 |
+
Refractive index of one medium.
|
277 |
+
n2 :
|
278 |
+
Refractive index of other medium.
|
279 |
+
|
280 |
+
See Also
|
281 |
+
========
|
282 |
+
|
283 |
+
RayTransferMatrix
|
284 |
+
|
285 |
+
Examples
|
286 |
+
========
|
287 |
+
|
288 |
+
>>> from sympy.physics.optics import CurvedRefraction
|
289 |
+
>>> from sympy import symbols
|
290 |
+
>>> R, n1, n2 = symbols('R n1 n2')
|
291 |
+
>>> CurvedRefraction(R, n1, n2)
|
292 |
+
Matrix([
|
293 |
+
[ 1, 0],
|
294 |
+
[(n1 - n2)/(R*n2), n1/n2]])
|
295 |
+
"""
|
296 |
+
def __new__(cls, R, n1, n2):
|
297 |
+
R, n1, n2 = map(sympify, (R, n1, n2))
|
298 |
+
return RayTransferMatrix.__new__(cls, 1, 0, (n1 - n2)/R/n2, n1/n2)
|
299 |
+
|
300 |
+
|
301 |
+
class FlatMirror(RayTransferMatrix):
|
302 |
+
"""
|
303 |
+
Ray Transfer Matrix for reflection.
|
304 |
+
|
305 |
+
See Also
|
306 |
+
========
|
307 |
+
|
308 |
+
RayTransferMatrix
|
309 |
+
|
310 |
+
Examples
|
311 |
+
========
|
312 |
+
|
313 |
+
>>> from sympy.physics.optics import FlatMirror
|
314 |
+
>>> FlatMirror()
|
315 |
+
Matrix([
|
316 |
+
[1, 0],
|
317 |
+
[0, 1]])
|
318 |
+
"""
|
319 |
+
def __new__(cls):
|
320 |
+
return RayTransferMatrix.__new__(cls, 1, 0, 0, 1)
|
321 |
+
|
322 |
+
|
323 |
+
class CurvedMirror(RayTransferMatrix):
|
324 |
+
"""
|
325 |
+
Ray Transfer Matrix for reflection from curved surface.
|
326 |
+
|
327 |
+
Parameters
|
328 |
+
==========
|
329 |
+
|
330 |
+
R : radius of curvature (positive for concave)
|
331 |
+
|
332 |
+
See Also
|
333 |
+
========
|
334 |
+
|
335 |
+
RayTransferMatrix
|
336 |
+
|
337 |
+
Examples
|
338 |
+
========
|
339 |
+
|
340 |
+
>>> from sympy.physics.optics import CurvedMirror
|
341 |
+
>>> from sympy import symbols
|
342 |
+
>>> R = symbols('R')
|
343 |
+
>>> CurvedMirror(R)
|
344 |
+
Matrix([
|
345 |
+
[ 1, 0],
|
346 |
+
[-2/R, 1]])
|
347 |
+
"""
|
348 |
+
def __new__(cls, R):
|
349 |
+
R = sympify(R)
|
350 |
+
return RayTransferMatrix.__new__(cls, 1, 0, -2/R, 1)
|
351 |
+
|
352 |
+
|
353 |
+
class ThinLens(RayTransferMatrix):
|
354 |
+
"""
|
355 |
+
Ray Transfer Matrix for a thin lens.
|
356 |
+
|
357 |
+
Parameters
|
358 |
+
==========
|
359 |
+
|
360 |
+
f :
|
361 |
+
The focal distance.
|
362 |
+
|
363 |
+
See Also
|
364 |
+
========
|
365 |
+
|
366 |
+
RayTransferMatrix
|
367 |
+
|
368 |
+
Examples
|
369 |
+
========
|
370 |
+
|
371 |
+
>>> from sympy.physics.optics import ThinLens
|
372 |
+
>>> from sympy import symbols
|
373 |
+
>>> f = symbols('f')
|
374 |
+
>>> ThinLens(f)
|
375 |
+
Matrix([
|
376 |
+
[ 1, 0],
|
377 |
+
[-1/f, 1]])
|
378 |
+
"""
|
379 |
+
def __new__(cls, f):
|
380 |
+
f = sympify(f)
|
381 |
+
return RayTransferMatrix.__new__(cls, 1, 0, -1/f, 1)
|
382 |
+
|
383 |
+
|
384 |
+
###
|
385 |
+
# Representation for geometric ray
|
386 |
+
###
|
387 |
+
|
388 |
+
class GeometricRay(MutableDenseMatrix):
|
389 |
+
"""
|
390 |
+
Representation for a geometric ray in the Ray Transfer Matrix formalism.
|
391 |
+
|
392 |
+
Parameters
|
393 |
+
==========
|
394 |
+
|
395 |
+
h : height, and
|
396 |
+
angle : angle, or
|
397 |
+
matrix : a 2x1 matrix (Matrix(2, 1, [height, angle]))
|
398 |
+
|
399 |
+
Examples
|
400 |
+
========
|
401 |
+
|
402 |
+
>>> from sympy.physics.optics import GeometricRay, FreeSpace
|
403 |
+
>>> from sympy import symbols, Matrix
|
404 |
+
>>> d, h, angle = symbols('d, h, angle')
|
405 |
+
|
406 |
+
>>> GeometricRay(h, angle)
|
407 |
+
Matrix([
|
408 |
+
[ h],
|
409 |
+
[angle]])
|
410 |
+
|
411 |
+
>>> FreeSpace(d)*GeometricRay(h, angle)
|
412 |
+
Matrix([
|
413 |
+
[angle*d + h],
|
414 |
+
[ angle]])
|
415 |
+
|
416 |
+
>>> GeometricRay( Matrix( ((h,), (angle,)) ) )
|
417 |
+
Matrix([
|
418 |
+
[ h],
|
419 |
+
[angle]])
|
420 |
+
|
421 |
+
See Also
|
422 |
+
========
|
423 |
+
|
424 |
+
RayTransferMatrix
|
425 |
+
|
426 |
+
"""
|
427 |
+
|
428 |
+
def __new__(cls, *args):
|
429 |
+
if len(args) == 1 and isinstance(args[0], Matrix) \
|
430 |
+
and args[0].shape == (2, 1):
|
431 |
+
temp = args[0]
|
432 |
+
elif len(args) == 2:
|
433 |
+
temp = ((args[0],), (args[1],))
|
434 |
+
else:
|
435 |
+
raise ValueError(filldedent('''
|
436 |
+
Expecting 2x1 Matrix or the 2 elements of
|
437 |
+
the Matrix but got %s''' % str(args)))
|
438 |
+
return Matrix.__new__(cls, temp)
|
439 |
+
|
440 |
+
@property
|
441 |
+
def height(self):
|
442 |
+
"""
|
443 |
+
The distance from the optical axis.
|
444 |
+
|
445 |
+
Examples
|
446 |
+
========
|
447 |
+
|
448 |
+
>>> from sympy.physics.optics import GeometricRay
|
449 |
+
>>> from sympy import symbols
|
450 |
+
>>> h, angle = symbols('h, angle')
|
451 |
+
>>> gRay = GeometricRay(h, angle)
|
452 |
+
>>> gRay.height
|
453 |
+
h
|
454 |
+
"""
|
455 |
+
return self[0]
|
456 |
+
|
457 |
+
@property
|
458 |
+
def angle(self):
|
459 |
+
"""
|
460 |
+
The angle with the optical axis.
|
461 |
+
|
462 |
+
Examples
|
463 |
+
========
|
464 |
+
|
465 |
+
>>> from sympy.physics.optics import GeometricRay
|
466 |
+
>>> from sympy import symbols
|
467 |
+
>>> h, angle = symbols('h, angle')
|
468 |
+
>>> gRay = GeometricRay(h, angle)
|
469 |
+
>>> gRay.angle
|
470 |
+
angle
|
471 |
+
"""
|
472 |
+
return self[1]
|
473 |
+
|
474 |
+
|
475 |
+
###
|
476 |
+
# Representation for gauss beam
|
477 |
+
###
|
478 |
+
|
479 |
+
class BeamParameter(Expr):
|
480 |
+
"""
|
481 |
+
Representation for a gaussian ray in the Ray Transfer Matrix formalism.
|
482 |
+
|
483 |
+
Parameters
|
484 |
+
==========
|
485 |
+
|
486 |
+
wavelen : the wavelength,
|
487 |
+
z : the distance to waist, and
|
488 |
+
w : the waist, or
|
489 |
+
z_r : the rayleigh range.
|
490 |
+
n : the refractive index of medium.
|
491 |
+
|
492 |
+
Examples
|
493 |
+
========
|
494 |
+
|
495 |
+
>>> from sympy.physics.optics import BeamParameter
|
496 |
+
>>> p = BeamParameter(530e-9, 1, w=1e-3)
|
497 |
+
>>> p.q
|
498 |
+
1 + 1.88679245283019*I*pi
|
499 |
+
|
500 |
+
>>> p.q.n()
|
501 |
+
1.0 + 5.92753330865999*I
|
502 |
+
>>> p.w_0.n()
|
503 |
+
0.00100000000000000
|
504 |
+
>>> p.z_r.n()
|
505 |
+
5.92753330865999
|
506 |
+
|
507 |
+
>>> from sympy.physics.optics import FreeSpace
|
508 |
+
>>> fs = FreeSpace(10)
|
509 |
+
>>> p1 = fs*p
|
510 |
+
>>> p.w.n()
|
511 |
+
0.00101413072159615
|
512 |
+
>>> p1.w.n()
|
513 |
+
0.00210803120913829
|
514 |
+
|
515 |
+
See Also
|
516 |
+
========
|
517 |
+
|
518 |
+
RayTransferMatrix
|
519 |
+
|
520 |
+
References
|
521 |
+
==========
|
522 |
+
|
523 |
+
.. [1] https://en.wikipedia.org/wiki/Complex_beam_parameter
|
524 |
+
.. [2] https://en.wikipedia.org/wiki/Gaussian_beam
|
525 |
+
"""
|
526 |
+
#TODO A class Complex may be implemented. The BeamParameter may
|
527 |
+
# subclass it. See:
|
528 |
+
# https://groups.google.com/d/topic/sympy/7XkU07NRBEs/discussion
|
529 |
+
|
530 |
+
def __new__(cls, wavelen, z, z_r=None, w=None, n=1):
|
531 |
+
wavelen = sympify(wavelen)
|
532 |
+
z = sympify(z)
|
533 |
+
n = sympify(n)
|
534 |
+
|
535 |
+
if z_r is not None and w is None:
|
536 |
+
z_r = sympify(z_r)
|
537 |
+
elif w is not None and z_r is None:
|
538 |
+
z_r = waist2rayleigh(sympify(w), wavelen, n)
|
539 |
+
elif z_r is None and w is None:
|
540 |
+
raise ValueError('Must specify one of w and z_r.')
|
541 |
+
|
542 |
+
return Expr.__new__(cls, wavelen, z, z_r, n)
|
543 |
+
|
544 |
+
@property
|
545 |
+
def wavelen(self):
|
546 |
+
return self.args[0]
|
547 |
+
|
548 |
+
@property
|
549 |
+
def z(self):
|
550 |
+
return self.args[1]
|
551 |
+
|
552 |
+
@property
|
553 |
+
def z_r(self):
|
554 |
+
return self.args[2]
|
555 |
+
|
556 |
+
@property
|
557 |
+
def n(self):
|
558 |
+
return self.args[3]
|
559 |
+
|
560 |
+
@property
|
561 |
+
def q(self):
|
562 |
+
"""
|
563 |
+
The complex parameter representing the beam.
|
564 |
+
|
565 |
+
Examples
|
566 |
+
========
|
567 |
+
|
568 |
+
>>> from sympy.physics.optics import BeamParameter
|
569 |
+
>>> p = BeamParameter(530e-9, 1, w=1e-3)
|
570 |
+
>>> p.q
|
571 |
+
1 + 1.88679245283019*I*pi
|
572 |
+
"""
|
573 |
+
return self.z + I*self.z_r
|
574 |
+
|
575 |
+
@property
|
576 |
+
def radius(self):
|
577 |
+
"""
|
578 |
+
The radius of curvature of the phase front.
|
579 |
+
|
580 |
+
Examples
|
581 |
+
========
|
582 |
+
|
583 |
+
>>> from sympy.physics.optics import BeamParameter
|
584 |
+
>>> p = BeamParameter(530e-9, 1, w=1e-3)
|
585 |
+
>>> p.radius
|
586 |
+
1 + 3.55998576005696*pi**2
|
587 |
+
"""
|
588 |
+
return self.z*(1 + (self.z_r/self.z)**2)
|
589 |
+
|
590 |
+
@property
|
591 |
+
def w(self):
|
592 |
+
"""
|
593 |
+
The radius of the beam w(z), at any position z along the beam.
|
594 |
+
The beam radius at `1/e^2` intensity (axial value).
|
595 |
+
|
596 |
+
See Also
|
597 |
+
========
|
598 |
+
|
599 |
+
w_0 :
|
600 |
+
The minimal radius of beam.
|
601 |
+
|
602 |
+
Examples
|
603 |
+
========
|
604 |
+
|
605 |
+
>>> from sympy.physics.optics import BeamParameter
|
606 |
+
>>> p = BeamParameter(530e-9, 1, w=1e-3)
|
607 |
+
>>> p.w
|
608 |
+
0.001*sqrt(0.2809/pi**2 + 1)
|
609 |
+
"""
|
610 |
+
return self.w_0*sqrt(1 + (self.z/self.z_r)**2)
|
611 |
+
|
612 |
+
@property
|
613 |
+
def w_0(self):
|
614 |
+
"""
|
615 |
+
The minimal radius of beam at `1/e^2` intensity (peak value).
|
616 |
+
|
617 |
+
See Also
|
618 |
+
========
|
619 |
+
|
620 |
+
w : the beam radius at `1/e^2` intensity (axial value).
|
621 |
+
|
622 |
+
Examples
|
623 |
+
========
|
624 |
+
|
625 |
+
>>> from sympy.physics.optics import BeamParameter
|
626 |
+
>>> p = BeamParameter(530e-9, 1, w=1e-3)
|
627 |
+
>>> p.w_0
|
628 |
+
0.00100000000000000
|
629 |
+
"""
|
630 |
+
return sqrt(self.z_r/(pi*self.n)*self.wavelen)
|
631 |
+
|
632 |
+
@property
|
633 |
+
def divergence(self):
|
634 |
+
"""
|
635 |
+
Half of the total angular spread.
|
636 |
+
|
637 |
+
Examples
|
638 |
+
========
|
639 |
+
|
640 |
+
>>> from sympy.physics.optics import BeamParameter
|
641 |
+
>>> p = BeamParameter(530e-9, 1, w=1e-3)
|
642 |
+
>>> p.divergence
|
643 |
+
0.00053/pi
|
644 |
+
"""
|
645 |
+
return self.wavelen/pi/self.w_0
|
646 |
+
|
647 |
+
@property
|
648 |
+
def gouy(self):
|
649 |
+
"""
|
650 |
+
The Gouy phase.
|
651 |
+
|
652 |
+
Examples
|
653 |
+
========
|
654 |
+
|
655 |
+
>>> from sympy.physics.optics import BeamParameter
|
656 |
+
>>> p = BeamParameter(530e-9, 1, w=1e-3)
|
657 |
+
>>> p.gouy
|
658 |
+
atan(0.53/pi)
|
659 |
+
"""
|
660 |
+
return atan2(self.z, self.z_r)
|
661 |
+
|
662 |
+
@property
|
663 |
+
def waist_approximation_limit(self):
|
664 |
+
"""
|
665 |
+
The minimal waist for which the gauss beam approximation is valid.
|
666 |
+
|
667 |
+
Explanation
|
668 |
+
===========
|
669 |
+
|
670 |
+
The gauss beam is a solution to the paraxial equation. For curvatures
|
671 |
+
that are too great it is not a valid approximation.
|
672 |
+
|
673 |
+
Examples
|
674 |
+
========
|
675 |
+
|
676 |
+
>>> from sympy.physics.optics import BeamParameter
|
677 |
+
>>> p = BeamParameter(530e-9, 1, w=1e-3)
|
678 |
+
>>> p.waist_approximation_limit
|
679 |
+
1.06e-6/pi
|
680 |
+
"""
|
681 |
+
return 2*self.wavelen/pi
|
682 |
+
|
683 |
+
|
684 |
+
###
|
685 |
+
# Utilities
|
686 |
+
###
|
687 |
+
|
688 |
+
def waist2rayleigh(w, wavelen, n=1):
|
689 |
+
"""
|
690 |
+
Calculate the rayleigh range from the waist of a gaussian beam.
|
691 |
+
|
692 |
+
See Also
|
693 |
+
========
|
694 |
+
|
695 |
+
rayleigh2waist, BeamParameter
|
696 |
+
|
697 |
+
Examples
|
698 |
+
========
|
699 |
+
|
700 |
+
>>> from sympy.physics.optics import waist2rayleigh
|
701 |
+
>>> from sympy import symbols
|
702 |
+
>>> w, wavelen = symbols('w wavelen')
|
703 |
+
>>> waist2rayleigh(w, wavelen)
|
704 |
+
pi*w**2/wavelen
|
705 |
+
"""
|
706 |
+
w, wavelen = map(sympify, (w, wavelen))
|
707 |
+
return w**2*n*pi/wavelen
|
708 |
+
|
709 |
+
|
710 |
+
def rayleigh2waist(z_r, wavelen):
|
711 |
+
"""Calculate the waist from the rayleigh range of a gaussian beam.
|
712 |
+
|
713 |
+
See Also
|
714 |
+
========
|
715 |
+
|
716 |
+
waist2rayleigh, BeamParameter
|
717 |
+
|
718 |
+
Examples
|
719 |
+
========
|
720 |
+
|
721 |
+
>>> from sympy.physics.optics import rayleigh2waist
|
722 |
+
>>> from sympy import symbols
|
723 |
+
>>> z_r, wavelen = symbols('z_r wavelen')
|
724 |
+
>>> rayleigh2waist(z_r, wavelen)
|
725 |
+
sqrt(wavelen*z_r)/sqrt(pi)
|
726 |
+
"""
|
727 |
+
z_r, wavelen = map(sympify, (z_r, wavelen))
|
728 |
+
return sqrt(z_r/pi*wavelen)
|
729 |
+
|
730 |
+
|
731 |
+
def geometric_conj_ab(a, b):
|
732 |
+
"""
|
733 |
+
Conjugation relation for geometrical beams under paraxial conditions.
|
734 |
+
|
735 |
+
Explanation
|
736 |
+
===========
|
737 |
+
|
738 |
+
Takes the distances to the optical element and returns the needed
|
739 |
+
focal distance.
|
740 |
+
|
741 |
+
See Also
|
742 |
+
========
|
743 |
+
|
744 |
+
geometric_conj_af, geometric_conj_bf
|
745 |
+
|
746 |
+
Examples
|
747 |
+
========
|
748 |
+
|
749 |
+
>>> from sympy.physics.optics import geometric_conj_ab
|
750 |
+
>>> from sympy import symbols
|
751 |
+
>>> a, b = symbols('a b')
|
752 |
+
>>> geometric_conj_ab(a, b)
|
753 |
+
a*b/(a + b)
|
754 |
+
"""
|
755 |
+
a, b = map(sympify, (a, b))
|
756 |
+
if a.is_infinite or b.is_infinite:
|
757 |
+
return a if b.is_infinite else b
|
758 |
+
else:
|
759 |
+
return a*b/(a + b)
|
760 |
+
|
761 |
+
|
762 |
+
def geometric_conj_af(a, f):
|
763 |
+
"""
|
764 |
+
Conjugation relation for geometrical beams under paraxial conditions.
|
765 |
+
|
766 |
+
Explanation
|
767 |
+
===========
|
768 |
+
|
769 |
+
Takes the object distance (for geometric_conj_af) or the image distance
|
770 |
+
(for geometric_conj_bf) to the optical element and the focal distance.
|
771 |
+
Then it returns the other distance needed for conjugation.
|
772 |
+
|
773 |
+
See Also
|
774 |
+
========
|
775 |
+
|
776 |
+
geometric_conj_ab
|
777 |
+
|
778 |
+
Examples
|
779 |
+
========
|
780 |
+
|
781 |
+
>>> from sympy.physics.optics.gaussopt import geometric_conj_af, geometric_conj_bf
|
782 |
+
>>> from sympy import symbols
|
783 |
+
>>> a, b, f = symbols('a b f')
|
784 |
+
>>> geometric_conj_af(a, f)
|
785 |
+
a*f/(a - f)
|
786 |
+
>>> geometric_conj_bf(b, f)
|
787 |
+
b*f/(b - f)
|
788 |
+
"""
|
789 |
+
a, f = map(sympify, (a, f))
|
790 |
+
return -geometric_conj_ab(a, -f)
|
791 |
+
|
792 |
+
geometric_conj_bf = geometric_conj_af
|
793 |
+
|
794 |
+
|
795 |
+
def gaussian_conj(s_in, z_r_in, f):
|
796 |
+
"""
|
797 |
+
Conjugation relation for gaussian beams.
|
798 |
+
|
799 |
+
Parameters
|
800 |
+
==========
|
801 |
+
|
802 |
+
s_in :
|
803 |
+
The distance to optical element from the waist.
|
804 |
+
z_r_in :
|
805 |
+
The rayleigh range of the incident beam.
|
806 |
+
f :
|
807 |
+
The focal length of the optical element.
|
808 |
+
|
809 |
+
Returns
|
810 |
+
=======
|
811 |
+
|
812 |
+
a tuple containing (s_out, z_r_out, m)
|
813 |
+
s_out :
|
814 |
+
The distance between the new waist and the optical element.
|
815 |
+
z_r_out :
|
816 |
+
The rayleigh range of the emergent beam.
|
817 |
+
m :
|
818 |
+
The ration between the new and the old waists.
|
819 |
+
|
820 |
+
Examples
|
821 |
+
========
|
822 |
+
|
823 |
+
>>> from sympy.physics.optics import gaussian_conj
|
824 |
+
>>> from sympy import symbols
|
825 |
+
>>> s_in, z_r_in, f = symbols('s_in z_r_in f')
|
826 |
+
|
827 |
+
>>> gaussian_conj(s_in, z_r_in, f)[0]
|
828 |
+
1/(-1/(s_in + z_r_in**2/(-f + s_in)) + 1/f)
|
829 |
+
|
830 |
+
>>> gaussian_conj(s_in, z_r_in, f)[1]
|
831 |
+
z_r_in/(1 - s_in**2/f**2 + z_r_in**2/f**2)
|
832 |
+
|
833 |
+
>>> gaussian_conj(s_in, z_r_in, f)[2]
|
834 |
+
1/sqrt(1 - s_in**2/f**2 + z_r_in**2/f**2)
|
835 |
+
"""
|
836 |
+
s_in, z_r_in, f = map(sympify, (s_in, z_r_in, f))
|
837 |
+
s_out = 1 / ( -1/(s_in + z_r_in**2/(s_in - f)) + 1/f )
|
838 |
+
m = 1/sqrt((1 - (s_in/f)**2) + (z_r_in/f)**2)
|
839 |
+
z_r_out = z_r_in / ((1 - (s_in/f)**2) + (z_r_in/f)**2)
|
840 |
+
return (s_out, z_r_out, m)
|
841 |
+
|
842 |
+
|
843 |
+
def conjugate_gauss_beams(wavelen, waist_in, waist_out, **kwargs):
|
844 |
+
"""
|
845 |
+
Find the optical setup conjugating the object/image waists.
|
846 |
+
|
847 |
+
Parameters
|
848 |
+
==========
|
849 |
+
|
850 |
+
wavelen :
|
851 |
+
The wavelength of the beam.
|
852 |
+
waist_in and waist_out :
|
853 |
+
The waists to be conjugated.
|
854 |
+
f :
|
855 |
+
The focal distance of the element used in the conjugation.
|
856 |
+
|
857 |
+
Returns
|
858 |
+
=======
|
859 |
+
|
860 |
+
a tuple containing (s_in, s_out, f)
|
861 |
+
s_in :
|
862 |
+
The distance before the optical element.
|
863 |
+
s_out :
|
864 |
+
The distance after the optical element.
|
865 |
+
f :
|
866 |
+
The focal distance of the optical element.
|
867 |
+
|
868 |
+
Examples
|
869 |
+
========
|
870 |
+
|
871 |
+
>>> from sympy.physics.optics import conjugate_gauss_beams
|
872 |
+
>>> from sympy import symbols, factor
|
873 |
+
>>> l, w_i, w_o, f = symbols('l w_i w_o f')
|
874 |
+
|
875 |
+
>>> conjugate_gauss_beams(l, w_i, w_o, f=f)[0]
|
876 |
+
f*(1 - sqrt(w_i**2/w_o**2 - pi**2*w_i**4/(f**2*l**2)))
|
877 |
+
|
878 |
+
>>> factor(conjugate_gauss_beams(l, w_i, w_o, f=f)[1])
|
879 |
+
f*w_o**2*(w_i**2/w_o**2 - sqrt(w_i**2/w_o**2 -
|
880 |
+
pi**2*w_i**4/(f**2*l**2)))/w_i**2
|
881 |
+
|
882 |
+
>>> conjugate_gauss_beams(l, w_i, w_o, f=f)[2]
|
883 |
+
f
|
884 |
+
"""
|
885 |
+
#TODO add the other possible arguments
|
886 |
+
wavelen, waist_in, waist_out = map(sympify, (wavelen, waist_in, waist_out))
|
887 |
+
m = waist_out / waist_in
|
888 |
+
z = waist2rayleigh(waist_in, wavelen)
|
889 |
+
if len(kwargs) != 1:
|
890 |
+
raise ValueError("The function expects only one named argument")
|
891 |
+
elif 'dist' in kwargs:
|
892 |
+
raise NotImplementedError(filldedent('''
|
893 |
+
Currently only focal length is supported as a parameter'''))
|
894 |
+
elif 'f' in kwargs:
|
895 |
+
f = sympify(kwargs['f'])
|
896 |
+
s_in = f * (1 - sqrt(1/m**2 - z**2/f**2))
|
897 |
+
s_out = gaussian_conj(s_in, z, f)[0]
|
898 |
+
elif 's_in' in kwargs:
|
899 |
+
raise NotImplementedError(filldedent('''
|
900 |
+
Currently only focal length is supported as a parameter'''))
|
901 |
+
else:
|
902 |
+
raise ValueError(filldedent('''
|
903 |
+
The functions expects the focal length as a named argument'''))
|
904 |
+
return (s_in, s_out, f)
|
905 |
+
|
906 |
+
#TODO
|
907 |
+
#def plot_beam():
|
908 |
+
# """Plot the beam radius as it propagates in space."""
|
909 |
+
# pass
|
910 |
+
|
911 |
+
#TODO
|
912 |
+
#def plot_beam_conjugation():
|
913 |
+
# """
|
914 |
+
# Plot the intersection of two beams.
|
915 |
+
#
|
916 |
+
# Represents the conjugation relation.
|
917 |
+
#
|
918 |
+
# See Also
|
919 |
+
# ========
|
920 |
+
#
|
921 |
+
# conjugate_gauss_beams
|
922 |
+
# """
|
923 |
+
# pass
|
venv/lib/python3.10/site-packages/sympy/physics/optics/medium.py
ADDED
@@ -0,0 +1,253 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
**Contains**
|
3 |
+
|
4 |
+
* Medium
|
5 |
+
"""
|
6 |
+
from sympy.physics.units import second, meter, kilogram, ampere
|
7 |
+
|
8 |
+
__all__ = ['Medium']
|
9 |
+
|
10 |
+
from sympy.core.basic import Basic
|
11 |
+
from sympy.core.symbol import Str
|
12 |
+
from sympy.core.sympify import _sympify
|
13 |
+
from sympy.functions.elementary.miscellaneous import sqrt
|
14 |
+
from sympy.physics.units import speed_of_light, u0, e0
|
15 |
+
|
16 |
+
|
17 |
+
c = speed_of_light.convert_to(meter/second)
|
18 |
+
_e0mksa = e0.convert_to(ampere**2*second**4/(kilogram*meter**3))
|
19 |
+
_u0mksa = u0.convert_to(meter*kilogram/(ampere**2*second**2))
|
20 |
+
|
21 |
+
|
22 |
+
class Medium(Basic):
|
23 |
+
|
24 |
+
"""
|
25 |
+
This class represents an optical medium. The prime reason to implement this is
|
26 |
+
to facilitate refraction, Fermat's principle, etc.
|
27 |
+
|
28 |
+
Explanation
|
29 |
+
===========
|
30 |
+
|
31 |
+
An optical medium is a material through which electromagnetic waves propagate.
|
32 |
+
The permittivity and permeability of the medium define how electromagnetic
|
33 |
+
waves propagate in it.
|
34 |
+
|
35 |
+
|
36 |
+
Parameters
|
37 |
+
==========
|
38 |
+
|
39 |
+
name: string
|
40 |
+
The display name of the Medium.
|
41 |
+
|
42 |
+
permittivity: Sympifyable
|
43 |
+
Electric permittivity of the space.
|
44 |
+
|
45 |
+
permeability: Sympifyable
|
46 |
+
Magnetic permeability of the space.
|
47 |
+
|
48 |
+
n: Sympifyable
|
49 |
+
Index of refraction of the medium.
|
50 |
+
|
51 |
+
|
52 |
+
Examples
|
53 |
+
========
|
54 |
+
|
55 |
+
>>> from sympy.abc import epsilon, mu
|
56 |
+
>>> from sympy.physics.optics import Medium
|
57 |
+
>>> m1 = Medium('m1')
|
58 |
+
>>> m2 = Medium('m2', epsilon, mu)
|
59 |
+
>>> m1.intrinsic_impedance
|
60 |
+
149896229*pi*kilogram*meter**2/(1250000*ampere**2*second**3)
|
61 |
+
>>> m2.refractive_index
|
62 |
+
299792458*meter*sqrt(epsilon*mu)/second
|
63 |
+
|
64 |
+
|
65 |
+
References
|
66 |
+
==========
|
67 |
+
|
68 |
+
.. [1] https://en.wikipedia.org/wiki/Optical_medium
|
69 |
+
|
70 |
+
"""
|
71 |
+
|
72 |
+
def __new__(cls, name, permittivity=None, permeability=None, n=None):
|
73 |
+
if not isinstance(name, Str):
|
74 |
+
name = Str(name)
|
75 |
+
|
76 |
+
permittivity = _sympify(permittivity) if permittivity is not None else permittivity
|
77 |
+
permeability = _sympify(permeability) if permeability is not None else permeability
|
78 |
+
n = _sympify(n) if n is not None else n
|
79 |
+
|
80 |
+
if n is not None:
|
81 |
+
if permittivity is not None and permeability is None:
|
82 |
+
permeability = n**2/(c**2*permittivity)
|
83 |
+
return MediumPP(name, permittivity, permeability)
|
84 |
+
elif permeability is not None and permittivity is None:
|
85 |
+
permittivity = n**2/(c**2*permeability)
|
86 |
+
return MediumPP(name, permittivity, permeability)
|
87 |
+
elif permittivity is not None and permittivity is not None:
|
88 |
+
raise ValueError("Specifying all of permittivity, permeability, and n is not allowed")
|
89 |
+
else:
|
90 |
+
return MediumN(name, n)
|
91 |
+
elif permittivity is not None and permeability is not None:
|
92 |
+
return MediumPP(name, permittivity, permeability)
|
93 |
+
elif permittivity is None and permeability is None:
|
94 |
+
return MediumPP(name, _e0mksa, _u0mksa)
|
95 |
+
else:
|
96 |
+
raise ValueError("Arguments are underspecified. Either specify n or any two of permittivity, "
|
97 |
+
"permeability, and n")
|
98 |
+
|
99 |
+
@property
|
100 |
+
def name(self):
|
101 |
+
return self.args[0]
|
102 |
+
|
103 |
+
@property
|
104 |
+
def speed(self):
|
105 |
+
"""
|
106 |
+
Returns speed of the electromagnetic wave travelling in the medium.
|
107 |
+
|
108 |
+
Examples
|
109 |
+
========
|
110 |
+
|
111 |
+
>>> from sympy.physics.optics import Medium
|
112 |
+
>>> m = Medium('m')
|
113 |
+
>>> m.speed
|
114 |
+
299792458*meter/second
|
115 |
+
>>> m2 = Medium('m2', n=1)
|
116 |
+
>>> m.speed == m2.speed
|
117 |
+
True
|
118 |
+
|
119 |
+
"""
|
120 |
+
return c / self.n
|
121 |
+
|
122 |
+
@property
|
123 |
+
def refractive_index(self):
|
124 |
+
"""
|
125 |
+
Returns refractive index of the medium.
|
126 |
+
|
127 |
+
Examples
|
128 |
+
========
|
129 |
+
|
130 |
+
>>> from sympy.physics.optics import Medium
|
131 |
+
>>> m = Medium('m')
|
132 |
+
>>> m.refractive_index
|
133 |
+
1
|
134 |
+
|
135 |
+
"""
|
136 |
+
return (c/self.speed)
|
137 |
+
|
138 |
+
|
139 |
+
class MediumN(Medium):
|
140 |
+
|
141 |
+
"""
|
142 |
+
Represents an optical medium for which only the refractive index is known.
|
143 |
+
Useful for simple ray optics.
|
144 |
+
|
145 |
+
This class should never be instantiated directly.
|
146 |
+
Instead it should be instantiated indirectly by instantiating Medium with
|
147 |
+
only n specified.
|
148 |
+
|
149 |
+
Examples
|
150 |
+
========
|
151 |
+
>>> from sympy.physics.optics import Medium
|
152 |
+
>>> m = Medium('m', n=2)
|
153 |
+
>>> m
|
154 |
+
MediumN(Str('m'), 2)
|
155 |
+
"""
|
156 |
+
|
157 |
+
def __new__(cls, name, n):
|
158 |
+
obj = super(Medium, cls).__new__(cls, name, n)
|
159 |
+
return obj
|
160 |
+
|
161 |
+
@property
|
162 |
+
def n(self):
|
163 |
+
return self.args[1]
|
164 |
+
|
165 |
+
|
166 |
+
class MediumPP(Medium):
|
167 |
+
"""
|
168 |
+
Represents an optical medium for which the permittivity and permeability are known.
|
169 |
+
|
170 |
+
This class should never be instantiated directly. Instead it should be
|
171 |
+
instantiated indirectly by instantiating Medium with any two of
|
172 |
+
permittivity, permeability, and n specified, or by not specifying any
|
173 |
+
of permittivity, permeability, or n, in which case default values for
|
174 |
+
permittivity and permeability will be used.
|
175 |
+
|
176 |
+
Examples
|
177 |
+
========
|
178 |
+
>>> from sympy.physics.optics import Medium
|
179 |
+
>>> from sympy.abc import epsilon, mu
|
180 |
+
>>> m1 = Medium('m1', permittivity=epsilon, permeability=mu)
|
181 |
+
>>> m1
|
182 |
+
MediumPP(Str('m1'), epsilon, mu)
|
183 |
+
>>> m2 = Medium('m2')
|
184 |
+
>>> m2
|
185 |
+
MediumPP(Str('m2'), 625000*ampere**2*second**4/(22468879468420441*pi*kilogram*meter**3), pi*kilogram*meter/(2500000*ampere**2*second**2))
|
186 |
+
"""
|
187 |
+
|
188 |
+
|
189 |
+
def __new__(cls, name, permittivity, permeability):
|
190 |
+
obj = super(Medium, cls).__new__(cls, name, permittivity, permeability)
|
191 |
+
return obj
|
192 |
+
|
193 |
+
@property
|
194 |
+
def intrinsic_impedance(self):
|
195 |
+
"""
|
196 |
+
Returns intrinsic impedance of the medium.
|
197 |
+
|
198 |
+
Explanation
|
199 |
+
===========
|
200 |
+
|
201 |
+
The intrinsic impedance of a medium is the ratio of the
|
202 |
+
transverse components of the electric and magnetic fields
|
203 |
+
of the electromagnetic wave travelling in the medium.
|
204 |
+
In a region with no electrical conductivity it simplifies
|
205 |
+
to the square root of ratio of magnetic permeability to
|
206 |
+
electric permittivity.
|
207 |
+
|
208 |
+
Examples
|
209 |
+
========
|
210 |
+
|
211 |
+
>>> from sympy.physics.optics import Medium
|
212 |
+
>>> m = Medium('m')
|
213 |
+
>>> m.intrinsic_impedance
|
214 |
+
149896229*pi*kilogram*meter**2/(1250000*ampere**2*second**3)
|
215 |
+
|
216 |
+
"""
|
217 |
+
return sqrt(self.permeability / self.permittivity)
|
218 |
+
|
219 |
+
@property
|
220 |
+
def permittivity(self):
|
221 |
+
"""
|
222 |
+
Returns electric permittivity of the medium.
|
223 |
+
|
224 |
+
Examples
|
225 |
+
========
|
226 |
+
|
227 |
+
>>> from sympy.physics.optics import Medium
|
228 |
+
>>> m = Medium('m')
|
229 |
+
>>> m.permittivity
|
230 |
+
625000*ampere**2*second**4/(22468879468420441*pi*kilogram*meter**3)
|
231 |
+
|
232 |
+
"""
|
233 |
+
return self.args[1]
|
234 |
+
|
235 |
+
@property
|
236 |
+
def permeability(self):
|
237 |
+
"""
|
238 |
+
Returns magnetic permeability of the medium.
|
239 |
+
|
240 |
+
Examples
|
241 |
+
========
|
242 |
+
|
243 |
+
>>> from sympy.physics.optics import Medium
|
244 |
+
>>> m = Medium('m')
|
245 |
+
>>> m.permeability
|
246 |
+
pi*kilogram*meter/(2500000*ampere**2*second**2)
|
247 |
+
|
248 |
+
"""
|
249 |
+
return self.args[2]
|
250 |
+
|
251 |
+
@property
|
252 |
+
def n(self):
|
253 |
+
return c*sqrt(self.permittivity*self.permeability)
|
venv/lib/python3.10/site-packages/sympy/physics/optics/polarization.py
ADDED
@@ -0,0 +1,732 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
"""
|
4 |
+
The module implements routines to model the polarization of optical fields
|
5 |
+
and can be used to calculate the effects of polarization optical elements on
|
6 |
+
the fields.
|
7 |
+
|
8 |
+
- Jones vectors.
|
9 |
+
|
10 |
+
- Stokes vectors.
|
11 |
+
|
12 |
+
- Jones matrices.
|
13 |
+
|
14 |
+
- Mueller matrices.
|
15 |
+
|
16 |
+
Examples
|
17 |
+
========
|
18 |
+
|
19 |
+
We calculate a generic Jones vector:
|
20 |
+
|
21 |
+
>>> from sympy import symbols, pprint, zeros, simplify
|
22 |
+
>>> from sympy.physics.optics.polarization import (jones_vector, stokes_vector,
|
23 |
+
... half_wave_retarder, polarizing_beam_splitter, jones_2_stokes)
|
24 |
+
|
25 |
+
>>> psi, chi, p, I0 = symbols("psi, chi, p, I0", real=True)
|
26 |
+
>>> x0 = jones_vector(psi, chi)
|
27 |
+
>>> pprint(x0, use_unicode=True)
|
28 |
+
⎡-ⅈ⋅sin(χ)⋅sin(ψ) + cos(χ)⋅cos(ψ)⎤
|
29 |
+
⎢ ⎥
|
30 |
+
⎣ⅈ⋅sin(χ)⋅cos(ψ) + sin(ψ)⋅cos(χ) ⎦
|
31 |
+
|
32 |
+
And the more general Stokes vector:
|
33 |
+
|
34 |
+
>>> s0 = stokes_vector(psi, chi, p, I0)
|
35 |
+
>>> pprint(s0, use_unicode=True)
|
36 |
+
⎡ I₀ ⎤
|
37 |
+
⎢ ⎥
|
38 |
+
⎢I₀⋅p⋅cos(2⋅χ)⋅cos(2⋅ψ)⎥
|
39 |
+
⎢ ⎥
|
40 |
+
⎢I₀⋅p⋅sin(2⋅ψ)⋅cos(2⋅χ)⎥
|
41 |
+
⎢ ⎥
|
42 |
+
⎣ I₀⋅p⋅sin(2⋅χ) ⎦
|
43 |
+
|
44 |
+
We calculate how the Jones vector is modified by a half-wave plate:
|
45 |
+
|
46 |
+
>>> alpha = symbols("alpha", real=True)
|
47 |
+
>>> HWP = half_wave_retarder(alpha)
|
48 |
+
>>> x1 = simplify(HWP*x0)
|
49 |
+
|
50 |
+
We calculate the very common operation of passing a beam through a half-wave
|
51 |
+
plate and then through a polarizing beam-splitter. We do this by putting this
|
52 |
+
Jones vector as the first entry of a two-Jones-vector state that is transformed
|
53 |
+
by a 4x4 Jones matrix modelling the polarizing beam-splitter to get the
|
54 |
+
transmitted and reflected Jones vectors:
|
55 |
+
|
56 |
+
>>> PBS = polarizing_beam_splitter()
|
57 |
+
>>> X1 = zeros(4, 1)
|
58 |
+
>>> X1[:2, :] = x1
|
59 |
+
>>> X2 = PBS*X1
|
60 |
+
>>> transmitted_port = X2[:2, :]
|
61 |
+
>>> reflected_port = X2[2:, :]
|
62 |
+
|
63 |
+
This allows us to calculate how the power in both ports depends on the initial
|
64 |
+
polarization:
|
65 |
+
|
66 |
+
>>> transmitted_power = jones_2_stokes(transmitted_port)[0]
|
67 |
+
>>> reflected_power = jones_2_stokes(reflected_port)[0]
|
68 |
+
>>> print(transmitted_power)
|
69 |
+
cos(-2*alpha + chi + psi)**2/2 + cos(2*alpha + chi - psi)**2/2
|
70 |
+
|
71 |
+
|
72 |
+
>>> print(reflected_power)
|
73 |
+
sin(-2*alpha + chi + psi)**2/2 + sin(2*alpha + chi - psi)**2/2
|
74 |
+
|
75 |
+
Please see the description of the individual functions for further
|
76 |
+
details and examples.
|
77 |
+
|
78 |
+
References
|
79 |
+
==========
|
80 |
+
|
81 |
+
.. [1] https://en.wikipedia.org/wiki/Jones_calculus
|
82 |
+
.. [2] https://en.wikipedia.org/wiki/Mueller_calculus
|
83 |
+
.. [3] https://en.wikipedia.org/wiki/Stokes_parameters
|
84 |
+
|
85 |
+
"""
|
86 |
+
|
87 |
+
from sympy.core.numbers import (I, pi)
|
88 |
+
from sympy.functions.elementary.complexes import (Abs, im, re)
|
89 |
+
from sympy.functions.elementary.exponential import exp
|
90 |
+
from sympy.functions.elementary.miscellaneous import sqrt
|
91 |
+
from sympy.functions.elementary.trigonometric import (cos, sin)
|
92 |
+
from sympy.matrices.dense import Matrix
|
93 |
+
from sympy.simplify.simplify import simplify
|
94 |
+
from sympy.physics.quantum import TensorProduct
|
95 |
+
|
96 |
+
|
97 |
+
def jones_vector(psi, chi):
|
98 |
+
"""A Jones vector corresponding to a polarization ellipse with `psi` tilt,
|
99 |
+
and `chi` circularity.
|
100 |
+
|
101 |
+
Parameters
|
102 |
+
==========
|
103 |
+
|
104 |
+
psi : numeric type or SymPy Symbol
|
105 |
+
The tilt of the polarization relative to the `x` axis.
|
106 |
+
|
107 |
+
chi : numeric type or SymPy Symbol
|
108 |
+
The angle adjacent to the mayor axis of the polarization ellipse.
|
109 |
+
|
110 |
+
|
111 |
+
Returns
|
112 |
+
=======
|
113 |
+
|
114 |
+
Matrix :
|
115 |
+
A Jones vector.
|
116 |
+
|
117 |
+
Examples
|
118 |
+
========
|
119 |
+
|
120 |
+
The axes on the Poincaré sphere.
|
121 |
+
|
122 |
+
>>> from sympy import pprint, symbols, pi
|
123 |
+
>>> from sympy.physics.optics.polarization import jones_vector
|
124 |
+
>>> psi, chi = symbols("psi, chi", real=True)
|
125 |
+
|
126 |
+
A general Jones vector.
|
127 |
+
|
128 |
+
>>> pprint(jones_vector(psi, chi), use_unicode=True)
|
129 |
+
⎡-ⅈ⋅sin(χ)⋅sin(ψ) + cos(χ)⋅cos(ψ)⎤
|
130 |
+
⎢ ⎥
|
131 |
+
⎣ⅈ⋅sin(χ)⋅cos(ψ) + sin(ψ)⋅cos(χ) ⎦
|
132 |
+
|
133 |
+
Horizontal polarization.
|
134 |
+
|
135 |
+
>>> pprint(jones_vector(0, 0), use_unicode=True)
|
136 |
+
⎡1⎤
|
137 |
+
⎢ ⎥
|
138 |
+
⎣0⎦
|
139 |
+
|
140 |
+
Vertical polarization.
|
141 |
+
|
142 |
+
>>> pprint(jones_vector(pi/2, 0), use_unicode=True)
|
143 |
+
⎡0⎤
|
144 |
+
⎢ ⎥
|
145 |
+
⎣1⎦
|
146 |
+
|
147 |
+
Diagonal polarization.
|
148 |
+
|
149 |
+
>>> pprint(jones_vector(pi/4, 0), use_unicode=True)
|
150 |
+
⎡√2⎤
|
151 |
+
⎢──⎥
|
152 |
+
⎢2 ⎥
|
153 |
+
⎢ ⎥
|
154 |
+
⎢√2⎥
|
155 |
+
⎢──⎥
|
156 |
+
⎣2 ⎦
|
157 |
+
|
158 |
+
Anti-diagonal polarization.
|
159 |
+
|
160 |
+
>>> pprint(jones_vector(-pi/4, 0), use_unicode=True)
|
161 |
+
⎡ √2 ⎤
|
162 |
+
⎢ ── ⎥
|
163 |
+
⎢ 2 ⎥
|
164 |
+
⎢ ⎥
|
165 |
+
⎢-√2 ⎥
|
166 |
+
⎢────⎥
|
167 |
+
⎣ 2 ⎦
|
168 |
+
|
169 |
+
Right-hand circular polarization.
|
170 |
+
|
171 |
+
>>> pprint(jones_vector(0, pi/4), use_unicode=True)
|
172 |
+
⎡ √2 ⎤
|
173 |
+
⎢ ── ⎥
|
174 |
+
⎢ 2 ⎥
|
175 |
+
⎢ ⎥
|
176 |
+
⎢√2⋅ⅈ⎥
|
177 |
+
⎢────⎥
|
178 |
+
⎣ 2 ⎦
|
179 |
+
|
180 |
+
Left-hand circular polarization.
|
181 |
+
|
182 |
+
>>> pprint(jones_vector(0, -pi/4), use_unicode=True)
|
183 |
+
⎡ √2 ⎤
|
184 |
+
⎢ ── ⎥
|
185 |
+
⎢ 2 ⎥
|
186 |
+
⎢ ⎥
|
187 |
+
⎢-√2⋅ⅈ ⎥
|
188 |
+
⎢──────⎥
|
189 |
+
⎣ 2 ⎦
|
190 |
+
|
191 |
+
"""
|
192 |
+
return Matrix([-I*sin(chi)*sin(psi) + cos(chi)*cos(psi),
|
193 |
+
I*sin(chi)*cos(psi) + sin(psi)*cos(chi)])
|
194 |
+
|
195 |
+
|
196 |
+
def stokes_vector(psi, chi, p=1, I=1):
|
197 |
+
"""A Stokes vector corresponding to a polarization ellipse with ``psi``
|
198 |
+
tilt, and ``chi`` circularity.
|
199 |
+
|
200 |
+
Parameters
|
201 |
+
==========
|
202 |
+
|
203 |
+
psi : numeric type or SymPy Symbol
|
204 |
+
The tilt of the polarization relative to the ``x`` axis.
|
205 |
+
chi : numeric type or SymPy Symbol
|
206 |
+
The angle adjacent to the mayor axis of the polarization ellipse.
|
207 |
+
p : numeric type or SymPy Symbol
|
208 |
+
The degree of polarization.
|
209 |
+
I : numeric type or SymPy Symbol
|
210 |
+
The intensity of the field.
|
211 |
+
|
212 |
+
|
213 |
+
Returns
|
214 |
+
=======
|
215 |
+
|
216 |
+
Matrix :
|
217 |
+
A Stokes vector.
|
218 |
+
|
219 |
+
Examples
|
220 |
+
========
|
221 |
+
|
222 |
+
The axes on the Poincaré sphere.
|
223 |
+
|
224 |
+
>>> from sympy import pprint, symbols, pi
|
225 |
+
>>> from sympy.physics.optics.polarization import stokes_vector
|
226 |
+
>>> psi, chi, p, I = symbols("psi, chi, p, I", real=True)
|
227 |
+
>>> pprint(stokes_vector(psi, chi, p, I), use_unicode=True)
|
228 |
+
⎡ I ⎤
|
229 |
+
⎢ ⎥
|
230 |
+
⎢I⋅p⋅cos(2⋅χ)⋅cos(2⋅ψ)⎥
|
231 |
+
⎢ ⎥
|
232 |
+
⎢I⋅p⋅sin(2⋅ψ)⋅cos(2⋅χ)⎥
|
233 |
+
⎢ ⎥
|
234 |
+
⎣ I⋅p⋅sin(2⋅χ) ⎦
|
235 |
+
|
236 |
+
|
237 |
+
Horizontal polarization
|
238 |
+
|
239 |
+
>>> pprint(stokes_vector(0, 0), use_unicode=True)
|
240 |
+
⎡1⎤
|
241 |
+
⎢ ⎥
|
242 |
+
⎢1⎥
|
243 |
+
⎢ ⎥
|
244 |
+
⎢0⎥
|
245 |
+
⎢ ⎥
|
246 |
+
⎣0⎦
|
247 |
+
|
248 |
+
Vertical polarization
|
249 |
+
|
250 |
+
>>> pprint(stokes_vector(pi/2, 0), use_unicode=True)
|
251 |
+
⎡1 ⎤
|
252 |
+
⎢ ⎥
|
253 |
+
⎢-1⎥
|
254 |
+
⎢ ⎥
|
255 |
+
⎢0 ⎥
|
256 |
+
⎢ ⎥
|
257 |
+
⎣0 ⎦
|
258 |
+
|
259 |
+
Diagonal polarization
|
260 |
+
|
261 |
+
>>> pprint(stokes_vector(pi/4, 0), use_unicode=True)
|
262 |
+
⎡1⎤
|
263 |
+
⎢ ⎥
|
264 |
+
⎢0⎥
|
265 |
+
⎢ ⎥
|
266 |
+
⎢1⎥
|
267 |
+
⎢ ⎥
|
268 |
+
⎣0⎦
|
269 |
+
|
270 |
+
Anti-diagonal polarization
|
271 |
+
|
272 |
+
>>> pprint(stokes_vector(-pi/4, 0), use_unicode=True)
|
273 |
+
⎡1 ⎤
|
274 |
+
⎢ ⎥
|
275 |
+
⎢0 ⎥
|
276 |
+
⎢ ⎥
|
277 |
+
⎢-1⎥
|
278 |
+
⎢ ⎥
|
279 |
+
⎣0 ⎦
|
280 |
+
|
281 |
+
Right-hand circular polarization
|
282 |
+
|
283 |
+
>>> pprint(stokes_vector(0, pi/4), use_unicode=True)
|
284 |
+
⎡1⎤
|
285 |
+
⎢ ⎥
|
286 |
+
⎢0⎥
|
287 |
+
⎢ ⎥
|
288 |
+
⎢0⎥
|
289 |
+
⎢ ⎥
|
290 |
+
⎣1⎦
|
291 |
+
|
292 |
+
Left-hand circular polarization
|
293 |
+
|
294 |
+
>>> pprint(stokes_vector(0, -pi/4), use_unicode=True)
|
295 |
+
⎡1 ⎤
|
296 |
+
⎢ ⎥
|
297 |
+
⎢0 ⎥
|
298 |
+
⎢ ⎥
|
299 |
+
⎢0 ⎥
|
300 |
+
⎢ ⎥
|
301 |
+
⎣-1⎦
|
302 |
+
|
303 |
+
Unpolarized light
|
304 |
+
|
305 |
+
>>> pprint(stokes_vector(0, 0, 0), use_unicode=True)
|
306 |
+
⎡1⎤
|
307 |
+
⎢ ⎥
|
308 |
+
⎢0⎥
|
309 |
+
⎢ ⎥
|
310 |
+
⎢0⎥
|
311 |
+
⎢ ⎥
|
312 |
+
⎣0⎦
|
313 |
+
|
314 |
+
"""
|
315 |
+
S0 = I
|
316 |
+
S1 = I*p*cos(2*psi)*cos(2*chi)
|
317 |
+
S2 = I*p*sin(2*psi)*cos(2*chi)
|
318 |
+
S3 = I*p*sin(2*chi)
|
319 |
+
return Matrix([S0, S1, S2, S3])
|
320 |
+
|
321 |
+
|
322 |
+
def jones_2_stokes(e):
|
323 |
+
"""Return the Stokes vector for a Jones vector ``e``.
|
324 |
+
|
325 |
+
Parameters
|
326 |
+
==========
|
327 |
+
|
328 |
+
e : SymPy Matrix
|
329 |
+
A Jones vector.
|
330 |
+
|
331 |
+
Returns
|
332 |
+
=======
|
333 |
+
|
334 |
+
SymPy Matrix
|
335 |
+
A Jones vector.
|
336 |
+
|
337 |
+
Examples
|
338 |
+
========
|
339 |
+
|
340 |
+
The axes on the Poincaré sphere.
|
341 |
+
|
342 |
+
>>> from sympy import pprint, pi
|
343 |
+
>>> from sympy.physics.optics.polarization import jones_vector
|
344 |
+
>>> from sympy.physics.optics.polarization import jones_2_stokes
|
345 |
+
>>> H = jones_vector(0, 0)
|
346 |
+
>>> V = jones_vector(pi/2, 0)
|
347 |
+
>>> D = jones_vector(pi/4, 0)
|
348 |
+
>>> A = jones_vector(-pi/4, 0)
|
349 |
+
>>> R = jones_vector(0, pi/4)
|
350 |
+
>>> L = jones_vector(0, -pi/4)
|
351 |
+
>>> pprint([jones_2_stokes(e) for e in [H, V, D, A, R, L]],
|
352 |
+
... use_unicode=True)
|
353 |
+
⎡⎡1⎤ ⎡1 ⎤ ⎡1⎤ ⎡1 ⎤ ⎡1⎤ ⎡1 ⎤⎤
|
354 |
+
⎢⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎥
|
355 |
+
⎢⎢1⎥ ⎢-1⎥ ⎢0⎥ ⎢0 ⎥ ⎢0⎥ ⎢0 ⎥⎥
|
356 |
+
⎢⎢ ⎥, ⎢ ⎥, ⎢ ⎥, ⎢ ⎥, ⎢ ⎥, ⎢ ⎥⎥
|
357 |
+
⎢⎢0⎥ ⎢0 ⎥ ⎢1⎥ ⎢-1⎥ ⎢0⎥ ⎢0 ⎥⎥
|
358 |
+
⎢⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎥
|
359 |
+
⎣⎣0⎦ ⎣0 ⎦ ⎣0⎦ ⎣0 ⎦ ⎣1⎦ ⎣-1⎦⎦
|
360 |
+
|
361 |
+
"""
|
362 |
+
ex, ey = e
|
363 |
+
return Matrix([Abs(ex)**2 + Abs(ey)**2,
|
364 |
+
Abs(ex)**2 - Abs(ey)**2,
|
365 |
+
2*re(ex*ey.conjugate()),
|
366 |
+
-2*im(ex*ey.conjugate())])
|
367 |
+
|
368 |
+
|
369 |
+
def linear_polarizer(theta=0):
|
370 |
+
"""A linear polarizer Jones matrix with transmission axis at
|
371 |
+
an angle ``theta``.
|
372 |
+
|
373 |
+
Parameters
|
374 |
+
==========
|
375 |
+
|
376 |
+
theta : numeric type or SymPy Symbol
|
377 |
+
The angle of the transmission axis relative to the horizontal plane.
|
378 |
+
|
379 |
+
Returns
|
380 |
+
=======
|
381 |
+
|
382 |
+
SymPy Matrix
|
383 |
+
A Jones matrix representing the polarizer.
|
384 |
+
|
385 |
+
Examples
|
386 |
+
========
|
387 |
+
|
388 |
+
A generic polarizer.
|
389 |
+
|
390 |
+
>>> from sympy import pprint, symbols
|
391 |
+
>>> from sympy.physics.optics.polarization import linear_polarizer
|
392 |
+
>>> theta = symbols("theta", real=True)
|
393 |
+
>>> J = linear_polarizer(theta)
|
394 |
+
>>> pprint(J, use_unicode=True)
|
395 |
+
⎡ 2 ⎤
|
396 |
+
⎢ cos (θ) sin(θ)⋅cos(θ)⎥
|
397 |
+
⎢ ⎥
|
398 |
+
⎢ 2 ⎥
|
399 |
+
⎣sin(θ)⋅cos(θ) sin (θ) ⎦
|
400 |
+
|
401 |
+
|
402 |
+
"""
|
403 |
+
M = Matrix([[cos(theta)**2, sin(theta)*cos(theta)],
|
404 |
+
[sin(theta)*cos(theta), sin(theta)**2]])
|
405 |
+
return M
|
406 |
+
|
407 |
+
|
408 |
+
def phase_retarder(theta=0, delta=0):
|
409 |
+
"""A phase retarder Jones matrix with retardance ``delta`` at angle ``theta``.
|
410 |
+
|
411 |
+
Parameters
|
412 |
+
==========
|
413 |
+
|
414 |
+
theta : numeric type or SymPy Symbol
|
415 |
+
The angle of the fast axis relative to the horizontal plane.
|
416 |
+
delta : numeric type or SymPy Symbol
|
417 |
+
The phase difference between the fast and slow axes of the
|
418 |
+
transmitted light.
|
419 |
+
|
420 |
+
Returns
|
421 |
+
=======
|
422 |
+
|
423 |
+
SymPy Matrix :
|
424 |
+
A Jones matrix representing the retarder.
|
425 |
+
|
426 |
+
Examples
|
427 |
+
========
|
428 |
+
|
429 |
+
A generic retarder.
|
430 |
+
|
431 |
+
>>> from sympy import pprint, symbols
|
432 |
+
>>> from sympy.physics.optics.polarization import phase_retarder
|
433 |
+
>>> theta, delta = symbols("theta, delta", real=True)
|
434 |
+
>>> R = phase_retarder(theta, delta)
|
435 |
+
>>> pprint(R, use_unicode=True)
|
436 |
+
⎡ -ⅈ⋅δ -ⅈ⋅δ ⎤
|
437 |
+
⎢ ───── ───── ⎥
|
438 |
+
⎢⎛ ⅈ⋅δ 2 2 ⎞ 2 ⎛ ⅈ⋅δ⎞ 2 ⎥
|
439 |
+
⎢⎝ℯ ⋅sin (θ) + cos (θ)⎠⋅ℯ ⎝1 - ℯ ⎠⋅ℯ ⋅sin(θ)⋅cos(θ)⎥
|
440 |
+
⎢ ⎥
|
441 |
+
⎢ -ⅈ⋅δ -ⅈ⋅δ ⎥
|
442 |
+
⎢ ───── ─────⎥
|
443 |
+
⎢⎛ ⅈ⋅δ⎞ 2 ⎛ ⅈ⋅δ 2 2 ⎞ 2 ⎥
|
444 |
+
⎣⎝1 - ℯ ⎠⋅ℯ ⋅sin(θ)⋅cos(θ) ⎝ℯ ⋅cos (θ) + sin (θ)⎠⋅ℯ ⎦
|
445 |
+
|
446 |
+
"""
|
447 |
+
R = Matrix([[cos(theta)**2 + exp(I*delta)*sin(theta)**2,
|
448 |
+
(1-exp(I*delta))*cos(theta)*sin(theta)],
|
449 |
+
[(1-exp(I*delta))*cos(theta)*sin(theta),
|
450 |
+
sin(theta)**2 + exp(I*delta)*cos(theta)**2]])
|
451 |
+
return R*exp(-I*delta/2)
|
452 |
+
|
453 |
+
|
454 |
+
def half_wave_retarder(theta):
|
455 |
+
"""A half-wave retarder Jones matrix at angle ``theta``.
|
456 |
+
|
457 |
+
Parameters
|
458 |
+
==========
|
459 |
+
|
460 |
+
theta : numeric type or SymPy Symbol
|
461 |
+
The angle of the fast axis relative to the horizontal plane.
|
462 |
+
|
463 |
+
Returns
|
464 |
+
=======
|
465 |
+
|
466 |
+
SymPy Matrix
|
467 |
+
A Jones matrix representing the retarder.
|
468 |
+
|
469 |
+
Examples
|
470 |
+
========
|
471 |
+
|
472 |
+
A generic half-wave plate.
|
473 |
+
|
474 |
+
>>> from sympy import pprint, symbols
|
475 |
+
>>> from sympy.physics.optics.polarization import half_wave_retarder
|
476 |
+
>>> theta= symbols("theta", real=True)
|
477 |
+
>>> HWP = half_wave_retarder(theta)
|
478 |
+
>>> pprint(HWP, use_unicode=True)
|
479 |
+
⎡ ⎛ 2 2 ⎞ ⎤
|
480 |
+
⎢-ⅈ⋅⎝- sin (θ) + cos (θ)⎠ -2⋅ⅈ⋅sin(θ)⋅cos(θ) ⎥
|
481 |
+
⎢ ⎥
|
482 |
+
⎢ ⎛ 2 2 ⎞⎥
|
483 |
+
⎣ -2⋅ⅈ⋅sin(θ)⋅cos(θ) -ⅈ⋅⎝sin (θ) - cos (θ)⎠⎦
|
484 |
+
|
485 |
+
"""
|
486 |
+
return phase_retarder(theta, pi)
|
487 |
+
|
488 |
+
|
489 |
+
def quarter_wave_retarder(theta):
|
490 |
+
"""A quarter-wave retarder Jones matrix at angle ``theta``.
|
491 |
+
|
492 |
+
Parameters
|
493 |
+
==========
|
494 |
+
|
495 |
+
theta : numeric type or SymPy Symbol
|
496 |
+
The angle of the fast axis relative to the horizontal plane.
|
497 |
+
|
498 |
+
Returns
|
499 |
+
=======
|
500 |
+
|
501 |
+
SymPy Matrix
|
502 |
+
A Jones matrix representing the retarder.
|
503 |
+
|
504 |
+
Examples
|
505 |
+
========
|
506 |
+
|
507 |
+
A generic quarter-wave plate.
|
508 |
+
|
509 |
+
>>> from sympy import pprint, symbols
|
510 |
+
>>> from sympy.physics.optics.polarization import quarter_wave_retarder
|
511 |
+
>>> theta= symbols("theta", real=True)
|
512 |
+
>>> QWP = quarter_wave_retarder(theta)
|
513 |
+
>>> pprint(QWP, use_unicode=True)
|
514 |
+
⎡ -ⅈ⋅π -ⅈ⋅π ⎤
|
515 |
+
⎢ ───── ───── ⎥
|
516 |
+
⎢⎛ 2 2 ⎞ 4 4 ⎥
|
517 |
+
⎢⎝ⅈ⋅sin (θ) + cos (θ)⎠⋅ℯ (1 - ⅈ)⋅ℯ ⋅sin(θ)⋅cos(θ)⎥
|
518 |
+
⎢ ⎥
|
519 |
+
⎢ -ⅈ⋅π -ⅈ⋅π ⎥
|
520 |
+
⎢ ───── ─────⎥
|
521 |
+
⎢ 4 ⎛ 2 2 ⎞ 4 ⎥
|
522 |
+
⎣(1 - ⅈ)⋅ℯ ⋅sin(θ)⋅cos(θ) ⎝sin (θ) + ⅈ⋅cos (θ)⎠⋅ℯ ⎦
|
523 |
+
|
524 |
+
"""
|
525 |
+
return phase_retarder(theta, pi/2)
|
526 |
+
|
527 |
+
|
528 |
+
def transmissive_filter(T):
|
529 |
+
"""An attenuator Jones matrix with transmittance ``T``.
|
530 |
+
|
531 |
+
Parameters
|
532 |
+
==========
|
533 |
+
|
534 |
+
T : numeric type or SymPy Symbol
|
535 |
+
The transmittance of the attenuator.
|
536 |
+
|
537 |
+
Returns
|
538 |
+
=======
|
539 |
+
|
540 |
+
SymPy Matrix
|
541 |
+
A Jones matrix representing the filter.
|
542 |
+
|
543 |
+
Examples
|
544 |
+
========
|
545 |
+
|
546 |
+
A generic filter.
|
547 |
+
|
548 |
+
>>> from sympy import pprint, symbols
|
549 |
+
>>> from sympy.physics.optics.polarization import transmissive_filter
|
550 |
+
>>> T = symbols("T", real=True)
|
551 |
+
>>> NDF = transmissive_filter(T)
|
552 |
+
>>> pprint(NDF, use_unicode=True)
|
553 |
+
⎡√T 0 ⎤
|
554 |
+
⎢ ⎥
|
555 |
+
⎣0 √T⎦
|
556 |
+
|
557 |
+
"""
|
558 |
+
return Matrix([[sqrt(T), 0], [0, sqrt(T)]])
|
559 |
+
|
560 |
+
|
561 |
+
def reflective_filter(R):
|
562 |
+
"""A reflective filter Jones matrix with reflectance ``R``.
|
563 |
+
|
564 |
+
Parameters
|
565 |
+
==========
|
566 |
+
|
567 |
+
R : numeric type or SymPy Symbol
|
568 |
+
The reflectance of the filter.
|
569 |
+
|
570 |
+
Returns
|
571 |
+
=======
|
572 |
+
|
573 |
+
SymPy Matrix
|
574 |
+
A Jones matrix representing the filter.
|
575 |
+
|
576 |
+
Examples
|
577 |
+
========
|
578 |
+
|
579 |
+
A generic filter.
|
580 |
+
|
581 |
+
>>> from sympy import pprint, symbols
|
582 |
+
>>> from sympy.physics.optics.polarization import reflective_filter
|
583 |
+
>>> R = symbols("R", real=True)
|
584 |
+
>>> pprint(reflective_filter(R), use_unicode=True)
|
585 |
+
⎡√R 0 ⎤
|
586 |
+
⎢ ⎥
|
587 |
+
⎣0 -√R⎦
|
588 |
+
|
589 |
+
"""
|
590 |
+
return Matrix([[sqrt(R), 0], [0, -sqrt(R)]])
|
591 |
+
|
592 |
+
|
593 |
+
def mueller_matrix(J):
|
594 |
+
"""The Mueller matrix corresponding to Jones matrix `J`.
|
595 |
+
|
596 |
+
Parameters
|
597 |
+
==========
|
598 |
+
|
599 |
+
J : SymPy Matrix
|
600 |
+
A Jones matrix.
|
601 |
+
|
602 |
+
Returns
|
603 |
+
=======
|
604 |
+
|
605 |
+
SymPy Matrix
|
606 |
+
The corresponding Mueller matrix.
|
607 |
+
|
608 |
+
Examples
|
609 |
+
========
|
610 |
+
|
611 |
+
Generic optical components.
|
612 |
+
|
613 |
+
>>> from sympy import pprint, symbols
|
614 |
+
>>> from sympy.physics.optics.polarization import (mueller_matrix,
|
615 |
+
... linear_polarizer, half_wave_retarder, quarter_wave_retarder)
|
616 |
+
>>> theta = symbols("theta", real=True)
|
617 |
+
|
618 |
+
A linear_polarizer
|
619 |
+
|
620 |
+
>>> pprint(mueller_matrix(linear_polarizer(theta)), use_unicode=True)
|
621 |
+
⎡ cos(2⋅θ) sin(2⋅θ) ⎤
|
622 |
+
⎢ 1/2 ──────── ──────── 0⎥
|
623 |
+
⎢ 2 2 ⎥
|
624 |
+
⎢ ⎥
|
625 |
+
⎢cos(2⋅θ) cos(4⋅θ) 1 sin(4⋅θ) ⎥
|
626 |
+
⎢──────── ──────── + ─ ──────── 0⎥
|
627 |
+
⎢ 2 4 4 4 ⎥
|
628 |
+
⎢ ⎥
|
629 |
+
⎢sin(2⋅θ) sin(4⋅θ) 1 cos(4⋅θ) ⎥
|
630 |
+
⎢──────── ──────── ─ - ──────── 0⎥
|
631 |
+
⎢ 2 4 4 4 ⎥
|
632 |
+
⎢ ⎥
|
633 |
+
⎣ 0 0 0 0⎦
|
634 |
+
|
635 |
+
A half-wave plate
|
636 |
+
|
637 |
+
>>> pprint(mueller_matrix(half_wave_retarder(theta)), use_unicode=True)
|
638 |
+
⎡1 0 0 0 ⎤
|
639 |
+
⎢ ⎥
|
640 |
+
⎢ 4 2 ⎥
|
641 |
+
⎢0 8⋅sin (θ) - 8⋅sin (θ) + 1 sin(4⋅θ) 0 ⎥
|
642 |
+
⎢ ⎥
|
643 |
+
⎢ 4 2 ⎥
|
644 |
+
⎢0 sin(4⋅θ) - 8⋅sin (θ) + 8⋅sin (θ) - 1 0 ⎥
|
645 |
+
⎢ ⎥
|
646 |
+
⎣0 0 0 -1⎦
|
647 |
+
|
648 |
+
A quarter-wave plate
|
649 |
+
|
650 |
+
>>> pprint(mueller_matrix(quarter_wave_retarder(theta)), use_unicode=True)
|
651 |
+
⎡1 0 0 0 ⎤
|
652 |
+
⎢ ⎥
|
653 |
+
⎢ cos(4⋅θ) 1 sin(4⋅θ) ⎥
|
654 |
+
⎢0 ──────── + ─ ──────── -sin(2⋅θ)⎥
|
655 |
+
⎢ 2 2 2 ⎥
|
656 |
+
⎢ ⎥
|
657 |
+
⎢ sin(4⋅θ) 1 cos(4⋅θ) ⎥
|
658 |
+
⎢0 ──────── ─ - ──────── cos(2⋅θ) ⎥
|
659 |
+
⎢ 2 2 2 ⎥
|
660 |
+
⎢ ⎥
|
661 |
+
⎣0 sin(2⋅θ) -cos(2⋅θ) 0 ⎦
|
662 |
+
|
663 |
+
"""
|
664 |
+
A = Matrix([[1, 0, 0, 1],
|
665 |
+
[1, 0, 0, -1],
|
666 |
+
[0, 1, 1, 0],
|
667 |
+
[0, -I, I, 0]])
|
668 |
+
|
669 |
+
return simplify(A*TensorProduct(J, J.conjugate())*A.inv())
|
670 |
+
|
671 |
+
|
672 |
+
def polarizing_beam_splitter(Tp=1, Rs=1, Ts=0, Rp=0, phia=0, phib=0):
|
673 |
+
r"""A polarizing beam splitter Jones matrix at angle `theta`.
|
674 |
+
|
675 |
+
Parameters
|
676 |
+
==========
|
677 |
+
|
678 |
+
J : SymPy Matrix
|
679 |
+
A Jones matrix.
|
680 |
+
Tp : numeric type or SymPy Symbol
|
681 |
+
The transmissivity of the P-polarized component.
|
682 |
+
Rs : numeric type or SymPy Symbol
|
683 |
+
The reflectivity of the S-polarized component.
|
684 |
+
Ts : numeric type or SymPy Symbol
|
685 |
+
The transmissivity of the S-polarized component.
|
686 |
+
Rp : numeric type or SymPy Symbol
|
687 |
+
The reflectivity of the P-polarized component.
|
688 |
+
phia : numeric type or SymPy Symbol
|
689 |
+
The phase difference between transmitted and reflected component for
|
690 |
+
output mode a.
|
691 |
+
phib : numeric type or SymPy Symbol
|
692 |
+
The phase difference between transmitted and reflected component for
|
693 |
+
output mode b.
|
694 |
+
|
695 |
+
|
696 |
+
Returns
|
697 |
+
=======
|
698 |
+
|
699 |
+
SymPy Matrix
|
700 |
+
A 4x4 matrix representing the PBS. This matrix acts on a 4x1 vector
|
701 |
+
whose first two entries are the Jones vector on one of the PBS ports,
|
702 |
+
and the last two entries the Jones vector on the other port.
|
703 |
+
|
704 |
+
Examples
|
705 |
+
========
|
706 |
+
|
707 |
+
Generic polarizing beam-splitter.
|
708 |
+
|
709 |
+
>>> from sympy import pprint, symbols
|
710 |
+
>>> from sympy.physics.optics.polarization import polarizing_beam_splitter
|
711 |
+
>>> Ts, Rs, Tp, Rp = symbols(r"Ts, Rs, Tp, Rp", positive=True)
|
712 |
+
>>> phia, phib = symbols("phi_a, phi_b", real=True)
|
713 |
+
>>> PBS = polarizing_beam_splitter(Tp, Rs, Ts, Rp, phia, phib)
|
714 |
+
>>> pprint(PBS, use_unicode=False)
|
715 |
+
[ ____ ____ ]
|
716 |
+
[ \/ Tp 0 I*\/ Rp 0 ]
|
717 |
+
[ ]
|
718 |
+
[ ____ ____ I*phi_a]
|
719 |
+
[ 0 \/ Ts 0 -I*\/ Rs *e ]
|
720 |
+
[ ]
|
721 |
+
[ ____ ____ ]
|
722 |
+
[I*\/ Rp 0 \/ Tp 0 ]
|
723 |
+
[ ]
|
724 |
+
[ ____ I*phi_b ____ ]
|
725 |
+
[ 0 -I*\/ Rs *e 0 \/ Ts ]
|
726 |
+
|
727 |
+
"""
|
728 |
+
PBS = Matrix([[sqrt(Tp), 0, I*sqrt(Rp), 0],
|
729 |
+
[0, sqrt(Ts), 0, -I*sqrt(Rs)*exp(I*phia)],
|
730 |
+
[I*sqrt(Rp), 0, sqrt(Tp), 0],
|
731 |
+
[0, -I*sqrt(Rs)*exp(I*phib), 0, sqrt(Ts)]])
|
732 |
+
return PBS
|
venv/lib/python3.10/site-packages/sympy/physics/optics/tests/__init__.py
ADDED
File without changes
|
venv/lib/python3.10/site-packages/sympy/physics/optics/tests/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (194 Bytes). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/optics/tests/__pycache__/test_gaussopt.cpython-310.pyc
ADDED
Binary file (4.11 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/optics/tests/__pycache__/test_medium.cpython-310.pyc
ADDED
Binary file (2.17 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/optics/tests/__pycache__/test_polarization.cpython-310.pyc
ADDED
Binary file (2.22 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/optics/tests/test_gaussopt.py
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from sympy.core.evalf import N
|
2 |
+
from sympy.core.numbers import (Float, I, oo, pi)
|
3 |
+
from sympy.core.symbol import symbols
|
4 |
+
from sympy.functions.elementary.miscellaneous import sqrt
|
5 |
+
from sympy.functions.elementary.trigonometric import atan2
|
6 |
+
from sympy.matrices.dense import Matrix
|
7 |
+
from sympy.polys.polytools import factor
|
8 |
+
|
9 |
+
from sympy.physics.optics import (BeamParameter, CurvedMirror,
|
10 |
+
CurvedRefraction, FlatMirror, FlatRefraction, FreeSpace, GeometricRay,
|
11 |
+
RayTransferMatrix, ThinLens, conjugate_gauss_beams,
|
12 |
+
gaussian_conj, geometric_conj_ab, geometric_conj_af, geometric_conj_bf,
|
13 |
+
rayleigh2waist, waist2rayleigh)
|
14 |
+
|
15 |
+
|
16 |
+
def streq(a, b):
|
17 |
+
return str(a) == str(b)
|
18 |
+
|
19 |
+
|
20 |
+
def test_gauss_opt():
|
21 |
+
mat = RayTransferMatrix(1, 2, 3, 4)
|
22 |
+
assert mat == Matrix([[1, 2], [3, 4]])
|
23 |
+
assert mat == RayTransferMatrix( Matrix([[1, 2], [3, 4]]) )
|
24 |
+
assert [mat.A, mat.B, mat.C, mat.D] == [1, 2, 3, 4]
|
25 |
+
|
26 |
+
d, f, h, n1, n2, R = symbols('d f h n1 n2 R')
|
27 |
+
lens = ThinLens(f)
|
28 |
+
assert lens == Matrix([[ 1, 0], [-1/f, 1]])
|
29 |
+
assert lens.C == -1/f
|
30 |
+
assert FreeSpace(d) == Matrix([[ 1, d], [0, 1]])
|
31 |
+
assert FlatRefraction(n1, n2) == Matrix([[1, 0], [0, n1/n2]])
|
32 |
+
assert CurvedRefraction(
|
33 |
+
R, n1, n2) == Matrix([[1, 0], [(n1 - n2)/(R*n2), n1/n2]])
|
34 |
+
assert FlatMirror() == Matrix([[1, 0], [0, 1]])
|
35 |
+
assert CurvedMirror(R) == Matrix([[ 1, 0], [-2/R, 1]])
|
36 |
+
assert ThinLens(f) == Matrix([[ 1, 0], [-1/f, 1]])
|
37 |
+
|
38 |
+
mul = CurvedMirror(R)*FreeSpace(d)
|
39 |
+
mul_mat = Matrix([[ 1, 0], [-2/R, 1]])*Matrix([[ 1, d], [0, 1]])
|
40 |
+
assert mul.A == mul_mat[0, 0]
|
41 |
+
assert mul.B == mul_mat[0, 1]
|
42 |
+
assert mul.C == mul_mat[1, 0]
|
43 |
+
assert mul.D == mul_mat[1, 1]
|
44 |
+
|
45 |
+
angle = symbols('angle')
|
46 |
+
assert GeometricRay(h, angle) == Matrix([[ h], [angle]])
|
47 |
+
assert FreeSpace(
|
48 |
+
d)*GeometricRay(h, angle) == Matrix([[angle*d + h], [angle]])
|
49 |
+
assert GeometricRay( Matrix( ((h,), (angle,)) ) ) == Matrix([[h], [angle]])
|
50 |
+
assert (FreeSpace(d)*GeometricRay(h, angle)).height == angle*d + h
|
51 |
+
assert (FreeSpace(d)*GeometricRay(h, angle)).angle == angle
|
52 |
+
|
53 |
+
p = BeamParameter(530e-9, 1, w=1e-3)
|
54 |
+
assert streq(p.q, 1 + 1.88679245283019*I*pi)
|
55 |
+
assert streq(N(p.q), 1.0 + 5.92753330865999*I)
|
56 |
+
assert streq(N(p.w_0), Float(0.00100000000000000))
|
57 |
+
assert streq(N(p.z_r), Float(5.92753330865999))
|
58 |
+
fs = FreeSpace(10)
|
59 |
+
p1 = fs*p
|
60 |
+
assert streq(N(p.w), Float(0.00101413072159615))
|
61 |
+
assert streq(N(p1.w), Float(0.00210803120913829))
|
62 |
+
|
63 |
+
w, wavelen = symbols('w wavelen')
|
64 |
+
assert waist2rayleigh(w, wavelen) == pi*w**2/wavelen
|
65 |
+
z_r, wavelen = symbols('z_r wavelen')
|
66 |
+
assert rayleigh2waist(z_r, wavelen) == sqrt(wavelen*z_r)/sqrt(pi)
|
67 |
+
|
68 |
+
a, b, f = symbols('a b f')
|
69 |
+
assert geometric_conj_ab(a, b) == a*b/(a + b)
|
70 |
+
assert geometric_conj_af(a, f) == a*f/(a - f)
|
71 |
+
assert geometric_conj_bf(b, f) == b*f/(b - f)
|
72 |
+
assert geometric_conj_ab(oo, b) == b
|
73 |
+
assert geometric_conj_ab(a, oo) == a
|
74 |
+
|
75 |
+
s_in, z_r_in, f = symbols('s_in z_r_in f')
|
76 |
+
assert gaussian_conj(
|
77 |
+
s_in, z_r_in, f)[0] == 1/(-1/(s_in + z_r_in**2/(-f + s_in)) + 1/f)
|
78 |
+
assert gaussian_conj(
|
79 |
+
s_in, z_r_in, f)[1] == z_r_in/(1 - s_in**2/f**2 + z_r_in**2/f**2)
|
80 |
+
assert gaussian_conj(
|
81 |
+
s_in, z_r_in, f)[2] == 1/sqrt(1 - s_in**2/f**2 + z_r_in**2/f**2)
|
82 |
+
|
83 |
+
l, w_i, w_o, f = symbols('l w_i w_o f')
|
84 |
+
assert conjugate_gauss_beams(l, w_i, w_o, f=f)[0] == f*(
|
85 |
+
-sqrt(w_i**2/w_o**2 - pi**2*w_i**4/(f**2*l**2)) + 1)
|
86 |
+
assert factor(conjugate_gauss_beams(l, w_i, w_o, f=f)[1]) == f*w_o**2*(
|
87 |
+
w_i**2/w_o**2 - sqrt(w_i**2/w_o**2 - pi**2*w_i**4/(f**2*l**2)))/w_i**2
|
88 |
+
assert conjugate_gauss_beams(l, w_i, w_o, f=f)[2] == f
|
89 |
+
|
90 |
+
z, l, w_0 = symbols('z l w_0', positive=True)
|
91 |
+
p = BeamParameter(l, z, w=w_0)
|
92 |
+
assert p.radius == z*(pi**2*w_0**4/(l**2*z**2) + 1)
|
93 |
+
assert p.w == w_0*sqrt(l**2*z**2/(pi**2*w_0**4) + 1)
|
94 |
+
assert p.w_0 == w_0
|
95 |
+
assert p.divergence == l/(pi*w_0)
|
96 |
+
assert p.gouy == atan2(z, pi*w_0**2/l)
|
97 |
+
assert p.waist_approximation_limit == 2*l/pi
|
98 |
+
|
99 |
+
p = BeamParameter(530e-9, 1, w=1e-3, n=2)
|
100 |
+
assert streq(p.q, 1 + 3.77358490566038*I*pi)
|
101 |
+
assert streq(N(p.z_r), Float(11.8550666173200))
|
102 |
+
assert streq(N(p.w_0), Float(0.00100000000000000))
|
venv/lib/python3.10/site-packages/sympy/physics/optics/tests/test_medium.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from sympy.functions.elementary.miscellaneous import sqrt
|
2 |
+
from sympy.physics.optics import Medium
|
3 |
+
from sympy.abc import epsilon, mu, n
|
4 |
+
from sympy.physics.units import speed_of_light, u0, e0, m, kg, s, A
|
5 |
+
|
6 |
+
from sympy.testing.pytest import raises
|
7 |
+
|
8 |
+
c = speed_of_light.convert_to(m/s)
|
9 |
+
e0 = e0.convert_to(A**2*s**4/(kg*m**3))
|
10 |
+
u0 = u0.convert_to(m*kg/(A**2*s**2))
|
11 |
+
|
12 |
+
|
13 |
+
def test_medium():
|
14 |
+
m1 = Medium('m1')
|
15 |
+
assert m1.intrinsic_impedance == sqrt(u0/e0)
|
16 |
+
assert m1.speed == 1/sqrt(e0*u0)
|
17 |
+
assert m1.refractive_index == c*sqrt(e0*u0)
|
18 |
+
assert m1.permittivity == e0
|
19 |
+
assert m1.permeability == u0
|
20 |
+
m2 = Medium('m2', epsilon, mu)
|
21 |
+
assert m2.intrinsic_impedance == sqrt(mu/epsilon)
|
22 |
+
assert m2.speed == 1/sqrt(epsilon*mu)
|
23 |
+
assert m2.refractive_index == c*sqrt(epsilon*mu)
|
24 |
+
assert m2.permittivity == epsilon
|
25 |
+
assert m2.permeability == mu
|
26 |
+
# Increasing electric permittivity and magnetic permeability
|
27 |
+
# by small amount from its value in vacuum.
|
28 |
+
m3 = Medium('m3', 9.0*10**(-12)*s**4*A**2/(m**3*kg), 1.45*10**(-6)*kg*m/(A**2*s**2))
|
29 |
+
assert m3.refractive_index > m1.refractive_index
|
30 |
+
assert m3 != m1
|
31 |
+
# Decreasing electric permittivity and magnetic permeability
|
32 |
+
# by small amount from its value in vacuum.
|
33 |
+
m4 = Medium('m4', 7.0*10**(-12)*s**4*A**2/(m**3*kg), 1.15*10**(-6)*kg*m/(A**2*s**2))
|
34 |
+
assert m4.refractive_index < m1.refractive_index
|
35 |
+
m5 = Medium('m5', permittivity=710*10**(-12)*s**4*A**2/(m**3*kg), n=1.33)
|
36 |
+
assert abs(m5.intrinsic_impedance - 6.24845417765552*kg*m**2/(A**2*s**3)) \
|
37 |
+
< 1e-12*kg*m**2/(A**2*s**3)
|
38 |
+
assert abs(m5.speed - 225407863.157895*m/s) < 1e-6*m/s
|
39 |
+
assert abs(m5.refractive_index - 1.33000000000000) < 1e-12
|
40 |
+
assert abs(m5.permittivity - 7.1e-10*A**2*s**4/(kg*m**3)) \
|
41 |
+
< 1e-20*A**2*s**4/(kg*m**3)
|
42 |
+
assert abs(m5.permeability - 2.77206575232851e-8*kg*m/(A**2*s**2)) \
|
43 |
+
< 1e-20*kg*m/(A**2*s**2)
|
44 |
+
m6 = Medium('m6', None, mu, n)
|
45 |
+
assert m6.permittivity == n**2/(c**2*mu)
|
46 |
+
# test for equality of refractive indices
|
47 |
+
assert Medium('m7').refractive_index == Medium('m8', e0, u0).refractive_index
|
48 |
+
raises(ValueError, lambda:Medium('m9', e0, u0, 2))
|
venv/lib/python3.10/site-packages/sympy/physics/optics/tests/test_polarization.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from sympy.physics.optics.polarization import (jones_vector, stokes_vector,
|
2 |
+
jones_2_stokes, linear_polarizer, phase_retarder, half_wave_retarder,
|
3 |
+
quarter_wave_retarder, transmissive_filter, reflective_filter,
|
4 |
+
mueller_matrix, polarizing_beam_splitter)
|
5 |
+
from sympy.core.numbers import (I, pi)
|
6 |
+
from sympy.core.singleton import S
|
7 |
+
from sympy.core.symbol import symbols
|
8 |
+
from sympy.functions.elementary.exponential import exp
|
9 |
+
from sympy.matrices.dense import Matrix
|
10 |
+
|
11 |
+
|
12 |
+
def test_polarization():
|
13 |
+
assert jones_vector(0, 0) == Matrix([1, 0])
|
14 |
+
assert jones_vector(pi/2, 0) == Matrix([0, 1])
|
15 |
+
#################################################################
|
16 |
+
assert stokes_vector(0, 0) == Matrix([1, 1, 0, 0])
|
17 |
+
assert stokes_vector(pi/2, 0) == Matrix([1, -1, 0, 0])
|
18 |
+
#################################################################
|
19 |
+
H = jones_vector(0, 0)
|
20 |
+
V = jones_vector(pi/2, 0)
|
21 |
+
D = jones_vector(pi/4, 0)
|
22 |
+
A = jones_vector(-pi/4, 0)
|
23 |
+
R = jones_vector(0, pi/4)
|
24 |
+
L = jones_vector(0, -pi/4)
|
25 |
+
|
26 |
+
res = [Matrix([1, 1, 0, 0]),
|
27 |
+
Matrix([1, -1, 0, 0]),
|
28 |
+
Matrix([1, 0, 1, 0]),
|
29 |
+
Matrix([1, 0, -1, 0]),
|
30 |
+
Matrix([1, 0, 0, 1]),
|
31 |
+
Matrix([1, 0, 0, -1])]
|
32 |
+
|
33 |
+
assert [jones_2_stokes(e) for e in [H, V, D, A, R, L]] == res
|
34 |
+
#################################################################
|
35 |
+
assert linear_polarizer(0) == Matrix([[1, 0], [0, 0]])
|
36 |
+
#################################################################
|
37 |
+
delta = symbols("delta", real=True)
|
38 |
+
res = Matrix([[exp(-I*delta/2), 0], [0, exp(I*delta/2)]])
|
39 |
+
assert phase_retarder(0, delta) == res
|
40 |
+
#################################################################
|
41 |
+
assert half_wave_retarder(0) == Matrix([[-I, 0], [0, I]])
|
42 |
+
#################################################################
|
43 |
+
res = Matrix([[exp(-I*pi/4), 0], [0, I*exp(-I*pi/4)]])
|
44 |
+
assert quarter_wave_retarder(0) == res
|
45 |
+
#################################################################
|
46 |
+
assert transmissive_filter(1) == Matrix([[1, 0], [0, 1]])
|
47 |
+
#################################################################
|
48 |
+
assert reflective_filter(1) == Matrix([[1, 0], [0, -1]])
|
49 |
+
|
50 |
+
res = Matrix([[S(1)/2, S(1)/2, 0, 0],
|
51 |
+
[S(1)/2, S(1)/2, 0, 0],
|
52 |
+
[0, 0, 0, 0],
|
53 |
+
[0, 0, 0, 0]])
|
54 |
+
assert mueller_matrix(linear_polarizer(0)) == res
|
55 |
+
#################################################################
|
56 |
+
res = Matrix([[1, 0, 0, 0], [0, 0, 0, -I], [0, 0, 1, 0], [0, -I, 0, 0]])
|
57 |
+
assert polarizing_beam_splitter() == res
|
venv/lib/python3.10/site-packages/sympy/physics/optics/tests/test_utils.py
ADDED
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from sympy.core.numbers import comp, Rational
|
2 |
+
from sympy.physics.optics.utils import (refraction_angle, fresnel_coefficients,
|
3 |
+
deviation, brewster_angle, critical_angle, lens_makers_formula,
|
4 |
+
mirror_formula, lens_formula, hyperfocal_distance,
|
5 |
+
transverse_magnification)
|
6 |
+
from sympy.physics.optics.medium import Medium
|
7 |
+
from sympy.physics.units import e0
|
8 |
+
|
9 |
+
from sympy.core.numbers import oo
|
10 |
+
from sympy.core.symbol import symbols
|
11 |
+
from sympy.functions.elementary.miscellaneous import sqrt
|
12 |
+
from sympy.matrices.dense import Matrix
|
13 |
+
from sympy.geometry.point import Point3D
|
14 |
+
from sympy.geometry.line import Ray3D
|
15 |
+
from sympy.geometry.plane import Plane
|
16 |
+
|
17 |
+
from sympy.testing.pytest import raises
|
18 |
+
|
19 |
+
|
20 |
+
ae = lambda a, b, n: comp(a, b, 10**-n)
|
21 |
+
|
22 |
+
|
23 |
+
def test_refraction_angle():
|
24 |
+
n1, n2 = symbols('n1, n2')
|
25 |
+
m1 = Medium('m1')
|
26 |
+
m2 = Medium('m2')
|
27 |
+
r1 = Ray3D(Point3D(-1, -1, 1), Point3D(0, 0, 0))
|
28 |
+
i = Matrix([1, 1, 1])
|
29 |
+
n = Matrix([0, 0, 1])
|
30 |
+
normal_ray = Ray3D(Point3D(0, 0, 0), Point3D(0, 0, 1))
|
31 |
+
P = Plane(Point3D(0, 0, 0), normal_vector=[0, 0, 1])
|
32 |
+
assert refraction_angle(r1, 1, 1, n) == Matrix([
|
33 |
+
[ 1],
|
34 |
+
[ 1],
|
35 |
+
[-1]])
|
36 |
+
assert refraction_angle([1, 1, 1], 1, 1, n) == Matrix([
|
37 |
+
[ 1],
|
38 |
+
[ 1],
|
39 |
+
[-1]])
|
40 |
+
assert refraction_angle((1, 1, 1), 1, 1, n) == Matrix([
|
41 |
+
[ 1],
|
42 |
+
[ 1],
|
43 |
+
[-1]])
|
44 |
+
assert refraction_angle(i, 1, 1, [0, 0, 1]) == Matrix([
|
45 |
+
[ 1],
|
46 |
+
[ 1],
|
47 |
+
[-1]])
|
48 |
+
assert refraction_angle(i, 1, 1, (0, 0, 1)) == Matrix([
|
49 |
+
[ 1],
|
50 |
+
[ 1],
|
51 |
+
[-1]])
|
52 |
+
assert refraction_angle(i, 1, 1, normal_ray) == Matrix([
|
53 |
+
[ 1],
|
54 |
+
[ 1],
|
55 |
+
[-1]])
|
56 |
+
assert refraction_angle(i, 1, 1, plane=P) == Matrix([
|
57 |
+
[ 1],
|
58 |
+
[ 1],
|
59 |
+
[-1]])
|
60 |
+
assert refraction_angle(r1, 1, 1, plane=P) == \
|
61 |
+
Ray3D(Point3D(0, 0, 0), Point3D(1, 1, -1))
|
62 |
+
assert refraction_angle(r1, m1, 1.33, plane=P) == \
|
63 |
+
Ray3D(Point3D(0, 0, 0), Point3D(Rational(100, 133), Rational(100, 133), -789378201649271*sqrt(3)/1000000000000000))
|
64 |
+
assert refraction_angle(r1, 1, m2, plane=P) == \
|
65 |
+
Ray3D(Point3D(0, 0, 0), Point3D(1, 1, -1))
|
66 |
+
assert refraction_angle(r1, n1, n2, plane=P) == \
|
67 |
+
Ray3D(Point3D(0, 0, 0), Point3D(n1/n2, n1/n2, -sqrt(3)*sqrt(-2*n1**2/(3*n2**2) + 1)))
|
68 |
+
assert refraction_angle(r1, 1.33, 1, plane=P) == 0 # TIR
|
69 |
+
assert refraction_angle(r1, 1, 1, normal_ray) == \
|
70 |
+
Ray3D(Point3D(0, 0, 0), direction_ratio=[1, 1, -1])
|
71 |
+
assert ae(refraction_angle(0.5, 1, 2), 0.24207, 5)
|
72 |
+
assert ae(refraction_angle(0.5, 2, 1), 1.28293, 5)
|
73 |
+
raises(ValueError, lambda: refraction_angle(r1, m1, m2, normal_ray, P))
|
74 |
+
raises(TypeError, lambda: refraction_angle(m1, m1, m2)) # can add other values for arg[0]
|
75 |
+
raises(TypeError, lambda: refraction_angle(r1, m1, m2, None, i))
|
76 |
+
raises(TypeError, lambda: refraction_angle(r1, m1, m2, m2))
|
77 |
+
|
78 |
+
|
79 |
+
def test_fresnel_coefficients():
|
80 |
+
assert all(ae(i, j, 5) for i, j in zip(
|
81 |
+
fresnel_coefficients(0.5, 1, 1.33),
|
82 |
+
[0.11163, -0.17138, 0.83581, 0.82862]))
|
83 |
+
assert all(ae(i, j, 5) for i, j in zip(
|
84 |
+
fresnel_coefficients(0.5, 1.33, 1),
|
85 |
+
[-0.07726, 0.20482, 1.22724, 1.20482]))
|
86 |
+
m1 = Medium('m1')
|
87 |
+
m2 = Medium('m2', n=2)
|
88 |
+
assert all(ae(i, j, 5) for i, j in zip(
|
89 |
+
fresnel_coefficients(0.3, m1, m2),
|
90 |
+
[0.31784, -0.34865, 0.65892, 0.65135]))
|
91 |
+
ans = [[-0.23563, -0.97184], [0.81648, -0.57738]]
|
92 |
+
got = fresnel_coefficients(0.6, m2, m1)
|
93 |
+
for i, j in zip(got, ans):
|
94 |
+
for a, b in zip(i.as_real_imag(), j):
|
95 |
+
assert ae(a, b, 5)
|
96 |
+
|
97 |
+
|
98 |
+
def test_deviation():
|
99 |
+
n1, n2 = symbols('n1, n2')
|
100 |
+
r1 = Ray3D(Point3D(-1, -1, 1), Point3D(0, 0, 0))
|
101 |
+
n = Matrix([0, 0, 1])
|
102 |
+
i = Matrix([-1, -1, -1])
|
103 |
+
normal_ray = Ray3D(Point3D(0, 0, 0), Point3D(0, 0, 1))
|
104 |
+
P = Plane(Point3D(0, 0, 0), normal_vector=[0, 0, 1])
|
105 |
+
assert deviation(r1, 1, 1, normal=n) == 0
|
106 |
+
assert deviation(r1, 1, 1, plane=P) == 0
|
107 |
+
assert deviation(r1, 1, 1.1, plane=P).evalf(3) + 0.119 < 1e-3
|
108 |
+
assert deviation(i, 1, 1.1, normal=normal_ray).evalf(3) + 0.119 < 1e-3
|
109 |
+
assert deviation(r1, 1.33, 1, plane=P) is None # TIR
|
110 |
+
assert deviation(r1, 1, 1, normal=[0, 0, 1]) == 0
|
111 |
+
assert deviation([-1, -1, -1], 1, 1, normal=[0, 0, 1]) == 0
|
112 |
+
assert ae(deviation(0.5, 1, 2), -0.25793, 5)
|
113 |
+
assert ae(deviation(0.5, 2, 1), 0.78293, 5)
|
114 |
+
|
115 |
+
|
116 |
+
def test_brewster_angle():
|
117 |
+
m1 = Medium('m1', n=1)
|
118 |
+
m2 = Medium('m2', n=1.33)
|
119 |
+
assert ae(brewster_angle(m1, m2), 0.93, 2)
|
120 |
+
m1 = Medium('m1', permittivity=e0, n=1)
|
121 |
+
m2 = Medium('m2', permittivity=e0, n=1.33)
|
122 |
+
assert ae(brewster_angle(m1, m2), 0.93, 2)
|
123 |
+
assert ae(brewster_angle(1, 1.33), 0.93, 2)
|
124 |
+
|
125 |
+
|
126 |
+
def test_critical_angle():
|
127 |
+
m1 = Medium('m1', n=1)
|
128 |
+
m2 = Medium('m2', n=1.33)
|
129 |
+
assert ae(critical_angle(m2, m1), 0.85, 2)
|
130 |
+
|
131 |
+
|
132 |
+
def test_lens_makers_formula():
|
133 |
+
n1, n2 = symbols('n1, n2')
|
134 |
+
m1 = Medium('m1', permittivity=e0, n=1)
|
135 |
+
m2 = Medium('m2', permittivity=e0, n=1.33)
|
136 |
+
assert lens_makers_formula(n1, n2, 10, -10) == 5.0*n2/(n1 - n2)
|
137 |
+
assert ae(lens_makers_formula(m1, m2, 10, -10), -20.15, 2)
|
138 |
+
assert ae(lens_makers_formula(1.33, 1, 10, -10), 15.15, 2)
|
139 |
+
|
140 |
+
|
141 |
+
def test_mirror_formula():
|
142 |
+
u, v, f = symbols('u, v, f')
|
143 |
+
assert mirror_formula(focal_length=f, u=u) == f*u/(-f + u)
|
144 |
+
assert mirror_formula(focal_length=f, v=v) == f*v/(-f + v)
|
145 |
+
assert mirror_formula(u=u, v=v) == u*v/(u + v)
|
146 |
+
assert mirror_formula(u=oo, v=v) == v
|
147 |
+
assert mirror_formula(u=oo, v=oo) is oo
|
148 |
+
assert mirror_formula(focal_length=oo, u=u) == -u
|
149 |
+
assert mirror_formula(u=u, v=oo) == u
|
150 |
+
assert mirror_formula(focal_length=oo, v=oo) is oo
|
151 |
+
assert mirror_formula(focal_length=f, v=oo) == f
|
152 |
+
assert mirror_formula(focal_length=oo, v=v) == -v
|
153 |
+
assert mirror_formula(focal_length=oo, u=oo) is oo
|
154 |
+
assert mirror_formula(focal_length=f, u=oo) == f
|
155 |
+
assert mirror_formula(focal_length=oo, u=u) == -u
|
156 |
+
raises(ValueError, lambda: mirror_formula(focal_length=f, u=u, v=v))
|
157 |
+
|
158 |
+
|
159 |
+
def test_lens_formula():
|
160 |
+
u, v, f = symbols('u, v, f')
|
161 |
+
assert lens_formula(focal_length=f, u=u) == f*u/(f + u)
|
162 |
+
assert lens_formula(focal_length=f, v=v) == f*v/(f - v)
|
163 |
+
assert lens_formula(u=u, v=v) == u*v/(u - v)
|
164 |
+
assert lens_formula(u=oo, v=v) == v
|
165 |
+
assert lens_formula(u=oo, v=oo) is oo
|
166 |
+
assert lens_formula(focal_length=oo, u=u) == u
|
167 |
+
assert lens_formula(u=u, v=oo) == -u
|
168 |
+
assert lens_formula(focal_length=oo, v=oo) is -oo
|
169 |
+
assert lens_formula(focal_length=oo, v=v) == v
|
170 |
+
assert lens_formula(focal_length=f, v=oo) == -f
|
171 |
+
assert lens_formula(focal_length=oo, u=oo) is oo
|
172 |
+
assert lens_formula(focal_length=oo, u=u) == u
|
173 |
+
assert lens_formula(focal_length=f, u=oo) == f
|
174 |
+
raises(ValueError, lambda: lens_formula(focal_length=f, u=u, v=v))
|
175 |
+
|
176 |
+
|
177 |
+
def test_hyperfocal_distance():
|
178 |
+
f, N, c = symbols('f, N, c')
|
179 |
+
assert hyperfocal_distance(f=f, N=N, c=c) == f**2/(N*c)
|
180 |
+
assert ae(hyperfocal_distance(f=0.5, N=8, c=0.0033), 9.47, 2)
|
181 |
+
|
182 |
+
|
183 |
+
def test_transverse_magnification():
|
184 |
+
si, so = symbols('si, so')
|
185 |
+
assert transverse_magnification(si, so) == -si/so
|
186 |
+
assert transverse_magnification(30, 15) == -2
|
187 |
+
|
188 |
+
|
189 |
+
def test_lens_makers_formula_thick_lens():
|
190 |
+
n1, n2 = symbols('n1, n2')
|
191 |
+
m1 = Medium('m1', permittivity=e0, n=1)
|
192 |
+
m2 = Medium('m2', permittivity=e0, n=1.33)
|
193 |
+
assert ae(lens_makers_formula(m1, m2, 10, -10, d=1), -19.82, 2)
|
194 |
+
assert lens_makers_formula(n1, n2, 1, -1, d=0.1) == n2/((2.0 - (0.1*n1 - 0.1*n2)/n1)*(n1 - n2))
|
195 |
+
|
196 |
+
|
197 |
+
def test_lens_makers_formula_plano_lens():
|
198 |
+
n1, n2 = symbols('n1, n2')
|
199 |
+
m1 = Medium('m1', permittivity=e0, n=1)
|
200 |
+
m2 = Medium('m2', permittivity=e0, n=1.33)
|
201 |
+
assert ae(lens_makers_formula(m1, m2, 10, oo), -40.30, 2)
|
202 |
+
assert lens_makers_formula(n1, n2, 10, oo) == 10.0*n2/(n1 - n2)
|
venv/lib/python3.10/site-packages/sympy/physics/optics/tests/test_waves.py
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from sympy.core.function import (Derivative, Function)
|
2 |
+
from sympy.core.numbers import (I, pi)
|
3 |
+
from sympy.core.symbol import (Symbol, symbols)
|
4 |
+
from sympy.functions.elementary.miscellaneous import sqrt
|
5 |
+
from sympy.functions.elementary.trigonometric import (atan2, cos, sin)
|
6 |
+
from sympy.simplify.simplify import simplify
|
7 |
+
from sympy.abc import epsilon, mu
|
8 |
+
from sympy.functions.elementary.exponential import exp
|
9 |
+
from sympy.physics.units import speed_of_light, m, s
|
10 |
+
from sympy.physics.optics import TWave
|
11 |
+
|
12 |
+
from sympy.testing.pytest import raises
|
13 |
+
|
14 |
+
c = speed_of_light.convert_to(m/s)
|
15 |
+
|
16 |
+
def test_twave():
|
17 |
+
A1, phi1, A2, phi2, f = symbols('A1, phi1, A2, phi2, f')
|
18 |
+
n = Symbol('n') # Refractive index
|
19 |
+
t = Symbol('t') # Time
|
20 |
+
x = Symbol('x') # Spatial variable
|
21 |
+
E = Function('E')
|
22 |
+
w1 = TWave(A1, f, phi1)
|
23 |
+
w2 = TWave(A2, f, phi2)
|
24 |
+
assert w1.amplitude == A1
|
25 |
+
assert w1.frequency == f
|
26 |
+
assert w1.phase == phi1
|
27 |
+
assert w1.wavelength == c/(f*n)
|
28 |
+
assert w1.time_period == 1/f
|
29 |
+
assert w1.angular_velocity == 2*pi*f
|
30 |
+
assert w1.wavenumber == 2*pi*f*n/c
|
31 |
+
assert w1.speed == c/n
|
32 |
+
|
33 |
+
w3 = w1 + w2
|
34 |
+
assert w3.amplitude == sqrt(A1**2 + 2*A1*A2*cos(phi1 - phi2) + A2**2)
|
35 |
+
assert w3.frequency == f
|
36 |
+
assert w3.phase == atan2(A1*sin(phi1) + A2*sin(phi2), A1*cos(phi1) + A2*cos(phi2))
|
37 |
+
assert w3.wavelength == c/(f*n)
|
38 |
+
assert w3.time_period == 1/f
|
39 |
+
assert w3.angular_velocity == 2*pi*f
|
40 |
+
assert w3.wavenumber == 2*pi*f*n/c
|
41 |
+
assert w3.speed == c/n
|
42 |
+
assert simplify(w3.rewrite(sin) - w2.rewrite(sin) - w1.rewrite(sin)) == 0
|
43 |
+
assert w3.rewrite('pde') == epsilon*mu*Derivative(E(x, t), t, t) + Derivative(E(x, t), x, x)
|
44 |
+
assert w3.rewrite(cos) == sqrt(A1**2 + 2*A1*A2*cos(phi1 - phi2)
|
45 |
+
+ A2**2)*cos(pi*f*n*x*s/(149896229*m) - 2*pi*f*t + atan2(A1*sin(phi1)
|
46 |
+
+ A2*sin(phi2), A1*cos(phi1) + A2*cos(phi2)))
|
47 |
+
assert w3.rewrite(exp) == sqrt(A1**2 + 2*A1*A2*cos(phi1 - phi2)
|
48 |
+
+ A2**2)*exp(I*(-2*pi*f*t + atan2(A1*sin(phi1) + A2*sin(phi2), A1*cos(phi1)
|
49 |
+
+ A2*cos(phi2)) + pi*s*f*n*x/(149896229*m)))
|
50 |
+
|
51 |
+
w4 = TWave(A1, None, 0, 1/f)
|
52 |
+
assert w4.frequency == f
|
53 |
+
|
54 |
+
w5 = w1 - w2
|
55 |
+
assert w5.amplitude == sqrt(A1**2 - 2*A1*A2*cos(phi1 - phi2) + A2**2)
|
56 |
+
assert w5.frequency == f
|
57 |
+
assert w5.phase == atan2(A1*sin(phi1) - A2*sin(phi2), A1*cos(phi1) - A2*cos(phi2))
|
58 |
+
assert w5.wavelength == c/(f*n)
|
59 |
+
assert w5.time_period == 1/f
|
60 |
+
assert w5.angular_velocity == 2*pi*f
|
61 |
+
assert w5.wavenumber == 2*pi*f*n/c
|
62 |
+
assert w5.speed == c/n
|
63 |
+
assert simplify(w5.rewrite(sin) - w1.rewrite(sin) + w2.rewrite(sin)) == 0
|
64 |
+
assert w5.rewrite('pde') == epsilon*mu*Derivative(E(x, t), t, t) + Derivative(E(x, t), x, x)
|
65 |
+
assert w5.rewrite(cos) == sqrt(A1**2 - 2*A1*A2*cos(phi1 - phi2)
|
66 |
+
+ A2**2)*cos(-2*pi*f*t + atan2(A1*sin(phi1) - A2*sin(phi2), A1*cos(phi1)
|
67 |
+
- A2*cos(phi2)) + pi*s*f*n*x/(149896229*m))
|
68 |
+
assert w5.rewrite(exp) == sqrt(A1**2 - 2*A1*A2*cos(phi1 - phi2)
|
69 |
+
+ A2**2)*exp(I*(-2*pi*f*t + atan2(A1*sin(phi1) - A2*sin(phi2), A1*cos(phi1)
|
70 |
+
- A2*cos(phi2)) + pi*s*f*n*x/(149896229*m)))
|
71 |
+
|
72 |
+
w6 = 2*w1
|
73 |
+
assert w6.amplitude == 2*A1
|
74 |
+
assert w6.frequency == f
|
75 |
+
assert w6.phase == phi1
|
76 |
+
w7 = -w6
|
77 |
+
assert w7.amplitude == -2*A1
|
78 |
+
assert w7.frequency == f
|
79 |
+
assert w7.phase == phi1
|
80 |
+
|
81 |
+
raises(ValueError, lambda:TWave(A1))
|
82 |
+
raises(ValueError, lambda:TWave(A1, f, phi1, t))
|
venv/lib/python3.10/site-packages/sympy/physics/optics/utils.py
ADDED
@@ -0,0 +1,698 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
**Contains**
|
3 |
+
|
4 |
+
* refraction_angle
|
5 |
+
* fresnel_coefficients
|
6 |
+
* deviation
|
7 |
+
* brewster_angle
|
8 |
+
* critical_angle
|
9 |
+
* lens_makers_formula
|
10 |
+
* mirror_formula
|
11 |
+
* lens_formula
|
12 |
+
* hyperfocal_distance
|
13 |
+
* transverse_magnification
|
14 |
+
"""
|
15 |
+
|
16 |
+
__all__ = ['refraction_angle',
|
17 |
+
'deviation',
|
18 |
+
'fresnel_coefficients',
|
19 |
+
'brewster_angle',
|
20 |
+
'critical_angle',
|
21 |
+
'lens_makers_formula',
|
22 |
+
'mirror_formula',
|
23 |
+
'lens_formula',
|
24 |
+
'hyperfocal_distance',
|
25 |
+
'transverse_magnification'
|
26 |
+
]
|
27 |
+
|
28 |
+
from sympy.core.numbers import (Float, I, oo, pi, zoo)
|
29 |
+
from sympy.core.singleton import S
|
30 |
+
from sympy.core.symbol import Symbol
|
31 |
+
from sympy.core.sympify import sympify
|
32 |
+
from sympy.functions.elementary.miscellaneous import sqrt
|
33 |
+
from sympy.functions.elementary.trigonometric import (acos, asin, atan2, cos, sin, tan)
|
34 |
+
from sympy.matrices.dense import Matrix
|
35 |
+
from sympy.polys.polytools import cancel
|
36 |
+
from sympy.series.limits import Limit
|
37 |
+
from sympy.geometry.line import Ray3D
|
38 |
+
from sympy.geometry.util import intersection
|
39 |
+
from sympy.geometry.plane import Plane
|
40 |
+
from sympy.utilities.iterables import is_sequence
|
41 |
+
from .medium import Medium
|
42 |
+
|
43 |
+
|
44 |
+
def refractive_index_of_medium(medium):
|
45 |
+
"""
|
46 |
+
Helper function that returns refractive index, given a medium
|
47 |
+
"""
|
48 |
+
if isinstance(medium, Medium):
|
49 |
+
n = medium.refractive_index
|
50 |
+
else:
|
51 |
+
n = sympify(medium)
|
52 |
+
return n
|
53 |
+
|
54 |
+
|
55 |
+
def refraction_angle(incident, medium1, medium2, normal=None, plane=None):
|
56 |
+
"""
|
57 |
+
This function calculates transmitted vector after refraction at planar
|
58 |
+
surface. ``medium1`` and ``medium2`` can be ``Medium`` or any sympifiable object.
|
59 |
+
If ``incident`` is a number then treated as angle of incidence (in radians)
|
60 |
+
in which case refraction angle is returned.
|
61 |
+
|
62 |
+
If ``incident`` is an object of `Ray3D`, `normal` also has to be an instance
|
63 |
+
of `Ray3D` in order to get the output as a `Ray3D`. Please note that if
|
64 |
+
plane of separation is not provided and normal is an instance of `Ray3D`,
|
65 |
+
``normal`` will be assumed to be intersecting incident ray at the plane of
|
66 |
+
separation. This will not be the case when `normal` is a `Matrix` or
|
67 |
+
any other sequence.
|
68 |
+
If ``incident`` is an instance of `Ray3D` and `plane` has not been provided
|
69 |
+
and ``normal`` is not `Ray3D`, output will be a `Matrix`.
|
70 |
+
|
71 |
+
Parameters
|
72 |
+
==========
|
73 |
+
|
74 |
+
incident : Matrix, Ray3D, sequence or a number
|
75 |
+
Incident vector or angle of incidence
|
76 |
+
medium1 : sympy.physics.optics.medium.Medium or sympifiable
|
77 |
+
Medium 1 or its refractive index
|
78 |
+
medium2 : sympy.physics.optics.medium.Medium or sympifiable
|
79 |
+
Medium 2 or its refractive index
|
80 |
+
normal : Matrix, Ray3D, or sequence
|
81 |
+
Normal vector
|
82 |
+
plane : Plane
|
83 |
+
Plane of separation of the two media.
|
84 |
+
|
85 |
+
Returns
|
86 |
+
=======
|
87 |
+
|
88 |
+
Returns an angle of refraction or a refracted ray depending on inputs.
|
89 |
+
|
90 |
+
Examples
|
91 |
+
========
|
92 |
+
|
93 |
+
>>> from sympy.physics.optics import refraction_angle
|
94 |
+
>>> from sympy.geometry import Point3D, Ray3D, Plane
|
95 |
+
>>> from sympy.matrices import Matrix
|
96 |
+
>>> from sympy import symbols, pi
|
97 |
+
>>> n = Matrix([0, 0, 1])
|
98 |
+
>>> P = Plane(Point3D(0, 0, 0), normal_vector=[0, 0, 1])
|
99 |
+
>>> r1 = Ray3D(Point3D(-1, -1, 1), Point3D(0, 0, 0))
|
100 |
+
>>> refraction_angle(r1, 1, 1, n)
|
101 |
+
Matrix([
|
102 |
+
[ 1],
|
103 |
+
[ 1],
|
104 |
+
[-1]])
|
105 |
+
>>> refraction_angle(r1, 1, 1, plane=P)
|
106 |
+
Ray3D(Point3D(0, 0, 0), Point3D(1, 1, -1))
|
107 |
+
|
108 |
+
With different index of refraction of the two media
|
109 |
+
|
110 |
+
>>> n1, n2 = symbols('n1, n2')
|
111 |
+
>>> refraction_angle(r1, n1, n2, n)
|
112 |
+
Matrix([
|
113 |
+
[ n1/n2],
|
114 |
+
[ n1/n2],
|
115 |
+
[-sqrt(3)*sqrt(-2*n1**2/(3*n2**2) + 1)]])
|
116 |
+
>>> refraction_angle(r1, n1, n2, plane=P)
|
117 |
+
Ray3D(Point3D(0, 0, 0), Point3D(n1/n2, n1/n2, -sqrt(3)*sqrt(-2*n1**2/(3*n2**2) + 1)))
|
118 |
+
>>> round(refraction_angle(pi/6, 1.2, 1.5), 5)
|
119 |
+
0.41152
|
120 |
+
"""
|
121 |
+
|
122 |
+
n1 = refractive_index_of_medium(medium1)
|
123 |
+
n2 = refractive_index_of_medium(medium2)
|
124 |
+
|
125 |
+
# check if an incidence angle was supplied instead of a ray
|
126 |
+
try:
|
127 |
+
angle_of_incidence = float(incident)
|
128 |
+
except TypeError:
|
129 |
+
angle_of_incidence = None
|
130 |
+
|
131 |
+
try:
|
132 |
+
critical_angle_ = critical_angle(medium1, medium2)
|
133 |
+
except (ValueError, TypeError):
|
134 |
+
critical_angle_ = None
|
135 |
+
|
136 |
+
if angle_of_incidence is not None:
|
137 |
+
if normal is not None or plane is not None:
|
138 |
+
raise ValueError('Normal/plane not allowed if incident is an angle')
|
139 |
+
|
140 |
+
if not 0.0 <= angle_of_incidence < pi*0.5:
|
141 |
+
raise ValueError('Angle of incidence not in range [0:pi/2)')
|
142 |
+
|
143 |
+
if critical_angle_ and angle_of_incidence > critical_angle_:
|
144 |
+
raise ValueError('Ray undergoes total internal reflection')
|
145 |
+
return asin(n1*sin(angle_of_incidence)/n2)
|
146 |
+
|
147 |
+
# Treat the incident as ray below
|
148 |
+
# A flag to check whether to return Ray3D or not
|
149 |
+
return_ray = False
|
150 |
+
|
151 |
+
if plane is not None and normal is not None:
|
152 |
+
raise ValueError("Either plane or normal is acceptable.")
|
153 |
+
|
154 |
+
if not isinstance(incident, Matrix):
|
155 |
+
if is_sequence(incident):
|
156 |
+
_incident = Matrix(incident)
|
157 |
+
elif isinstance(incident, Ray3D):
|
158 |
+
_incident = Matrix(incident.direction_ratio)
|
159 |
+
else:
|
160 |
+
raise TypeError(
|
161 |
+
"incident should be a Matrix, Ray3D, or sequence")
|
162 |
+
else:
|
163 |
+
_incident = incident
|
164 |
+
|
165 |
+
# If plane is provided, get direction ratios of the normal
|
166 |
+
# to the plane from the plane else go with `normal` param.
|
167 |
+
if plane is not None:
|
168 |
+
if not isinstance(plane, Plane):
|
169 |
+
raise TypeError("plane should be an instance of geometry.plane.Plane")
|
170 |
+
# If we have the plane, we can get the intersection
|
171 |
+
# point of incident ray and the plane and thus return
|
172 |
+
# an instance of Ray3D.
|
173 |
+
if isinstance(incident, Ray3D):
|
174 |
+
return_ray = True
|
175 |
+
intersection_pt = plane.intersection(incident)[0]
|
176 |
+
_normal = Matrix(plane.normal_vector)
|
177 |
+
else:
|
178 |
+
if not isinstance(normal, Matrix):
|
179 |
+
if is_sequence(normal):
|
180 |
+
_normal = Matrix(normal)
|
181 |
+
elif isinstance(normal, Ray3D):
|
182 |
+
_normal = Matrix(normal.direction_ratio)
|
183 |
+
if isinstance(incident, Ray3D):
|
184 |
+
intersection_pt = intersection(incident, normal)
|
185 |
+
if len(intersection_pt) == 0:
|
186 |
+
raise ValueError(
|
187 |
+
"Normal isn't concurrent with the incident ray.")
|
188 |
+
else:
|
189 |
+
return_ray = True
|
190 |
+
intersection_pt = intersection_pt[0]
|
191 |
+
else:
|
192 |
+
raise TypeError(
|
193 |
+
"Normal should be a Matrix, Ray3D, or sequence")
|
194 |
+
else:
|
195 |
+
_normal = normal
|
196 |
+
|
197 |
+
eta = n1/n2 # Relative index of refraction
|
198 |
+
# Calculating magnitude of the vectors
|
199 |
+
mag_incident = sqrt(sum([i**2 for i in _incident]))
|
200 |
+
mag_normal = sqrt(sum([i**2 for i in _normal]))
|
201 |
+
# Converting vectors to unit vectors by dividing
|
202 |
+
# them with their magnitudes
|
203 |
+
_incident /= mag_incident
|
204 |
+
_normal /= mag_normal
|
205 |
+
c1 = -_incident.dot(_normal) # cos(angle_of_incidence)
|
206 |
+
cs2 = 1 - eta**2*(1 - c1**2) # cos(angle_of_refraction)**2
|
207 |
+
if cs2.is_negative: # This is the case of total internal reflection(TIR).
|
208 |
+
return S.Zero
|
209 |
+
drs = eta*_incident + (eta*c1 - sqrt(cs2))*_normal
|
210 |
+
# Multiplying unit vector by its magnitude
|
211 |
+
drs = drs*mag_incident
|
212 |
+
if not return_ray:
|
213 |
+
return drs
|
214 |
+
else:
|
215 |
+
return Ray3D(intersection_pt, direction_ratio=drs)
|
216 |
+
|
217 |
+
|
218 |
+
def fresnel_coefficients(angle_of_incidence, medium1, medium2):
|
219 |
+
"""
|
220 |
+
This function uses Fresnel equations to calculate reflection and
|
221 |
+
transmission coefficients. Those are obtained for both polarisations
|
222 |
+
when the electric field vector is in the plane of incidence (labelled 'p')
|
223 |
+
and when the electric field vector is perpendicular to the plane of
|
224 |
+
incidence (labelled 's'). There are four real coefficients unless the
|
225 |
+
incident ray reflects in total internal in which case there are two complex
|
226 |
+
ones. Angle of incidence is the angle between the incident ray and the
|
227 |
+
surface normal. ``medium1`` and ``medium2`` can be ``Medium`` or any
|
228 |
+
sympifiable object.
|
229 |
+
|
230 |
+
Parameters
|
231 |
+
==========
|
232 |
+
|
233 |
+
angle_of_incidence : sympifiable
|
234 |
+
|
235 |
+
medium1 : Medium or sympifiable
|
236 |
+
Medium 1 or its refractive index
|
237 |
+
|
238 |
+
medium2 : Medium or sympifiable
|
239 |
+
Medium 2 or its refractive index
|
240 |
+
|
241 |
+
Returns
|
242 |
+
=======
|
243 |
+
|
244 |
+
Returns a list with four real Fresnel coefficients:
|
245 |
+
[reflection p (TM), reflection s (TE),
|
246 |
+
transmission p (TM), transmission s (TE)]
|
247 |
+
If the ray is undergoes total internal reflection then returns a
|
248 |
+
list of two complex Fresnel coefficients:
|
249 |
+
[reflection p (TM), reflection s (TE)]
|
250 |
+
|
251 |
+
Examples
|
252 |
+
========
|
253 |
+
|
254 |
+
>>> from sympy.physics.optics import fresnel_coefficients
|
255 |
+
>>> fresnel_coefficients(0.3, 1, 2)
|
256 |
+
[0.317843553417859, -0.348645229818821,
|
257 |
+
0.658921776708929, 0.651354770181179]
|
258 |
+
>>> fresnel_coefficients(0.6, 2, 1)
|
259 |
+
[-0.235625382192159 - 0.971843958291041*I,
|
260 |
+
0.816477005968898 - 0.577377951366403*I]
|
261 |
+
|
262 |
+
References
|
263 |
+
==========
|
264 |
+
|
265 |
+
.. [1] https://en.wikipedia.org/wiki/Fresnel_equations
|
266 |
+
"""
|
267 |
+
if not 0 <= 2*angle_of_incidence < pi:
|
268 |
+
raise ValueError('Angle of incidence not in range [0:pi/2)')
|
269 |
+
|
270 |
+
n1 = refractive_index_of_medium(medium1)
|
271 |
+
n2 = refractive_index_of_medium(medium2)
|
272 |
+
|
273 |
+
angle_of_refraction = asin(n1*sin(angle_of_incidence)/n2)
|
274 |
+
try:
|
275 |
+
angle_of_total_internal_reflection_onset = critical_angle(n1, n2)
|
276 |
+
except ValueError:
|
277 |
+
angle_of_total_internal_reflection_onset = None
|
278 |
+
|
279 |
+
if angle_of_total_internal_reflection_onset is None or\
|
280 |
+
angle_of_total_internal_reflection_onset > angle_of_incidence:
|
281 |
+
R_s = -sin(angle_of_incidence - angle_of_refraction)\
|
282 |
+
/sin(angle_of_incidence + angle_of_refraction)
|
283 |
+
R_p = tan(angle_of_incidence - angle_of_refraction)\
|
284 |
+
/tan(angle_of_incidence + angle_of_refraction)
|
285 |
+
T_s = 2*sin(angle_of_refraction)*cos(angle_of_incidence)\
|
286 |
+
/sin(angle_of_incidence + angle_of_refraction)
|
287 |
+
T_p = 2*sin(angle_of_refraction)*cos(angle_of_incidence)\
|
288 |
+
/(sin(angle_of_incidence + angle_of_refraction)\
|
289 |
+
*cos(angle_of_incidence - angle_of_refraction))
|
290 |
+
return [R_p, R_s, T_p, T_s]
|
291 |
+
else:
|
292 |
+
n = n2/n1
|
293 |
+
R_s = cancel((cos(angle_of_incidence)-\
|
294 |
+
I*sqrt(sin(angle_of_incidence)**2 - n**2))\
|
295 |
+
/(cos(angle_of_incidence)+\
|
296 |
+
I*sqrt(sin(angle_of_incidence)**2 - n**2)))
|
297 |
+
R_p = cancel((n**2*cos(angle_of_incidence)-\
|
298 |
+
I*sqrt(sin(angle_of_incidence)**2 - n**2))\
|
299 |
+
/(n**2*cos(angle_of_incidence)+\
|
300 |
+
I*sqrt(sin(angle_of_incidence)**2 - n**2)))
|
301 |
+
return [R_p, R_s]
|
302 |
+
|
303 |
+
|
304 |
+
def deviation(incident, medium1, medium2, normal=None, plane=None):
|
305 |
+
"""
|
306 |
+
This function calculates the angle of deviation of a ray
|
307 |
+
due to refraction at planar surface.
|
308 |
+
|
309 |
+
Parameters
|
310 |
+
==========
|
311 |
+
|
312 |
+
incident : Matrix, Ray3D, sequence or float
|
313 |
+
Incident vector or angle of incidence
|
314 |
+
medium1 : sympy.physics.optics.medium.Medium or sympifiable
|
315 |
+
Medium 1 or its refractive index
|
316 |
+
medium2 : sympy.physics.optics.medium.Medium or sympifiable
|
317 |
+
Medium 2 or its refractive index
|
318 |
+
normal : Matrix, Ray3D, or sequence
|
319 |
+
Normal vector
|
320 |
+
plane : Plane
|
321 |
+
Plane of separation of the two media.
|
322 |
+
|
323 |
+
Returns angular deviation between incident and refracted rays
|
324 |
+
|
325 |
+
Examples
|
326 |
+
========
|
327 |
+
|
328 |
+
>>> from sympy.physics.optics import deviation
|
329 |
+
>>> from sympy.geometry import Point3D, Ray3D, Plane
|
330 |
+
>>> from sympy.matrices import Matrix
|
331 |
+
>>> from sympy import symbols
|
332 |
+
>>> n1, n2 = symbols('n1, n2')
|
333 |
+
>>> n = Matrix([0, 0, 1])
|
334 |
+
>>> P = Plane(Point3D(0, 0, 0), normal_vector=[0, 0, 1])
|
335 |
+
>>> r1 = Ray3D(Point3D(-1, -1, 1), Point3D(0, 0, 0))
|
336 |
+
>>> deviation(r1, 1, 1, n)
|
337 |
+
0
|
338 |
+
>>> deviation(r1, n1, n2, plane=P)
|
339 |
+
-acos(-sqrt(-2*n1**2/(3*n2**2) + 1)) + acos(-sqrt(3)/3)
|
340 |
+
>>> round(deviation(0.1, 1.2, 1.5), 5)
|
341 |
+
-0.02005
|
342 |
+
"""
|
343 |
+
refracted = refraction_angle(incident,
|
344 |
+
medium1,
|
345 |
+
medium2,
|
346 |
+
normal=normal,
|
347 |
+
plane=plane)
|
348 |
+
try:
|
349 |
+
angle_of_incidence = Float(incident)
|
350 |
+
except TypeError:
|
351 |
+
angle_of_incidence = None
|
352 |
+
|
353 |
+
if angle_of_incidence is not None:
|
354 |
+
return float(refracted) - angle_of_incidence
|
355 |
+
|
356 |
+
if refracted != 0:
|
357 |
+
if isinstance(refracted, Ray3D):
|
358 |
+
refracted = Matrix(refracted.direction_ratio)
|
359 |
+
|
360 |
+
if not isinstance(incident, Matrix):
|
361 |
+
if is_sequence(incident):
|
362 |
+
_incident = Matrix(incident)
|
363 |
+
elif isinstance(incident, Ray3D):
|
364 |
+
_incident = Matrix(incident.direction_ratio)
|
365 |
+
else:
|
366 |
+
raise TypeError(
|
367 |
+
"incident should be a Matrix, Ray3D, or sequence")
|
368 |
+
else:
|
369 |
+
_incident = incident
|
370 |
+
|
371 |
+
if plane is None:
|
372 |
+
if not isinstance(normal, Matrix):
|
373 |
+
if is_sequence(normal):
|
374 |
+
_normal = Matrix(normal)
|
375 |
+
elif isinstance(normal, Ray3D):
|
376 |
+
_normal = Matrix(normal.direction_ratio)
|
377 |
+
else:
|
378 |
+
raise TypeError(
|
379 |
+
"normal should be a Matrix, Ray3D, or sequence")
|
380 |
+
else:
|
381 |
+
_normal = normal
|
382 |
+
else:
|
383 |
+
_normal = Matrix(plane.normal_vector)
|
384 |
+
|
385 |
+
mag_incident = sqrt(sum([i**2 for i in _incident]))
|
386 |
+
mag_normal = sqrt(sum([i**2 for i in _normal]))
|
387 |
+
mag_refracted = sqrt(sum([i**2 for i in refracted]))
|
388 |
+
_incident /= mag_incident
|
389 |
+
_normal /= mag_normal
|
390 |
+
refracted /= mag_refracted
|
391 |
+
i = acos(_incident.dot(_normal))
|
392 |
+
r = acos(refracted.dot(_normal))
|
393 |
+
return i - r
|
394 |
+
|
395 |
+
|
396 |
+
def brewster_angle(medium1, medium2):
|
397 |
+
"""
|
398 |
+
This function calculates the Brewster's angle of incidence to Medium 2 from
|
399 |
+
Medium 1 in radians.
|
400 |
+
|
401 |
+
Parameters
|
402 |
+
==========
|
403 |
+
|
404 |
+
medium 1 : Medium or sympifiable
|
405 |
+
Refractive index of Medium 1
|
406 |
+
medium 2 : Medium or sympifiable
|
407 |
+
Refractive index of Medium 1
|
408 |
+
|
409 |
+
Examples
|
410 |
+
========
|
411 |
+
|
412 |
+
>>> from sympy.physics.optics import brewster_angle
|
413 |
+
>>> brewster_angle(1, 1.33)
|
414 |
+
0.926093295503462
|
415 |
+
|
416 |
+
"""
|
417 |
+
|
418 |
+
n1 = refractive_index_of_medium(medium1)
|
419 |
+
n2 = refractive_index_of_medium(medium2)
|
420 |
+
|
421 |
+
return atan2(n2, n1)
|
422 |
+
|
423 |
+
def critical_angle(medium1, medium2):
|
424 |
+
"""
|
425 |
+
This function calculates the critical angle of incidence (marking the onset
|
426 |
+
of total internal) to Medium 2 from Medium 1 in radians.
|
427 |
+
|
428 |
+
Parameters
|
429 |
+
==========
|
430 |
+
|
431 |
+
medium 1 : Medium or sympifiable
|
432 |
+
Refractive index of Medium 1.
|
433 |
+
medium 2 : Medium or sympifiable
|
434 |
+
Refractive index of Medium 1.
|
435 |
+
|
436 |
+
Examples
|
437 |
+
========
|
438 |
+
|
439 |
+
>>> from sympy.physics.optics import critical_angle
|
440 |
+
>>> critical_angle(1.33, 1)
|
441 |
+
0.850908514477849
|
442 |
+
|
443 |
+
"""
|
444 |
+
|
445 |
+
n1 = refractive_index_of_medium(medium1)
|
446 |
+
n2 = refractive_index_of_medium(medium2)
|
447 |
+
|
448 |
+
if n2 > n1:
|
449 |
+
raise ValueError('Total internal reflection impossible for n1 < n2')
|
450 |
+
else:
|
451 |
+
return asin(n2/n1)
|
452 |
+
|
453 |
+
|
454 |
+
|
455 |
+
def lens_makers_formula(n_lens, n_surr, r1, r2, d=0):
|
456 |
+
"""
|
457 |
+
This function calculates focal length of a lens.
|
458 |
+
It follows cartesian sign convention.
|
459 |
+
|
460 |
+
Parameters
|
461 |
+
==========
|
462 |
+
|
463 |
+
n_lens : Medium or sympifiable
|
464 |
+
Index of refraction of lens.
|
465 |
+
n_surr : Medium or sympifiable
|
466 |
+
Index of reflection of surrounding.
|
467 |
+
r1 : sympifiable
|
468 |
+
Radius of curvature of first surface.
|
469 |
+
r2 : sympifiable
|
470 |
+
Radius of curvature of second surface.
|
471 |
+
d : sympifiable, optional
|
472 |
+
Thickness of lens, default value is 0.
|
473 |
+
|
474 |
+
Examples
|
475 |
+
========
|
476 |
+
|
477 |
+
>>> from sympy.physics.optics import lens_makers_formula
|
478 |
+
>>> from sympy import S
|
479 |
+
>>> lens_makers_formula(1.33, 1, 10, -10)
|
480 |
+
15.1515151515151
|
481 |
+
>>> lens_makers_formula(1.2, 1, 10, S.Infinity)
|
482 |
+
50.0000000000000
|
483 |
+
>>> lens_makers_formula(1.33, 1, 10, -10, d=1)
|
484 |
+
15.3418463277618
|
485 |
+
|
486 |
+
"""
|
487 |
+
|
488 |
+
if isinstance(n_lens, Medium):
|
489 |
+
n_lens = n_lens.refractive_index
|
490 |
+
else:
|
491 |
+
n_lens = sympify(n_lens)
|
492 |
+
if isinstance(n_surr, Medium):
|
493 |
+
n_surr = n_surr.refractive_index
|
494 |
+
else:
|
495 |
+
n_surr = sympify(n_surr)
|
496 |
+
d = sympify(d)
|
497 |
+
|
498 |
+
focal_length = 1/((n_lens - n_surr) / n_surr*(1/r1 - 1/r2 + (((n_lens - n_surr) * d) / (n_lens * r1 * r2))))
|
499 |
+
|
500 |
+
if focal_length == zoo:
|
501 |
+
return S.Infinity
|
502 |
+
return focal_length
|
503 |
+
|
504 |
+
|
505 |
+
def mirror_formula(focal_length=None, u=None, v=None):
|
506 |
+
"""
|
507 |
+
This function provides one of the three parameters
|
508 |
+
when two of them are supplied.
|
509 |
+
This is valid only for paraxial rays.
|
510 |
+
|
511 |
+
Parameters
|
512 |
+
==========
|
513 |
+
|
514 |
+
focal_length : sympifiable
|
515 |
+
Focal length of the mirror.
|
516 |
+
u : sympifiable
|
517 |
+
Distance of object from the pole on
|
518 |
+
the principal axis.
|
519 |
+
v : sympifiable
|
520 |
+
Distance of the image from the pole
|
521 |
+
on the principal axis.
|
522 |
+
|
523 |
+
Examples
|
524 |
+
========
|
525 |
+
|
526 |
+
>>> from sympy.physics.optics import mirror_formula
|
527 |
+
>>> from sympy.abc import f, u, v
|
528 |
+
>>> mirror_formula(focal_length=f, u=u)
|
529 |
+
f*u/(-f + u)
|
530 |
+
>>> mirror_formula(focal_length=f, v=v)
|
531 |
+
f*v/(-f + v)
|
532 |
+
>>> mirror_formula(u=u, v=v)
|
533 |
+
u*v/(u + v)
|
534 |
+
|
535 |
+
"""
|
536 |
+
if focal_length and u and v:
|
537 |
+
raise ValueError("Please provide only two parameters")
|
538 |
+
|
539 |
+
focal_length = sympify(focal_length)
|
540 |
+
u = sympify(u)
|
541 |
+
v = sympify(v)
|
542 |
+
if u is oo:
|
543 |
+
_u = Symbol('u')
|
544 |
+
if v is oo:
|
545 |
+
_v = Symbol('v')
|
546 |
+
if focal_length is oo:
|
547 |
+
_f = Symbol('f')
|
548 |
+
if focal_length is None:
|
549 |
+
if u is oo and v is oo:
|
550 |
+
return Limit(Limit(_v*_u/(_v + _u), _u, oo), _v, oo).doit()
|
551 |
+
if u is oo:
|
552 |
+
return Limit(v*_u/(v + _u), _u, oo).doit()
|
553 |
+
if v is oo:
|
554 |
+
return Limit(_v*u/(_v + u), _v, oo).doit()
|
555 |
+
return v*u/(v + u)
|
556 |
+
if u is None:
|
557 |
+
if v is oo and focal_length is oo:
|
558 |
+
return Limit(Limit(_v*_f/(_v - _f), _v, oo), _f, oo).doit()
|
559 |
+
if v is oo:
|
560 |
+
return Limit(_v*focal_length/(_v - focal_length), _v, oo).doit()
|
561 |
+
if focal_length is oo:
|
562 |
+
return Limit(v*_f/(v - _f), _f, oo).doit()
|
563 |
+
return v*focal_length/(v - focal_length)
|
564 |
+
if v is None:
|
565 |
+
if u is oo and focal_length is oo:
|
566 |
+
return Limit(Limit(_u*_f/(_u - _f), _u, oo), _f, oo).doit()
|
567 |
+
if u is oo:
|
568 |
+
return Limit(_u*focal_length/(_u - focal_length), _u, oo).doit()
|
569 |
+
if focal_length is oo:
|
570 |
+
return Limit(u*_f/(u - _f), _f, oo).doit()
|
571 |
+
return u*focal_length/(u - focal_length)
|
572 |
+
|
573 |
+
|
574 |
+
def lens_formula(focal_length=None, u=None, v=None):
|
575 |
+
"""
|
576 |
+
This function provides one of the three parameters
|
577 |
+
when two of them are supplied.
|
578 |
+
This is valid only for paraxial rays.
|
579 |
+
|
580 |
+
Parameters
|
581 |
+
==========
|
582 |
+
|
583 |
+
focal_length : sympifiable
|
584 |
+
Focal length of the mirror.
|
585 |
+
u : sympifiable
|
586 |
+
Distance of object from the optical center on
|
587 |
+
the principal axis.
|
588 |
+
v : sympifiable
|
589 |
+
Distance of the image from the optical center
|
590 |
+
on the principal axis.
|
591 |
+
|
592 |
+
Examples
|
593 |
+
========
|
594 |
+
|
595 |
+
>>> from sympy.physics.optics import lens_formula
|
596 |
+
>>> from sympy.abc import f, u, v
|
597 |
+
>>> lens_formula(focal_length=f, u=u)
|
598 |
+
f*u/(f + u)
|
599 |
+
>>> lens_formula(focal_length=f, v=v)
|
600 |
+
f*v/(f - v)
|
601 |
+
>>> lens_formula(u=u, v=v)
|
602 |
+
u*v/(u - v)
|
603 |
+
|
604 |
+
"""
|
605 |
+
if focal_length and u and v:
|
606 |
+
raise ValueError("Please provide only two parameters")
|
607 |
+
|
608 |
+
focal_length = sympify(focal_length)
|
609 |
+
u = sympify(u)
|
610 |
+
v = sympify(v)
|
611 |
+
if u is oo:
|
612 |
+
_u = Symbol('u')
|
613 |
+
if v is oo:
|
614 |
+
_v = Symbol('v')
|
615 |
+
if focal_length is oo:
|
616 |
+
_f = Symbol('f')
|
617 |
+
if focal_length is None:
|
618 |
+
if u is oo and v is oo:
|
619 |
+
return Limit(Limit(_v*_u/(_u - _v), _u, oo), _v, oo).doit()
|
620 |
+
if u is oo:
|
621 |
+
return Limit(v*_u/(_u - v), _u, oo).doit()
|
622 |
+
if v is oo:
|
623 |
+
return Limit(_v*u/(u - _v), _v, oo).doit()
|
624 |
+
return v*u/(u - v)
|
625 |
+
if u is None:
|
626 |
+
if v is oo and focal_length is oo:
|
627 |
+
return Limit(Limit(_v*_f/(_f - _v), _v, oo), _f, oo).doit()
|
628 |
+
if v is oo:
|
629 |
+
return Limit(_v*focal_length/(focal_length - _v), _v, oo).doit()
|
630 |
+
if focal_length is oo:
|
631 |
+
return Limit(v*_f/(_f - v), _f, oo).doit()
|
632 |
+
return v*focal_length/(focal_length - v)
|
633 |
+
if v is None:
|
634 |
+
if u is oo and focal_length is oo:
|
635 |
+
return Limit(Limit(_u*_f/(_u + _f), _u, oo), _f, oo).doit()
|
636 |
+
if u is oo:
|
637 |
+
return Limit(_u*focal_length/(_u + focal_length), _u, oo).doit()
|
638 |
+
if focal_length is oo:
|
639 |
+
return Limit(u*_f/(u + _f), _f, oo).doit()
|
640 |
+
return u*focal_length/(u + focal_length)
|
641 |
+
|
642 |
+
def hyperfocal_distance(f, N, c):
|
643 |
+
"""
|
644 |
+
|
645 |
+
Parameters
|
646 |
+
==========
|
647 |
+
|
648 |
+
f: sympifiable
|
649 |
+
Focal length of a given lens.
|
650 |
+
|
651 |
+
N: sympifiable
|
652 |
+
F-number of a given lens.
|
653 |
+
|
654 |
+
c: sympifiable
|
655 |
+
Circle of Confusion (CoC) of a given image format.
|
656 |
+
|
657 |
+
Example
|
658 |
+
=======
|
659 |
+
|
660 |
+
>>> from sympy.physics.optics import hyperfocal_distance
|
661 |
+
>>> round(hyperfocal_distance(f = 0.5, N = 8, c = 0.0033), 2)
|
662 |
+
9.47
|
663 |
+
"""
|
664 |
+
|
665 |
+
f = sympify(f)
|
666 |
+
N = sympify(N)
|
667 |
+
c = sympify(c)
|
668 |
+
|
669 |
+
return (1/(N * c))*(f**2)
|
670 |
+
|
671 |
+
def transverse_magnification(si, so):
|
672 |
+
"""
|
673 |
+
|
674 |
+
Calculates the transverse magnification, which is the ratio of the
|
675 |
+
image size to the object size.
|
676 |
+
|
677 |
+
Parameters
|
678 |
+
==========
|
679 |
+
|
680 |
+
so: sympifiable
|
681 |
+
Lens-object distance.
|
682 |
+
|
683 |
+
si: sympifiable
|
684 |
+
Lens-image distance.
|
685 |
+
|
686 |
+
Example
|
687 |
+
=======
|
688 |
+
|
689 |
+
>>> from sympy.physics.optics import transverse_magnification
|
690 |
+
>>> transverse_magnification(30, 15)
|
691 |
+
-2
|
692 |
+
|
693 |
+
"""
|
694 |
+
|
695 |
+
si = sympify(si)
|
696 |
+
so = sympify(so)
|
697 |
+
|
698 |
+
return (-(si/so))
|
venv/lib/python3.10/site-packages/sympy/physics/optics/waves.py
ADDED
@@ -0,0 +1,340 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
This module has all the classes and functions related to waves in optics.
|
3 |
+
|
4 |
+
**Contains**
|
5 |
+
|
6 |
+
* TWave
|
7 |
+
"""
|
8 |
+
|
9 |
+
__all__ = ['TWave']
|
10 |
+
|
11 |
+
from sympy.core.basic import Basic
|
12 |
+
from sympy.core.expr import Expr
|
13 |
+
from sympy.core.function import Derivative, Function
|
14 |
+
from sympy.core.numbers import (Number, pi, I)
|
15 |
+
from sympy.core.singleton import S
|
16 |
+
from sympy.core.symbol import (Symbol, symbols)
|
17 |
+
from sympy.core.sympify import _sympify, sympify
|
18 |
+
from sympy.functions.elementary.exponential import exp
|
19 |
+
from sympy.functions.elementary.miscellaneous import sqrt
|
20 |
+
from sympy.functions.elementary.trigonometric import (atan2, cos, sin)
|
21 |
+
from sympy.physics.units import speed_of_light, meter, second
|
22 |
+
|
23 |
+
|
24 |
+
c = speed_of_light.convert_to(meter/second)
|
25 |
+
|
26 |
+
|
27 |
+
class TWave(Expr):
|
28 |
+
|
29 |
+
r"""
|
30 |
+
This is a simple transverse sine wave travelling in a one-dimensional space.
|
31 |
+
Basic properties are required at the time of creation of the object,
|
32 |
+
but they can be changed later with respective methods provided.
|
33 |
+
|
34 |
+
Explanation
|
35 |
+
===========
|
36 |
+
|
37 |
+
It is represented as :math:`A \times cos(k*x - \omega \times t + \phi )`,
|
38 |
+
where :math:`A` is the amplitude, :math:`\omega` is the angular frequency,
|
39 |
+
:math:`k` is the wavenumber (spatial frequency), :math:`x` is a spatial variable
|
40 |
+
to represent the position on the dimension on which the wave propagates,
|
41 |
+
and :math:`\phi` is the phase angle of the wave.
|
42 |
+
|
43 |
+
|
44 |
+
Arguments
|
45 |
+
=========
|
46 |
+
|
47 |
+
amplitude : Sympifyable
|
48 |
+
Amplitude of the wave.
|
49 |
+
frequency : Sympifyable
|
50 |
+
Frequency of the wave.
|
51 |
+
phase : Sympifyable
|
52 |
+
Phase angle of the wave.
|
53 |
+
time_period : Sympifyable
|
54 |
+
Time period of the wave.
|
55 |
+
n : Sympifyable
|
56 |
+
Refractive index of the medium.
|
57 |
+
|
58 |
+
Raises
|
59 |
+
=======
|
60 |
+
|
61 |
+
ValueError : When neither frequency nor time period is provided
|
62 |
+
or they are not consistent.
|
63 |
+
TypeError : When anything other than TWave objects is added.
|
64 |
+
|
65 |
+
|
66 |
+
Examples
|
67 |
+
========
|
68 |
+
|
69 |
+
>>> from sympy import symbols
|
70 |
+
>>> from sympy.physics.optics import TWave
|
71 |
+
>>> A1, phi1, A2, phi2, f = symbols('A1, phi1, A2, phi2, f')
|
72 |
+
>>> w1 = TWave(A1, f, phi1)
|
73 |
+
>>> w2 = TWave(A2, f, phi2)
|
74 |
+
>>> w3 = w1 + w2 # Superposition of two waves
|
75 |
+
>>> w3
|
76 |
+
TWave(sqrt(A1**2 + 2*A1*A2*cos(phi1 - phi2) + A2**2), f,
|
77 |
+
atan2(A1*sin(phi1) + A2*sin(phi2), A1*cos(phi1) + A2*cos(phi2)), 1/f, n)
|
78 |
+
>>> w3.amplitude
|
79 |
+
sqrt(A1**2 + 2*A1*A2*cos(phi1 - phi2) + A2**2)
|
80 |
+
>>> w3.phase
|
81 |
+
atan2(A1*sin(phi1) + A2*sin(phi2), A1*cos(phi1) + A2*cos(phi2))
|
82 |
+
>>> w3.speed
|
83 |
+
299792458*meter/(second*n)
|
84 |
+
>>> w3.angular_velocity
|
85 |
+
2*pi*f
|
86 |
+
|
87 |
+
"""
|
88 |
+
|
89 |
+
def __new__(
|
90 |
+
cls,
|
91 |
+
amplitude,
|
92 |
+
frequency=None,
|
93 |
+
phase=S.Zero,
|
94 |
+
time_period=None,
|
95 |
+
n=Symbol('n')):
|
96 |
+
if time_period is not None:
|
97 |
+
time_period = _sympify(time_period)
|
98 |
+
_frequency = S.One/time_period
|
99 |
+
if frequency is not None:
|
100 |
+
frequency = _sympify(frequency)
|
101 |
+
_time_period = S.One/frequency
|
102 |
+
if time_period is not None:
|
103 |
+
if frequency != S.One/time_period:
|
104 |
+
raise ValueError("frequency and time_period should be consistent.")
|
105 |
+
if frequency is None and time_period is None:
|
106 |
+
raise ValueError("Either frequency or time period is needed.")
|
107 |
+
if frequency is None:
|
108 |
+
frequency = _frequency
|
109 |
+
if time_period is None:
|
110 |
+
time_period = _time_period
|
111 |
+
|
112 |
+
amplitude = _sympify(amplitude)
|
113 |
+
phase = _sympify(phase)
|
114 |
+
n = sympify(n)
|
115 |
+
obj = Basic.__new__(cls, amplitude, frequency, phase, time_period, n)
|
116 |
+
return obj
|
117 |
+
|
118 |
+
@property
|
119 |
+
def amplitude(self):
|
120 |
+
"""
|
121 |
+
Returns the amplitude of the wave.
|
122 |
+
|
123 |
+
Examples
|
124 |
+
========
|
125 |
+
|
126 |
+
>>> from sympy import symbols
|
127 |
+
>>> from sympy.physics.optics import TWave
|
128 |
+
>>> A, phi, f = symbols('A, phi, f')
|
129 |
+
>>> w = TWave(A, f, phi)
|
130 |
+
>>> w.amplitude
|
131 |
+
A
|
132 |
+
"""
|
133 |
+
return self.args[0]
|
134 |
+
|
135 |
+
@property
|
136 |
+
def frequency(self):
|
137 |
+
"""
|
138 |
+
Returns the frequency of the wave,
|
139 |
+
in cycles per second.
|
140 |
+
|
141 |
+
Examples
|
142 |
+
========
|
143 |
+
|
144 |
+
>>> from sympy import symbols
|
145 |
+
>>> from sympy.physics.optics import TWave
|
146 |
+
>>> A, phi, f = symbols('A, phi, f')
|
147 |
+
>>> w = TWave(A, f, phi)
|
148 |
+
>>> w.frequency
|
149 |
+
f
|
150 |
+
"""
|
151 |
+
return self.args[1]
|
152 |
+
|
153 |
+
@property
|
154 |
+
def phase(self):
|
155 |
+
"""
|
156 |
+
Returns the phase angle of the wave,
|
157 |
+
in radians.
|
158 |
+
|
159 |
+
Examples
|
160 |
+
========
|
161 |
+
|
162 |
+
>>> from sympy import symbols
|
163 |
+
>>> from sympy.physics.optics import TWave
|
164 |
+
>>> A, phi, f = symbols('A, phi, f')
|
165 |
+
>>> w = TWave(A, f, phi)
|
166 |
+
>>> w.phase
|
167 |
+
phi
|
168 |
+
"""
|
169 |
+
return self.args[2]
|
170 |
+
|
171 |
+
@property
|
172 |
+
def time_period(self):
|
173 |
+
"""
|
174 |
+
Returns the temporal period of the wave,
|
175 |
+
in seconds per cycle.
|
176 |
+
|
177 |
+
Examples
|
178 |
+
========
|
179 |
+
|
180 |
+
>>> from sympy import symbols
|
181 |
+
>>> from sympy.physics.optics import TWave
|
182 |
+
>>> A, phi, f = symbols('A, phi, f')
|
183 |
+
>>> w = TWave(A, f, phi)
|
184 |
+
>>> w.time_period
|
185 |
+
1/f
|
186 |
+
"""
|
187 |
+
return self.args[3]
|
188 |
+
|
189 |
+
@property
|
190 |
+
def n(self):
|
191 |
+
"""
|
192 |
+
Returns the refractive index of the medium
|
193 |
+
"""
|
194 |
+
return self.args[4]
|
195 |
+
|
196 |
+
@property
|
197 |
+
def wavelength(self):
|
198 |
+
"""
|
199 |
+
Returns the wavelength (spatial period) of the wave,
|
200 |
+
in meters per cycle.
|
201 |
+
It depends on the medium of the wave.
|
202 |
+
|
203 |
+
Examples
|
204 |
+
========
|
205 |
+
|
206 |
+
>>> from sympy import symbols
|
207 |
+
>>> from sympy.physics.optics import TWave
|
208 |
+
>>> A, phi, f = symbols('A, phi, f')
|
209 |
+
>>> w = TWave(A, f, phi)
|
210 |
+
>>> w.wavelength
|
211 |
+
299792458*meter/(second*f*n)
|
212 |
+
"""
|
213 |
+
return c/(self.frequency*self.n)
|
214 |
+
|
215 |
+
|
216 |
+
@property
|
217 |
+
def speed(self):
|
218 |
+
"""
|
219 |
+
Returns the propagation speed of the wave,
|
220 |
+
in meters per second.
|
221 |
+
It is dependent on the propagation medium.
|
222 |
+
|
223 |
+
Examples
|
224 |
+
========
|
225 |
+
|
226 |
+
>>> from sympy import symbols
|
227 |
+
>>> from sympy.physics.optics import TWave
|
228 |
+
>>> A, phi, f = symbols('A, phi, f')
|
229 |
+
>>> w = TWave(A, f, phi)
|
230 |
+
>>> w.speed
|
231 |
+
299792458*meter/(second*n)
|
232 |
+
"""
|
233 |
+
return self.wavelength*self.frequency
|
234 |
+
|
235 |
+
@property
|
236 |
+
def angular_velocity(self):
|
237 |
+
"""
|
238 |
+
Returns the angular velocity of the wave,
|
239 |
+
in radians per second.
|
240 |
+
|
241 |
+
Examples
|
242 |
+
========
|
243 |
+
|
244 |
+
>>> from sympy import symbols
|
245 |
+
>>> from sympy.physics.optics import TWave
|
246 |
+
>>> A, phi, f = symbols('A, phi, f')
|
247 |
+
>>> w = TWave(A, f, phi)
|
248 |
+
>>> w.angular_velocity
|
249 |
+
2*pi*f
|
250 |
+
"""
|
251 |
+
return 2*pi*self.frequency
|
252 |
+
|
253 |
+
@property
|
254 |
+
def wavenumber(self):
|
255 |
+
"""
|
256 |
+
Returns the wavenumber of the wave,
|
257 |
+
in radians per meter.
|
258 |
+
|
259 |
+
Examples
|
260 |
+
========
|
261 |
+
|
262 |
+
>>> from sympy import symbols
|
263 |
+
>>> from sympy.physics.optics import TWave
|
264 |
+
>>> A, phi, f = symbols('A, phi, f')
|
265 |
+
>>> w = TWave(A, f, phi)
|
266 |
+
>>> w.wavenumber
|
267 |
+
pi*second*f*n/(149896229*meter)
|
268 |
+
"""
|
269 |
+
return 2*pi/self.wavelength
|
270 |
+
|
271 |
+
def __str__(self):
|
272 |
+
"""String representation of a TWave."""
|
273 |
+
from sympy.printing import sstr
|
274 |
+
return type(self).__name__ + sstr(self.args)
|
275 |
+
|
276 |
+
__repr__ = __str__
|
277 |
+
|
278 |
+
def __add__(self, other):
|
279 |
+
"""
|
280 |
+
Addition of two waves will result in their superposition.
|
281 |
+
The type of interference will depend on their phase angles.
|
282 |
+
"""
|
283 |
+
if isinstance(other, TWave):
|
284 |
+
if self.frequency == other.frequency and self.wavelength == other.wavelength:
|
285 |
+
return TWave(sqrt(self.amplitude**2 + other.amplitude**2 + 2 *
|
286 |
+
self.amplitude*other.amplitude*cos(
|
287 |
+
self.phase - other.phase)),
|
288 |
+
self.frequency,
|
289 |
+
atan2(self.amplitude*sin(self.phase)
|
290 |
+
+ other.amplitude*sin(other.phase),
|
291 |
+
self.amplitude*cos(self.phase)
|
292 |
+
+ other.amplitude*cos(other.phase))
|
293 |
+
)
|
294 |
+
else:
|
295 |
+
raise NotImplementedError("Interference of waves with different frequencies"
|
296 |
+
" has not been implemented.")
|
297 |
+
else:
|
298 |
+
raise TypeError(type(other).__name__ + " and TWave objects cannot be added.")
|
299 |
+
|
300 |
+
def __mul__(self, other):
|
301 |
+
"""
|
302 |
+
Multiplying a wave by a scalar rescales the amplitude of the wave.
|
303 |
+
"""
|
304 |
+
other = sympify(other)
|
305 |
+
if isinstance(other, Number):
|
306 |
+
return TWave(self.amplitude*other, *self.args[1:])
|
307 |
+
else:
|
308 |
+
raise TypeError(type(other).__name__ + " and TWave objects cannot be multiplied.")
|
309 |
+
|
310 |
+
def __sub__(self, other):
|
311 |
+
return self.__add__(-1*other)
|
312 |
+
|
313 |
+
def __neg__(self):
|
314 |
+
return self.__mul__(-1)
|
315 |
+
|
316 |
+
def __radd__(self, other):
|
317 |
+
return self.__add__(other)
|
318 |
+
|
319 |
+
def __rmul__(self, other):
|
320 |
+
return self.__mul__(other)
|
321 |
+
|
322 |
+
def __rsub__(self, other):
|
323 |
+
return (-self).__radd__(other)
|
324 |
+
|
325 |
+
def _eval_rewrite_as_sin(self, *args, **kwargs):
|
326 |
+
return self.amplitude*sin(self.wavenumber*Symbol('x')
|
327 |
+
- self.angular_velocity*Symbol('t') + self.phase + pi/2, evaluate=False)
|
328 |
+
|
329 |
+
def _eval_rewrite_as_cos(self, *args, **kwargs):
|
330 |
+
return self.amplitude*cos(self.wavenumber*Symbol('x')
|
331 |
+
- self.angular_velocity*Symbol('t') + self.phase)
|
332 |
+
|
333 |
+
def _eval_rewrite_as_pde(self, *args, **kwargs):
|
334 |
+
mu, epsilon, x, t = symbols('mu, epsilon, x, t')
|
335 |
+
E = Function('E')
|
336 |
+
return Derivative(E(x, t), x, 2) + mu*epsilon*Derivative(E(x, t), t, 2)
|
337 |
+
|
338 |
+
def _eval_rewrite_as_exp(self, *args, **kwargs):
|
339 |
+
return self.amplitude*exp(I*(self.wavenumber*Symbol('x')
|
340 |
+
- self.angular_velocity*Symbol('t') + self.phase))
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_boson.cpython-310.pyc
ADDED
Binary file (1.7 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_cartesian.cpython-310.pyc
ADDED
Binary file (3.91 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_circuitplot.cpython-310.pyc
ADDED
Binary file (2.8 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_constants.cpython-310.pyc
ADDED
Binary file (604 Bytes). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_density.cpython-310.pyc
ADDED
Binary file (8.47 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_fermion.cpython-310.pyc
ADDED
Binary file (1.18 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_grover.cpython-310.pyc
ADDED
Binary file (3.46 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_hilbert.cpython-310.pyc
ADDED
Binary file (2.93 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_identitysearch.cpython-310.pyc
ADDED
Binary file (10.1 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_innerproduct.cpython-310.pyc
ADDED
Binary file (2.83 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_matrixutils.cpython-310.pyc
ADDED
Binary file (3.59 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_operator.cpython-310.pyc
ADDED
Binary file (7.41 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_operatorordering.cpython-310.pyc
ADDED
Binary file (1.41 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_operatorset.cpython-310.pyc
ADDED
Binary file (2.51 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_piab.cpython-310.pyc
ADDED
Binary file (1.6 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_qapply.cpython-310.pyc
ADDED
Binary file (6.36 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_qasm.cpython-310.pyc
ADDED
Binary file (4.31 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_qexpr.cpython-310.pyc
ADDED
Binary file (1.9 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_qubit.cpython-310.pyc
ADDED
Binary file (7.98 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_represent.cpython-310.pyc
ADDED
Binary file (6.09 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_sho1d.cpython-310.pyc
ADDED
Binary file (4.97 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_shor.cpython-310.pyc
ADDED
Binary file (1.03 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_spin.cpython-310.pyc
ADDED
Binary file (200 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_state.cpython-310.pyc
ADDED
Binary file (7.26 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_trace.cpython-310.pyc
ADDED
Binary file (3.32 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/vector/__init__.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
__all__ = [
|
2 |
+
'CoordinateSym', 'ReferenceFrame',
|
3 |
+
|
4 |
+
'Dyadic',
|
5 |
+
|
6 |
+
'Vector',
|
7 |
+
|
8 |
+
'Point',
|
9 |
+
|
10 |
+
'cross', 'dot', 'express', 'time_derivative', 'outer',
|
11 |
+
'kinematic_equations', 'get_motion_params', 'partial_velocity',
|
12 |
+
'dynamicsymbols',
|
13 |
+
|
14 |
+
'vprint', 'vsstrrepr', 'vsprint', 'vpprint', 'vlatex', 'init_vprinting',
|
15 |
+
|
16 |
+
'curl', 'divergence', 'gradient', 'is_conservative', 'is_solenoidal',
|
17 |
+
'scalar_potential', 'scalar_potential_difference',
|
18 |
+
|
19 |
+
]
|
20 |
+
from .frame import CoordinateSym, ReferenceFrame
|
21 |
+
|
22 |
+
from .dyadic import Dyadic
|
23 |
+
|
24 |
+
from .vector import Vector
|
25 |
+
|
26 |
+
from .point import Point
|
27 |
+
|
28 |
+
from .functions import (cross, dot, express, time_derivative, outer,
|
29 |
+
kinematic_equations, get_motion_params, partial_velocity,
|
30 |
+
dynamicsymbols)
|
31 |
+
|
32 |
+
from .printing import (vprint, vsstrrepr, vsprint, vpprint, vlatex,
|
33 |
+
init_vprinting)
|
34 |
+
|
35 |
+
from .fieldfunctions import (curl, divergence, gradient, is_conservative,
|
36 |
+
is_solenoidal, scalar_potential, scalar_potential_difference)
|
venv/lib/python3.10/site-packages/sympy/physics/vector/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (1.08 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/vector/__pycache__/dyadic.cpython-310.pyc
ADDED
Binary file (17.5 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/vector/__pycache__/fieldfunctions.cpython-310.pyc
ADDED
Binary file (7.75 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/vector/__pycache__/frame.cpython-310.pyc
ADDED
Binary file (45.8 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/vector/__pycache__/functions.cpython-310.pyc
ADDED
Binary file (19.4 kB). View file
|
|
venv/lib/python3.10/site-packages/sympy/physics/vector/__pycache__/point.cpython-310.pyc
ADDED
Binary file (18.7 kB). View file
|
|