Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 16, 2024
1 parent ed7eb7e commit 85967b4
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 25 deletions.
4 changes: 3 additions & 1 deletion lasy/profiles/combined_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 25 additions & 2 deletions lasy/profiles/gaussian_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
83 changes: 61 additions & 22 deletions lasy/profiles/longitudinal/gaussian_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -74,17 +86,17 @@ 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:
assert (
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):
"""
Expand All @@ -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

0 comments on commit 85967b4

Please sign in to comment.