got rid of readjust_wavelength
This commit is contained in:
@@ -251,9 +251,3 @@ upper_wavelength_interp_limit: float
|
|||||||
|
|
||||||
interp_degree: int
|
interp_degree: int
|
||||||
max degree of the Taylor polynomial fitting the dispersion data
|
max degree of the Taylor polynomial fitting the dispersion data
|
||||||
|
|
||||||
readjust_wavelength : bool
|
|
||||||
if a custom input field is set, it is likely that the maximum of its corresponding spectrum doesn't lies exactly at the
|
|
||||||
set wavelength. If this setting is True, the program will override the wavelength parameter so that the maximum of the spectrum
|
|
||||||
lies on the desired wavelength.
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ default_parameters = dict(
|
|||||||
upper_wavelength_interp_limit=2000e-9,
|
upper_wavelength_interp_limit=2000e-9,
|
||||||
interp_degree=8,
|
interp_degree=8,
|
||||||
ideal_gas=False,
|
ideal_gas=False,
|
||||||
readjust_wavelength=False,
|
|
||||||
recovery_last_stored=0,
|
recovery_last_stored=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -133,13 +133,6 @@ class Params(BareParams):
|
|||||||
self.energy,
|
self.energy,
|
||||||
self.field_0,
|
self.field_0,
|
||||||
) = pulse.setup_custom_field(self)
|
) = pulse.setup_custom_field(self)
|
||||||
if self.readjust_wavelength:
|
|
||||||
old_wl = self.wavelength
|
|
||||||
self.wavelength = pulse.correct_wavelength(self.wavelength, self.w_c, self.field_0)
|
|
||||||
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.t, self.wavelength, self.interp_degree
|
|
||||||
)
|
|
||||||
|
|
||||||
return did_set_custom_pulse
|
return did_set_custom_pulse
|
||||||
|
|
||||||
@@ -238,7 +231,6 @@ class Config(BareConfig):
|
|||||||
"upper_wavelength_interp_limit",
|
"upper_wavelength_interp_limit",
|
||||||
"interp_degree",
|
"interp_degree",
|
||||||
"ideal_gas",
|
"ideal_gas",
|
||||||
"readjust_wavelength",
|
|
||||||
"recovery_last_stored",
|
"recovery_last_stored",
|
||||||
]:
|
]:
|
||||||
self.get(param)
|
self.get(param)
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ scgenerator module but some function may be used in any python program
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from argparse import ArgumentTypeError
|
|
||||||
import itertools
|
import itertools
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
import random
|
||||||
import re
|
import re
|
||||||
import threading
|
import threading
|
||||||
from collections import abc
|
from collections import abc
|
||||||
@@ -14,13 +14,11 @@ from copy import deepcopy
|
|||||||
from dataclasses import asdict, replace
|
from dataclasses import asdict, replace
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, Iterable, Iterator, List, Tuple, TypeVar, Union
|
from typing import Any, Iterable, Iterator, TypeVar, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import random
|
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
|
|
||||||
from .. import env
|
from .. import env
|
||||||
from ..const import PARAM_SEPARATOR
|
from ..const import PARAM_SEPARATOR
|
||||||
from ..math import *
|
from ..math import *
|
||||||
@@ -168,7 +166,7 @@ def progress_worker(
|
|||||||
progress_queue : multiprocessing.Queue
|
progress_queue : multiprocessing.Queue
|
||||||
values are either
|
values are either
|
||||||
Literal[0] : stop the worker and close the progress bars
|
Literal[0] : stop the worker and close the progress bars
|
||||||
Tuple[int, float] : worker id and relative progress between 0 and 1
|
tuple[int, float] : worker id and relative progress between 0 and 1
|
||||||
"""
|
"""
|
||||||
with PBars(
|
with PBars(
|
||||||
num_steps, "Simulating " + name, num_workers, head_kwargs=dict(unit="step")
|
num_steps, "Simulating " + name, num_workers, head_kwargs=dict(unit="step")
|
||||||
@@ -182,7 +180,7 @@ def progress_worker(
|
|||||||
pbars[0].update()
|
pbars[0].update()
|
||||||
|
|
||||||
|
|
||||||
def format_variable_list(l: List[Tuple[str, Any]]):
|
def format_variable_list(l: list[tuple[str, Any]]):
|
||||||
joints = 2 * PARAM_SEPARATOR
|
joints = 2 * PARAM_SEPARATOR
|
||||||
str_list = []
|
str_list = []
|
||||||
for p_name, p_value in l:
|
for p_name, p_value in l:
|
||||||
@@ -192,7 +190,7 @@ def format_variable_list(l: List[Tuple[str, Any]]):
|
|||||||
return joints[0].join(str_list)
|
return joints[0].join(str_list)
|
||||||
|
|
||||||
|
|
||||||
def branch_id(branch: Tuple[Path, ...]) -> str:
|
def branch_id(branch: tuple[Path, ...]) -> str:
|
||||||
return "".join("".join(re.sub(r"id\d+\S*num\d+", "", b.name).split()[2:-2]) for b in branch)
|
return "".join("".join(re.sub(r"id\d+\S*num\d+", "", b.name).split()[2:-2]) for b in branch)
|
||||||
|
|
||||||
|
|
||||||
@@ -237,7 +235,7 @@ def pretty_format_from_sim_name(name: str) -> str:
|
|||||||
return PARAM_SEPARATOR.join(out)
|
return PARAM_SEPARATOR.join(out)
|
||||||
|
|
||||||
|
|
||||||
def variable_iterator(config: BareConfig) -> Iterator[Tuple[List[Tuple[str, Any]], dict[str, Any]]]:
|
def variable_iterator(config: BareConfig) -> Iterator[tuple[list[tuple[str, Any]], dict[str, Any]]]:
|
||||||
"""given a config with "variable" parameters, iterates through every possible combination,
|
"""given a config with "variable" parameters, iterates through every possible combination,
|
||||||
yielding a a list of (parameter_name, value) tuples and a full config dictionary.
|
yielding a a list of (parameter_name, value) tuples and a full config dictionary.
|
||||||
|
|
||||||
@@ -248,7 +246,7 @@ def variable_iterator(config: BareConfig) -> Iterator[Tuple[List[Tuple[str, Any]
|
|||||||
|
|
||||||
Yields
|
Yields
|
||||||
-------
|
-------
|
||||||
Iterator[Tuple[List[Tuple[str, Any]], dict[str, Any]]]
|
Iterator[tuple[list[tuple[str, Any]], dict[str, Any]]]
|
||||||
variable_list : a list of (name, value) tuple of parameter name and value that are variable.
|
variable_list : a list of (name, value) tuple of parameter name and value that are variable.
|
||||||
|
|
||||||
params : a dict[str, Any] to be fed to Params
|
params : a dict[str, Any] to be fed to Params
|
||||||
@@ -277,13 +275,13 @@ def variable_iterator(config: BareConfig) -> Iterator[Tuple[List[Tuple[str, Any]
|
|||||||
|
|
||||||
def required_simulations(
|
def required_simulations(
|
||||||
*configs: BareConfig,
|
*configs: BareConfig,
|
||||||
) -> Iterator[Tuple[List[Tuple[str, Any]], BareParams]]:
|
) -> Iterator[tuple[list[tuple[str, Any]], BareParams]]:
|
||||||
"""takes the output of `scgenerator.utils.variable_iterator` which is a new dict per different
|
"""takes the output of `scgenerator.utils.variable_iterator` which is a new dict per different
|
||||||
parameter set and iterates through every single necessary simulation
|
parameter set and iterates through every single necessary simulation
|
||||||
|
|
||||||
Yields
|
Yields
|
||||||
-------
|
-------
|
||||||
Iterator[Tuple[List[Tuple[str, Any]], dict]]
|
Iterator[tuple[list[tuple[str, Any]], dict]]
|
||||||
variable_ind : a list of (name, value) tuple of parameter name and value that are variable. The parameter
|
variable_ind : a list of (name, value) tuple of parameter name and value that are variable. The parameter
|
||||||
"num" (how many times this specific parameter set has been yielded already) and "id" (how many parameter sets
|
"num" (how many times this specific parameter set has been yielded already) and "id" (how many parameter sets
|
||||||
have been exhausted already) are added to the list to make sure every yielded list is unique.
|
have been exhausted already) are added to the list to make sure every yielded list is unique.
|
||||||
@@ -322,9 +320,6 @@ def override_config(new: BareConfig, old: BareConfig = None) -> BareConfig:
|
|||||||
variable[k] = v
|
variable[k] = v
|
||||||
for k in variable:
|
for k in variable:
|
||||||
new_dict[k] = None
|
new_dict[k] = None
|
||||||
|
|
||||||
new_dict["readjust_wavelength"] = False
|
|
||||||
|
|
||||||
return replace(old, variable=variable, **new_dict)
|
return replace(old, variable=variable, **new_dict)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -286,7 +286,6 @@ valid_variable = {
|
|||||||
"tolerated_error",
|
"tolerated_error",
|
||||||
"step_size",
|
"step_size",
|
||||||
"ideal_gas",
|
"ideal_gas",
|
||||||
"readjust_wavelength",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hc_model_specific_parameters = dict(
|
hc_model_specific_parameters = dict(
|
||||||
@@ -379,7 +378,6 @@ class BareParams:
|
|||||||
upper_wavelength_interp_limit: float = Parameter(in_range_incl(200e-9, 5000e-9))
|
upper_wavelength_interp_limit: float = Parameter(in_range_incl(200e-9, 5000e-9))
|
||||||
interp_degree: int = Parameter(positive(int))
|
interp_degree: int = Parameter(positive(int))
|
||||||
prev_sim_dir: str = Parameter(string)
|
prev_sim_dir: str = Parameter(string)
|
||||||
readjust_wavelength: bool = Parameter(boolean)
|
|
||||||
recovery_last_stored: int = Parameter(non_negative(int))
|
recovery_last_stored: int = Parameter(non_negative(int))
|
||||||
worker_num: int = Parameter(positive(int))
|
worker_num: int = Parameter(positive(int))
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ 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
|
||||||
mean_power = 220e-3
|
mean_power = 220e-3
|
||||||
readjust_wavelength = true
|
|
||||||
repetition_rate = 40e6
|
repetition_rate = 40e6
|
||||||
t_num = 2048
|
t_num = 2048
|
||||||
wavelength = 1000e-9
|
wavelength = 1000e-9
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
dt = 1e-15
|
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
|
||||||
readjust_wavelength = true
|
|
||||||
t_num = 2048
|
t_num = 2048
|
||||||
wavelength = 1000e-9
|
wavelength = 1000e-9
|
||||||
z_num = 32
|
z_num = 32
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ 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 = false
|
|
||||||
t_num = 2048
|
t_num = 2048
|
||||||
wavelength = 1593e-9
|
wavelength = 1593e-9
|
||||||
z_num = 32
|
z_num = 32
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ dt = 1e-15
|
|||||||
input_transmission = 1
|
input_transmission = 1
|
||||||
length = 1
|
length = 1
|
||||||
prev_data_dir = "testing/configs/custom_field/recover_data"
|
prev_data_dir = "testing/configs/custom_field/recover_data"
|
||||||
readjust_wavelength = true
|
|
||||||
t_num = 2048
|
t_num = 2048
|
||||||
wavelength = 1000e-9
|
wavelength = 1000e-9
|
||||||
z_num = 32
|
z_num = 32
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ dt = 1e-15
|
|||||||
input_transmission = 0.9
|
input_transmission = 0.9
|
||||||
length = 1
|
length = 1
|
||||||
prev_data_dir = "testing/configs/custom_field/recover_data"
|
prev_data_dir = "testing/configs/custom_field/recover_data"
|
||||||
readjust_wavelength = true
|
|
||||||
t_num = 2048
|
t_num = 2048
|
||||||
wavelength = 1000e-9
|
wavelength = 1000e-9
|
||||||
z_num = 32
|
z_num = 32
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ wavelength = 1050e-9
|
|||||||
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"
|
||||||
readjust_wavelength = true
|
|
||||||
t_num = 16384
|
t_num = 16384
|
||||||
time_window = 37e-12
|
time_window = 37e-12
|
||||||
tolerated_error = 1e-11
|
tolerated_error = 1e-11
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ quantum_noise = false
|
|||||||
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"
|
||||||
readjust_wavelength = true
|
|
||||||
t_num = 16384
|
t_num = 16384
|
||||||
time_window = 37e-12
|
time_window = 37e-12
|
||||||
tolerated_error = 1e-11
|
tolerated_error = 1e-11
|
||||||
|
|||||||
Reference in New Issue
Block a user