diff --git a/lasy/profiles/combined_profile.py b/lasy/profiles/combined_profile.py index eb4b48d6..8ffcca51 100644 --- a/lasy/profiles/combined_profile.py +++ b/lasy/profiles/combined_profile.py @@ -68,5 +68,7 @@ def evaluate(self, x, y, t): Contains the value of the envelope at the specified points This array has the same shape as the arrays x, y, t """ - envelope = self.trans_profile.evaluate(x, y) * self.long_profile.evaluate(t, x, y) + envelope = self.trans_profile.evaluate(x, y) * self.long_profile.evaluate( + t, x, y + ) return envelope diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 8f05dce8..5ae2c0a4 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -126,12 +126,35 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): """ def __init__( - self, wavelength, pol, laser_energy, w0, tau, t_peak, cep_phase=0, z_foc=0, phi2=0, beta=0, zeta=0, stc_theta=0 + self, + wavelength, + pol, + laser_energy, + w0, + tau, + t_peak, + cep_phase=0, + z_foc=0, + phi2=0, + beta=0, + zeta=0, + stc_theta=0, ): super().__init__( wavelength, pol, laser_energy, - GaussianLongitudinalProfile(wavelength, tau, t_peak, cep_phase, beta=beta, phi2=phi2, zeta=zeta, stc_theta=0, w0=w0, z_foc=z_foc), + GaussianLongitudinalProfile( + wavelength, + tau, + t_peak, + cep_phase, + beta=beta, + phi2=phi2, + zeta=zeta, + stc_theta=0, + w0=w0, + z_foc=z_foc, + ), GaussianTransverseProfile(w0, z_foc, wavelength), ) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index cef8432a..989591c6 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -63,7 +63,19 @@ class GaussianLongitudinalProfile(LongitudinalProfile): The waist of the laser pulse. """ - def __init__(self, wavelength, tau, t_peak, cep_phase=0, beta=0, phi2=0, zeta=0, stc_theta=0,w0=None, z_foc=0): + def __init__( + self, + wavelength, + tau, + t_peak, + cep_phase=0, + beta=0, + phi2=0, + zeta=0, + stc_theta=0, + w0=None, + z_foc=0, + ): super().__init__(wavelength) self.tau = tau self.t_peak = t_peak @@ -74,8 +86,9 @@ def __init__(self, wavelength, tau, t_peak, cep_phase=0, beta=0, phi2=0, zeta=0, self.w0 = w0 self.stc_theta = stc_theta if beta: - assert (w0 is not None and z_foc is not None),\ - "Both w0 and z_foc should be specified if angular dispersion beta is not 0" + assert ( + w0 is not None and z_foc is not None + ), "Both w0 and z_foc should be specified if angular dispersion beta is not 0" if z_foc == 0: self.z_foc_over_zr = 0 else: @@ -83,8 +96,7 @@ def __init__(self, wavelength, tau, t_peak, cep_phase=0, beta=0, phi2=0, zeta=0, wavelength is not None ), "You need to pass the wavelength, when `z_foc` is non-zero." self.z_foc_over_zr = z_foc * wavelength / (np.pi * w0**2) - self.k0 = 2.0 * scc.pi/wavelength - + self.k0 = 2.0 * scc.pi / wavelength def evaluate(self, t, x=None, y=None): """ @@ -105,23 +117,50 @@ def evaluate(self, t, x=None, y=None): specified points. This array has the same shape as the array t. """ stretch_factor = 1.0 - inv_tau2 = self.tau**(-2) - if (self.phi2 or self.zeta or self.beta): - assert(x is not None and y is not None),\ - "transverse points should be specified if spatio-temperal coupling exits" - inv_complex_waist_2 = 1.0 / (self.w0**2 * (1.0 + 2.0j *\ - self.z_foc_over_zr /(self.k0 * self.w0**2))) if self.beta else 0 - stretch_factor += 4.0 * (self.zeta + self.beta * self.z_foc_over_zr * inv_tau2)\ - * (self.zeta + self.beta * self.z_foc_over_zr * inv_complex_waist_2)\ - + 2.0j * (self.phi2 - self.beta**2 * self.k0 * self.z_foc_over_zr) * inv_tau2 - stc_exponent = 1.0 / stretch_factor * inv_tau2 * (t - self.t_peak - \ - self.beta * self.k0 *(x * np.cos(self.stc_theta) +y * np.sin(self.stc_theta))-\ - 2.0j * (x * np.cos(self.stc_theta) +y * np.sin(self.stc_theta))\ - * (self.zeta - self.beta * self.z_foc_over_zr) * inv_complex_waist_2)**2 + inv_tau2 = self.tau ** (-2) + if self.phi2 or self.zeta or self.beta: + assert ( + x is not None and y is not None + ), "transverse points should be specified if spatio-temperal coupling exits" + inv_complex_waist_2 = ( + 1.0 + / ( + self.w0**2 + * (1.0 + 2.0j * self.z_foc_over_zr / (self.k0 * self.w0**2)) + ) + if self.beta + else 0 + ) + stretch_factor += ( + 4.0 + * (self.zeta + self.beta * self.z_foc_over_zr * inv_tau2) + * (self.zeta + self.beta * self.z_foc_over_zr * inv_complex_waist_2) + + 2.0j + * (self.phi2 - self.beta**2 * self.k0 * self.z_foc_over_zr) + * inv_tau2 + ) + stc_exponent = ( + 1.0 + / stretch_factor + * inv_tau2 + * ( + t + - self.t_peak + - self.beta + * self.k0 + * (x * np.cos(self.stc_theta) + y * np.sin(self.stc_theta)) + - 2.0j + * (x * np.cos(self.stc_theta) + y * np.sin(self.stc_theta)) + * (self.zeta - self.beta * self.z_foc_over_zr) + * inv_complex_waist_2 + ) + ** 2 + ) envelope = np.exp(-stc_exponent) - else: envelope = np.exp( - -((t - self.t_peak) ** 2) / self.tau**2 - + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) - ) + else: + envelope = np.exp( + -((t - self.t_peak) ** 2) / self.tau**2 + + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) + ) return envelope