ElectroMagneticPython 2.2.1__tar.gz → 2.2.4__tar.gz
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.
- electromagneticpython-2.2.4/.bumpversion.cfg +6 -0
- electromagneticpython-2.2.4/.flake8 +3 -0
- electromagneticpython-2.2.4/.github/dependabot.yml +13 -0
- electromagneticpython-2.2.4/.github/workflows/codeql-analysis.yml +70 -0
- electromagneticpython-2.2.4/.github/workflows/publish.yml +36 -0
- electromagneticpython-2.2.4/.github/workflows/python-app.yml +40 -0
- electromagneticpython-2.2.4/.gitignore +8 -0
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/EMpy/RCWA.py +32 -12
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/EMpy/__init__.py +10 -2
- electromagneticpython-2.2.4/EMpy/_version.py +24 -0
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/EMpy/constants.py +0 -2
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/EMpy/devices.py +8 -32
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/EMpy/materials.py +1 -8
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/EMpy/modesolvers/FD.py +34 -76
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/EMpy/modesolvers/FMM.py +24 -23
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/EMpy/modesolvers/__init__.py +1 -0
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/EMpy/modesolvers/geometries.py +8 -9
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/EMpy/transfer_matrix.py +10 -6
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/EMpy/utils.py +12 -26
- electromagneticpython-2.2.4/ElectroMagneticPython.egg-info/PKG-INFO +99 -0
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/ElectroMagneticPython.egg-info/SOURCES.txt +20 -6
- electromagneticpython-2.2.4/ElectroMagneticPython.egg-info/scm_file_list.json +56 -0
- electromagneticpython-2.2.4/ElectroMagneticPython.egg-info/scm_version.json +8 -0
- electromagneticpython-2.2.4/ElectroMagneticPython.egg-info/top_level.txt +5 -0
- electromagneticpython-2.2.4/Makefile +45 -0
- electromagneticpython-2.2.4/PKG-INFO +99 -0
- electromagneticpython-2.2.4/README.md +76 -0
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/examples/ex_APRR.py +8 -7
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/examples/ex_NRR.py +11 -9
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/examples/ex_RCWA.py +8 -9
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/examples/ex_RCWA_2.py +8 -9
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/examples/ex_RCWA_3.py +9 -9
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/examples/ex_SRR.py +11 -9
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/examples/ex_laser_etch_monitor.py +5 -9
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/examples/ex_modesolver.py +16 -15
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/examples/ex_modesolver_2.py +11 -10
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/examples/ex_modesolver_3.py +10 -9
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/examples/ex_modesolver_4.py +8 -7
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/examples/ex_transfer_matrix.py +9 -8
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/examples/ex_transfer_matrix_2.py +12 -11
- electromagneticpython-2.2.4/examples/ex_transfer_matrix_2.py.png +0 -0
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/examples/ex_transfer_matrix_3.py +10 -9
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/examples/nk.py +2 -8
- electromagneticpython-2.2.4/mypy.ini +5 -0
- electromagneticpython-2.2.4/pyproject.toml +55 -0
- electromagneticpython-2.2.4/scripts/FDTD.py +741 -0
- electromagneticpython-2.2.4/setup.cfg +4 -0
- electromagneticpython-2.2.4/tests/devices_test.py +31 -0
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/tests/materials_test.py +1 -1
- electromagneticpython-2.2.4/tests/modesolvers_test.py +36 -0
- electromagneticpython-2.2.4/tests/transfer_matrix_test.py +134 -0
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/tests/utils_test.py +9 -5
- electromagneticpython-2.2.4/uv.lock +1455 -0
- electromagneticpython-2.2.1/EMpy/version.py +0 -1
- electromagneticpython-2.2.1/ElectroMagneticPython.egg-info/PKG-INFO +0 -109
- electromagneticpython-2.2.1/ElectroMagneticPython.egg-info/top_level.txt +0 -2
- electromagneticpython-2.2.1/MANIFEST.in +0 -3
- electromagneticpython-2.2.1/PKG-INFO +0 -109
- electromagneticpython-2.2.1/README.rst +0 -83
- electromagneticpython-2.2.1/requirements.txt +0 -34
- electromagneticpython-2.2.1/setup.cfg +0 -11
- electromagneticpython-2.2.1/setup.py +0 -42
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/EMpy/modesolvers/interface.py +0 -0
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/EMpy/scattering.py +0 -0
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/ElectroMagneticPython.egg-info/dependency_links.txt +0 -0
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/ElectroMagneticPython.egg-info/requires.txt +0 -0
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/LICENSE +0 -0
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/examples/ex_modesolver_dch.py +0 -0
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/examples/ex_modesolver_dch_anis.py +0 -0
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/examples/lc_data.dat +0 -0
- {electromagneticpython-2.2.1 → electromagneticpython-2.2.4}/tests/__init__.py +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Keep GitHub Actions up to date with GitHub's Dependabot...
|
|
2
|
+
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
|
|
3
|
+
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
|
|
4
|
+
# Working with uv
|
|
5
|
+
# https://docs.astral.sh/uv/guides/integration/dependency-bots/#dependabot
|
|
6
|
+
|
|
7
|
+
version: 2
|
|
8
|
+
|
|
9
|
+
updates:
|
|
10
|
+
- package-ecosystem: uv
|
|
11
|
+
directory: /
|
|
12
|
+
schedule:
|
|
13
|
+
interval: weekly
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# For most projects, this workflow file will not need changing; you simply need
|
|
2
|
+
# to commit it to your repository.
|
|
3
|
+
#
|
|
4
|
+
# You may wish to alter this file to override the set of languages analyzed,
|
|
5
|
+
# or to provide custom queries or build logic.
|
|
6
|
+
#
|
|
7
|
+
# ******** NOTE ********
|
|
8
|
+
# We have attempted to detect the languages in your repository. Please check
|
|
9
|
+
# the `language` matrix defined below to confirm you have the correct set of
|
|
10
|
+
# supported CodeQL languages.
|
|
11
|
+
#
|
|
12
|
+
name: "CodeQL"
|
|
13
|
+
|
|
14
|
+
on:
|
|
15
|
+
push:
|
|
16
|
+
branches: [ master ]
|
|
17
|
+
pull_request:
|
|
18
|
+
# The branches below must be a subset of the branches above
|
|
19
|
+
branches: [ master ]
|
|
20
|
+
schedule:
|
|
21
|
+
- cron: '43 12 * * 4'
|
|
22
|
+
|
|
23
|
+
jobs:
|
|
24
|
+
analyze:
|
|
25
|
+
name: Analyze
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
permissions:
|
|
28
|
+
actions: read
|
|
29
|
+
contents: read
|
|
30
|
+
security-events: write
|
|
31
|
+
|
|
32
|
+
strategy:
|
|
33
|
+
fail-fast: false
|
|
34
|
+
matrix:
|
|
35
|
+
language: [ 'python' ]
|
|
36
|
+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
|
37
|
+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
|
38
|
+
|
|
39
|
+
steps:
|
|
40
|
+
- name: Checkout repository
|
|
41
|
+
uses: actions/checkout@v6
|
|
42
|
+
|
|
43
|
+
# Initializes the CodeQL tools for scanning.
|
|
44
|
+
- name: Initialize CodeQL
|
|
45
|
+
uses: github/codeql-action/init@v4
|
|
46
|
+
with:
|
|
47
|
+
languages: ${{ matrix.language }}
|
|
48
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
49
|
+
# By default, queries listed here will override any specified in a config file.
|
|
50
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
51
|
+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
|
52
|
+
|
|
53
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
|
54
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
|
55
|
+
- name: Autobuild
|
|
56
|
+
uses: github/codeql-action/autobuild@v4
|
|
57
|
+
|
|
58
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
|
59
|
+
# 📚 https://git.io/JvXDl
|
|
60
|
+
|
|
61
|
+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
|
62
|
+
# and modify them (or add more) to build your code if your project
|
|
63
|
+
# uses a compiled language
|
|
64
|
+
|
|
65
|
+
#- run: |
|
|
66
|
+
# make bootstrap
|
|
67
|
+
# make release
|
|
68
|
+
|
|
69
|
+
- name: Perform CodeQL Analysis
|
|
70
|
+
uses: github/codeql-action/analyze@v4
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Release and Publish
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
tags:
|
|
7
|
+
- '[0-9]+.[0-9]+.[0-9]+'
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
release:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- name: Checkout
|
|
14
|
+
uses: actions/checkout@v6
|
|
15
|
+
- name: Release on GitHub
|
|
16
|
+
uses: softprops/action-gh-release@v2
|
|
17
|
+
publish:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
environment:
|
|
20
|
+
name: pypi
|
|
21
|
+
permissions:
|
|
22
|
+
id-token: write
|
|
23
|
+
contents: read
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v6
|
|
26
|
+
|
|
27
|
+
- name: Install uv and set the Python version
|
|
28
|
+
uses: astral-sh/setup-uv@v7
|
|
29
|
+
with:
|
|
30
|
+
python-version: '3.12'
|
|
31
|
+
|
|
32
|
+
- name: Build
|
|
33
|
+
run: uv build
|
|
34
|
+
|
|
35
|
+
- name: Publish
|
|
36
|
+
run: uv publish
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: Python application
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ master ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ master ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
strategy:
|
|
15
|
+
fail-fast: false
|
|
16
|
+
matrix:
|
|
17
|
+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v6
|
|
21
|
+
|
|
22
|
+
- name: Install uv and set the Python version
|
|
23
|
+
uses: astral-sh/setup-uv@v7
|
|
24
|
+
with:
|
|
25
|
+
python-version: ${{ matrix.python-version }}
|
|
26
|
+
|
|
27
|
+
- name: Install the project
|
|
28
|
+
run: uv sync --locked --all-extras --dev
|
|
29
|
+
|
|
30
|
+
- name: Lint with flake8
|
|
31
|
+
run: uv run flake8 EMpy tests examples scripts
|
|
32
|
+
|
|
33
|
+
- name: Lint with pyflakes
|
|
34
|
+
run: uv run pyflakes EMpy tests examples scripts
|
|
35
|
+
|
|
36
|
+
- name: Lint with mypy
|
|
37
|
+
run: uv run mypy EMpy tests examples scripts
|
|
38
|
+
|
|
39
|
+
- name: Run tests
|
|
40
|
+
run: uv run pytest
|
|
@@ -12,6 +12,7 @@ for every diffraction order and layer thickness, and an anisotropic
|
|
|
12
12
|
one, only stable for low diffraction orders and thin layers.
|
|
13
13
|
|
|
14
14
|
"""
|
|
15
|
+
|
|
15
16
|
__author__ = "Lorenzo Bolla"
|
|
16
17
|
|
|
17
18
|
import numpy as np
|
|
@@ -95,7 +96,6 @@ def dispersion_relation_extraordinary(kx, ky, k, nO, nE, c):
|
|
|
95
96
|
|
|
96
97
|
|
|
97
98
|
class RCWA:
|
|
98
|
-
|
|
99
99
|
"""Class to handle the RCWA solvers.
|
|
100
100
|
|
|
101
101
|
NOTE
|
|
@@ -168,7 +168,6 @@ class RCWA:
|
|
|
168
168
|
|
|
169
169
|
|
|
170
170
|
class IsotropicRCWA(RCWA):
|
|
171
|
-
|
|
172
171
|
"""Isotropic RCWA solver."""
|
|
173
172
|
|
|
174
173
|
def solve(self, wls):
|
|
@@ -215,7 +214,11 @@ class IsotropicRCWA(RCWA):
|
|
|
215
214
|
DE3 = np.zeros_like(DE1)
|
|
216
215
|
|
|
217
216
|
dirk1 = np.array(
|
|
218
|
-
[
|
|
217
|
+
[
|
|
218
|
+
np.sin(alpha) * np.cos(delta),
|
|
219
|
+
np.sin(alpha) * np.sin(delta),
|
|
220
|
+
np.cos(alpha),
|
|
221
|
+
]
|
|
219
222
|
)
|
|
220
223
|
|
|
221
224
|
# usefull matrices
|
|
@@ -323,7 +326,9 @@ class IsotropicRCWA(RCWA):
|
|
|
323
326
|
# H_S_reduced = np.dot(Ky, Ky) + np.dot(Kx, linsolve(E, np.dot(Kx, E11))) - E11
|
|
324
327
|
H_S_reduced = (
|
|
325
328
|
(ky / k) ** 2 * I
|
|
326
|
-
+ kx[:, np.newaxis]
|
|
329
|
+
+ kx[:, np.newaxis]
|
|
330
|
+
/ k
|
|
331
|
+
* linsolve(E, kx[:, np.newaxis] / k * E11)
|
|
327
332
|
- E11
|
|
328
333
|
)
|
|
329
334
|
|
|
@@ -448,7 +453,6 @@ class IsotropicRCWA(RCWA):
|
|
|
448
453
|
|
|
449
454
|
|
|
450
455
|
class AnisotropicRCWA(RCWA):
|
|
451
|
-
|
|
452
456
|
"""Anisotropic RCWA solver."""
|
|
453
457
|
|
|
454
458
|
def solve(self, wls):
|
|
@@ -487,14 +491,20 @@ class AnisotropicRCWA(RCWA):
|
|
|
487
491
|
# grating on the xy plane
|
|
488
492
|
K = 2 * pi / LAMBDA * np.array([np.sin(phi), 0.0, np.cos(phi)], dtype=complex)
|
|
489
493
|
dirk1 = np.array(
|
|
490
|
-
[
|
|
494
|
+
[
|
|
495
|
+
np.sin(alpha) * np.cos(delta),
|
|
496
|
+
np.sin(alpha) * np.sin(delta),
|
|
497
|
+
np.cos(alpha),
|
|
498
|
+
]
|
|
491
499
|
)
|
|
492
500
|
|
|
493
501
|
# D polarization vector
|
|
494
502
|
u = np.array(
|
|
495
503
|
[
|
|
496
|
-
np.cos(psi) * np.cos(alpha) * np.cos(delta)
|
|
497
|
-
|
|
504
|
+
np.cos(psi) * np.cos(alpha) * np.cos(delta)
|
|
505
|
+
- np.sin(psi) * np.sin(delta),
|
|
506
|
+
np.cos(psi) * np.cos(alpha) * np.sin(delta)
|
|
507
|
+
+ np.sin(psi) * np.cos(delta),
|
|
498
508
|
-np.cos(psi) * np.sin(alpha),
|
|
499
509
|
]
|
|
500
510
|
)
|
|
@@ -814,7 +824,11 @@ class AnisotropicRCWA(RCWA):
|
|
|
814
824
|
denom = (k1[2] - np.dot(u, k1) * u[2]).real
|
|
815
825
|
DEO1[:, iwl] = (
|
|
816
826
|
-(
|
|
817
|
-
(
|
|
827
|
+
(
|
|
828
|
+
np.absolute(ROx) ** 2
|
|
829
|
+
+ np.absolute(ROy) ** 2
|
|
830
|
+
+ np.absolute(ROz) ** 2
|
|
831
|
+
)
|
|
818
832
|
* np.conj(kO1i[2, :])
|
|
819
833
|
- (ROx * kO1i[0, :] + ROy * kO1i[1, :] + ROz * kO1i[2, :])
|
|
820
834
|
* np.conj(ROz)
|
|
@@ -823,7 +837,11 @@ class AnisotropicRCWA(RCWA):
|
|
|
823
837
|
)
|
|
824
838
|
DEE1[:, iwl] = (
|
|
825
839
|
-(
|
|
826
|
-
(
|
|
840
|
+
(
|
|
841
|
+
np.absolute(REx) ** 2
|
|
842
|
+
+ np.absolute(REy) ** 2
|
|
843
|
+
+ np.absolute(REz) ** 2
|
|
844
|
+
)
|
|
827
845
|
* np.conj(kE1i[2, :])
|
|
828
846
|
- (REx * kE1i[0, :] + REy * kE1i[1, :] + REz * kE1i[2, :])
|
|
829
847
|
* np.conj(REz)
|
|
@@ -833,12 +851,14 @@ class AnisotropicRCWA(RCWA):
|
|
|
833
851
|
DEO3[:, iwl] = (
|
|
834
852
|
(np.absolute(TOx) ** 2 + np.absolute(TOy) ** 2 + np.absolute(TOz) ** 2)
|
|
835
853
|
* np.conj(kO3i[2, :])
|
|
836
|
-
- (TOx * kO3i[0, :] + TOy * kO3i[1, :] + TOz * kO3i[2, :])
|
|
854
|
+
- (TOx * kO3i[0, :] + TOy * kO3i[1, :] + TOz * kO3i[2, :])
|
|
855
|
+
* np.conj(TOz)
|
|
837
856
|
).real / denom
|
|
838
857
|
DEE3[:, iwl] = (
|
|
839
858
|
(np.absolute(TEx) ** 2 + np.absolute(TEy) ** 2 + np.absolute(TEz) ** 2)
|
|
840
859
|
* np.conj(kE3i[2, :])
|
|
841
|
-
- (TEx * kE3i[0, :] + TEy * kE3i[1, :] + TEz * kE3i[2, :])
|
|
860
|
+
- (TEx * kE3i[0, :] + TEy * kE3i[1, :] + TEz * kE3i[2, :])
|
|
861
|
+
* np.conj(TEz)
|
|
842
862
|
).real / denom
|
|
843
863
|
|
|
844
864
|
# save the results
|
|
@@ -10,6 +10,7 @@ The package contains some useful routines to study electromagnetic problems with
|
|
|
10
10
|
It is based on U{numpy<http://numpy.scipy.org>} and U{scipy<http://www.scipy.org>}.
|
|
11
11
|
|
|
12
12
|
"""
|
|
13
|
+
|
|
13
14
|
__all__ = [
|
|
14
15
|
"constants",
|
|
15
16
|
"devices",
|
|
@@ -30,6 +31,13 @@ from . import RCWA
|
|
|
30
31
|
from . import scattering
|
|
31
32
|
from . import transfer_matrix
|
|
32
33
|
from . import utils
|
|
33
|
-
from .version import version
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
try:
|
|
36
|
+
from ._version import version as __version__
|
|
37
|
+
except ImportError:
|
|
38
|
+
# Fallback for development environments or edge cases
|
|
39
|
+
try:
|
|
40
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
41
|
+
__version__ = version("electromagneticpython")
|
|
42
|
+
except PackageNotFoundError:
|
|
43
|
+
__version__ = "0.0.0.dev0"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '2.2.4'
|
|
22
|
+
__version_tuple__ = version_tuple = (2, 2, 4)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = 'gd8c276251'
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# pylint: disable=C0302,W0622,W1001,R0902,R0903,W0201,R0913,R0914,C0325,W0221
|
|
2
|
-
|
|
3
1
|
"""Set of objects and functions to describe the behaviour of some
|
|
4
2
|
widely known devices and build new ones.
|
|
5
3
|
|
|
@@ -31,6 +29,7 @@ devices, new ones can be studied.
|
|
|
31
29
|
isnumber=8367>}
|
|
32
30
|
|
|
33
31
|
"""
|
|
32
|
+
|
|
34
33
|
__author__ = "Lorenzo Bolla"
|
|
35
34
|
|
|
36
35
|
import numpy
|
|
@@ -39,7 +38,6 @@ from functools import reduce
|
|
|
39
38
|
|
|
40
39
|
|
|
41
40
|
class DeviceMatrix:
|
|
42
|
-
|
|
43
41
|
"""Device Matrix.
|
|
44
42
|
|
|
45
43
|
Base class for TransferMatrix and ChainMatrix.
|
|
@@ -62,7 +60,7 @@ class DeviceMatrix:
|
|
|
62
60
|
return self.__data
|
|
63
61
|
|
|
64
62
|
def setdata(self, value):
|
|
65
|
-
self.__data = numpy.
|
|
63
|
+
self.__data = numpy.array(value)
|
|
66
64
|
|
|
67
65
|
__data = None
|
|
68
66
|
data = property(fget=getdata, fset=setdata, doc="data")
|
|
@@ -83,7 +81,6 @@ class DeviceMatrix:
|
|
|
83
81
|
|
|
84
82
|
|
|
85
83
|
class TransferMatrix(DeviceMatrix):
|
|
86
|
-
|
|
87
84
|
"""Transfer Matrix.
|
|
88
85
|
|
|
89
86
|
Notation::
|
|
@@ -138,6 +135,7 @@ class TransferMatrix(DeviceMatrix):
|
|
|
138
135
|
|
|
139
136
|
Notation::
|
|
140
137
|
|
|
138
|
+
|
|
141
139
|
b12 = H1 a12 and d12 = H2 c12, but b12 == c12,
|
|
142
140
|
|
|
143
141
|
therefore::
|
|
@@ -154,11 +152,10 @@ class TransferMatrix(DeviceMatrix):
|
|
|
154
152
|
|
|
155
153
|
"""
|
|
156
154
|
|
|
157
|
-
return TransferMatrix(M.to_transfer().data
|
|
155
|
+
return TransferMatrix(M.to_transfer().data @ self.data)
|
|
158
156
|
|
|
159
157
|
|
|
160
158
|
class ChainMatrix(DeviceMatrix):
|
|
161
|
-
|
|
162
159
|
"""Chain Matrix.
|
|
163
160
|
|
|
164
161
|
Notation::
|
|
@@ -229,7 +226,7 @@ class ChainMatrix(DeviceMatrix):
|
|
|
229
226
|
|
|
230
227
|
"""
|
|
231
228
|
|
|
232
|
-
return ChainMatrix(self.data
|
|
229
|
+
return ChainMatrix(self.data @ M.to_chain().data)
|
|
233
230
|
|
|
234
231
|
|
|
235
232
|
def composeTM(A, B):
|
|
@@ -289,7 +286,6 @@ def composeCMlist(CMlist):
|
|
|
289
286
|
|
|
290
287
|
|
|
291
288
|
class Device:
|
|
292
|
-
|
|
293
289
|
"""Generic device.
|
|
294
290
|
|
|
295
291
|
Notes
|
|
@@ -307,7 +303,6 @@ class Device:
|
|
|
307
303
|
|
|
308
304
|
|
|
309
305
|
class Coupler(Device):
|
|
310
|
-
|
|
311
306
|
"""Coupler.
|
|
312
307
|
|
|
313
308
|
Examples
|
|
@@ -436,7 +431,6 @@ class Coupler(Device):
|
|
|
436
431
|
|
|
437
432
|
|
|
438
433
|
class Line(Device):
|
|
439
|
-
|
|
440
434
|
"""Line.
|
|
441
435
|
|
|
442
436
|
Notes
|
|
@@ -570,7 +564,6 @@ class Line(Device):
|
|
|
570
564
|
|
|
571
565
|
|
|
572
566
|
class MZ(Device):
|
|
573
|
-
|
|
574
567
|
"""Mach-Zehnder Interferometer (MZI).
|
|
575
568
|
|
|
576
569
|
A MZI is made of two L{Coupler}s connected by a L{Line}.
|
|
@@ -679,7 +672,6 @@ class MZ(Device):
|
|
|
679
672
|
|
|
680
673
|
|
|
681
674
|
class APRR(Device):
|
|
682
|
-
|
|
683
675
|
"""All-Pass Ring Resonator.
|
|
684
676
|
|
|
685
677
|
An APRR is made of a L{Coupler} with a feedback line (the ring).
|
|
@@ -746,7 +738,6 @@ class APRR(Device):
|
|
|
746
738
|
|
|
747
739
|
|
|
748
740
|
class SRR(Device):
|
|
749
|
-
|
|
750
741
|
"""Single Ring Resonator.
|
|
751
742
|
|
|
752
743
|
A SRR is made of the parallel of a L{Coupler} a feedback line (the
|
|
@@ -872,7 +863,6 @@ class SRR(Device):
|
|
|
872
863
|
|
|
873
864
|
|
|
874
865
|
class NRR(Device):
|
|
875
|
-
|
|
876
866
|
"""N-Rings Resonator.
|
|
877
867
|
|
|
878
868
|
A NRR is made of the parallel of two lines connected by N ring resonators.
|
|
@@ -996,7 +986,6 @@ class NRR(Device):
|
|
|
996
986
|
|
|
997
987
|
|
|
998
988
|
class T_TCRR(Device):
|
|
999
|
-
|
|
1000
989
|
"""Tunable Triple-Coupled Ring Resonator.
|
|
1001
990
|
|
|
1002
991
|
A T_TCRR is made of a L{MZ}, with a feedback line.
|
|
@@ -1056,8 +1045,7 @@ class T_TCRR(Device):
|
|
|
1056
1045
|
t4 = numpy.exp(-1j * beta * l[3])
|
|
1057
1046
|
|
|
1058
1047
|
denom = (
|
|
1059
|
-
q**3 * Kbar[2] * t3 * t4 * (Kbar[0] * Kbar[1] * t1 - K[0] * K[1] * t2)
|
|
1060
|
-
- 1.0
|
|
1048
|
+
q**3 * Kbar[2] * t3 * t4 * (Kbar[0] * Kbar[1] * t1 - K[0] * K[1] * t2) - 1.0
|
|
1061
1049
|
)
|
|
1062
1050
|
self.DROP = (
|
|
1063
1051
|
q**3 * K[2] * t3 * (K[0] * Kbar[1] * t1 + Kbar[0] * K[1] * t2) / denom
|
|
@@ -1071,7 +1059,6 @@ class T_TCRR(Device):
|
|
|
1071
1059
|
|
|
1072
1060
|
|
|
1073
1061
|
class T_CRTCRR(Device):
|
|
1074
|
-
|
|
1075
1062
|
"""Tunable Coupled Ring Triple-Coupled Ring Resonator.
|
|
1076
1063
|
|
|
1077
1064
|
NOTE
|
|
@@ -1129,16 +1116,7 @@ class T_CRTCRR(Device):
|
|
|
1129
1116
|
- q**2 * Kbar[1] * t2**2 * (Kbar[2] - q**3 * t1**2 * N1)
|
|
1130
1117
|
)
|
|
1131
1118
|
self.DROP = (
|
|
1132
|
-
1j
|
|
1133
|
-
* q**4
|
|
1134
|
-
* K[0]
|
|
1135
|
-
* K[1]
|
|
1136
|
-
* K[2]
|
|
1137
|
-
* Kbar[0]
|
|
1138
|
-
* t1**1.5
|
|
1139
|
-
* t2
|
|
1140
|
-
* (1 + t31)
|
|
1141
|
-
/ denom
|
|
1119
|
+
1j * q**4 * K[0] * K[1] * K[2] * Kbar[0] * t1**1.5 * t2 * (1 + t31) / denom
|
|
1142
1120
|
)
|
|
1143
1121
|
self.THRU = (
|
|
1144
1122
|
q**2
|
|
@@ -1156,7 +1134,6 @@ class T_CRTCRR(Device):
|
|
|
1156
1134
|
|
|
1157
1135
|
|
|
1158
1136
|
class T_CTCRR(Device):
|
|
1159
|
-
|
|
1160
1137
|
"""Tunable Coupled Triple Coupled Ring Resonator.
|
|
1161
1138
|
|
|
1162
1139
|
NOTE
|
|
@@ -1363,7 +1340,6 @@ class SWG(Device):
|
|
|
1363
1340
|
|
|
1364
1341
|
|
|
1365
1342
|
class Etalon(Device):
|
|
1366
|
-
|
|
1367
1343
|
"""Etalon.
|
|
1368
1344
|
|
|
1369
1345
|
@ivar R: Reflectivity.
|
|
@@ -1402,7 +1378,7 @@ class Etalon(Device):
|
|
|
1402
1378
|
self.wl0 = numpy.mean(wls)
|
|
1403
1379
|
self.FSRwl = self.wl0**2 / (2 * n * l * numpy.cos(self.theta) + self.wl0)
|
|
1404
1380
|
|
|
1405
|
-
|
|
1381
|
+
self.f0, self.FSR = EMpy.utils.wl2f(self.wl0, self.FSRwl)
|
|
1406
1382
|
|
|
1407
1383
|
self.FINESSE = numpy.pi / (2 * numpy.arcsin(1.0 / numpy.sqrt(self.F)))
|
|
1408
1384
|
# self.FINESSE = numpy.pi * numpy.sqrt(self.F) / 2.
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
# pylint: disable=W0622,R0903,R0902,R0913,W0633
|
|
2
|
-
|
|
3
1
|
"""Functions and objects to manipulate materials.
|
|
4
2
|
|
|
5
3
|
A material is an object with a refractive index function.
|
|
6
4
|
|
|
7
5
|
"""
|
|
6
|
+
|
|
8
7
|
from functools import partial
|
|
9
8
|
|
|
10
9
|
import numpy
|
|
@@ -15,7 +14,6 @@ __author__ = "Lorenzo Bolla"
|
|
|
15
14
|
|
|
16
15
|
|
|
17
16
|
class Material:
|
|
18
|
-
|
|
19
17
|
"""Generic class to handle materials.
|
|
20
18
|
|
|
21
19
|
This class is intended to be subclassed to obtain isotropic and
|
|
@@ -28,7 +26,6 @@ class Material:
|
|
|
28
26
|
|
|
29
27
|
|
|
30
28
|
class RefractiveIndex:
|
|
31
|
-
|
|
32
29
|
"""Refractive Index.
|
|
33
30
|
|
|
34
31
|
Unaware of temperature.
|
|
@@ -146,7 +143,6 @@ class RefractiveIndex:
|
|
|
146
143
|
|
|
147
144
|
|
|
148
145
|
class ThermalOpticCoefficient:
|
|
149
|
-
|
|
150
146
|
"""Thermal Optic Coefficient."""
|
|
151
147
|
|
|
152
148
|
def __init__(self, data=None, T0=300):
|
|
@@ -168,7 +164,6 @@ class ThermalOpticCoefficient:
|
|
|
168
164
|
|
|
169
165
|
|
|
170
166
|
class IsotropicMaterial(Material):
|
|
171
|
-
|
|
172
167
|
"""Subclasses Material to describe isotropic materials.
|
|
173
168
|
|
|
174
169
|
Frequency dispersion and thermic aware.
|
|
@@ -232,7 +227,6 @@ class EpsilonTensor:
|
|
|
232
227
|
|
|
233
228
|
|
|
234
229
|
class AnisotropicMaterial(Material):
|
|
235
|
-
|
|
236
230
|
"""Subclass Material to describe anisotropic materials.
|
|
237
231
|
|
|
238
232
|
No frequency dispersion nor thermic aware.
|
|
@@ -292,7 +286,6 @@ BK7 = IsotropicMaterial(
|
|
|
292
286
|
|
|
293
287
|
|
|
294
288
|
class LiquidCrystal(Material):
|
|
295
|
-
|
|
296
289
|
"""Liquid Crystal.
|
|
297
290
|
|
|
298
291
|
A liquid crystal is determined by it ordinary and extraordinary
|