moved examples
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import click
|
||||||
import colorcet as cc
|
import colorcet as cc
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@@ -6,6 +7,7 @@ from plotapp import PlotApp
|
|||||||
import scgenerator as sc
|
import scgenerator as sc
|
||||||
|
|
||||||
params = sc.Parameters(
|
params = sc.Parameters(
|
||||||
|
name="Dudley2006 example",
|
||||||
wavelength=835e-9,
|
wavelength=835e-9,
|
||||||
width=50e-15,
|
width=50e-15,
|
||||||
peak_power=10e3,
|
peak_power=10e3,
|
||||||
@@ -35,14 +37,12 @@ params = sc.Parameters(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def compute_manual():
|
def compute_manual(save: bool):
|
||||||
spec0 = params.compute("spec_0")
|
spec0 = params.compute("spec_0")
|
||||||
w_c, w0, gamma = params.compute("w_c", "w0", "gamma")
|
w_c, w0, gamma = params.compute("w_c", "w0", "gamma")
|
||||||
p = params.compile()
|
p = params.compile()
|
||||||
print(p.dt)
|
print(p.dt)
|
||||||
beta_op = sc.operators.constant_polynomial_dispersion(
|
beta_op = sc.operators.constant_polynomial_dispersion(params.beta2_coefficients, w_c)
|
||||||
params.beta2_coefficients, w_c, params.compute("dispersion_ind")
|
|
||||||
)
|
|
||||||
linear = sc.operators.envelope_linear_operator(
|
linear = sc.operators.envelope_linear_operator(
|
||||||
beta_op,
|
beta_op,
|
||||||
# sc.operators.constant_quantity(0),
|
# sc.operators.constant_quantity(0),
|
||||||
@@ -94,7 +94,10 @@ def compute_manual():
|
|||||||
def linear(_):
|
def linear(_):
|
||||||
return linear_arr
|
return linear_arr
|
||||||
|
|
||||||
prop = sc.propagation("examples/dudley_manual.zip", params)
|
if save:
|
||||||
|
prop = sc.propagation("examples/dudley_manual.zip", params)
|
||||||
|
else:
|
||||||
|
prop = sc.propagation(params)
|
||||||
z = []
|
z = []
|
||||||
for i, (spec, stat) in enumerate(
|
for i, (spec, stat) in enumerate(
|
||||||
sc.solve43(spec0, linear, nonlinear, params.length, 1e-6, 1e-6, 0.9, h_const=20e-6)
|
sc.solve43(spec0, linear, nonlinear, params.length, 1e-6, 1e-6, 0.9, h_const=20e-6)
|
||||||
@@ -106,8 +109,11 @@ def compute_manual():
|
|||||||
z.append(stat["z"])
|
z.append(stat["z"])
|
||||||
|
|
||||||
|
|
||||||
def compute_auto():
|
def compute_auto(save: bool):
|
||||||
sc.compute(params, True, "examples/dudley2006")
|
if save:
|
||||||
|
sc.compute(params, True, "examples/dudley2006")
|
||||||
|
else:
|
||||||
|
sc.compute(params)
|
||||||
|
|
||||||
|
|
||||||
def plot():
|
def plot():
|
||||||
@@ -120,6 +126,15 @@ def plot():
|
|||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
@click.command()
|
||||||
|
@click.option("--show/--no-show", default=False)
|
||||||
|
@click.option("--save/--no-save", default=False)
|
||||||
|
def main(show: bool, save: bool):
|
||||||
|
compute_manual(save)
|
||||||
|
compute_auto(save)
|
||||||
|
if show:
|
||||||
|
plot()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# compute_auto()
|
main()
|
||||||
plot()
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
series of helper functions
|
series of helper functions
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import warnings
|
import warnings
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -166,28 +167,25 @@ def extend_axis(axis: np.ndarray) -> np.ndarray:
|
|||||||
def compute(
|
def compute(
|
||||||
parameters: Parameters, overwrite: bool = False, output: os.PathLike | None = None
|
parameters: Parameters, overwrite: bool = False, output: os.PathLike | None = None
|
||||||
) -> Propagation:
|
) -> Propagation:
|
||||||
|
prop_params = parameters.compile()
|
||||||
if output is None:
|
if output is None:
|
||||||
name = Path(parameters.compute("name")).stem + ".zip"
|
prop = propagation(prop_params)
|
||||||
else:
|
else:
|
||||||
path = Path(output)
|
path = Path(output)
|
||||||
name = path.parent / (path.stem + ".zip")
|
name = path.parent / (path.stem + ".zip")
|
||||||
|
prop = propagation(name, prop_params, bundle_data=True, overwrite=overwrite)
|
||||||
prop_params = parameters.compile()
|
|
||||||
prop = propagation(name, prop_params, bundle_data=True, overwrite=overwrite)
|
|
||||||
|
|
||||||
with warnings.catch_warnings(), tqdm(total=prop_params.z_num) as pbar:
|
with warnings.catch_warnings(), tqdm(total=prop_params.z_num) as pbar:
|
||||||
warnings.filterwarnings("error")
|
warnings.filterwarnings("error")
|
||||||
for i, (spec, new_stat) in enumerate(
|
for spec, _ in solve43(
|
||||||
solve43(
|
prop_params.spec_0,
|
||||||
prop_params.spec_0,
|
prop_params.linear_operator,
|
||||||
prop_params.linear_operator,
|
prop_params.nonlinear_operator,
|
||||||
prop_params.nonlinear_operator,
|
prop_params.length,
|
||||||
prop_params.length,
|
prop_params.tolerated_error,
|
||||||
prop_params.tolerated_error,
|
prop_params.tolerated_error,
|
||||||
prop_params.tolerated_error,
|
0.9,
|
||||||
0.9,
|
targets=prop_params.z_targets,
|
||||||
targets=prop_params.z_targets,
|
|
||||||
)
|
|
||||||
):
|
):
|
||||||
pbar.update()
|
pbar.update()
|
||||||
prop.append(spec)
|
prop.append(spec)
|
||||||
|
|||||||
@@ -22,16 +22,10 @@ c = 299792458.0
|
|||||||
def fft_functions(
|
def fft_functions(
|
||||||
full_field: bool,
|
full_field: bool,
|
||||||
) -> tuple[Callable[[np.ndarray], np.ndarray], Callable[[np.ndarray], np.ndarray]]:
|
) -> tuple[Callable[[np.ndarray], np.ndarray], Callable[[np.ndarray], np.ndarray]]:
|
||||||
if platform.processor() == "arm":
|
if full_field:
|
||||||
if full_field:
|
return sfft.rfft, sfft.irfft
|
||||||
return sfft.rfft, sfft.irfft
|
|
||||||
else:
|
|
||||||
return sfft.fft, sfft.ifft
|
|
||||||
else:
|
else:
|
||||||
if full_field:
|
return sfft.fft, sfft.ifft
|
||||||
return np.fft.rfft, np.fft.irfft
|
|
||||||
else:
|
|
||||||
return np.fft.fft, np.fft.ifft
|
|
||||||
|
|
||||||
|
|
||||||
def expm1_int(y: np.ndarray, dx: float) -> np.ndarray:
|
def expm1_int(y: np.ndarray, dx: float) -> np.ndarray:
|
||||||
|
|||||||
Reference in New Issue
Block a user