working fullfied (kind of), better units

This commit is contained in:
Benoît Sierro
2021-11-03 17:00:19 +01:00
parent 772c480397
commit 50c9128fa5
13 changed files with 193 additions and 65 deletions

View File

@@ -8,12 +8,12 @@ width = 30e-15
core_radius = 10e-6
model = "marcatili"
gas_name = "argon"
pressure = 1e5
pressure = 3.2e5
length = 0.1
interpolation_range = [100e-9, 3000e-9]
interpolation_range = [120e-9, 3000e-9]
full_field = true
dt = 0.1e-15
dt = 0.05e-15
t_num = 32768
z_num = 128
step_size = 2e-6
step_size = 10e-6

View File

@@ -1,36 +1,61 @@
import warnings
import matplotlib.pyplot as plt
import numpy as np
import rediscache
import scgenerator as sc
from customfunc.app import PlotApp
from scgenerator.physics.simulate import RK4IP
from customfunc import pprint
from scipy.interpolate import interp1d
from tqdm import tqdm
warnings.filterwarnings("error")
# warnings.filterwarnings("error")
@rediscache.rcache
def get_specs(params: dict):
p = sc.Parameters(**params)
sim = sc.RK4IP(p)
return [s[-1] for s in tqdm(sim.irun(), total=p.z_num)], p.dump_dict()
def main():
params = sc.Parameters.load("testing/configs/Chang2011Fig2.toml")
x = params.l * 1e9
o = np.argsort(x)
x = x[o]
specs, params = get_specs(params.dump_dict(add_metadata=False))
params = sc.Parameters(**params)
rs = sc.PlotRange(100, 1500, "nm")
rt = sc.PlotRange(-500, 500, "fs")
x, o, ext = rs.sort_axis(params.w)
vmin = -50
with PlotApp(i=(int, 0, params.z_num - 1)) as app:
spec_ax = app[0]
spec_ax.set_xlabel(rs.unit.label)
field_ax = app[1]
field_ax.set_xlabel(rt.unit.label)
x: float = 4.5
y = sc.units.m.to.nm(x)
plt.plot(x, sc.abs2(params.spec_0[o]))
state = sc.operators.CurrentState(
params.length, 0, params.step_size, 1.0, params.ifft, params.spec_0
)
# expD = np.exp(state.h / 2 * params.linear_operator(state))
# plt.plot(x, expD.imag[o], x, expD.real[o])
plt.plot(x, sc.abs2(params.nonlinear_operator(state))[o])
plt.yscale("log")
plt.xlim(100, 2000)
plt.show()
@app.update
def draw(i):
spec, *fields = compute(i)
spec_ax.set_line_data("spec", *spec, label=f"z = {params.z_targets[i]*1e2:.0f}cm")
for label, x, y in fields:
field_ax.set_line_data(label, x, y)
# for *_, spec in RK4IP(params).irun():
# plt.plot(w[2:-2], sc.abs2(spec[ind]))
# plt.show()
# plt.close()
print(params)
@app.cache
def compute(i):
xt, field = sc.transform_1D_values(params.ifft(specs[i]), rt, params)
x, spec = sc.transform_1D_values(sc.abs2(specs[i]), rs, params, log=True)
# spec = np.where(spec > vmin, spec, vmin)
field2 = sc.abs2(field)
bot, top = sc.math.envelope_ind(field2)
return (x, spec), ("field^2", xt, field2), ("envelope", xt[top], field2[top])
# bot, top = sc.math.envelope_ind(field)
# bot = interp1d(xt[bot], field[bot], "cubic", bounds_error=False, fill_value=0)(xt)
# top = interp1d(xt[top], field[top], "cubic", bounds_error=False, fill_value=0)(xt)
# return ((x, spec), ("upper", xt, top), ("field", xt, field), ("lower", xt, bot))
if __name__ == "__main__":