Skip to content

Commit

Permalink
Make wavelength optional for transverse profiles (#144)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
RemiLehe and pre-commit-ci[bot] authored May 24, 2023
1 parent 0bfb07d commit a7113e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
9 changes: 7 additions & 2 deletions lasy/profiles/gaussian_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile):
in the above formula (i.e. the phase of the laser
oscillation, at the time where the laser envelope is maximum)
z_foc : float (in meter), optional
Position of the focal plane. (The laser pulse is initialized at `z=0`.)
Examples
--------
>>> import matplotlib.pyplot as plt
Expand Down Expand Up @@ -99,11 +102,13 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile):
>>> plt.ylabel('r (µm)')
"""

def __init__(self, wavelength, pol, laser_energy, w0, tau, t_peak, cep_phase=0):
def __init__(
self, wavelength, pol, laser_energy, w0, tau, t_peak, cep_phase=0, z_foc=0
):
super().__init__(
wavelength,
pol,
laser_energy,
GaussianLongitudinalProfile(wavelength, tau, t_peak, cep_phase),
GaussianTransverseProfile(w0, wavelength),
GaussianTransverseProfile(w0, z_foc, wavelength),
)
17 changes: 12 additions & 5 deletions lasy/profiles/transverse/gaussian_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ class GaussianTransverseProfile(TransverseProfile):
w0 : float (in meter)
The waist of the laser pulse, i.e. :math:`w_0` in the above formula.
wavelength : float (in meter)
The main laser wavelength :math:`\\lambda_0` of the laser.
z_foc : float (in meter), optional
Position of the focal plane. (The laser pulse is initialized at `z=0`.)
wavelength : float (in meter), optional
The main laser wavelength :math:`\\lambda_0` of the laser.
(Only needed if `z_foc` is different than 0.)
.. warning::
In order to initialize the pulse out of focus, you can either:
Expand All @@ -37,10 +38,16 @@ class GaussianTransverseProfile(TransverseProfile):
not make this approximation.
"""

def __init__(self, w0, wavelength, z_foc=0):
def __init__(self, w0, wavelength=None, z_foc=0):
super().__init__()
self.w0 = w0
self.z_foc_over_zr = z_foc * wavelength / (np.pi * w0**2)
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)

def _evaluate(self, x, y):
"""
Expand Down

0 comments on commit a7113e6

Please sign in to comment.