nothing fancy

This commit is contained in:
Benoît Sierro
2023-01-24 09:33:43 +01:00
parent aa225a0820
commit 239eaddd7c
7 changed files with 2992 additions and 253 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -11,9 +11,7 @@ reference = [
B = [1.03961212, 0.231792344, 1.01046945] B = [1.03961212, 0.231792344, 1.01046945]
C = [6.00069867e-15, 2.00179144e-14, 1.03560653e-10] C = [6.00069867e-15, 2.00179144e-14, 1.03560653e-10]
kind = 1 kind = 1
reference = [ reference = ["SCHOTT Zemax catalog 2017-01-20b (obtained from http://www.schott.com)"]
"SCHOTT Zemax catalog 2017-01-20b (obtained from http://www.schott.com)",
]
[e7.sellmeier] [e7.sellmeier]
B = [0.0, 7.2e-15, 3e-28] B = [0.0, 7.2e-15, 3e-28]
@@ -24,14 +22,7 @@ reference = [
] ]
[d-zlaf52la.sellmeier] [d-zlaf52la.sellmeier]
B = [ B = [-8.48750283e9, 3.1753525, 3.71301651e-14, -1.09609062e-27, 2.4418582e-40, -8.94583294e-54]
-8.48750283e9,
3.1753525,
3.71301651e-14,
-1.09609062e-27,
2.4418582e-40,
-8.94583294e-54,
]
C = [] C = []
kind = 3 kind = 3
reference = ["CDGM Zemax catalog 2017-09 (obtained from http://www.cdgmgd.com)"] reference = ["CDGM Zemax catalog 2017-09 (obtained from http://www.cdgmgd.com)"]
@@ -42,8 +33,8 @@ reference = ["CDGM Zemax catalog 2017-09 (obtained from http://www.cdgmgd.com)"]
[air] [air]
a = 0.1358 a = 0.1358
b = 3.64e-5
atomic_mass = 4.809e-26 atomic_mass = 4.809e-26
b = 3.64e-5
[air.sellmeier] [air.sellmeier]
B = [57921050000.0, 1679170000.0] B = [57921050000.0, 1679170000.0]
@@ -60,8 +51,8 @@ source = "Pigeon, J. J., Tochitsky, S. Y., Welch, E. C., & Joshi, C. (2016). Mea
[nitrogen] [nitrogen]
a = 0.137 a = 0.137
b = 1.709e-5
atomic_mass = 2.3259e-26 atomic_mass = 2.3259e-26
b = 1.709e-5
[nitrogen.sellmeier] [nitrogen.sellmeier]
B = [32431570000.0] B = [32431570000.0]
@@ -79,10 +70,10 @@ source = "Wahlstrand, J. K., Cheng, Y. H., & Milchberg, H. M. (2012). High field
[helium] [helium]
a = 0.00346 a = 0.00346
atomic_mass = 6.646477e-27
atomic_number = 2
b = 2.38e-5 b = 2.38e-5
ionization_energy = 3.9393356074281e-18 ionization_energy = 3.9393356074281e-18
atomic_number = 2
atomic_mass = 6.646477e-27
[helium.sellmeier] [helium.sellmeier]
B = [2.16463842e-5, 2.10561127e-7, 4.7509272e-5] B = [2.16463842e-5, 2.10561127e-7, 4.7509272e-5]
@@ -117,8 +108,8 @@ n2 = 3.1e-25
[hydrogen] [hydrogen]
a = 0.02453 a = 0.02453
b = 2.651e-5
atomic_mass = 1.674e-27 atomic_mass = 1.674e-27
b = 2.651e-5
[hydrogen.sellmeier] [hydrogen.sellmeier]
B = [0.0148956, 0.0049037] B = [0.0148956, 0.0049037]
@@ -136,10 +127,10 @@ source = "Shelton, D. P., & Rice, J. E. (1994). Measurements and calculations of
[neon] [neon]
a = 0.02135 a = 0.02135
atomic_mass = 3.35092e-26
atomic_number = 10
b = 1.709e-5 b = 1.709e-5
ionization_energy = 3.45501365359425e-18 ionization_energy = 3.45501365359425e-18
atomic_number = 10
atomic_mass = 3.35092e-26
[neon.sellmeier] [neon.sellmeier]
B = [1281450000.0, 22048600000.0] B = [1281450000.0, 22048600000.0]
@@ -156,10 +147,10 @@ source = "Wahlstrand, J. K., Cheng, Y. H., & Milchberg, H. M. (2012). High field
[argon] [argon]
a = 0.1355 a = 0.1355
atomic_mass = 6.6338e-26
atomic_number = 18
b = 3.201e-5 b = 3.201e-5
ionization_energy = 2.5249661793774e-18 ionization_energy = 2.5249661793774e-18
atomic_number = 18
atomic_mass = 6.6338e-26
[argon.sellmeier] [argon.sellmeier]
B = [2501410000.0, 500283000.0, 52234300000.0] B = [2501410000.0, 500283000.0, 52234300000.0]
@@ -214,10 +205,10 @@ source = "Wahlstrand, J. K., Cheng, Y. H., & Milchberg, H. M. (2012). High field
[krypton] [krypton]
a = 0.2349 a = 0.2349
atomic_mass = 1.3915e-25
atomic_number = 36
b = 3.978e-5 b = 3.978e-5
ionization_energy = 2.2429831039374e-18 ionization_energy = 2.2429831039374e-18
atomic_number = 36
atomic_mass = 1.3915e-25
[krypton.sellmeier] [krypton.sellmeier]
B = [2536370000.0, 2736490000.0, 62080200000.0] B = [2536370000.0, 2736490000.0, 62080200000.0]
@@ -234,10 +225,10 @@ source = "Wahlstrand, J. K., Cheng, Y. H., & Milchberg, H. M. (2012). High field
[xenon] [xenon]
a = 0.425 a = 0.425
atomic_mass = 2.18017e-25
atomic_number = 54
b = 5.105e-5 b = 5.105e-5
ionization_energy = 1.94342415157935 ionization_energy = 1.94342415157935
atomic_number = 54
atomic_mass = 2.18017e-25
[xenon.sellmeier] [xenon.sellmeier]
B = [3228690000.0, 3553930000.0, 60676400000.0] B = [3228690000.0, 3553930000.0, 60676400000.0]
@@ -254,8 +245,8 @@ source = "Wahlstrand, J. K., Cheng, Y. H., & Milchberg, H. M. (2012). High field
[vacuum] [vacuum]
a = 0 a = 0
b = 0
atomic_mass = 0 atomic_mass = 0
b = 0
[vacuum.sellmeier] [vacuum.sellmeier]
B = [] B = []

File diff suppressed because it is too large Load Diff

View File

@@ -2,12 +2,14 @@
series of helper functions series of helper functions
""" """
from scgenerator.physics.materials import n_gas_2
from scgenerator.physics.fiber import n_eff_marcatili, beta2, beta2_to_D
from scgenerator.physics.units import c
import numpy as np import numpy as np
__all__ = ["capillary_dispersion"] from scgenerator.math import all_zeros
from scgenerator.physics.fiber import beta2, n_eff_marcatili, n_eff_hasan
from scgenerator.physics.materials import n_gas_2
from scgenerator.physics.units import c
__all__ = ["capillary_dispersion", "capillary_zdw", "revolver_dispersion"]
def capillary_dispersion( def capillary_dispersion(
@@ -43,11 +45,100 @@ def capillary_dispersion(
return beta2(w, n)[2:-2] return beta2(w, n)[2:-2]
def extend_axis(wl): def capillary_zdw(
dwl_left = wl[1] - wl[0] radius: float,
dwl_right = wl[-1] - wl[-2] gas_name: str,
wl = np.concatenate( pressure=None,
([wl[0] - 2 * dwl_left, wl[0] - dwl_left], wl, [wl[-1] + dwl_right, wl[-1] + 2 * dwl_right]) temperature=None,
search_range: tuple[float, float] = (200e-9, 3000e-9),
) -> np.ndarray:
"""find the zero dispersion wavelength of a capilally
Parameters
----------
radius : float
in mnm
gas_name : str
gas name (case insensitive)
pressure : float, optional
pressure in Pa (multiply mbar by 100 to get Pa), by default atm pressure
temperature : float, optional
temperature in K, by default 20°C
search_range : (float, float), optional
range of wavelength (in m) in which to search for the ZDW, by default (200e-9, 3000e-9)
Returns
-------
np.ndarray
array of zero dispersion wavelength(s)
"""
wl = np.linspace(*search_range[:2], 1024)
disp = capillary_dispersion(wl, radius, gas_name, pressure, temperature)
return all_zeros(wl, disp)
def revolver_dispersion(
wl: np.ndarray,
core_radius: float,
gas_name: str,
capillary_num: int,
capillary_thickness: float,
capillary_spacing: float,
capillary_nested: int = 0,
capillary_resonance_strengths: list[float] = None,
pressure=None,
temperature=None,
) -> np.ndarray:
"""computes the dispersion (beta2) of a capillary tube
Parameters
----------
wl : np.ndarray
wavelength in m
radius : float
core radius in m
gas_name : str
gas name (case insensitive)
pressure : float, optional
pressure in Pa (multiply mbar by 100 to get Pa), by default atm pressure
temperature : float, optional
temperature in K, by default 20°C
Returns
-------
np.ndarray
D parameter
"""
capillary_resonance_strengths = capillary_resonance_strengths or []
wl = extend_axis(wl)
if pressure is None:
pressure = 101325
if temperature is None:
temperature = 293.15
n = n_eff_hasan(
wl,
n_gas_2(wl, gas_name.lower(), pressure, temperature, False),
core_radius,
capillary_num,
capillary_nested,
capillary_thickness,
capillary_spacing,
capillary_resonance_strengths,
)
w = 2 * np.pi * c / wl
return beta2(w, n)[2:-2]
def extend_axis(axis: np.ndarray) -> np.ndarray:
"""add 4 values to an array, 2 on each 'side'"""
dwl_left = axis[1] - axis[0]
dwl_right = axis[-1] - axis[-2]
axis = np.concatenate(
(
[axis[0] - 2 * dwl_left, axis[0] - dwl_left],
axis,
[axis[-1] + dwl_right, axis[-1] + 2 * dwl_right],
)
) )
return wl return axis

View File

@@ -4,15 +4,14 @@ import numpy as np
from numpy import e from numpy import e
from numpy.fft import fft from numpy.fft import fft
from numpy.polynomial.chebyshev import Chebyshev, cheb2poly from numpy.polynomial.chebyshev import Chebyshev, cheb2poly
from scgenerator import utils
from scgenerator.cache import np_cache
from scgenerator.math import argclosest, u_nm
from scgenerator.physics import materials as mat
from scgenerator.physics import units
from scgenerator.physics.units import c, pi
from scipy.interpolate import interp1d from scipy.interpolate import interp1d
from .. import utils
from ..cache import np_cache
from ..math import argclosest, u_nm
from . import materials as mat
from . import units
from .units import c, pi
pipi = 2 * pi pipi = 2 * pi
T = TypeVar("T") T = TypeVar("T")
@@ -328,7 +327,9 @@ def n_eff_hasan(
Reference Reference
---------- ----------
Hasan, Md Imran, Nail Akhmediev, and Wonkeun Chang. "Empirical formulae for dispersion and effective mode area in hollow-core antiresonant fibers." Journal of Lightwave Technology 36.18 (2018): 4060-4065. Hasan, Md Imran, Nail Akhmediev, and Wonkeun Chang. "Empirical formulae for dispersion and
effective mode area in hollow-core antiresonant fibers." Journal of Lightwave Technology 36.18
(2018): 4060-4065.
""" """
u = u_nm(1, 1) u = u_nm(1, 1)
alpha = 5e-12 alpha = 5e-12
@@ -627,7 +628,6 @@ def beta2(w_for_disp: np.ndarray, n_eff: np.ndarray) -> np.ndarray:
return np.gradient(np.gradient(beta(w_for_disp, n_eff), w_for_disp), w_for_disp) return np.gradient(np.gradient(beta(w_for_disp, n_eff), w_for_disp), w_for_disp)
def frame_velocity(beta1_arr: np.ndarray, w0_ind: int) -> float: def frame_velocity(beta1_arr: np.ndarray, w0_ind: int) -> float:
return 1.0 / beta1_arr[w0_ind] return 1.0 / beta1_arr[w0_ind]

View File

@@ -1,14 +1,15 @@
from __future__ import annotations
import functools import functools
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import Any, TypeVar from typing import Any, TypeVar
import numpy as np import numpy as np
from scgenerator import utils
from .. import utils from scgenerator.cache import np_cache
from ..cache import np_cache from scgenerator.logger import get_logger
from ..logger import get_logger from scgenerator.physics import units
from . import units from scgenerator.physics.units import NA, c, epsilon0, kB
from .units import NA, c, epsilon0, kB
T = TypeVar("T", np.floating, np.ndarray) T = TypeVar("T", np.floating, np.ndarray)
@@ -22,6 +23,21 @@ class Sellmeier:
kind: int = 2 kind: int = 2
constant: float = 0 constant: float = 0
@classmethod
def load(cls, name: str) -> Sellmeier:
mat_dico = utils.load_material_dico(name)
s = mat_dico.get("sellmeier", {})
return cls(
**{
newk: s.get(k, None)
for newk, k in zip(
["B", "C", "pressure_ref", "temperature_ref", "kind", "constant"],
["B", "C", "P0", "T0", "kind", "const"],
)
if k in s
}
)
def chi(self, wl: T) -> T: def chi(self, wl: T) -> T:
"""n^2 - 1""" """n^2 - 1"""
if isinstance(wl, np.ndarray): if isinstance(wl, np.ndarray):

View File

@@ -14,16 +14,16 @@ from dataclasses import dataclass
from functools import cache, lru_cache from functools import cache, lru_cache
from pathlib import Path from pathlib import Path
from string import printable as str_printable from string import printable as str_printable
from typing import Any, Callable, MutableMapping, Sequence, TypeVar, Set, Union from typing import Any, Callable, MutableMapping, Sequence, TypeVar, Union
import numpy as np import numpy as np
import pkg_resources as pkg import pkg_resources as pkg
import tomli import tomli
import tomli_w import tomli_w
from .const import PARAM_FN, PARAM_SEPARATOR, SPEC1_FN, Z_FN, ROOT_PARAMETERS from scgenerator.const import PARAM_FN, PARAM_SEPARATOR, ROOT_PARAMETERS, SPEC1_FN, Z_FN
from .logger import get_logger from scgenerator.errors import DuplicateParameterError
from .errors import DuplicateParameterError from scgenerator.logger import get_logger
T_ = TypeVar("T_") T_ = TypeVar("T_")
@@ -85,8 +85,8 @@ class Paths:
class SubConfig: class SubConfig:
fixed: dict[str, Any] fixed: dict[str, Any]
variable: list[dict[str, list]] variable: list[dict[str, list]]
fixed_keys: Set[str] fixed_keys: set[str]
variable_keys: Set[str] variable_keys: set[str]
def __init__(self, dico: dict[str, Any]): def __init__(self, dico: dict[str, Any]):
dico = dico.copy() dico = dico.copy()