misc
This commit is contained in:
@@ -141,8 +141,8 @@ hasan :
|
||||
capillary_num : int
|
||||
number of capillaries
|
||||
|
||||
capillary_outer_d : float, optional if g is specified
|
||||
outer diameter of the capillaries
|
||||
capillary_radius : float, optional if g is specified
|
||||
outer radius of the capillaries
|
||||
|
||||
capillary_thickness : float
|
||||
thickness of the capillary walls
|
||||
|
||||
@@ -55,7 +55,7 @@ VALID_VARIABLE = {
|
||||
"effective_mode_diameter",
|
||||
"core_radius",
|
||||
"capillary_num",
|
||||
"capillary_outer_d",
|
||||
"capillary_radius",
|
||||
"capillary_thickness",
|
||||
"capillary_spacing",
|
||||
"capillary_resonance_strengths",
|
||||
@@ -374,7 +374,7 @@ class Parameters(_AbstractParameters):
|
||||
)
|
||||
length: float = Parameter(non_negative(float, 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_spacing: float = Parameter(in_range_excl(0, 1e-3))
|
||||
capillary_resonance_strengths: Iterable[float] = Parameter(num_list, default=[])
|
||||
@@ -1104,7 +1104,7 @@ default_rules: list[Rule] = [
|
||||
["wl_for_disp", "pitch", "pitch_ratio"],
|
||||
conditions=dict(model="pcf"),
|
||||
),
|
||||
Rule("capillary_spacing", fiber.HCARF_gap),
|
||||
Rule("capillary_spacing", fiber.capillary_spacing_hasan),
|
||||
# Fiber nonlinearity
|
||||
Rule("A_eff", fiber.A_eff_from_V),
|
||||
Rule("A_eff", fiber.A_eff_from_diam),
|
||||
|
||||
@@ -109,11 +109,12 @@ def sort_axis(
|
||||
|
||||
|
||||
def get_arg_names(func: Callable) -> list[str]:
|
||||
spec = inspect.getfullargspec(func)
|
||||
args = spec.args
|
||||
if spec.defaults is not None and len(spec.defaults) > 0:
|
||||
args = args[: -len(spec.defaults)]
|
||||
return args
|
||||
# spec = inspect.getfullargspec(func)
|
||||
# args = spec.args
|
||||
# if spec.defaults is not None and len(spec.defaults) > 0:
|
||||
# args = args[: -len(spec.defaults)]
|
||||
# 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]):
|
||||
@@ -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])
|
||||
|
||||
|
||||
def iter_simulations(path: os.PathLike) -> list[Path]:
|
||||
def simulations_list(path: os.PathLike) -> list[Path]:
|
||||
"""finds simulations folders contained in a parent directory
|
||||
|
||||
Parameters
|
||||
@@ -246,9 +247,9 @@ def iter_simulations(path: os.PathLike) -> list[Path]:
|
||||
path : os.PathLike
|
||||
parent path
|
||||
|
||||
Yields
|
||||
Returns
|
||||
-------
|
||||
Path
|
||||
list[Path]
|
||||
Absolute Path to the simulation folder
|
||||
"""
|
||||
paths: list[Path] = []
|
||||
|
||||
@@ -7,7 +7,7 @@ from scipy.interpolate import interp1d
|
||||
|
||||
from ..logger import get_logger
|
||||
|
||||
from .. import _utils
|
||||
from .. import _utils as utils
|
||||
from ..math import abs2, argclosest, power_fact, u_nm
|
||||
from .._utils.cache import np_cache
|
||||
from . import materials as mat
|
||||
@@ -48,27 +48,6 @@ def is_dynamic_dispersion(pressure=None):
|
||||
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):
|
||||
"""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
|
||||
@@ -208,6 +187,14 @@ def A_eff_marcatili(core_radius: float) -> float:
|
||||
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
|
||||
def n_eff_hasan(
|
||||
wl_for_disp: np.ndarray,
|
||||
|
||||
@@ -17,6 +17,7 @@ from .._utils.parameter import (
|
||||
Configuration,
|
||||
Parameters,
|
||||
)
|
||||
from .._utils.utils import simulations_list
|
||||
|
||||
|
||||
def fingerprint(params: Parameters):
|
||||
@@ -31,7 +32,7 @@ def plot_all(sim_dir: Path, limits: list[str], show=False, **opts):
|
||||
opts[k] = int(v)
|
||||
if k in {"log", "renormalize"}:
|
||||
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:
|
||||
dir_list = [sim_dir]
|
||||
limits = [
|
||||
|
||||
@@ -10,7 +10,7 @@ import numpy as np
|
||||
from . import math
|
||||
from ._utils import load_spectrum
|
||||
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 .logger import get_logger
|
||||
from .physics import pulse, units
|
||||
@@ -129,7 +129,7 @@ class SimulationSeries:
|
||||
|
||||
def __init__(self, path: os.PathLike):
|
||||
self.logger = get_logger()
|
||||
for self.path in iter_simulations(path):
|
||||
for self.path in simulations_list(path):
|
||||
break
|
||||
else:
|
||||
raise FileNotFoundError(f"No simulation in {path}")
|
||||
|
||||
Reference in New Issue
Block a user