Small improvements

This commit is contained in:
Benoît Sierro
2023-06-28 14:04:53 +02:00
parent 8e41c4aa17
commit 514dc4d99f
12 changed files with 187 additions and 65 deletions

View File

@@ -1,3 +1,9 @@
"""
May 2023
Testing the new solver / operators structure
using parameters from the 2022 Optica paper
"""
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import interp1d
@@ -19,11 +25,12 @@ def main():
#
# plt.plot(params.w, params.linear_operator(0).imag)
# plt.show()
breakpoint()
res = sol.integrate(params.spec_0, params.length, params.linear_operator, params.nonlinear_operator)
res = sol.integrate(
params.spec_0, params.length, params.linear_operator, params.nonlinear_operator
)
new_z = np.linspace(0, params.length, 256)

15
tests/Travers/Travers.toml Executable file
View File

@@ -0,0 +1,15 @@
name = "Travers"
repetition_rate = 1e3
wavelength = 800e-9
tolerated_error = 1e-6
z_num = 128
t_num = 4096
dt = 50e-18
core_radius = 125e-6
gas_name = "helium"
pressure = 400e2
energy = 0.4e-3
width = 10e-15
length = 3
full_field = true
shape = "sech"

View File

@@ -0,0 +1,69 @@
"""
Testing the the solver / operator mechanism with
parameters from the 2019 Travers paper
"""
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import interp1d
import scgenerator as sc
import scgenerator.math as math
import scgenerator.physics.units as units
import scgenerator.plotting as plot
import scgenerator.solver as sol
def main():
params = sc.Parameters(**sc.open_single_config("./tests/Travers/Travers.toml"))
# print(params.nonlinear_operator)
# print(params.compute("dispersion_op"))
# print(params.linear_operator)
# print(params.spec_0)
# print(params.compute("gamma_op"))
#
# plt.plot(params.w, params.linear_operator(0).imag)
# plt.show()
breakpoint()
res = sol.integrate(
params.spec_0, params.length, params.linear_operator, params.nonlinear_operator
)
new_z = np.linspace(0, params.length, 256)
specs2 = math.abs2(res.spectra)
specs2 = units.to_WL(specs2, params.l)
x = params.l
# x = units.THz.inv(w)
# new_x = np.linspace(100, 2200, 1024)
new_x = np.linspace(100e-9, 1200e-9, 1024)
solution = interp1d(res.z, specs2, axis=0)(new_z)
solution = interp1d(x, solution)(new_x)
solution = units.to_log2D(solution)
plt.imshow(
solution,
origin="lower",
aspect="auto",
extent=plot.get_extent(1e9 * new_x, new_z * 1e2),
vmin=-30,
)
plt.show()
fields = np.fft.irfft(res.spectra)
solution = math.abs2(fields)
solution = interp1d(res.z, solution, axis=0)(new_z)
solution.T[:] /= solution.max(axis=1)
plt.imshow(
solution,
origin="lower",
aspect="auto",
extent=plot.get_extent(params.t * 1e15, new_z * 1e2),
)
plt.show()
if __name__ == "__main__":
main()