ElectroMagneticPython 2.1.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
EMpy/version.py ADDED
@@ -0,0 +1 @@
1
+ version = "2.1.4"
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Lorenzo Bolla
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,95 @@
1
+ Metadata-Version: 2.1
2
+ Name: ElectroMagneticPython
3
+ Version: 2.1.4
4
+ Summary: EMpy - ElectroMagnetic Python
5
+ Home-page: http://lbolla.github.io/EMpy/
6
+ Download-URL: https://github.com/lbolla/EMpy
7
+ Author: Lorenzo Bolla
8
+ Author-email: code@lbolla.info
9
+ License: BSD
10
+ Platform: Windows
11
+ Platform: Linux
12
+ Platform: Mac OS-X
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: BSD License
17
+ Classifier: Natural Language :: English
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Topic :: Scientific/Engineering :: Physics
21
+ Provides: EMpy
22
+ License-File: LICENSE
23
+ Requires-Dist: numpy (>=1.18)
24
+ Requires-Dist: scipy (>=1.7)
25
+ Requires-Dist: matplotlib (>=3.1)
26
+
27
+ EMpy - ElectroMagnetic Python
28
+ *****************************
29
+
30
+ .. image:: https://github.com/lbolla/EMpy/actions/workflows/python-app.yml/badge.svg
31
+ :target: https://github.com/lbolla/EMpy/actions/workflows/python-app.yml
32
+
33
+ .. image:: https://badge.fury.io/py/ElectroMagneticPython.svg
34
+ :target: https://badge.fury.io/py/ElectroMagneticPython
35
+
36
+ `EMpy - ElectroMagnetic Python` is a suite of algorithms widely known
37
+ and used in electromagnetic problems and optics: the transfer matrix
38
+ algorithm, the rigorous coupled wave analysis algorithm and more.
39
+
40
+ Run the examples in `examples/*` to have an idea how EMpy works.
41
+
42
+ Visit http://lbolla.github.io/EMpy/ for more information.
43
+
44
+ Installation
45
+ ============
46
+
47
+ .. code-block:: bash
48
+
49
+ $> pip install ElectromagneticPython
50
+
51
+ Optionally, install `bvp`:
52
+
53
+ .. code-block:: bash
54
+
55
+ $> pip install scikits.bvp1lg
56
+
57
+ Development
58
+ ===========
59
+
60
+ First, download the source code from https://github.com/lbolla/EMpy. Then, from inside a `virtualenv`, install with:
61
+
62
+ .. code-block:: bash
63
+
64
+ $> pip install -r requirements_dev.txt
65
+ $> python setup.py develop
66
+
67
+ Run tests with:
68
+
69
+ .. code-block:: bash
70
+
71
+ $> python setup.py test
72
+
73
+ Release process
74
+ ===============
75
+
76
+ 1. Edit CHANGES
77
+ 2. `bumpversion major|minor|patch`
78
+ 3. `git push && git push --tags`
79
+
80
+ Citation
81
+ ========
82
+
83
+ If you find EMpy useful in your job, please consider adding a citation.
84
+
85
+ As reference:
86
+
87
+ .. code-block::
88
+
89
+ Bolla, L. (2017). EMpy [Computer software]. https://github.com/lbolla/EMpy/
90
+
91
+ As text:
92
+
93
+ .. code-block::
94
+
95
+ We used EMpy (version x.y.z) to complete our work.
@@ -0,0 +1,22 @@
1
+ EMpy/RCWA.py,sha256=howWQ1gy8VbpSCp9TwEqE9sSYRGWKWRqX0GfM0CCm0w,31913
2
+ EMpy/__init__.py,sha256=m4M1qqNgScI9Yn2gOoN56ygRyurIhn4FNglAbgqpJfk,1075
3
+ EMpy/constants.py,sha256=x1N8eRXQW_gdr1557n7tvUXiM4RW_Fc_EydLd5AUC1o,723
4
+ EMpy/devices.py,sha256=LOlWb_WbtswhivKyfGq-ciKge0DZdBebZf65Nw5F_lw,37920
5
+ EMpy/materials.py,sha256=OTkFtrNbz1-l6qzXmEbXWxw_BukzosukPNzcdD9JHU0,10688
6
+ EMpy/scattering.py,sha256=1rY8_TI0kzTLYwpFSSXndaO9FzDzVPRVow55vzIDQiM,7339
7
+ EMpy/transfer_matrix.py,sha256=1695DcrywNcwU5Uwx_TJGc_vGKl-PfNMN-U0tMqtd7U,14429
8
+ EMpy/utils.py,sha256=hYzLoUldbU4AsgY70qPVGYFn2p7Mm5kBbJ5ugqy57_4,42014
9
+ EMpy/version.py,sha256=BofvhQH1y4YmNkdc-ljDgAFDfxNgkZ3LhNP6EKaLgIE,18
10
+ EMpy/modesolvers/FD.py,sha256=IDRCft6Lr0AaOA5YO3URPABtY_rEKcSy0UrINSig7ag,80113
11
+ EMpy/modesolvers/FMM.py,sha256=L13nURMTh8O8ZxIMNvc5UBSFjBLA_fP8hMKpgIkMlpQ,78423
12
+ EMpy/modesolvers/__init__.py,sha256=bAFq4_6rPDV4RgFx6rct9ywRDLCt_pGhiVtgC6L9A_Y,221
13
+ EMpy/modesolvers/geometries.py,sha256=wTSw5cFv4eA4USimMs4gxEq8mn7xASZozBS6QDoylFQ,7897
14
+ EMpy/modesolvers/interface.py,sha256=X1BLvjys4aFUaHYaekHUTKCLlpiHOEr12eCTVfvbVgk,2399
15
+ tests/__init__.py,sha256=XNMyfmlHhqih2xHEklXlmQ8GVUAdiiWrkT3trIOMpRQ,29
16
+ tests/materials_test.py,sha256=v_UlUvPkiKqkkPNFywbTGTTO4eNnuk-itZPr5YIEUWw,1875
17
+ tests/utils_test.py,sha256=Voe_Ph9LDDf47Vnt04hHLXoTPFGYXeRqzQDVkvPUVy8,597
18
+ ElectroMagneticPython-2.1.4.dist-info/LICENSE,sha256=NlQFsrkwMvQ2aD8531IDm6Rk01KzlI42HVzK5M1Hpw8,1065
19
+ ElectroMagneticPython-2.1.4.dist-info/METADATA,sha256=ORt5Mio-w8kslqf_4BegjDvuAicWZSzvB5AYAwf77vM,2385
20
+ ElectroMagneticPython-2.1.4.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
21
+ ElectroMagneticPython-2.1.4.dist-info/top_level.txt,sha256=JCRI2zyREl3Lql3CyAFrqXFLGqMV0LqdsqQisk907AI,11
22
+ ElectroMagneticPython-2.1.4.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.38.4)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ EMpy
2
+ tests
tests/__init__.py ADDED
@@ -0,0 +1 @@
1
+ __author__ = "Lorenzo Bolla"
@@ -0,0 +1,60 @@
1
+ # pylint: disable=no-self-use
2
+ from unittest import TestCase
3
+
4
+ from numpy import array
5
+ from numpy.testing import assert_almost_equal, assert_raises
6
+
7
+ import EMpy.materials as mat
8
+
9
+
10
+ class RefractiveIndexTest(TestCase):
11
+ def test_all_nones(self):
12
+ with assert_raises(ValueError):
13
+ mat.RefractiveIndex()
14
+
15
+ def test_const(self):
16
+ test_rix = 1.50
17
+ a = mat.RefractiveIndex(n0_const=test_rix)
18
+ self.assertEqual(a.get_rix(1.0)[0], array([test_rix]))
19
+
20
+ def test_poly(self):
21
+ test_poly = [1, 1] # n(wl) = 1 * wl + 1
22
+ test_rix = 2.0 # n(1) = 1 * 1 + 1 = 2
23
+ a = mat.RefractiveIndex(n0_poly=test_poly)
24
+ assert_almost_equal(a.get_rix(1.0)[0], array([test_rix]))
25
+
26
+ def test_smcoeffs(self):
27
+ test_poly = [1] * 6
28
+ """ 6-coeffs:
29
+ n(wls) = 1. +
30
+ B1 * wls ** 2 / (wls ** 2 - C1) +
31
+ B2 * wls ** 2 / (wls ** 2 - C2) +
32
+ B3 * wls ** 2 / (wls ** 2 - C3)
33
+ """
34
+ test_rix = 1.0536712127723509e-08
35
+ a = mat.RefractiveIndex(n0_smcoeffs=test_poly)
36
+ assert_almost_equal(a.get_rix(0.5)[0], array([test_rix]))
37
+
38
+ def test_func(self):
39
+ test_rix = 1.50
40
+
41
+ def test_func_const(x):
42
+ # returns a const
43
+ return 0.0 * x + test_rix
44
+
45
+ a = mat.RefractiveIndex(n0_func=test_func_const)
46
+ assert_almost_equal(a.get_rix([1.0, 1.5]), array([1.5, 1.5]))
47
+
48
+ def test_func_var(x):
49
+ # returns a const
50
+ return 1.0 * x + test_rix
51
+
52
+ b = mat.RefractiveIndex(n0_func=test_func_var)
53
+ assert_almost_equal(b.get_rix([1.0, 1.5]), array([2.5, 3.0]))
54
+
55
+ def test_known(self):
56
+ test_rix = 1.50
57
+ test_wl = 1.0
58
+ n0_known = {test_wl: test_rix}
59
+ a = mat.RefractiveIndex(n0_known=n0_known)
60
+ self.assertEqual(a.get_rix(test_wl)[0], array([test_rix]))
tests/utils_test.py ADDED
@@ -0,0 +1,23 @@
1
+ # pylint: disable=no-self-use
2
+ from unittest import TestCase
3
+
4
+ import random
5
+ import math
6
+
7
+ from numpy import pi
8
+ from numpy.testing import assert_almost_equal
9
+
10
+ import EMpy.utils as U
11
+
12
+
13
+ class UtilsTest(TestCase):
14
+ def test_deg2rad(self):
15
+ # TODO use hypothesis
16
+ x = -2 * pi + 4 * pi * random.random()
17
+ assert_almost_equal(x, U.deg2rad(U.rad2deg(x)))
18
+
19
+ def test_norm(self):
20
+ self.assertEqual(U.norm([1, 0, 0]), 1)
21
+ self.assertEqual(U.norm([0, 1, 0]), 1)
22
+ self.assertEqual(U.norm([0, 0, 1]), 1)
23
+ assert_almost_equal(U.norm([1, 0, 1]), math.sqrt(2))