added missing rules
This commit is contained in:
@@ -509,25 +509,11 @@ default_rules: list[Rule] = [
|
||||
Rule("effective_area", fiber.effective_area_hasan, conditions=dict(model="hasan")),
|
||||
Rule("effective_area", fiber.effective_area_from_gamma, priorities=-1),
|
||||
Rule("effective_area", fiber.effective_area_marcatili, priorities=-2),
|
||||
Rule("effective_area_arr", fiber.effective_area_from_V, ["core_radius", "V_eff_arr"]),
|
||||
Rule("effective_area", fiber.effective_area_from_pitch),
|
||||
Rule("effective_area_arr", fiber.effective_area_from_V, ["core_radius", "V_eff"]),
|
||||
Rule("effective_area_arr", fiber.load_custom_effective_area),
|
||||
Rule(
|
||||
"V_eff",
|
||||
fiber.V_parameter_koshiba,
|
||||
["wavelength", "pcf_pitch", "pcf_pitch_ratio"],
|
||||
conditions=dict(model="pcf"),
|
||||
),
|
||||
Rule(
|
||||
"V_eff",
|
||||
fiber.V_eff_step_index,
|
||||
["l", "wavelength", "core_radius", "numerical_aperture"],
|
||||
),
|
||||
Rule("V_eff_arr", fiber.V_parameter_koshiba, conditions=dict(model="pcf")),
|
||||
Rule(
|
||||
"V_eff_arr",
|
||||
fiber.V_eff_step_index,
|
||||
["l", "core_radius", "numerical_aperture", "wavelength_window"],
|
||||
),
|
||||
Rule("V_eff", fiber.V_parameter_koshiba, conditions=dict(model="pcf")),
|
||||
Rule("V_eff", fiber.V_eff_step_index),
|
||||
Rule("n2", materials.gas_n2),
|
||||
Rule("n2", lambda: 2.2e-20, priorities=-1),
|
||||
Rule("gamma", lambda gamma_arr: gamma_arr[0], priorities=-1),
|
||||
@@ -557,6 +543,7 @@ default_rules: list[Rule] = [
|
||||
envelope_rules = default_rules + [
|
||||
# Grid
|
||||
Rule(["w_c", "w", "w_order"], math.build_envelope_w_grid),
|
||||
Rule("dt", math._dt_from_wl_window),
|
||||
# Pulse
|
||||
Rule("spectrum_factor", pulse.spectrum_factor_envelope, priorities=-1),
|
||||
Rule("pre_field_0", pulse.initial_field_envelope, priorities=1),
|
||||
|
||||
@@ -203,6 +203,14 @@ def tspace(time_window=None, t_num=None, dt=None):
|
||||
raise TypeError("not enough parameter to determine time vector")
|
||||
|
||||
|
||||
def dt_from_min_wl(wl_min: float, wavelength: float) -> float:
|
||||
return 0.5 * 1 / c * 1 / (1 / wl_min - 1 / wavelength)
|
||||
|
||||
|
||||
def _dt_from_wl_window(wavelength_window: tuple[float, float], wavelength: float) -> float:
|
||||
return dt_from_min_wl(wavelength_window[0], wavelength)
|
||||
|
||||
|
||||
def build_envelope_w_grid(t: np.ndarray, w0: float) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
|
||||
"""
|
||||
convenience function to
|
||||
|
||||
@@ -422,7 +422,7 @@ def V_eff_step_index(
|
||||
return pi2cn / l
|
||||
|
||||
|
||||
def V_parameter_koshiba(l: np.ndarray, pcf_pitch: float, pcf_pitch_ratio: float) -> float:
|
||||
def V_parameter_koshiba(l: np.ndarray, pcf_pitch: float, pcf_pitch_ratio: float) -> np.ndarray:
|
||||
"""
|
||||
returns the V parameter according to Koshiba2004
|
||||
|
||||
@@ -445,7 +445,7 @@ def V_parameter_koshiba(l: np.ndarray, pcf_pitch: float, pcf_pitch_ratio: float)
|
||||
"""
|
||||
ratio_l = l / pcf_pitch
|
||||
n_co = 1.45
|
||||
a_eff = pcf_pitch / np.sqrt(3)
|
||||
a_eff = effective_area_from_pitch(pcf_pitch)
|
||||
pi2a = pipi * a_eff
|
||||
A, B = saitoh_paramters(pcf_pitch_ratio)
|
||||
|
||||
@@ -457,6 +457,10 @@ def V_parameter_koshiba(l: np.ndarray, pcf_pitch: float, pcf_pitch_ratio: float)
|
||||
return V_eff
|
||||
|
||||
|
||||
def effective_area_from_pitch(pcf_pitch: float):
|
||||
return pcf_pitch / np.sqrt(3)
|
||||
|
||||
|
||||
def effective_area_from_V(core_radius: float, V_eff: T) -> T:
|
||||
"""
|
||||
According to Marcuse1978
|
||||
|
||||
@@ -36,7 +36,7 @@ def test_simple():
|
||||
assert evaluator.compute("w0") == pytest.approx(units.nm(800))
|
||||
|
||||
|
||||
def test_default_args():
|
||||
def test_default_args_simple():
|
||||
def some_function(a: int, b: int, c: int = 5):
|
||||
return a + b + c
|
||||
|
||||
@@ -51,3 +51,19 @@ def test_default_args():
|
||||
evaluator.set(c=10)
|
||||
assert evaluator.compute("c") == 10
|
||||
assert evaluator.compute("d") == 14
|
||||
|
||||
|
||||
def test_default_args_real():
|
||||
evaluator = Evaluator.default()
|
||||
evaluator.set(
|
||||
wavelength=1050e-9,
|
||||
peak_power=5000,
|
||||
width=1500e-15,
|
||||
wavelength_window=(800e-9, 1500e-9),
|
||||
t_num=2048,
|
||||
)
|
||||
|
||||
assert evaluator.compute("dt") == pytest.approx(math.dt_from_min_wl(800e-9, 1050e-9), abs=0)
|
||||
assert evaluator.compute("t") == pytest.approx(
|
||||
math.tspace(t_num=2048, dt=evaluator.compute("dt")), abs=0
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user