misc
This commit is contained in:
@@ -141,8 +141,8 @@ hasan :
|
|||||||
capillary_num : int
|
capillary_num : int
|
||||||
number of capillaries
|
number of capillaries
|
||||||
|
|
||||||
capillary_outer_d : float, optional if g is specified
|
capillary_radius : float, optional if g is specified
|
||||||
outer diameter of the capillaries
|
outer radius of the capillaries
|
||||||
|
|
||||||
capillary_thickness : float
|
capillary_thickness : float
|
||||||
thickness of the capillary walls
|
thickness of the capillary walls
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ VALID_VARIABLE = {
|
|||||||
"effective_mode_diameter",
|
"effective_mode_diameter",
|
||||||
"core_radius",
|
"core_radius",
|
||||||
"capillary_num",
|
"capillary_num",
|
||||||
"capillary_outer_d",
|
"capillary_radius",
|
||||||
"capillary_thickness",
|
"capillary_thickness",
|
||||||
"capillary_spacing",
|
"capillary_spacing",
|
||||||
"capillary_resonance_strengths",
|
"capillary_resonance_strengths",
|
||||||
@@ -374,7 +374,7 @@ class Parameters(_AbstractParameters):
|
|||||||
)
|
)
|
||||||
length: float = Parameter(non_negative(float, int))
|
length: float = Parameter(non_negative(float, int))
|
||||||
capillary_num: int = Parameter(positive(int))
|
capillary_num: int = Parameter(positive(int))
|
||||||
capillary_outer_d: float = Parameter(in_range_excl(0, 1e-3))
|
capillary_radius: float = Parameter(in_range_excl(0, 1e-3))
|
||||||
capillary_thickness: float = Parameter(in_range_excl(0, 1e-3))
|
capillary_thickness: float = Parameter(in_range_excl(0, 1e-3))
|
||||||
capillary_spacing: float = Parameter(in_range_excl(0, 1e-3))
|
capillary_spacing: float = Parameter(in_range_excl(0, 1e-3))
|
||||||
capillary_resonance_strengths: Iterable[float] = Parameter(num_list, default=[])
|
capillary_resonance_strengths: Iterable[float] = Parameter(num_list, default=[])
|
||||||
@@ -1104,7 +1104,7 @@ default_rules: list[Rule] = [
|
|||||||
["wl_for_disp", "pitch", "pitch_ratio"],
|
["wl_for_disp", "pitch", "pitch_ratio"],
|
||||||
conditions=dict(model="pcf"),
|
conditions=dict(model="pcf"),
|
||||||
),
|
),
|
||||||
Rule("capillary_spacing", fiber.HCARF_gap),
|
Rule("capillary_spacing", fiber.capillary_spacing_hasan),
|
||||||
# Fiber nonlinearity
|
# Fiber nonlinearity
|
||||||
Rule("A_eff", fiber.A_eff_from_V),
|
Rule("A_eff", fiber.A_eff_from_V),
|
||||||
Rule("A_eff", fiber.A_eff_from_diam),
|
Rule("A_eff", fiber.A_eff_from_diam),
|
||||||
|
|||||||
@@ -109,11 +109,12 @@ def sort_axis(
|
|||||||
|
|
||||||
|
|
||||||
def get_arg_names(func: Callable) -> list[str]:
|
def get_arg_names(func: Callable) -> list[str]:
|
||||||
spec = inspect.getfullargspec(func)
|
# spec = inspect.getfullargspec(func)
|
||||||
args = spec.args
|
# args = spec.args
|
||||||
if spec.defaults is not None and len(spec.defaults) > 0:
|
# if spec.defaults is not None and len(spec.defaults) > 0:
|
||||||
args = args[: -len(spec.defaults)]
|
# args = args[: -len(spec.defaults)]
|
||||||
return args
|
# return args
|
||||||
|
return [k for k, v in inspect.signature(func).parameters.items() if v.default is inspect._empty]
|
||||||
|
|
||||||
|
|
||||||
def validate_arg_names(names: list[str]):
|
def validate_arg_names(names: list[str]):
|
||||||
@@ -238,7 +239,7 @@ def fiber_folder(i: int, sim_name: str, fiber_name: str) -> str:
|
|||||||
return PARAM_SEPARATOR.join([format(i), sim_name, fiber_name])
|
return PARAM_SEPARATOR.join([format(i), sim_name, fiber_name])
|
||||||
|
|
||||||
|
|
||||||
def iter_simulations(path: os.PathLike) -> list[Path]:
|
def simulations_list(path: os.PathLike) -> list[Path]:
|
||||||
"""finds simulations folders contained in a parent directory
|
"""finds simulations folders contained in a parent directory
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -246,9 +247,9 @@ def iter_simulations(path: os.PathLike) -> list[Path]:
|
|||||||
path : os.PathLike
|
path : os.PathLike
|
||||||
parent path
|
parent path
|
||||||
|
|
||||||
Yields
|
Returns
|
||||||
-------
|
-------
|
||||||
Path
|
list[Path]
|
||||||
Absolute Path to the simulation folder
|
Absolute Path to the simulation folder
|
||||||
"""
|
"""
|
||||||
paths: list[Path] = []
|
paths: list[Path] = []
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from scipy.interpolate import interp1d
|
|||||||
|
|
||||||
from ..logger import get_logger
|
from ..logger import get_logger
|
||||||
|
|
||||||
from .. import _utils
|
from .. import _utils as utils
|
||||||
from ..math import abs2, argclosest, power_fact, u_nm
|
from ..math import abs2, argclosest, power_fact, u_nm
|
||||||
from .._utils.cache import np_cache
|
from .._utils.cache import np_cache
|
||||||
from . import materials as mat
|
from . import materials as mat
|
||||||
@@ -48,27 +48,6 @@ def is_dynamic_dispersion(pressure=None):
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
def HCARF_gap(core_radius: float, capillary_num: int, capillary_outer_d: float):
|
|
||||||
"""computes the gap length between capillaries of a hollow core anti-resonance fiber
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
core_radius : float
|
|
||||||
radius of the core (m) (from cented to edge of a capillary)
|
|
||||||
capillary_num : int
|
|
||||||
number of capillaries
|
|
||||||
capillary_outer_d : float
|
|
||||||
diameter of the capillaries including the wall thickness(m). The core together with the microstructure has a diameter of 2R + 2d
|
|
||||||
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
gap : float
|
|
||||||
"""
|
|
||||||
return (core_radius + capillary_outer_d / 2) * 2 * np.sin(
|
|
||||||
pi / capillary_num
|
|
||||||
) - capillary_outer_d
|
|
||||||
|
|
||||||
|
|
||||||
def gvd_from_n_eff(n_eff: np.ndarray, wl_for_disp: np.ndarray):
|
def gvd_from_n_eff(n_eff: np.ndarray, wl_for_disp: np.ndarray):
|
||||||
"""computes the dispersion parameter D from an effective index of refraction n_eff
|
"""computes the dispersion parameter D from an effective index of refraction n_eff
|
||||||
Since computing gradients/derivatives of discrete arrays is not well defined on the boundary, it is
|
Since computing gradients/derivatives of discrete arrays is not well defined on the boundary, it is
|
||||||
@@ -208,6 +187,14 @@ def A_eff_marcatili(core_radius: float) -> float:
|
|||||||
return 1.5 * core_radius ** 2
|
return 1.5 * core_radius ** 2
|
||||||
|
|
||||||
|
|
||||||
|
def capillary_spacing_hasan(
|
||||||
|
capillary_num: int, capillary_radius: float, core_radius: float
|
||||||
|
) -> float:
|
||||||
|
return (
|
||||||
|
2 * (capillary_radius + core_radius) * np.sin(np.pi / capillary_num) - 2 * capillary_radius
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@np_cache
|
@np_cache
|
||||||
def n_eff_hasan(
|
def n_eff_hasan(
|
||||||
wl_for_disp: np.ndarray,
|
wl_for_disp: np.ndarray,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ from .._utils.parameter import (
|
|||||||
Configuration,
|
Configuration,
|
||||||
Parameters,
|
Parameters,
|
||||||
)
|
)
|
||||||
|
from .._utils.utils import simulations_list
|
||||||
|
|
||||||
|
|
||||||
def fingerprint(params: Parameters):
|
def fingerprint(params: Parameters):
|
||||||
@@ -31,7 +32,7 @@ def plot_all(sim_dir: Path, limits: list[str], show=False, **opts):
|
|||||||
opts[k] = int(v)
|
opts[k] = int(v)
|
||||||
if k in {"log", "renormalize"}:
|
if k in {"log", "renormalize"}:
|
||||||
opts[k] = True if v == "True" else False
|
opts[k] = True if v == "True" else False
|
||||||
dir_list = list(p for p in sim_dir.glob("*") if p.is_dir())
|
dir_list = simulations_list(sim_dir)
|
||||||
if len(dir_list) == 0:
|
if len(dir_list) == 0:
|
||||||
dir_list = [sim_dir]
|
dir_list = [sim_dir]
|
||||||
limits = [
|
limits = [
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import numpy as np
|
|||||||
from . import math
|
from . import math
|
||||||
from ._utils import load_spectrum
|
from ._utils import load_spectrum
|
||||||
from ._utils.parameter import Parameters
|
from ._utils.parameter import Parameters
|
||||||
from ._utils.utils import PlotRange, iter_simulations
|
from ._utils.utils import PlotRange, simulations_list
|
||||||
from .const import PARAM_FN, SPEC1_FN, SPEC1_FN_N
|
from .const import PARAM_FN, SPEC1_FN, SPEC1_FN_N
|
||||||
from .logger import get_logger
|
from .logger import get_logger
|
||||||
from .physics import pulse, units
|
from .physics import pulse, units
|
||||||
@@ -129,7 +129,7 @@ class SimulationSeries:
|
|||||||
|
|
||||||
def __init__(self, path: os.PathLike):
|
def __init__(self, path: os.PathLike):
|
||||||
self.logger = get_logger()
|
self.logger = get_logger()
|
||||||
for self.path in iter_simulations(path):
|
for self.path in simulations_list(path):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise FileNotFoundError(f"No simulation in {path}")
|
raise FileNotFoundError(f"No simulation in {path}")
|
||||||
|
|||||||
Reference in New Issue
Block a user