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_hasan, conditions=dict(model="hasan")),
|
||||||
Rule("effective_area", fiber.effective_area_from_gamma, priorities=-1),
|
Rule("effective_area", fiber.effective_area_from_gamma, priorities=-1),
|
||||||
Rule("effective_area", fiber.effective_area_marcatili, priorities=-2),
|
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("effective_area_arr", fiber.load_custom_effective_area),
|
||||||
Rule(
|
Rule("V_eff", fiber.V_parameter_koshiba, conditions=dict(model="pcf")),
|
||||||
"V_eff",
|
Rule("V_eff", fiber.V_eff_step_index),
|
||||||
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("n2", materials.gas_n2),
|
Rule("n2", materials.gas_n2),
|
||||||
Rule("n2", lambda: 2.2e-20, priorities=-1),
|
Rule("n2", lambda: 2.2e-20, priorities=-1),
|
||||||
Rule("gamma", lambda gamma_arr: gamma_arr[0], priorities=-1),
|
Rule("gamma", lambda gamma_arr: gamma_arr[0], priorities=-1),
|
||||||
@@ -557,6 +543,7 @@ default_rules: list[Rule] = [
|
|||||||
envelope_rules = default_rules + [
|
envelope_rules = default_rules + [
|
||||||
# Grid
|
# Grid
|
||||||
Rule(["w_c", "w", "w_order"], math.build_envelope_w_grid),
|
Rule(["w_c", "w", "w_order"], math.build_envelope_w_grid),
|
||||||
|
Rule("dt", math._dt_from_wl_window),
|
||||||
# Pulse
|
# Pulse
|
||||||
Rule("spectrum_factor", pulse.spectrum_factor_envelope, priorities=-1),
|
Rule("spectrum_factor", pulse.spectrum_factor_envelope, priorities=-1),
|
||||||
Rule("pre_field_0", pulse.initial_field_envelope, priorities=1),
|
Rule("pre_field_0", pulse.initial_field_envelope, priorities=1),
|
||||||
|
|||||||
@@ -171,24 +171,24 @@ def tspace(time_window=None, t_num=None, dt=None):
|
|||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
time_window : float
|
time_window : float
|
||||||
total time spanned
|
total time spanned
|
||||||
t_num : int
|
t_num : int
|
||||||
number of points
|
number of points
|
||||||
dt : float
|
dt : float
|
||||||
time resolution
|
time resolution
|
||||||
|
|
||||||
at least 2 arguments must be given. They are prioritize as such
|
at least 2 arguments must be given. They are prioritize as such
|
||||||
t_num > time_window > dt
|
t_num > time_window > dt
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
t : array
|
t : array
|
||||||
a linearily spaced time array
|
a linearily spaced time array
|
||||||
Raises
|
Raises
|
||||||
------
|
------
|
||||||
TypeError
|
TypeError
|
||||||
missing at least 1 argument
|
missing at least 1 argument
|
||||||
"""
|
"""
|
||||||
if t_num is not None:
|
if t_num is not None:
|
||||||
if isinstance(time_window, (float, int)):
|
if isinstance(time_window, (float, int)):
|
||||||
@@ -203,6 +203,14 @@ def tspace(time_window=None, t_num=None, dt=None):
|
|||||||
raise TypeError("not enough parameter to determine time vector")
|
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]:
|
def build_envelope_w_grid(t: np.ndarray, w0: float) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
|
||||||
"""
|
"""
|
||||||
convenience function to
|
convenience function to
|
||||||
|
|||||||
@@ -422,7 +422,7 @@ def V_eff_step_index(
|
|||||||
return pi2cn / l
|
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
|
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
|
ratio_l = l / pcf_pitch
|
||||||
n_co = 1.45
|
n_co = 1.45
|
||||||
a_eff = pcf_pitch / np.sqrt(3)
|
a_eff = effective_area_from_pitch(pcf_pitch)
|
||||||
pi2a = pipi * a_eff
|
pi2a = pipi * a_eff
|
||||||
A, B = saitoh_paramters(pcf_pitch_ratio)
|
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
|
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:
|
def effective_area_from_V(core_radius: float, V_eff: T) -> T:
|
||||||
"""
|
"""
|
||||||
According to Marcuse1978
|
According to Marcuse1978
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ def test_simple():
|
|||||||
assert evaluator.compute("w0") == pytest.approx(units.nm(800))
|
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):
|
def some_function(a: int, b: int, c: int = 5):
|
||||||
return a + b + c
|
return a + b + c
|
||||||
|
|
||||||
@@ -51,3 +51,19 @@ def test_default_args():
|
|||||||
evaluator.set(c=10)
|
evaluator.set(c=10)
|
||||||
assert evaluator.compute("c") == 10
|
assert evaluator.compute("c") == 10
|
||||||
assert evaluator.compute("d") == 14
|
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