PyOptik 1.10.8__tar.gz → 1.12.0__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.
- {pyoptik-1.10.8 → pyoptik-1.12.0}/.gitignore +1 -1
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PKG-INFO +7 -3
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/__init__.py +2 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/__main__.py +1 -1
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/_version.py +2 -2
- pyoptik-1.12.0/PyOptik/data/sellmeier/BK7.yml +57 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/directories.py +8 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/libraries/classics.yml +4 -2
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/libraries/dielectrics.yml +2 -1
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/libraries/repertoire.yml +1 -1
- pyoptik-1.12.0/PyOptik/material/base_class.py +137 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/material/sellmeier_class.py +12 -12
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/material/tabulated_class.py +10 -13
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/material_bank.py +62 -52
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/material_type.py +2 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/units.py +12 -7
- pyoptik-1.12.0/PyOptik/utils.py +97 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik.egg-info/PKG-INFO +7 -3
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik.egg-info/SOURCES.txt +6 -30
- {pyoptik-1.10.8 → pyoptik-1.12.0}/README.rst +5 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/source/conf.py +1 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/meta.yaml +3 -1
- {pyoptik-1.10.8 → pyoptik-1.12.0}/pyproject.toml +3 -2
- pyoptik-1.12.0/tests/test_base_material_decorator.py +38 -0
- pyoptik-1.12.0/tests/test_group_properties.py +27 -0
- pyoptik-1.12.0/tests/test_material_bank_extra.py +34 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/tests/test_sellmeier.py +16 -1
- {pyoptik-1.10.8 → pyoptik-1.12.0}/tests/test_tabulated.py +1 -1
- {pyoptik-1.10.8 → pyoptik-1.12.0}/tests/test_usual_materials.py +3 -2
- {pyoptik-1.10.8 → pyoptik-1.12.0}/tests/test_utils.py +19 -21
- pyoptik-1.12.0/tests/test_utils_extra.py +41 -0
- pyoptik-1.10.8/PyOptik/data/sellmeier/BAF10.yml +0 -59
- pyoptik-1.10.8/PyOptik/data/sellmeier/FK51A.yml +0 -64
- pyoptik-1.10.8/PyOptik/data/sellmeier/LASF9.yml +0 -57
- pyoptik-1.10.8/PyOptik/data/sellmeier/SF10.yml +0 -56
- pyoptik-1.10.8/PyOptik/data/sellmeier/SF11.yml +0 -55
- pyoptik-1.10.8/PyOptik/data/sellmeier/acetylene.yml +0 -18
- pyoptik-1.10.8/PyOptik/data/sellmeier/cellulose.yml +0 -17
- pyoptik-1.10.8/PyOptik/data/sellmeier/ethane.yml +0 -20
- pyoptik-1.10.8/PyOptik/data/sellmeier/ethanol.yml +0 -16
- pyoptik-1.10.8/PyOptik/data/sellmeier/ethylene.yml +0 -18
- pyoptik-1.10.8/PyOptik/data/sellmeier/glycerol.yml +0 -16
- pyoptik-1.10.8/PyOptik/data/sellmeier/methane.yml +0 -18
- pyoptik-1.10.8/PyOptik/data/sellmeier/methanol.yml +0 -16
- pyoptik-1.10.8/PyOptik/data/sellmeier/polycarbonate.yml +0 -17
- pyoptik-1.10.8/PyOptik/data/sellmeier/polystyrene.yml +0 -17
- pyoptik-1.10.8/PyOptik/data/sellmeier/propanol.yml +0 -16
- pyoptik-1.10.8/PyOptik/data/sellmeier/pvc.yml +0 -16
- pyoptik-1.10.8/PyOptik/data/tabulated/BK7.yml +0 -862
- pyoptik-1.10.8/PyOptik/data/tabulated/bismuth.yml +0 -163
- pyoptik-1.10.8/PyOptik/data/tabulated/chromium.yml +0 -62
- pyoptik-1.10.8/PyOptik/data/tabulated/lead.yml +0 -163
- pyoptik-1.10.8/PyOptik/data/tabulated/magnesium.yml +0 -153
- pyoptik-1.10.8/PyOptik/data/tabulated/paladium.yml +0 -62
- pyoptik-1.10.8/PyOptik/data/tabulated/pva.yml +0 -635
- pyoptik-1.10.8/PyOptik/data/tabulated/rhodium.yml +0 -21
- pyoptik-1.10.8/PyOptik/data/tabulated/tantalum.yml +0 -163
- pyoptik-1.10.8/PyOptik/data/tabulated/titanium.yml +0 -62
- pyoptik-1.10.8/PyOptik/data/tabulated/tungsten.yml +0 -163
- pyoptik-1.10.8/PyOptik/data/tabulated/vanadium.yml +0 -62
- pyoptik-1.10.8/PyOptik/material/base_class.py +0 -90
- pyoptik-1.10.8/PyOptik/utils.py +0 -45
- {pyoptik-1.10.8 → pyoptik-1.12.0}/.flake8 +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/.github/dependabot.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/.github/workflows/deploy_PyPi.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/.github/workflows/deploy_anaconda.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/.github/workflows/deploy_coverage.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/.github/workflows/deploy_documentation.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/LICENSE +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/__init__.py +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/sellmeier/BAK1.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/sellmeier/SF5.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/sellmeier/ZBLAN.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/sellmeier/acetone.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/sellmeier/air.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/sellmeier/argon.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/sellmeier/crown.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/sellmeier/flint.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/sellmeier/fused_silica.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/sellmeier/germanium.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/sellmeier/lithium_niobate.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/sellmeier/polystyren.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/sellmeier/soda_lime_glass.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/sellmeier/water.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/tabulated/aluminium.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/tabulated/calcium.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/tabulated/copper.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/tabulated/gold.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/tabulated/iron.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/tabulated/nickel.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/tabulated/polyetylene.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/tabulated/silicon.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/tabulated/silver.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/tabulated/sodium.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/data/tabulated/zinc.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/libraries/__init__.py +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/libraries/metals.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/libraries/minimal.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/libraries/organics.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/libraries/others.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/libraries/polymers.yml +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik/material/__init__.py +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik.egg-info/dependency_links.txt +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik.egg-info/requires.txt +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/PyOptik.egg-info/top_level.txt +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/development/dev_0.py +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/Makefile +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/examples/README.rst +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/examples/sellmeier/README.rst +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/examples/sellmeier/plot_bk7.py +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/examples/sellmeier/plot_silica.py +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/examples/sellmeier/plot_water.py +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/examples/tabulated/README.rst +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/examples/tabulated/plot_sf5.py +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/examples/tabulated/plot_silver.py +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/examples/utils/README.rst +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/examples/utils/__build_library.py +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/examples/utils/__download_yml_file.py +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/examples/utils/create_sellmeier_file.py +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/examples/utils/create_tabulated_file.py +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/images/example_bk7.png +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/images/logo.png +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/make.bat +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/source/_static/default.css +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/source/_static/thumbnail.png +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/source/code.rst +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/source/gallery/index.rst +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/source/index.rst +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/docs/source/references.rst +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/setup.cfg +0 -0
- {pyoptik-1.10.8 → pyoptik-1.12.0}/tests/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyOptik
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.12.0
|
|
4
4
|
Summary: A package for refractive index values.
|
|
5
5
|
Author-email: Martin Poinsinet de Sivry-Houle <martin.poinsinet.de.sivry@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -25,13 +25,12 @@ License: MIT License
|
|
|
25
25
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
26
|
SOFTWARE.
|
|
27
27
|
|
|
28
|
-
Keywords:
|
|
28
|
+
Keywords: refractive index,optics
|
|
29
29
|
Classifier: Programming Language :: Python
|
|
30
30
|
Classifier: Programming Language :: Python :: 3
|
|
31
31
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
32
32
|
Classifier: Development Status :: 4 - Beta
|
|
33
33
|
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
34
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
35
34
|
Classifier: Intended Audience :: Science/Research
|
|
36
35
|
Requires-Python: >=3.10
|
|
37
36
|
Description-Content-Type: text/x-rst
|
|
@@ -93,6 +92,7 @@ Features
|
|
|
93
92
|
- **Simulation Ready**: Ideal for light-matter interaction simulations, particularly in optics and photonics.
|
|
94
93
|
- **Simple API**: Easy-to-use API that integrates well with other Python libraries.
|
|
95
94
|
- **Open Source**: Fully open-source.
|
|
95
|
+
- **Group Index and Velocity**: Compute group index and group velocity directly from material objects.
|
|
96
96
|
|
|
97
97
|
Installation
|
|
98
98
|
************
|
|
@@ -175,6 +175,10 @@ After installing PyOptik and building the material library, you can easily acces
|
|
|
175
175
|
bk7 = MaterialBank.BK7
|
|
176
176
|
n = bk7.compute_refractive_index(0.55e-6)
|
|
177
177
|
print(f"Refractive index at 0.55 µm: {n}")
|
|
178
|
+
# Group index and group velocity
|
|
179
|
+
n_g = bk7.compute_group_index(0.55e-6)
|
|
180
|
+
v_g = bk7.compute_group_velocity(0.55e-6)
|
|
181
|
+
print(f"Group index: {n_g:.3f}, group velocity: {v_g:.1f}")
|
|
178
182
|
|
|
179
183
|
Example
|
|
180
184
|
*******
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# this file is part of refractiveindex.info database
|
|
2
|
+
# refractiveindex.info database is in the public domain
|
|
3
|
+
# copyright and related rights waived via CC0 1.0
|
|
4
|
+
|
|
5
|
+
REFERENCES: |
|
|
6
|
+
<a href="https://refractiveindex.info/download/data/2017/schott_2017-01-20b.agf">SCHOTT Zemax catalog 2017-01-20b</a> (obtained from <a href="https://www.schott.com/en-us/products/optical-glass-p1000267/downloads/">http://www.schott.com</a>)<br>See also <a href="https://refractiveindex.info/download/data/2017/schott_2017-01-20.pdf">SCHOTT glass data sheets</a>
|
|
7
|
+
COMMENTS: |
|
|
8
|
+
suitable for precision molding
|
|
9
|
+
DATA:
|
|
10
|
+
- type: formula 2
|
|
11
|
+
wavelength_range: 0.31 2.5
|
|
12
|
+
coefficients: 0 1.18318503 0.00722141956 0.0871756426 0.0268216805 1.03133701 101.702362
|
|
13
|
+
- type: tabulated k
|
|
14
|
+
data: |
|
|
15
|
+
0.310 3.8602E-06
|
|
16
|
+
0.320 1.4536E-06
|
|
17
|
+
0.334 3.3459E-07
|
|
18
|
+
0.350 8.0850E-08
|
|
19
|
+
0.365 3.1801E-08
|
|
20
|
+
0.370 2.4996E-08
|
|
21
|
+
0.380 1.7054E-08
|
|
22
|
+
0.390 1.2477E-08
|
|
23
|
+
0.400 1.0227E-08
|
|
24
|
+
0.405 9.0558E-09
|
|
25
|
+
0.420 8.0456E-09
|
|
26
|
+
0.436 8.3521E-09
|
|
27
|
+
0.460 7.3395E-09
|
|
28
|
+
0.500 6.3790E-09
|
|
29
|
+
0.546 5.2218E-09
|
|
30
|
+
0.580 5.5469E-09
|
|
31
|
+
0.620 5.9295E-09
|
|
32
|
+
0.660 6.3120E-09
|
|
33
|
+
0.700 6.6946E-09
|
|
34
|
+
1.060 3.3758E-09
|
|
35
|
+
1.530 1.0336E-07
|
|
36
|
+
1.970 5.2286E-07
|
|
37
|
+
2.325 2.6396E-06
|
|
38
|
+
2.500 6.1794E-06
|
|
39
|
+
PROPERTIES:
|
|
40
|
+
nd: 1.5164
|
|
41
|
+
Vd: 64.06
|
|
42
|
+
glass_code: 516641.243
|
|
43
|
+
glass_status: standard
|
|
44
|
+
density:
|
|
45
|
+
- value: 2433
|
|
46
|
+
thermal_expansion:
|
|
47
|
+
- temperature_range: 243 343
|
|
48
|
+
value: 5.99e-06
|
|
49
|
+
- temperature_range: 293 573
|
|
50
|
+
value: 7.32e-06
|
|
51
|
+
dPgF: -0.0025
|
|
52
|
+
resistance:
|
|
53
|
+
climatic: 1.0
|
|
54
|
+
stain: 0.0
|
|
55
|
+
acid: 1.0
|
|
56
|
+
alkali: 2.3
|
|
57
|
+
phosphate: 2.3
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
|
|
4
|
+
"""Convenience paths used throughout the :mod:`PyOptik` package.
|
|
5
|
+
|
|
6
|
+
This module exposes commonly referenced directories such as the project
|
|
7
|
+
root, documentation and data folders. It is imported by other modules to
|
|
8
|
+
construct absolute paths in a centralised manner and therefore simplifies
|
|
9
|
+
file handling across the code base.
|
|
10
|
+
"""
|
|
11
|
+
|
|
4
12
|
from pathlib import Path
|
|
5
13
|
import PyOptik
|
|
6
14
|
|
|
@@ -13,10 +13,11 @@ sellmeier:
|
|
|
13
13
|
- argon
|
|
14
14
|
- air
|
|
15
15
|
- water
|
|
16
|
+
- acetone
|
|
17
|
+
- BK7
|
|
16
18
|
|
|
17
19
|
tabulated:
|
|
18
20
|
- silicon
|
|
19
|
-
- BK7
|
|
20
21
|
- silver
|
|
21
22
|
- aluminium
|
|
22
23
|
- gold
|
|
@@ -25,4 +26,5 @@ tabulated:
|
|
|
25
26
|
- iron
|
|
26
27
|
- sodium
|
|
27
28
|
- nickel
|
|
28
|
-
- zinc
|
|
29
|
+
- zinc
|
|
30
|
+
- polyetylene
|
|
@@ -13,6 +13,7 @@ sellmeier:
|
|
|
13
13
|
lithium_niobate: https://refractiveindex.info/database/data/main/LiNbO3/nk/Zelmon-o.yml
|
|
14
14
|
germanium: https://refractiveindex.info/database/data/main/Ge/nk/Icenogle.yml
|
|
15
15
|
|
|
16
|
+
BK7: https://refractiveindex.info/database/data/specs/schott/optical/P-BK7.yml
|
|
16
17
|
soda_lime_glass: https://refractiveindex.info/database/data/glass/misc/soda-lime/nk/Rubin-clear.yml
|
|
17
18
|
crown: https://refractiveindex.info/database/data/specs/schott/optical/K7.yml
|
|
18
19
|
flint: https://refractiveindex.info/database/data/specs/schott/optical/F2.yml
|
|
@@ -37,7 +38,6 @@ tabulated:
|
|
|
37
38
|
pva: https://refractiveindex.info/database/data/organic/(C2H3Cl)n%20-%20polyvinyl%20chloride/nk/Zhang.yml
|
|
38
39
|
polyetylene: https://refractiveindex.info/database/data/organic/(C2H4)n%20-%20polyethylene/nk/Smith.yml
|
|
39
40
|
silicon: https://refractiveindex.info/database/data/main/Si/nk/Aspnes.yml
|
|
40
|
-
BK7: https://refractiveindex.info/database/data/specs/schott/optical/P-BK7.yml
|
|
41
41
|
silver: https://refractiveindex.info/database/data/main/Ag/nk/Johnson.yml
|
|
42
42
|
aluminium: https://refractiveindex.info/database/data/main/Al/nk/Rakic.yml
|
|
43
43
|
gold: https://refractiveindex.info/database/data/main/Au/nk/Johnson.yml
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
from typing import Callable
|
|
5
|
+
from PyOptik import units
|
|
6
|
+
import numpy
|
|
7
|
+
import warnings
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class BaseMaterial(object):
|
|
11
|
+
def __eq__(self, other) -> bool:
|
|
12
|
+
if not isinstance(other, self.__class__):
|
|
13
|
+
return False
|
|
14
|
+
|
|
15
|
+
if self.filename != other.filename:
|
|
16
|
+
return False
|
|
17
|
+
|
|
18
|
+
return True
|
|
19
|
+
|
|
20
|
+
def __str__(self) -> str:
|
|
21
|
+
"""
|
|
22
|
+
Provides an informal string representation of the Material object.
|
|
23
|
+
|
|
24
|
+
Returns
|
|
25
|
+
-------
|
|
26
|
+
str
|
|
27
|
+
Informal representation of the Material object.
|
|
28
|
+
"""
|
|
29
|
+
return f"Material: {self.filename}"
|
|
30
|
+
|
|
31
|
+
def __repr__(self) -> str:
|
|
32
|
+
"""
|
|
33
|
+
Provides a formal string representation of the Material object, including key attributes.
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
-------
|
|
37
|
+
str
|
|
38
|
+
Formal representation of the Material object.
|
|
39
|
+
"""
|
|
40
|
+
return self.__str__()
|
|
41
|
+
|
|
42
|
+
def _check_wavelength(self, wavelength: units.Quantity) -> None:
|
|
43
|
+
"""
|
|
44
|
+
Checks if a wavelength is within the material's allowable range and raises a warning if it is not.
|
|
45
|
+
|
|
46
|
+
Parameters
|
|
47
|
+
----------
|
|
48
|
+
wavelength : Quantity
|
|
49
|
+
The wavelength to check, in micrometers.
|
|
50
|
+
|
|
51
|
+
Raises
|
|
52
|
+
------
|
|
53
|
+
UserWarning
|
|
54
|
+
If the wavelength is outside the allowable range.
|
|
55
|
+
"""
|
|
56
|
+
if self.wavelength_bound is not None:
|
|
57
|
+
min_value, max_value = self.wavelength_bound
|
|
58
|
+
|
|
59
|
+
if numpy.any((wavelength < min_value) | (wavelength > max_value)):
|
|
60
|
+
warnings.warn(
|
|
61
|
+
f"Wavelength range goes from {wavelength.min().to_compact()} to {wavelength.max().to_compact()} "
|
|
62
|
+
f"which is outside the allowable range of {min_value.to_compact()} to {max_value.to_compact()} µm. "
|
|
63
|
+
f"[Material: {self.filename}]"
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
def ensure_units(func) -> Callable:
|
|
67
|
+
"""Decorator ensuring the wavelength argument carries units.
|
|
68
|
+
|
|
69
|
+
Parameters
|
|
70
|
+
----------
|
|
71
|
+
func : Callable
|
|
72
|
+
Function that expects a wavelength :class:`~PyOptik.units.Quantity`.
|
|
73
|
+
|
|
74
|
+
Returns
|
|
75
|
+
-------
|
|
76
|
+
Callable
|
|
77
|
+
Wrapped version of ``func`` that accepts numerical wavelengths and
|
|
78
|
+
converts them to metre-based :class:`~PyOptik.units.Quantity` objects.
|
|
79
|
+
"""
|
|
80
|
+
def wrapper(self, wavelength: units.Quantity = None, *args, **kwargs):
|
|
81
|
+
if wavelength is None:
|
|
82
|
+
if self.wavelength_bound is None:
|
|
83
|
+
raise ValueError('Wavelength must be provided for computation.')
|
|
84
|
+
wavelength = numpy.linspace(self.wavelength_bound[0].magnitude, self.wavelength_bound[1].magnitude, 100) * self.wavelength_bound.units
|
|
85
|
+
|
|
86
|
+
if not isinstance(wavelength, units.Quantity):
|
|
87
|
+
wavelength = wavelength * units.meter
|
|
88
|
+
return func(self, wavelength, *args, **kwargs)
|
|
89
|
+
return wrapper
|
|
90
|
+
|
|
91
|
+
@ensure_units
|
|
92
|
+
def compute_group_index(self, wavelength: units.Quantity, delta: units.Quantity = 1 * units.nanometer) -> units.Quantity:
|
|
93
|
+
"""
|
|
94
|
+
Calculate the group refractive index n_g(\u03bb).
|
|
95
|
+
The group index is defined as n_g(\u03bb) = n(\u03bb) - \u03bb * dn/d\u03bb,
|
|
96
|
+
where n(\u03bb) is the refractive index and dn/d\u03bb is the derivative of
|
|
97
|
+
the refractive index with respect to wavelength.
|
|
98
|
+
|
|
99
|
+
Parameters
|
|
100
|
+
----------
|
|
101
|
+
wavelength : units.Quantity
|
|
102
|
+
Wavelength at which to compute the group index, in metres.
|
|
103
|
+
delta : units.Quantity, optional
|
|
104
|
+
Small change in wavelength for numerical differentiation, default is 1 nanometer.
|
|
105
|
+
|
|
106
|
+
Returns
|
|
107
|
+
-------
|
|
108
|
+
units.Quantity
|
|
109
|
+
Group refractive index at the specified wavelength, in dimensionless units.
|
|
110
|
+
-------
|
|
111
|
+
units.Quantity
|
|
112
|
+
Group refractive index at the specified wavelength, in dimensionless units.
|
|
113
|
+
"""
|
|
114
|
+
n = self.compute_refractive_index(wavelength)
|
|
115
|
+
n_plus = self.compute_refractive_index(wavelength + delta)
|
|
116
|
+
dn_dlambda = (n_plus - n) / delta
|
|
117
|
+
return n - wavelength * dn_dlambda
|
|
118
|
+
|
|
119
|
+
@ensure_units
|
|
120
|
+
def compute_group_velocity(self, wavelength: units.Quantity) -> units.Quantity:
|
|
121
|
+
"""
|
|
122
|
+
Calculate the group velocity v_g(\u03bb) = c / n_g(\u03bb),
|
|
123
|
+
where c is the speed of light in vacuum and n_g(\u03bb) is the group index.
|
|
124
|
+
|
|
125
|
+
Parameters
|
|
126
|
+
----------
|
|
127
|
+
wavelength : units.Quantity
|
|
128
|
+
Wavelength at which to compute the group velocity, in metres.
|
|
129
|
+
|
|
130
|
+
Returns
|
|
131
|
+
-------
|
|
132
|
+
units.Quantity
|
|
133
|
+
Group velocity at the specified wavelength, in metres per second.
|
|
134
|
+
"""
|
|
135
|
+
ng = self.compute_group_index(wavelength)
|
|
136
|
+
c = 299792458 * units.meter / units.second
|
|
137
|
+
return c / ng
|
|
@@ -7,7 +7,7 @@ import itertools
|
|
|
7
7
|
from MPSPlots.styles import mps
|
|
8
8
|
import matplotlib.pyplot as plt
|
|
9
9
|
from typing import Optional, Union
|
|
10
|
-
from PyOptik
|
|
10
|
+
from PyOptik import units
|
|
11
11
|
from PyOptik.directories import sellmeier_data_path
|
|
12
12
|
from PyOptik.material.base_class import BaseMaterial
|
|
13
13
|
|
|
@@ -80,7 +80,7 @@ class SellmeierMaterial(BaseMaterial):
|
|
|
80
80
|
if 'wavelength_range' in parsed_yaml['DATA'][0]:
|
|
81
81
|
data_str = parsed_yaml['DATA'][0]['wavelength_range'].split()
|
|
82
82
|
|
|
83
|
-
self.wavelength_bound = numpy.array([float(val) for val in data_str]) * micrometer
|
|
83
|
+
self.wavelength_bound = numpy.array([float(val) for val in data_str]) * units.micrometer
|
|
84
84
|
|
|
85
85
|
else:
|
|
86
86
|
self.wavelength_bound = None
|
|
@@ -89,18 +89,18 @@ class SellmeierMaterial(BaseMaterial):
|
|
|
89
89
|
self.reference = parsed_yaml.get('REFERENCES', None)
|
|
90
90
|
|
|
91
91
|
@BaseMaterial.ensure_units
|
|
92
|
-
def compute_refractive_index(self, wavelength: Union[Quantity]) -> Union[float, numpy.ndarray]:
|
|
92
|
+
def compute_refractive_index(self, wavelength: Union[units.Quantity]) -> Union[float, numpy.ndarray]:
|
|
93
93
|
r"""
|
|
94
94
|
Computes the refractive index n(\u03bb) using the appropriate formula (either Formula 1, 2, 5, or 6).
|
|
95
95
|
|
|
96
96
|
Parameters
|
|
97
97
|
----------
|
|
98
|
-
wavelength : Union[Quantity]
|
|
98
|
+
wavelength : Union[units.Quantity]
|
|
99
99
|
The wavelength \u03bb in meters, can be a single float or a numpy array.
|
|
100
100
|
|
|
101
101
|
Returns
|
|
102
102
|
-------
|
|
103
|
-
Union[Quantity]
|
|
103
|
+
Union[units.Quantity]
|
|
104
104
|
The refractive index n(\u03bb) for the given wavelength or array of wavelengths.
|
|
105
105
|
|
|
106
106
|
Raises
|
|
@@ -120,25 +120,25 @@ class SellmeierMaterial(BaseMaterial):
|
|
|
120
120
|
case 1: # Formula 1 computation (standard Sellmeier)
|
|
121
121
|
n_squared = 1.0
|
|
122
122
|
for (B, C) in zipped_coefficients:
|
|
123
|
-
n_squared += (B * wavelength.to(micrometer).magnitude**2) / (wavelength.to(micrometer).magnitude**2 - C**2)
|
|
123
|
+
n_squared += (B * wavelength.to(units.micrometer).magnitude**2) / (wavelength.to(units.micrometer).magnitude**2 - C**2)
|
|
124
124
|
|
|
125
125
|
n = numpy.sqrt(n_squared)
|
|
126
126
|
|
|
127
127
|
case 2: # Formula 2 computation (extended Sellmeier)
|
|
128
128
|
n_squared = 1 + self.coefficients[0]
|
|
129
129
|
for (B, C) in zipped_coefficients:
|
|
130
|
-
n_squared += (B * wavelength.to(micrometer).magnitude**2) / (wavelength.to(micrometer).magnitude**2 - C)
|
|
130
|
+
n_squared += (B * wavelength.to(units.micrometer).magnitude**2) / (wavelength.to(units.micrometer).magnitude**2 - C)
|
|
131
131
|
n = numpy.sqrt(n_squared)
|
|
132
132
|
|
|
133
133
|
case 5: # Formula 5 computation (extended Sellmeier)
|
|
134
134
|
n = 1 + self.coefficients[0]
|
|
135
135
|
for (B, C) in zipped_coefficients:
|
|
136
|
-
n
|
|
136
|
+
n += B * wavelength.to(units.micrometer).magnitude**C
|
|
137
137
|
|
|
138
138
|
case 6:
|
|
139
139
|
n = 1 + self.coefficients[0]
|
|
140
140
|
for (B, C) in zipped_coefficients:
|
|
141
|
-
n = B / (C - wavelength.to(micrometer).magnitude**-2)
|
|
141
|
+
n = B / (C - wavelength.to(units.micrometer).magnitude**-2)
|
|
142
142
|
|
|
143
143
|
case _:
|
|
144
144
|
raise ValueError(f"Unsupported formula type: {self.formula_type}")
|
|
@@ -146,13 +146,13 @@ class SellmeierMaterial(BaseMaterial):
|
|
|
146
146
|
return n[0] if return_as_scalar else n
|
|
147
147
|
|
|
148
148
|
@BaseMaterial.ensure_units
|
|
149
|
-
def plot(self, wavelength: Optional[Quantity] = None) -> None:
|
|
149
|
+
def plot(self, wavelength: Optional[units.Quantity] = None) -> None:
|
|
150
150
|
"""
|
|
151
151
|
Plots the refractive index as a function of wavelength over a specified range.
|
|
152
152
|
|
|
153
153
|
Parameters
|
|
154
154
|
----------
|
|
155
|
-
wavelength : Optional[Quantity]
|
|
155
|
+
wavelength : Optional[units.Quantity]
|
|
156
156
|
The range of wavelengths to plot, in meters. If not provided, the entire allowable wavelength range is used.
|
|
157
157
|
|
|
158
158
|
Raises
|
|
@@ -174,7 +174,7 @@ class SellmeierMaterial(BaseMaterial):
|
|
|
174
174
|
xlabel=r'Wavelength [$\mu$m]',
|
|
175
175
|
title=f"Refractive Index vs. Wavelength: [{self.filename}]"
|
|
176
176
|
)
|
|
177
|
-
ax.plot(wavelength.to(micrometer).magnitude, refractive_index.real, linewidth=2, label='Real Part')
|
|
177
|
+
ax.plot(wavelength.to(units.micrometer).magnitude, refractive_index.real, linewidth=2, label='Real Part')
|
|
178
178
|
ax.legend()
|
|
179
179
|
|
|
180
180
|
plt.show()
|
|
@@ -8,7 +8,7 @@ from PyOptik.directories import tabulated_data_path
|
|
|
8
8
|
from PyOptik.material.base_class import BaseMaterial
|
|
9
9
|
from MPSPlots.styles import mps
|
|
10
10
|
import matplotlib.pyplot as plt
|
|
11
|
-
from PyOptik
|
|
11
|
+
from PyOptik import units
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
@@ -74,6 +74,7 @@ class TabulatedMaterial(BaseMaterial):
|
|
|
74
74
|
raise FileNotFoundError(f"YAML file {file_path} not found.")
|
|
75
75
|
|
|
76
76
|
with file_path.with_suffix('.yml').open('r') as file:
|
|
77
|
+
print(file)
|
|
77
78
|
parsed_yaml = yaml.safe_load(file)
|
|
78
79
|
|
|
79
80
|
try:
|
|
@@ -81,19 +82,19 @@ class TabulatedMaterial(BaseMaterial):
|
|
|
81
82
|
data_points = parsed_yaml['DATA'][0]['data'].strip().split('\n')
|
|
82
83
|
data = numpy.array([[float(value) for value in point.split()] for point in data_points])
|
|
83
84
|
|
|
84
|
-
self.wavelength = data[:, 0] * micrometer
|
|
85
|
+
self.wavelength = data[:, 0] * units.micrometer
|
|
85
86
|
self.n_values = data[:, 1]
|
|
86
87
|
self.k_values = data[:, 2]
|
|
87
88
|
except (KeyError, IndexError, ValueError):
|
|
88
89
|
raise ValueError(f"Invalid or missing data in YAML file {file_path}")
|
|
89
90
|
|
|
90
|
-
self.wavelength_bound = [self.wavelength.min().magnitude, self.wavelength.max().magnitude] * micrometer
|
|
91
|
+
self.wavelength_bound = [self.wavelength.min().magnitude, self.wavelength.max().magnitude] * units.micrometer
|
|
91
92
|
|
|
92
93
|
# Extract reference
|
|
93
94
|
self.reference = parsed_yaml.get('REFERENCES', None)
|
|
94
95
|
|
|
95
96
|
@BaseMaterial.ensure_units
|
|
96
|
-
def compute_refractive_index(self, wavelength: Union[float, Quantity]) -> numpy.ndarray:
|
|
97
|
+
def compute_refractive_index(self, wavelength: Union[float, units.Quantity]) -> numpy.ndarray:
|
|
97
98
|
"""
|
|
98
99
|
Interpolates the refractive index (n) and absorption (k) values for the given wavelength(s).
|
|
99
100
|
|
|
@@ -118,15 +119,15 @@ class TabulatedMaterial(BaseMaterial):
|
|
|
118
119
|
|
|
119
120
|
self._check_wavelength(wavelength)
|
|
120
121
|
|
|
121
|
-
n_interp = numpy.interp(wavelength.to(meter).magnitude, self.wavelength.to(meter).magnitude, self.n_values)
|
|
122
|
-
k_interp = numpy.interp(wavelength.to(meter).magnitude, self.wavelength.to(meter).magnitude, self.k_values)
|
|
122
|
+
n_interp = numpy.interp(wavelength.to(units.meter).magnitude, self.wavelength.to(units.meter).magnitude, self.n_values)
|
|
123
|
+
k_interp = numpy.interp(wavelength.to(units.meter).magnitude, self.wavelength.to(units.meter).magnitude, self.k_values)
|
|
123
124
|
|
|
124
125
|
index = n_interp + 1j * k_interp
|
|
125
126
|
|
|
126
127
|
return index[0] if return_as_scalar else index
|
|
127
128
|
|
|
128
129
|
@BaseMaterial.ensure_units
|
|
129
|
-
def plot(self, wavelength: Optional[Quantity] = None) -> None:
|
|
130
|
+
def plot(self, wavelength: Optional[units.Quantity] = None) -> None:
|
|
130
131
|
"""
|
|
131
132
|
Plots the tabulated refractive index (n) and absorption (k) as a function of wavelength.
|
|
132
133
|
|
|
@@ -134,10 +135,6 @@ class TabulatedMaterial(BaseMaterial):
|
|
|
134
135
|
----------
|
|
135
136
|
wavelength : Optional[Quantity]
|
|
136
137
|
The range of wavelengths to plot, in micrometers. If not provided, the entire tabulated wavelength range is used.
|
|
137
|
-
title : str, optional
|
|
138
|
-
Title of the plot.
|
|
139
|
-
grid : bool, optional
|
|
140
|
-
Whether to show grid lines on the plot.
|
|
141
138
|
|
|
142
139
|
Raises
|
|
143
140
|
------
|
|
@@ -155,7 +152,7 @@ class TabulatedMaterial(BaseMaterial):
|
|
|
155
152
|
ylabel='Refractive Index (n)',
|
|
156
153
|
)
|
|
157
154
|
|
|
158
|
-
ax1.plot(wavelength.to(micrometer).magnitude, n_values, 'o-', color='tab:blue', label='n')
|
|
155
|
+
ax1.plot(wavelength.to(units.micrometer).magnitude, n_values, 'o-', color='tab:blue', label='n')
|
|
159
156
|
|
|
160
157
|
ax2 = ax1.twinx()
|
|
161
158
|
|
|
@@ -164,7 +161,7 @@ class TabulatedMaterial(BaseMaterial):
|
|
|
164
161
|
ylabel='Absorption (k)',
|
|
165
162
|
)
|
|
166
163
|
|
|
167
|
-
ax2.plot(wavelength.to(micrometer).magnitude, k_values, 'o-', color='tab:red', label='k')
|
|
164
|
+
ax2.plot(wavelength.to(units.micrometer).magnitude, k_values, 'o-', color='tab:red', label='k')
|
|
168
165
|
|
|
169
166
|
plt.show()
|
|
170
167
|
|