working on old/new cq solver

This commit is contained in:
Benoît Sierro
2024-01-24 15:24:46 +01:00
parent 820dbbdea5
commit 400ae2fd48
10 changed files with 276 additions and 15 deletions

View File

@@ -0,0 +1,55 @@
import multiprocessing
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import scgenerator as sc
PARAMS = Path("./examples/noisy.toml")
SEED = 2564
def path(i) -> Path:
return Path(f"build/{Path(__file__).stem}_{i}.zip")
def propagate(i):
np.random.seed(SEED + i)
params = sc.Parameters.load("./examples/noisy.toml")
sc.propagation(path(i), params.compile()).simulate()
def propagate_all(n):
to_do = [i for i in range(n) if not path(i).exists()]
with multiprocessing.Pool(4) as pool:
pool.map(propagate, to_do)
spec, props = sc.propagation_series([path(i) for i in range(n)])
return spec, props
def main():
n = 1
spec, props = propagate_all(n)
print(spec.shape)
wl, ind, _ = sc.PlotRange(
spec.wl_disp[spec.wl_disp > 0].min() * 1e9,
props.parameters.wavelength_window[1] * 1e9,
"nm",
).sort_axis(spec.wl_disp)
for i in range(spec.shape[1]):
fig, (left, right) = plt.subplots(1, 2)
for s in spec[:, i].time_int:
left.plot(spec.t, s)
for s in spec[:, i].wl_int:
right.plot(wl, s[ind])
plt.show()
if __name__ == "__main__":
main()

26
examples/noisy.toml Normal file
View File

@@ -0,0 +1,26 @@
name = "Sierro2020 Noisy"
width = 50e-15
shape = "gaussian"
peak_power = 100e3
wavelength = 1050e-9
gamma = 0.018
beta2_coefficients = [
1.001190e-26,
-2.131124e-41,
3.286793e-55,
-1.290523e-69,
1.047255e-84,
1.696410e-98,
-9.261236e-113,
2.149311e-127,
-2.028394e-142,
]
length = 0.1
raman_type = "measured"
input_transmission = 1.0
wavelength_window = [550e-9, 2000e-9]
t_num = 8192
quantum_noise = true
z_num = 21