tidying, still major bug with chi_silica
This commit is contained in:
@@ -393,7 +393,7 @@ class CapillaryLoss(ConstantLoss):
|
|||||||
interpolation_range: tuple[float, float],
|
interpolation_range: tuple[float, float],
|
||||||
he_mode: tuple[int, int],
|
he_mode: tuple[int, int],
|
||||||
):
|
):
|
||||||
mask = (l < interpolation_range[1]) & (l > 0)
|
mask = (l < interpolation_range[1]) & (l > interpolation_range[0])
|
||||||
alpha = fiber.capillary_loss(l[mask], he_mode, core_radius)
|
alpha = fiber.capillary_loss(l[mask], he_mode, core_radius)
|
||||||
self.arr = np.zeros_like(l)
|
self.arr = np.zeros_like(l)
|
||||||
self.arr[mask] = alpha
|
self.arr[mask] = alpha
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ from typing import Any, Iterable, Literal, TypeVar
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpy import e
|
from numpy import e
|
||||||
from numpy.fft import fft, ifft
|
from numpy.fft import fft
|
||||||
from numpy.polynomial.chebyshev import Chebyshev, cheb2poly
|
from numpy.polynomial.chebyshev import Chebyshev, cheb2poly
|
||||||
from scipy.interpolate import interp1d
|
from scipy.interpolate import interp1d
|
||||||
|
|
||||||
from .. import utils
|
from .. import utils
|
||||||
from ..cache import np_cache
|
from ..cache import np_cache
|
||||||
from ..logger import get_logger
|
from ..logger import get_logger
|
||||||
from ..math import abs2, argclosest, power_fact, u_nm
|
from ..math import argclosest, power_fact, u_nm
|
||||||
from . import materials as mat
|
from . import materials as mat
|
||||||
from . import units
|
from . import units
|
||||||
from .units import c, pi
|
from .units import c, pi
|
||||||
@@ -668,8 +668,11 @@ def dynamic_HCPCF_dispersion(
|
|||||||
A_eff = 1.5 * core_radius ** 2
|
A_eff = 1.5 * core_radius ** 2
|
||||||
|
|
||||||
# defining function instead of storing every possilble value
|
# defining function instead of storing every possilble value
|
||||||
pressure = lambda r: mat.pressure_from_gradient(r, *pressure_values)
|
def pressure(r):
|
||||||
beta2 = lambda r: HCPCF_dispersion(
|
return mat.pressure_from_gradient(r, *pressure_values)
|
||||||
|
|
||||||
|
def beta2(r):
|
||||||
|
return HCPCF_dispersion(
|
||||||
wl_for_disp,
|
wl_for_disp,
|
||||||
core_radius,
|
core_radius,
|
||||||
material_dico,
|
material_dico,
|
||||||
@@ -680,7 +683,9 @@ def dynamic_HCPCF_dispersion(
|
|||||||
ideal_gas,
|
ideal_gas,
|
||||||
)
|
)
|
||||||
|
|
||||||
n2 = lambda r: mat.non_linear_refractive_index(material_dico, pressure(r), temperature)
|
def n2(r):
|
||||||
|
return mat.non_linear_refractive_index(material_dico, pressure(r), temperature)
|
||||||
|
|
||||||
ratio_range = np.linspace(0, 1, 256)
|
ratio_range = np.linspace(0, 1, 256)
|
||||||
|
|
||||||
gamma_grid = np.array([gamma_parameter(n2(r), w0, A_eff) for r in ratio_range])
|
gamma_grid = np.array([gamma_parameter(n2(r), w0, A_eff) for r in ratio_range])
|
||||||
@@ -742,7 +747,6 @@ def n_eff_pcf(wl_for_disp: np.ndarray, pitch: float, pitch_ratio: float) -> np.n
|
|||||||
if pitch_ratio < 0.2 or pitch_ratio > 0.8:
|
if pitch_ratio < 0.2 or pitch_ratio > 0.8:
|
||||||
print("WARNING : Fitted formula valid only for pitch ratio between 0.2 and 0.8")
|
print("WARNING : Fitted formula valid only for pitch ratio between 0.2 and 0.8")
|
||||||
|
|
||||||
n_co = 1.45
|
|
||||||
a_eff = pitch / np.sqrt(3)
|
a_eff = pitch / np.sqrt(3)
|
||||||
pi2a = pipi * a_eff
|
pi2a = pipi * a_eff
|
||||||
|
|
||||||
@@ -959,9 +963,7 @@ def delayed_raman_t(t: np.ndarray, raman_type: str) -> np.ndarray:
|
|||||||
path = utils.Paths.get("hr_t")
|
path = utils.Paths.get("hr_t")
|
||||||
loaded = np.load(path)
|
loaded = np.load(path)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(
|
print("Not able to find the measured Raman response function. Going with agrawal model")
|
||||||
f"Not able to find the measured Raman response function. Going with agrawal model"
|
|
||||||
)
|
|
||||||
return delayed_raman_t(t, raman_type="agrawal")
|
return delayed_raman_t(t, raman_type="agrawal")
|
||||||
|
|
||||||
t_stored, hr_arr_stored = loaded["t"], loaded["hr_arr"]
|
t_stored, hr_arr_stored = loaded["t"], loaded["hr_arr"]
|
||||||
@@ -979,72 +981,6 @@ def delayed_raman_w(t: np.ndarray, raman_type: str) -> np.ndarray:
|
|||||||
return fft(delayed_raman_t(t, raman_type)) * (t[1] - t[0])
|
return fft(delayed_raman_t(t, raman_type)) * (t[1] - t[0])
|
||||||
|
|
||||||
|
|
||||||
def create_non_linear_op(behaviors, w_c, w0, gamma, raman_type="stolen", f_r=0, hr_w=None):
|
|
||||||
"""
|
|
||||||
Creates a non-linear operator with the desired features
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
behaviors : list of str
|
|
||||||
behaviors wanted
|
|
||||||
w_c : 1d array
|
|
||||||
symetric frequency array generated by scgenerator.initialize.wspace
|
|
||||||
w0 : float
|
|
||||||
pump angular frenquency
|
|
||||||
gamma : float
|
|
||||||
nonlinear parameter
|
|
||||||
raman_type : str, optional
|
|
||||||
name of the raman response function model. default : "stolen"
|
|
||||||
f_r : float, optional
|
|
||||||
fractional contribution of the delayed raman effect. default : 0
|
|
||||||
hr_w : 1d array, optional unless "raman" in behaviors
|
|
||||||
pre-calculated frequency-dependent delayed raman response function
|
|
||||||
|
|
||||||
returns
|
|
||||||
-------
|
|
||||||
func
|
|
||||||
a function to be passed to RK4IP which takes a spectrum as input and returns
|
|
||||||
a new spectrum modified with the non-linear interactions.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Compute raman response function if necessary
|
|
||||||
if "raman" in behaviors:
|
|
||||||
if hr_w is None:
|
|
||||||
raise ValueError("freq-dependent Raman response must be give")
|
|
||||||
if f_r == 0:
|
|
||||||
f_r = 0.18
|
|
||||||
if raman_type == "agrawal":
|
|
||||||
f_r = 0.245
|
|
||||||
|
|
||||||
if "spm" in behaviors:
|
|
||||||
spm_part = lambda fi: (1 - f_r) * abs2(fi)
|
|
||||||
else:
|
|
||||||
spm_part = lambda fi: 0
|
|
||||||
|
|
||||||
if "raman" in behaviors:
|
|
||||||
raman_part = lambda fi: f_r * ifft(hr_w * fft(abs2(fi)))
|
|
||||||
else:
|
|
||||||
raman_part = lambda fi: 0
|
|
||||||
|
|
||||||
ss_part = w_c / w0 if "ss" in behaviors else 0
|
|
||||||
|
|
||||||
if isinstance(gamma, (float, int, np.ndarray)):
|
|
||||||
|
|
||||||
def N_func(spectrum: np.ndarray, r=0) -> np.ndarray:
|
|
||||||
field = ifft(spectrum)
|
|
||||||
return -1j * gamma * (1 + ss_part) * fft(field * (spm_part(field) + raman_part(field)))
|
|
||||||
|
|
||||||
else:
|
|
||||||
|
|
||||||
def N_func(spectrum: np.ndarray, r=0) -> np.ndarray:
|
|
||||||
field = ifft(spectrum)
|
|
||||||
return (
|
|
||||||
-1j * gamma(r) * (1 + ss_part) * fft(field * (spm_part(field) + raman_part(field)))
|
|
||||||
)
|
|
||||||
|
|
||||||
return N_func
|
|
||||||
|
|
||||||
|
|
||||||
def fast_dispersion_op(w_c, beta_arr, power_fact_arr, where=slice(None)):
|
def fast_dispersion_op(w_c, beta_arr, power_fact_arr, where=slice(None)):
|
||||||
"""
|
"""
|
||||||
dispersive operator
|
dispersive operator
|
||||||
|
|||||||
@@ -394,7 +394,6 @@ def pulse_energy(spec2, dw) -> float:
|
|||||||
|
|
||||||
|
|
||||||
def pulse_energy_with_loss(spec2, dw, alpha, h) -> float:
|
def pulse_energy_with_loss(spec2, dw, alpha, h) -> float:
|
||||||
spec2 = spec2
|
|
||||||
return np.sum(spec2 * dw) - h * np.sum(alpha * spec2 * dw)
|
return np.sum(spec2 * dw) - h * np.sum(alpha * spec2 * dw)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user