updated testing

This commit is contained in:
Benoît Sierro
2021-06-10 16:20:39 +02:00
parent 69c89f04c4
commit 03b29f29f4
46 changed files with 428 additions and 411 deletions

View File

@@ -1,6 +1,6 @@
## add parameter ## add parameter
- add it to ```const.valid_param_types``` - add it to ```utils.parameters```
- add it to README.md - add it to README.md
- add the necessary logic in the appropriate ```initialize._ensure_consistency``` subfunction - add the necessary logic in the appropriate ```initialize:Config``` class
- optional : add a default value - optional : add a default value
- optional : add to valid_variable - optional : add to valid_variable

26
lol.txt Normal file
View File

@@ -0,0 +1,26 @@
name = "test config"
# fiber
# gamma = 0.018
length = 1
model = "pcf"
pitch = 1.5e-6
pitch_ratio = 0.37
# pulse
intensity_noise = 0.05e-2
peak_power = 100e3
quantum_noise = true
shape = "gaussian"
wavelength = 1050e-9
width = 50e-15
# simulation
behaviors = ["spm", "raman", "ss"]
parallel = false
raman_type = "agrawal"
repeat = 4
t_num = 16384
time_window = 37e-12
tolerated_error = 1e-11
z_num = 128

View File

@@ -29,19 +29,7 @@ class Params(BareParams):
def compute(self): def compute(self):
logger = get_logger(__name__) logger = get_logger(__name__)
( build_sim_grid_in_place(self)
self.z_targets,
self.t,
self.time_window,
self.t_num,
self.dt,
self.w_c,
self.w0,
self.w,
self.w_power_fact,
) = build_sim_grid(
self.length, self.z_num, self.wavelength, self.time_window, self.t_num, self.dt
)
# Initial field may influence the grid # Initial field may influence the grid
if self.mean_power is not None: if self.mean_power is not None:
@@ -54,9 +42,9 @@ class Params(BareParams):
self.field_0, self.field_0,
) = pulse.setup_custom_field(self) ) = pulse.setup_custom_field(self)
if self.readjust_wavelength: if self.readjust_wavelength:
delta_w = self.w_c[np.argmax(abs2(np.fft.fft(self.field_0)))] old_wl = self.wavelength
logger.debug(f"adjusted w by {delta_w}") self.wavelength = pulse.correct_wavelength(self.wavelength, self.w_c, self.field_0)
self.wavelength = units.m.inv(units.m(self.wavelength) - delta_w) logger.info(f"moved wavelength from {1e9*old_wl:.2f} to {1e9*self.wavelength:.2f}")
self.w_c, self.w0, self.w, self.w_power_fact = update_frequency_domain( self.w_c, self.w0, self.w, self.w_power_fact = update_frequency_domain(
self.t, self.wavelength self.t, self.wavelength
) )
@@ -138,21 +126,6 @@ class Params(BareParams):
self.spec_0 = np.fft.fft(self.field_0) self.spec_0 = np.fft.fft(self.field_0)
def build_sim_grid(self):
(
self.z_targets,
self.t,
self.time_window,
self.t_num,
self.dt,
self.w_c,
self.w0,
self.w,
self.w_power_fact,
) = build_sim_grid(
self.length, self.z_num, self.wavelength, self.time_window, self.t_num, self.dt
)
@dataclass @dataclass
class Config(BareConfig): class Config(BareConfig):
@@ -174,24 +147,24 @@ class Config(BareConfig):
def fiber_consistency(self): def fiber_consistency(self):
if self.contains("beta"): if self.contains("beta"):
if not (self.contains("A_eff") or self.contains("effective_mode_diameter")): if not (self.contains("A_eff") or self.contains("effective_mode_diameter")):
self.gamma = self.get("gamma", specified_parameters=["beta"]) self.get("gamma", specified_parameters=["beta"])
self.setdefault("model", "custom") self.setdefault("model", "custom")
elif self.contains("dispersion_file"): elif self.contains("dispersion_file"):
if not (self.contains("A_eff") or self.contains("effective_mode_diameter")): if not (self.contains("A_eff") or self.contains("effective_mode_diameter")):
fiber = self.get("gamma", specified_parameters=["dispersion_file"]) self.get("gamma", specified_parameters=["dispersion_file"])
self.setdefault("model", "custom") self.setdefault("model", "custom")
else: else:
fiber = self.get("model") self.get("model")
if self.model == "pcf": if self.model == "pcf":
fiber = self.get_fiber("pitch") self.get_fiber("pitch")
fiber = self.get_fiber("pitch_ratio") self.get_fiber("pitch_ratio")
elif self.model == "hasan": elif self.model == "hasan":
fiber = self.get_multiple( self.get_multiple(
fiber, ["capillary_spacing", "capillary_outer_d"], 1, fiber_model="hasan" ["capillary_spacing", "capillary_outer_d"], 1, fiber_model="hasan"
) )
for param in [ for param in [
"core_radius", "core_radius",
@@ -200,12 +173,12 @@ class Config(BareConfig):
"capillary_resonance_strengths", "capillary_resonance_strengths",
"capillary_nested", "capillary_nested",
]: ]:
fiber = self.get_fiber(param) self.get_fiber(param)
else: else:
for param in hc_model_specific_parameters[self.model]: for param in hc_model_specific_parameters[self.model]:
fiber = self.get_fiber(param) self.get_fiber(param)
for param in ["length", "input_transmission"]: for param in ["length", "input_transmission"]:
fiber = self.get(param) self.get(param)
def gas_consistency(self): def gas_consistency(self):
for param in ["gas_name", "temperature", "pressure", "plasma_density"]: for param in ["gas_name", "temperature", "pressure", "plasma_density"]:
@@ -578,19 +551,7 @@ def recover_params(params: BareParams, data_folder: Path) -> Params:
params = Params.from_bare(params) params = Params.from_bare(params)
try: try:
prev = io.load_params(data_folder / "params.toml") prev = io.load_params(data_folder / "params.toml")
( build_sim_grid_in_place(prev)
prev.z_targets,
prev.t,
prev.time_window,
prev.t_num,
prev.dt,
prev.w_c,
prev.w0,
prev.w,
prev.w_power_fact,
) = build_sim_grid(
prev.length, prev.z_num, prev.wavelength, prev.time_window, prev.t_num, prev.dt
)
except FileNotFoundError: except FileNotFoundError:
prev = BareParams() prev = BareParams()
for k, v in filter(lambda el: el[1] is not None, vars(prev).items()): for k, v in filter(lambda el: el[1] is not None, vars(prev).items()):
@@ -634,7 +595,40 @@ def build_sim_grid(
return z_targets, t, time_window, t_num, dt, w_c, w0, w, w_power_fact return z_targets, t, time_window, t_num, dt, w_c, w0, w, w_power_fact
def update_frequency_domain(t, wavelength): def build_sim_grid_in_place(params: BareParams):
"""similar to calling build_sim_grid, but sets the attributes in place"""
(
params.z_targets,
params.t,
params.time_window,
params.t_num,
params.dt,
params.w_c,
params.w0,
params.w,
params.w_power_fact,
) = build_sim_grid(
params.length, params.z_num, params.wavelength, params.time_window, params.t_num, params.dt
)
def update_frequency_domain(
t: np.ndarray, wavelength: float
) -> Tuple[np.ndarray, float, np.ndarray, np.ndarray]:
"""updates the frequency grid
Parameters
----------
t : np.ndarray
time array
wavelength : float
wavelength
Returns
-------
Tuple[np.ndarray, float, np.ndarray, np.ndarray]
w_c, w0, w, w_power_fact
"""
w_c = wspace(t) w_c = wspace(t)
w0 = units.m(wavelength) w0 = units.m(wavelength)
w = w_c + w0 w = w_c + w0

View File

@@ -88,10 +88,6 @@ def load_toml(path: os.PathLike):
path = conform_toml_path(path) path = conform_toml_path(path)
with open(path, mode="r") as file: with open(path, mode="r") as file:
dico = toml.load(file) dico = toml.load(file)
for section in ["simulation", "fiber", "pulse", "gas"]:
dico.update(dico.pop(section, {}))
return dico return dico

View File

@@ -26,6 +26,7 @@ from ..logger import get_logger
from ..math import * from ..math import *
from ..plotting import plot_setup from ..plotting import plot_setup
from ..utils.parameter import BareParams from ..utils.parameter import BareParams
from . import units
c = 299792458.0 c = 299792458.0
hbar = 1.05457148e-34 hbar = 1.05457148e-34
@@ -248,6 +249,15 @@ def setup_custom_field(params: BareParams) -> bool:
return did_set, width, peak_power, energy, field_0 return did_set, width, peak_power, energy, field_0
def correct_wavelength(init_wavelength: float, w_c: np.ndarray, field_0: np.ndarray) -> float:
"""
finds a new wavelength parameter such that the maximum of the spectrum corresponding
to field_0 is located at init_wavelength
"""
delta_w = w_c[np.argmax(abs2(np.fft.fft(field_0)))]
return units.m.inv(units.m(init_wavelength) - delta_w)
def E0_to_P0(E0, t0, shape="gaussian"): def E0_to_P0(E0, t0, shape="gaussian"):
"""convert an initial total pulse energy to a pulse peak peak_power""" """convert an initial total pulse energy to a pulse peak peak_power"""
return E0 / (t0 * P0T0_to_E0_fac[shape]) return E0 / (t0 * P0T0_to_E0_fac[shape])

View File

@@ -45,13 +45,13 @@ class Pulse(Sequence):
except FileNotFoundError: except FileNotFoundError:
self.logger.info(f"parameters corresponding to {self.path} not found") self.logger.info(f"parameters corresponding to {self.path} not found")
self.params = initialize.build_sim_grid(self.params) initialize.build_sim_grid_in_place(self.params)
try: try:
self.z = np.load(os.path.join(path, "z.npy")) self.z = np.load(os.path.join(path, "z.npy"))
except FileNotFoundError: except FileNotFoundError:
if self.params is not None: if self.params is not None:
self.z = self.params["z_targets"] self.z = self.params.z_targets
else: else:
raise raise
self.cache: Dict[int, Spectrum] = {} self.cache: Dict[int, Spectrum] = {}
@@ -59,13 +59,13 @@ class Pulse(Sequence):
if self.nmax <= 0: if self.nmax <= 0:
raise FileNotFoundError(f"No appropriate file in specified folder {self.path}") raise FileNotFoundError(f"No appropriate file in specified folder {self.path}")
self.t = self.params["t"] self.t = self.params.t
w = initialize.wspace(self.t) + units.m(self.params["wavelength"]) w = initialize.wspace(self.t) + units.m(self.params.wavelength)
self.w_order = np.argsort(w) self.w_order = np.argsort(w)
self.w = w self.w = w
self.wl = units.m.inv(self.w) self.wl = units.m.inv(self.w)
self.params["w"] = self.w self.params.w = self.w
self.params["z_targets"] = self.z self.params.z_targets = self.z
def __iter__(self): def __iter__(self):
""" """
@@ -197,6 +197,6 @@ class Pulse(Sequence):
spec = np.load(self.path / SPECN_FN.format(i)) spec = np.load(self.path / SPECN_FN.format(i))
if self.__ensure_2d: if self.__ensure_2d:
spec = np.atleast_2d(spec) spec = np.atleast_2d(spec)
spec = Spectrum(spec, self.wl, self.params["frep"]) spec = Spectrum(spec, self.wl, self.params.frep)
self.cache[i] = spec self.cache[i] = spec
return spec return spec

View File

@@ -275,5 +275,5 @@ def override_config(new: Dict[str, Any], old: BareConfig = None) -> BareConfig:
variable = deepcopy(old.variable) variable = deepcopy(old.variable)
variable.update(new.pop("variable", {})) # add new variable variable.update(new.pop("variable", {})) # add new variable
for k in new: for k in new:
variable.pop(k) # remove old ones variable.pop(k, None) # remove old ones
return replace(old, variable=variable, **{k: None for k in variable}, **new) return replace(old, variable=variable, **{k: None for k in variable}, **new)

View File

@@ -1,4 +1,4 @@
import datetime import datetime as datetime_module
from copy import copy from copy import copy
from dataclasses import asdict, dataclass from dataclasses import asdict, dataclass
from functools import lru_cache from functools import lru_cache
@@ -205,6 +205,7 @@ class Parameter:
class VariableParameter: class VariableParameter:
def __init__(self, parameterBase): def __init__(self, parameterBase):
self.pbase = parameterBase self.pbase = parameterBase
self.list_checker = type_checker(list, tuple, np.ndarray)
def __set_name__(self, owner, name): def __set_name__(self, owner, name):
self.name = name self.name = name
@@ -222,8 +223,9 @@ class VariableParameter:
value = {} value = {}
else: else:
for k, v in value.items(): for k, v in value.items():
self.list_checker("variable " + k, v)
if k not in valid_variable: if k not in valid_variable:
raise TypeError(f"{k!r} is not a valide variable parameter") raise TypeError(f"{k!r} is not a valid variable parameter")
if len(v) == 0: if len(v) == 0:
raise ValueError(f"variable parameter {k!r} must not be empty") raise ValueError(f"variable parameter {k!r} must not be empty")
@@ -381,11 +383,13 @@ class BareParams:
beta_func: Callable[[float], List[float]] = Parameter(func_validator) beta_func: Callable[[float], List[float]] = Parameter(func_validator)
gamma_func: Callable[[float], float] = Parameter(func_validator) gamma_func: Callable[[float], float] = Parameter(func_validator)
interp_range: Tuple[float, float] = Parameter(float_pair) interp_range: Tuple[float, float] = Parameter(float_pair)
datetime: datetime_module.datetime = Parameter(type_checker(datetime_module.datetime))
version: str = Parameter(string)
def prepare_for_dump(self) -> Dict[str, Any]: def prepare_for_dump(self) -> Dict[str, Any]:
param = asdict(self) param = asdict(self)
param = BareParams.strip_params_dict(param) param = BareParams.strip_params_dict(param)
param["datetime"] = datetime.datetime.now() param["datetime"] = datetime_module.datetime.now()
param["version"] = __version__ param["version"] = __version__
return param return param

View File

@@ -1,13 +1,13 @@
name = "test config" name = "test config"
[fiber] # fiber
# gamma = 0.018 # gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
intensity_noise = 0.05e-2 intensity_noise = 0.05e-2
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
@@ -15,7 +15,7 @@ shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
width = 50e-15 width = 50e-15
[simulation] # simulation
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = false parallel = false
raman_type = "agrawal" raman_type = "agrawal"

View File

@@ -1,19 +1,13 @@
[fiber] # fiber
core_radius = 50e-6 core_radius = 50e-6
length = 50e-2 length = 50e-2
model = "marcatili" model = "marcatili"
[gas.variable] # pulse
gas_name = ["air", "helium"]
[pulse]
peak_power = 100e3 peak_power = 100e3
wavelength = 800e-9 wavelength = 800e-9
[pulse.variable] # simulation
width = [250e-15, 240e-15, 230e-15, 220e-15, 210e-15]
[simulation]
parallel = true parallel = true
repeat = 4 repeat = 4
t_num = 16384 t_num = 16384
@@ -21,5 +15,10 @@ time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[simulation.variable] [variable]
# gas.variable
gas_name = ["air", "helium"]
# pulse.variable
width = [250e-15, 240e-15, 230e-15, 220e-15, 210e-15]
# simulation.variable
behaviors = [["spm", "raman", "ss"], ["spm", "raman"], ["spm"]] behaviors = [["spm", "raman", "ss"], ["spm", "raman"], ["spm"]]

View File

@@ -1,17 +1,17 @@
[fiber] # fiber
core_radius = 50e-6 core_radius = 50e-6
length = 50e-2 length = 50e-2
model = "marcatili" model = "marcatili"
[gas] # gas
gas_name = "air" gas_name = "air"
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
wavelength = 800e-9 wavelength = 800e-9
width = 250e-15 width = 250e-15
[simulation] # simulation
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
repeat = 1 repeat = 1

View File

@@ -1,19 +1,16 @@
[fiber] # fiber
core_radius = 50e-6 core_radius = 50e-6
length = 50e-2 length = 50e-2
model = "marcatili" model = "marcatili"
[gas] # gas
gas_name = "air" gas_name = "air"
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
wavelength = 800e-9 wavelength = 800e-9
[pulse.variable] # simulation
width = [250e-15]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
repeat = 1 repeat = 1
@@ -21,3 +18,5 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
width = [250e-15]

View File

@@ -1,17 +1,17 @@
[fiber] # fiber
core_radius = 50e-6 core_radius = 50e-6
length = 50e-2 length = 50e-2
model = "marcatili" model = "marcatili"
[gas] # gas
gas_name = "air" gas_name = "air"
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
wavelength = 800e-9 wavelength = 800e-9
width = 250e-15 width = 250e-15
[simulation] # simulation
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
repeat = 2 repeat = 2

View File

@@ -1,20 +1,17 @@
[fiber] # fiber
core_radius = 50e-6 core_radius = 50e-6
length = 50e-2 length = 50e-2
model = "marcatili" model = "marcatili"
[gas] # gas
gas_name = "air" gas_name = "air"
[pulse] # pulse
soliton_num = 5 soliton_num = 5
wavelength = 800e-9 wavelength = 800e-9
width = 250e-15 width = 250e-15
[pulse.variable] # simulation
shape = ["gaussian", "sech"]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
repeat = 1 repeat = 1
@@ -22,3 +19,6 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
shape = ["gaussian", "sech"]

View File

@@ -2,7 +2,7 @@ dt = 1e-15
field_file = "testing/configs/custom_field/init_field.npz" field_file = "testing/configs/custom_field/init_field.npz"
length = 1 length = 1
peak_power = 20000 peak_power = 20000
readjust_wavelength = true readjust_wavelength = false
t_num = 2048 t_num = 2048
wavelength = 1593e-9 wavelength = 1593e-9
z_num = 32 z_num = 32

View File

@@ -1,17 +1,17 @@
name = "test config" name = "test config"
[fiber] # fiber
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
field_file = "testing/configs/custom_field/init_field.npz" field_file = "testing/configs/custom_field/init_field.npz"
quantum_noise = false quantum_noise = false
wavelength = 1050e-9 wavelength = 1050e-9
[simulation] # simulation
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
lower_wavelength_interp_limit = 300e-9 lower_wavelength_interp_limit = 300e-9
raman_type = "agrawal" raman_type = "agrawal"

View File

@@ -1,18 +1,16 @@
name = "test config" name = "test config"
[fiber] # fiber
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
field_file = "testing/configs/custom_field/init_field.npz" field_file = "testing/configs/custom_field/init_field.npz"
quantum_noise = false quantum_noise = false
[pulse.variable]
wavelength = [1050e-9, 1321e-9, 1593e-9]
[simulation] # simulation
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
lower_wavelength_interp_limit = 300e-9 lower_wavelength_interp_limit = 300e-9
raman_type = "agrawal" raman_type = "agrawal"
@@ -22,3 +20,7 @@ time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
upper_wavelength_interp_limit = 1900e-9 upper_wavelength_interp_limit = 1900e-9
z_num = 128 z_num = 128
[variable]
# pulse.variable
wavelength = [1050e-9, 1321e-9, 1593e-9]

View File

@@ -2,23 +2,20 @@
name = "test config" name = "test config"
[fiber] # fiber
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
intensity_noise = [0.05e-2, 0.1e-2]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
raman_type = "agrawal" raman_type = "agrawal"
@@ -27,3 +24,7 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = [0.05e-2, 0.1e-2]

View File

@@ -2,23 +2,19 @@
name = "test config" name = "test config"
[fiber] # fiber
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
intensity_noise = [0.05e-2, 0.1e-2]
soliton_num = [1, 2, 3, 4]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
raman_type = "agrawal" raman_type = "agrawal"
@@ -27,3 +23,8 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = [0.05e-2, 0.1e-2]
soliton_num = [1, 2, 3, 4]

View File

@@ -2,24 +2,20 @@
name = "test config" name = "test config"
[fiber] # fiber
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
raman_type = "agrawal" raman_type = "agrawal"
@@ -27,3 +23,8 @@ repeat = 4
t_num = 16384 t_num = 16384
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]

View File

@@ -2,25 +2,21 @@
name = "test config" name = "test config"
[fiber] # fiber
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
width = 120e-15 width = 120e-15
[pulse.variable] # simulation
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
raman_type = "agrawal" raman_type = "agrawal"
@@ -29,3 +25,8 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]

View File

@@ -2,7 +2,7 @@
name = "test config" name = "test config"
[fiber] # fiber
capillary_num = 6 capillary_num = 6
capillary_outer_d = 2e-6 capillary_outer_d = 2e-6
capillary_spacing = 4e-6 capillary_spacing = 4e-6
@@ -11,17 +11,13 @@ gamma = 0.018
length = 1 length = 1
model = "hasan" model = "hasan"
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
raman_type = "agrawal" raman_type = "agrawal"
@@ -30,3 +26,8 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]

View File

@@ -2,7 +2,7 @@
name = "test config" name = "test config"
[fiber] # fiber
capillary_num = 6 capillary_num = 6
capillary_thickness = 4e-6 capillary_thickness = 4e-6
core_radius = 50e-6 core_radius = 50e-6
@@ -10,17 +10,13 @@ gamma = 0.018
length = 1 length = 1
model = "hasan" model = "hasan"
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
raman_type = "agrawal" raman_type = "agrawal"
@@ -29,3 +25,8 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]

View File

@@ -2,24 +2,20 @@
name = "test config" name = "test config"
[fiber] # fiber
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
raman_type = "agrawal" raman_type = "agrawal"
@@ -28,3 +24,8 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]

View File

@@ -2,24 +2,20 @@
name = "test config" name = "test config"
[fiber] # fiber
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
repeat = 4 repeat = 4
@@ -27,3 +23,8 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]

View File

@@ -1,23 +1,19 @@
# name should be added # name should be added
[fiber] # fiber
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
raman_type = "agrawal" raman_type = "agrawal"
@@ -26,3 +22,8 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]

View File

@@ -2,7 +2,7 @@
name = "test config" name = "test config"
[fiber] # fiber
capillary_num = 6 capillary_num = 6
capillary_outer_d = 2e-6 capillary_outer_d = 2e-6
capillary_spacing = 4e-6 capillary_spacing = 4e-6
@@ -11,23 +11,16 @@ core_radius = 50e-6
length = 1 length = 1
model = "hasan" model = "hasan"
[gas] # gas
gas_name = "helium" gas_name = "helium"
[gas.variable] # pulse
temperature = [300, 350, 400]
[pulse]
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
raman_type = "agrawal" raman_type = "agrawal"
@@ -36,3 +29,10 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# gas.variable
temperature = [300, 350, 400]
# pulse.variable
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]

View File

@@ -2,23 +2,19 @@
name = "test config" name = "test config"
[fiber] # fiber
core_radius = 50e-6 core_radius = 50e-6
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "marcatili" model = "marcatili"
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
raman_type = "agrawal" raman_type = "agrawal"
@@ -27,3 +23,8 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]

View File

@@ -3,24 +3,20 @@
name = "test config" name = "test config"
[fiber] # fiber
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
raman_type = "agrawal" raman_type = "agrawal"
@@ -29,3 +25,8 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]

View File

@@ -1,13 +1,13 @@
name = "fiber 2" name = "fiber 2"
[fiber] # fiber
beta = [-1.183e-26, 8.1038e-41, -9.5205e-56, 2.0737e-70, -5.3943e-85, 1.3486e-99, -2.5495e-114, 3.0524e-129, -1.714e-144] beta = [-1.183e-26, 8.1038e-41, -9.5205e-56, 2.0737e-70, -5.3943e-85, 1.3486e-99, -2.5495e-114, 3.0524e-129, -1.714e-144]
gamma = 0.13 gamma = 0.13
length = 0.05 length = 0.05
model = "custom" model = "custom"
[fiber.variable] # simulation
input_transmission = [0.9, 0.95]
[simulation]
z_num = 16 z_num = 16
[variable]
# fiber.variable
input_transmission = [0.9, 0.95]

View File

@@ -1,20 +1,20 @@
name = "full anomalous" name = "full anomalous"
[fiber] # fiber
beta = [-1.183e-26, 8.1038e-41, -9.5205e-56, 2.0737e-70, -5.3943e-85, 1.3486e-99, -2.5495e-114, 3.0524e-129, -1.714e-144] beta = [-1.183e-26, 8.1038e-41, -9.5205e-56, 2.0737e-70, -5.3943e-85, 1.3486e-99, -2.5495e-114, 3.0524e-129, -1.714e-144]
gamma = 0.11 gamma = 0.11
input_transmission = 1.0 input_transmission = 1.0
length = 0.02 length = 0.02
model = "custom" model = "custom"
[pulse] # pulse
intensity_noise = 0 intensity_noise = 0
peak_power = 10000 peak_power = 10000
quantum_noise = false quantum_noise = false
shape = "gaussian" shape = "gaussian"
t0 = 2.84e-14 t0 = 2.84e-14
[simulation] # simulation
behaviors = ["spm", "ss"] behaviors = ["spm", "ss"]
dt = 1e-15 dt = 1e-15
frep = 80000000.0 frep = 80000000.0
@@ -28,5 +28,6 @@ tolerated_error = 1e-9
upper_wavelength_interp_limit = 1.9e-6 upper_wavelength_interp_limit = 1.9e-6
z_num = 64 z_num = 64
[pulse.variable] [variable]
# pulse.variable
wavelength = [8.35e-7, 8.3375e-7] wavelength = [8.35e-7, 8.3375e-7]

View File

@@ -2,24 +2,21 @@
name = "test config" name = "test config"
[fiber] # fiber
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
width = 50e-15 width = 50e-15
[pulse.variable] # simulation
intensity_noise = [0.10000000005e-2, 0.1e-2]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
repeat = 4 repeat = 4
@@ -27,3 +24,7 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = [0.10000000005e-2, 0.1e-2]

View File

@@ -2,24 +2,21 @@
name = "test config" name = "test config"
[fiber] # fiber
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
width = 50e-15 width = 50e-15
[pulse.variable] # simulation
intensity_noise = [0.1e-2, 0.001]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
repeat = 4 repeat = 4
@@ -27,3 +24,7 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = [0.1e-2, 0.001]

View File

@@ -2,14 +2,14 @@
name = "test config" name = "test config"
[fiber] # fiber
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
intensity_noise = 0.1e-2 intensity_noise = 0.1e-2
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
@@ -17,7 +17,7 @@ shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
width = 50e-15 width = 50e-15
[simulation] # simulation
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
repeat = 4 repeat = 4

View File

@@ -1,6 +1,6 @@
name = "full anomalous" name = "full anomalous"
[fiber] # fiber
beta = [ beta = [
-1.183e-26, -1.183e-26,
8.1038e-41, 8.1038e-41,
@@ -15,14 +15,11 @@ beta = [
gamma = 0.11 gamma = 0.11
length = 0.02 length = 0.02
[pulse] # pulse
peak_power = 10000 peak_power = 10000
t0 = 2.84e-14 t0 = 2.84e-14
[pulse.variable] # simulation
wavelength = [835e-9, 830e-9]
[simulation]
dt = 1e-15 dt = 1e-15
parallel = true parallel = true
raman_type = "measured" raman_type = "measured"
@@ -30,3 +27,7 @@ repeat = 4
t_num = 16384 t_num = 16384
tolerated_error = 1e-10 tolerated_error = 1e-10
z_num = 64 z_num = 64
[variable]
# pulse.variable
wavelength = [835e-9, 830e-9]

View File

@@ -2,24 +2,20 @@
name = "test config" name = "test config"
[fiber] # fiber
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
pitch = 1.5e-6 pitch = 1.5e-6
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
raman_type = "agrawal" raman_type = "agrawal"
@@ -28,3 +24,8 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]

View File

@@ -2,24 +2,20 @@
name = "test config" name = "test config"
[fiber] # fiber
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss", "q_noise"] behaviors = ["spm", "raman", "ss", "q_noise"]
parallel = true parallel = true
raman_type = "agrawal" raman_type = "agrawal"
@@ -28,3 +24,8 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]

View File

@@ -2,24 +2,20 @@
name = "test config" name = "test config"
[fiber] # fiber
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
intensity_noise = [0.05e-2, 0.1e-2]
width = ["gaussian", "sech"]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
raman_type = "agrawal" raman_type = "agrawal"
@@ -28,3 +24,8 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = [0.05e-2, 0.1e-2]
width = ["gaussian", "sech"]

View File

@@ -2,24 +2,20 @@
name = "test config" name = "test config"
[fiber] # fiber
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
raman_type = "agrawal" raman_type = "agrawal"
repeat = 4 repeat = 4
@@ -28,5 +24,9 @@ time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 1 z_num = 1
[simulation.variable] [variable]
# pulse.variable
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]
# simulation.variable
parallel = [true, false] parallel = [true, false]

View File

@@ -2,24 +2,20 @@
name = "test config" name = "test config"
[fiber] # fiber
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
intensity_noise = 0.05e-2
width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
raman_type = "agrawal" raman_type = "agrawal"
@@ -28,3 +24,8 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = 0.05e-2
width = [50e-15, 100e-15, 200e-15]

View File

@@ -2,24 +2,21 @@
name = "test config" name = "test config"
[fiber] # fiber
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
intensity_noise = 0.05e-2 intensity_noise = 0.05e-2
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
raman_type = "agrawal" raman_type = "agrawal"
@@ -28,3 +25,7 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
width = [50e-15, 100e-15, 200e-15]

View File

@@ -2,22 +2,18 @@
name = "test config" name = "test config"
[fiber] # fiber
beta = [1, 2, 3] beta = [1, 2, 3]
gamma = 0.018 gamma = 0.018
length = 1 length = 1
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
intensity_noise = []
width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
raman_type = "agrawal" raman_type = "agrawal"
@@ -26,3 +22,8 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = []
width = [50e-15, 100e-15, 200e-15]

View File

@@ -1,23 +1,19 @@
name = "test config" name = "test config"
[fiber] # fiber
gamma = 0.018 gamma = 0.018
length = 1 length = 1
model = "pcf" model = "pcf"
pitch = 1.5e-6 pitch = 1.5e-6
pitch_ratio = 0.37 pitch_ratio = 0.37
[pulse] # pulse
peak_power = 100e3 peak_power = 100e3
quantum_noise = true quantum_noise = true
shape = "gaussian" shape = "gaussian"
wavelength = 1050e-9 wavelength = 1050e-9
[pulse.variable] # simulation
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"] behaviors = ["spm", "raman", "ss"]
parallel = true parallel = true
raman_type = "agrawal" raman_type = "agrawal"
@@ -26,3 +22,8 @@ t_num = 16384
time_window = 37e-12 time_window = 37e-12
tolerated_error = 1e-11 tolerated_error = 1e-11
z_num = 128 z_num = 128
[variable]
# pulse.variable
intensity_noise = [0.05e-2, 0.1e-2]
width = [50e-15, 100e-15, 200e-15]

View File

@@ -6,7 +6,8 @@ import numpy as np
import toml import toml
from scgenerator import defaults, utils, math from scgenerator import defaults, utils, math
from scgenerator.errors import * from scgenerator.errors import *
from scgenerator.physics import units from scgenerator.physics import pulse, units
from scgenerator.utils.parameter import BareConfig, BareParams
def load_conf(name): def load_conf(name):
@@ -38,12 +39,6 @@ class TestParamSequence(unittest.TestCase):
l.append(vary_list) l.append(vary_list)
s.append(utils.format_variable_list(vary_list)) s.append(utils.format_variable_list(vary_list))
def test_init_config_not_affected_by_iteration(self):
for param_seq in self.iterconf(["almost_equal", "equal", "no_variations"]):
config = deepcopy(param_seq.config)
for _ in utils.required_simulations(param_seq.config):
self.assertEqual(config.items(), param_seq.config.items())
def test_no_variations_yields_only_num_and_id(self): def test_no_variations_yields_only_num_and_id(self):
for param_seq in self.iterconf(["no_variations"]): for param_seq in self.iterconf(["no_variations"]):
for vary_list, _ in utils.required_simulations(param_seq.config): for vary_list, _ in utils.required_simulations(param_seq.config):
@@ -55,34 +50,30 @@ class TestParamSequence(unittest.TestCase):
class TestInitializeMethods(unittest.TestCase): class TestInitializeMethods(unittest.TestCase):
def test_validate_types(self): def test_validate_types(self):
conf = lambda s: load_conf("validate_types/" + s) conf = lambda s: load_conf("validate_types/" + s)
with self.assertRaisesRegex(TypeError, "belong"):
init._validate_types(conf("bad1"))
with self.assertRaisesRegex(TypeError, "valid list of behaviors"): with self.assertRaisesRegex(ValueError, r"'behaviors\[3\]' must be a str in"):
init._validate_types(conf("bad2")) init.Config(**conf("bad2"))
with self.assertRaisesRegex(TypeError, "single, real, non-negative number"): with self.assertRaisesRegex(TypeError, "value must be of type <class 'float'>"):
init._validate_types(conf("bad3")) init.Config(**conf("bad3"))
with self.assertRaisesRegex(TypeError, "'parallel' is not a valid variable parameter"): with self.assertRaisesRegex(TypeError, "'parallel' is not a valid variable parameter"):
init._validate_types(conf("bad4")) init.Config(**conf("bad4"))
with self.assertRaisesRegex(TypeError, "Variable parameters should be specified in a list"):
init._validate_types(conf("bad5"))
with self.assertRaisesRegex( with self.assertRaisesRegex(
TypeError, TypeError, "'variable intensity_noise' value must be of type <class 'list'>"
"value '0' of type .*int.* for key 'repeat' is not valid, must be a strictly positive integer",
): ):
init._validate_types(conf("bad6")) init.Config(**conf("bad5"))
with self.assertRaisesRegex(ValueError, "'repeat' must be positive"):
init.Config(**conf("bad6"))
with self.assertRaisesRegex( with self.assertRaisesRegex(
ValueError, ValueError, "variable parameter 'intensity_noise' must not be empty"
r"Variable parameters lists should contain at least 1 element",
): ):
init._ensure_consistency(conf("bad7")) init.Config(**conf("bad7"))
self.assertIsNone(init._validate_types(conf("good"))) self.assertIsNone(init.Config(**conf("good")).hr_w)
def test_ensure_consistency(self): def test_ensure_consistency(self):
conf = lambda s: load_conf("ensure_consistency/" + s) conf = lambda s: load_conf("ensure_consistency/" + s)
@@ -90,68 +81,66 @@ class TestInitializeMethods(unittest.TestCase):
MissingParameterError, MissingParameterError,
r"1 of '\['t0', 'width'\]' is required and no defaults have been set", r"1 of '\['t0', 'width'\]' is required and no defaults have been set",
): ):
init._ensure_consistency(conf("bad1")) init.Config(**conf("bad1"))
with self.assertRaisesRegex( with self.assertRaisesRegex(
MissingParameterError, MissingParameterError,
r"1 of '\['peak_power', 'mean_power', 'energy', 'width', 't0'\]' is required when 'soliton_num' is specified and no defaults have been set", r"1 of '\['peak_power', 'mean_power', 'energy', 'width', 't0'\]' is required when 'soliton_num' is specified and no defaults have been set",
): ):
init._ensure_consistency(conf("bad2")) init.Config(**conf("bad2"))
with self.assertRaisesRegex( with self.assertRaisesRegex(
MissingParameterError, MissingParameterError,
r"2 of '\['dt', 't_num', 'time_window'\]' are required and no defaults have been set", r"2 of '\['dt', 't_num', 'time_window'\]' are required and no defaults have been set",
): ):
init._ensure_consistency(conf("bad3")) init.Config(**conf("bad3"))
with self.assertRaisesRegex( with self.assertRaisesRegex(
DuplicateParameterError, DuplicateParameterError,
r"got multiple values for parameter 'width'", r"got multiple values for parameter 'width'",
): ):
init._ensure_consistency(conf("bad4")) init.Config(**conf("bad4"))
with self.assertRaisesRegex( with self.assertRaisesRegex(
MissingParameterError, MissingParameterError,
r"'capillary_thickness' is a required parameter for fiber model 'hasan' and no defaults have been set", r"'capillary_thickness' is a required parameter for fiber model 'hasan' and no defaults have been set",
): ):
init._ensure_consistency(conf("bad5")) init.Config(**conf("bad5"))
with self.assertRaisesRegex( with self.assertRaisesRegex(
MissingParameterError, MissingParameterError,
r"1 of '\['capillary_spacing', 'capillary_outer_d'\]' is required for fiber model 'hasan' and no defaults have been set", r"1 of '\['capillary_spacing', 'capillary_outer_d'\]' is required for fiber model 'hasan' and no defaults have been set",
): ):
init._ensure_consistency(conf("bad6")) init.Config(**conf("bad6"))
self.assertLessEqual( self.assertLessEqual(
{"model": "pcf"}.items(), init._ensure_consistency(conf("good1"))["fiber"].items() {"model": "pcf"}.items(), init.Config(**conf("good1")).__dict__.items()
) )
self.assertNotIn("gas", init._ensure_consistency(conf("good1"))) self.assertIsNone(init.Config(**conf("good4")).gamma)
self.assertNotIn("gamma", init._ensure_consistency(conf("good4"))["fiber"])
self.assertLessEqual( self.assertLessEqual(
{"raman_type": "agrawal"}.items(), {"raman_type": "agrawal"}.items(),
init._ensure_consistency(conf("good2"))["simulation"].items(), init.Config(**conf("good2")).__dict__.items(),
) )
self.assertLessEqual( self.assertLessEqual(
{"name": "no name"}.items(), init._ensure_consistency(conf("good3")).items() {"name": "no name"}.items(), init.Config(**conf("good3")).__dict__.items()
) )
self.assertLessEqual( self.assertLessEqual(
{"capillary_nested": 0, "capillary_resonance_strengths": []}.items(), {"capillary_nested": 0, "capillary_resonance_strengths": []}.items(),
init._ensure_consistency(conf("good4"))["fiber"].items(), init.Config(**conf("good4")).__dict__.items(),
) )
self.assertLessEqual( self.assertLessEqual(
dict(he_mode=(1, 1)).items(), dict(he_mode=(1, 1)).items(),
init._ensure_consistency(conf("good5"))["fiber"].items(), init.Config(**conf("good5")).__dict__.items(),
) )
self.assertLessEqual( self.assertLessEqual(
dict(temperature=300, pressure=1e5, gas_name="vacuum", plasma_density=0).items(), dict(temperature=300, pressure=1e5, gas_name="vacuum", plasma_density=0).items(),
init._ensure_consistency(conf("good5"))["gas"].items(), init.Config(**conf("good5")).__dict__.items(),
) )
self.assertLessEqual( self.assertLessEqual(
@@ -165,62 +154,75 @@ class TestInitializeMethods(unittest.TestCase):
"upper_wavelength_interp_limit" "upper_wavelength_interp_limit"
], ],
).items(), ).items(),
init._ensure_consistency(conf("good6"))["simulation"].items(), init.Config(**conf("good6")).__dict__.items(),
) )
def setup_conf_custom_field(self, path) -> BareParams:
conf = load_conf(path)
conf = BareParams(**conf)
init.build_sim_grid_in_place(conf)
return conf
def test_setup_custom_field(self): def test_setup_custom_field(self):
d = np.load("testing/configs/custom_field/init_field.npz") d = np.load("testing/configs/custom_field/init_field.npz")
t = d["time"] t = d["time"]
field = d["field"] field = d["field"]
conf = load_conf("custom_field/no_change") conf = self.setup_conf_custom_field("custom_field/no_change")
conf = init.build_sim_grid(conf) result, conf.width, conf.peak_power, conf.energy, conf.field_0 = pulse.setup_custom_field(
result = init.setup_custom_field(conf) conf
self.assertAlmostEqual(conf["field_0"].real.max(), field.real.max(), 4)
self.assertTrue(result)
conf = load_conf("custom_field/peak_power")
conf = init.build_sim_grid(conf)
result = init.setup_custom_field(conf)
self.assertAlmostEqual(math.abs2(conf["field_0"]).max(), 20000, 4)
self.assertTrue(result)
self.assertNotAlmostEqual(conf["wavelength"], 1593e-9)
conf = load_conf("custom_field/mean_power")
conf = init.build_sim_grid(conf)
result = init.setup_custom_field(conf)
self.assertAlmostEqual(np.trapz(math.abs2(conf["field_0"]), conf["t"]), 0.22 / 40e6, 4)
self.assertTrue(result)
conf = load_conf("custom_field/recover1")
conf = init.build_sim_grid(conf)
result = init.setup_custom_field(conf)
self.assertAlmostEqual(math.abs2(conf["field_0"] - field).sum(), 0)
self.assertTrue(result)
conf = load_conf("custom_field/recover2")
conf = init.build_sim_grid(conf)
result = init.setup_custom_field(conf)
self.assertAlmostEqual((math.abs2(conf["field_0"]) / 0.9 - math.abs2(field)).sum(), 0)
self.assertTrue(result)
conf = load_conf("custom_field/wavelength_shift1")
result = init.compute_init_parameters(conf)
self.assertAlmostEqual(
units.m.inv(result["w"])[np.argmax(math.abs2(result["spec_0"]))], 1050e-9
) )
self.assertAlmostEqual(conf.field_0.real.max(), field.real.max(), 4)
self.assertTrue(result)
conf = load_conf("custom_field/wavelength_shift1") conf = self.setup_conf_custom_field("custom_field/peak_power")
conf["pulse"]["wavelength"] = 1593e-9 result, conf.width, conf.peak_power, conf.energy, conf.field_0 = pulse.setup_custom_field(
result = init.compute_init_parameters(conf) conf
)
conf.wavelength = pulse.correct_wavelength(conf.wavelength, conf.w_c, conf.field_0)
self.assertAlmostEqual(math.abs2(conf.field_0).max(), 20000, 4)
self.assertTrue(result)
self.assertNotAlmostEqual(conf.wavelength, 1593e-9)
conf = self.setup_conf_custom_field("custom_field/mean_power")
result, conf.width, conf.peak_power, conf.energy, conf.field_0 = pulse.setup_custom_field(
conf
)
self.assertAlmostEqual(np.trapz(math.abs2(conf.field_0), conf.t), 0.22 / 40e6, 4)
self.assertTrue(result)
conf = self.setup_conf_custom_field("custom_field/recover1")
result, conf.width, conf.peak_power, conf.energy, conf.field_0 = pulse.setup_custom_field(
conf
)
self.assertAlmostEqual(math.abs2(conf.field_0 - field).sum(), 0)
self.assertTrue(result)
conf = self.setup_conf_custom_field("custom_field/recover2")
result, conf.width, conf.peak_power, conf.energy, conf.field_0 = pulse.setup_custom_field(
conf
)
self.assertAlmostEqual((math.abs2(conf.field_0) / 0.9 - math.abs2(field)).sum(), 0)
self.assertTrue(result)
conf = self.setup_conf_custom_field("custom_field/wavelength_shift1")
result = init.Params.from_bare(conf)
self.assertAlmostEqual(units.m.inv(result.w)[np.argmax(math.abs2(result.spec_0))], 1050e-9)
conf = self.setup_conf_custom_field("custom_field/wavelength_shift1")
conf.wavelength = 1593e-9
result = init.Params.from_bare(conf)
conf = load_conf("custom_field/wavelength_shift2") conf = load_conf("custom_field/wavelength_shift2")
conf = init.Config(**conf)
for target, (variable, config) in zip( for target, (variable, config) in zip(
[1050e-9, 1321e-9, 1593e-9], init.ParamSequence(conf) [1050e-9, 1321e-9, 1593e-9], init.ParamSequence(conf)
): ):
init.build_sim_grid_in_place(conf)
self.assertAlmostEqual( self.assertAlmostEqual(
units.m.inv(config["w"])[np.argmax(math.abs2(config["spec_0"]))], target units.m.inv(config.w)[np.argmax(math.abs2(config.spec_0))], target
) )
print(config["wavelength"], target) print(config.wavelength, target)
if __name__ == "__main__": if __name__ == "__main__":

View File

@@ -1,37 +0,0 @@
from numba.core import config
from scgenerator.initialize import Config, Params, BareParams
from scgenerator.utils import variable_iterator, override_config
from scgenerator.io import load_toml
from pprint import pprint
from dataclasses import asdict
dico = load_toml("testing/configs/ensure_consistency/good2.toml")
out = dict(variable=dict())
for k, v in dico.items():
if isinstance(v, dict):
for kk, vv in v.items():
if kk == "variable":
for kkk, vvv in vv.items():
out["variable"][kkk] = vvv
else:
out[kk] = vv
pprint(out)
p = Config(**out)
print(p)
for l, c in variable_iterator(p):
print(l, c.width, c.intensity_noise)
print()
config2 = override_config(dict(width=1.2e-13, variable=dict(peak_power=[1e5, 2e5])), p)
print(
f"{config2.variable=}",
f"{config2.intensity_noise=}",
f"{config2.width=}",
f"{config2.peak_power=}",
)
par = BareParams()
print(all(v is None for v in vars(par).values()))

View File

@@ -14,9 +14,9 @@ def load_conf(name):
def conf_maker(folder, val=True): def conf_maker(folder, val=True):
def conf(name): def conf(name):
if val: if val:
return initialize.validate(load_conf(folder + "/" + name)) return initialize.Config(**load_conf(folder + "/" + name))
else: else:
return load_conf(folder + "/" + name) return initialize.BareConfig(**load_conf(folder + "/" + name))
return conf return conf
@@ -58,9 +58,9 @@ class TestUtilsMethods(unittest.TestCase):
old = conf("initial_config") old = conf("initial_config")
new = conf("fiber2") new = conf("fiber2")
over = utils.override_config(new, old) over = utils.override_config(vars(new), old)
self.assertIn("input_transmission", over["fiber"]["variable"]) self.assertNotIn("input_transmission", over.variable)
self.assertNotIn("input_transmission", over["fiber"]) self.assertIsNone(over.input_transmission)
if __name__ == "__main__": if __name__ == "__main__":