From 63de3326d2153b5e217ed00a33be8571d22d07cc Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Wed, 13 Sep 2023 14:05:41 +0200 Subject: [PATCH 01/55] Add files via upload space-time profile --- lasy/profiles/spacetime_profile.py | 111 +++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 lasy/profiles/spacetime_profile.py diff --git a/lasy/profiles/spacetime_profile.py b/lasy/profiles/spacetime_profile.py new file mode 100644 index 00000000..b8e8dac3 --- /dev/null +++ b/lasy/profiles/spacetime_profile.py @@ -0,0 +1,111 @@ +import numpy as np + +from .profile import Profile + + +class SpaceTimeProfile(Profile): + """ + Class that can evaluate a pulse that has certain space-time couplings + """ + + def __init__(self, wavelength, pol, laser_energy, w0, tau, sc, t_peak, cep_phase=0): + """ + Defines a laser pulse. + + More precisely, the electric field corresponds to: + + .. math:: + + E_u(\\boldsymbol{x}_\\perp,t) = Re\\left[ E_0\\, + \\exp\\left(-\\frac{\\boldsymbol{x}_\\perp^2}{w_0^2} + - \\frac{(t-t_{peak}+2ibx/w_0^2)^2}{\\tau_{eff}^2} + - i\\omega_0(t-t_{peak}) + i\\phi_{cep}\\right) \\times p_u \\right] + + where :math:`u` is either :math:`x` or :math:`y`, :math:`p_u` is + the polarization vector, :math:`Re` represent the real part. + The other parameters in this formula are defined below. + + Parameters + ---------- + wavelength: float (in meter) + The main laser wavelength :math:`\\lambda_0` of the laser, which + defines :math:`\\omega_0` in the above formula, according to + :math:`\\omega_0 = 2\\pi c/\\lambda_0`. + + pol: list of 2 complex numbers (dimensionless) + Polarization vector. It corresponds to :math:`p_u` in the above + formula ; :math:`p_x` is the first element of the list and + :math:`p_y` is the second element of the list. Using complex + numbers enables elliptical polarizations. + + laser_energy: float (in Joule) + The total energy of the laser pulse. The amplitude of the laser + field (:math:`E_0` in the above formula) is automatically + calculated so that the pulse has the prescribed energy. + + tau: float (in second) + The duration of the laser pulse, i.e. :math:`\\tau` in the above + formula. Note that :math:`\\tau = \\tau_{FWHM}/\\sqrt{2\\log(2)}`, + where :math:`\\tau_{FWHM}` is the Full-Width-Half-Maximum duration + of the intensity distribution of the pulse. + + w0: float (in meter) + The waist of the laser pulse, i.e. :math:`w_0` in the above formula. + + sc: spatial chirp, b in the above formula, that results in a mixing + of the longitudinal and transverse profiles. Must be in units + of [x/omega]. An imaginary value for this property is possible, + which would represent a pulse-front tilt in the focus. + A representative real value is b = w0 * tau. + + t_peak: float (in second) + The time at which the laser envelope reaches its maximum amplitude, + i.e. :math:`t_{peak}` in the above formula. + + cep_phase: float (in radian), optional + The Carrier Enveloppe Phase (CEP), i.e. :math:`\\phi_{cep}` + in the above formula (i.e. the phase of the laser + oscillation, at the time where the laser envelope is maximum) + """ + super().__init__(wavelength, pol) + wavelength, + pol, + laser_energy, + self.w0 = w0 + self.tau = tau + self.sc = sc + self.t_peak = t_peak + self.cep_phase = cep_phase + + def evaluate(self, x, y, t): + """ + Returns the envelope field of the laser + + Parameters + ---------- + x, y, t: ndarrays of floats + Define points on which to evaluate the envelope + These arrays need to all have the same shape. + + Returns + ------- + envelope: ndarray of complex numbers + Contains the value of the envelope at the specified points + This array has the same shape as the arrays x, y, t + """ + transverse = np.exp(-(x**2 + y**2) / self.w0**2) + + tau_eff = np.sqrt(self.tau**2 + (2 * self.sc / self.w0)**2) + + spacetime = np.exp( + -(time - self.t_peak + + (2 * 1j * self.sc * x / self.w0**2))**2 / tau_eff**2 + ) + + oscillatory = *np.exp( + 1.0j * (self.cep_phase - self.omega0 * (time - self.t_peak)) + ) + + envelope = transverse*spacetime*oscillatory + + return envelope \ No newline at end of file From 92f3b71b756b6fb52e166ee297b70367585340e1 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Wed, 13 Sep 2023 14:06:45 +0200 Subject: [PATCH 02/55] Update spacetime_profile.py --- lasy/profiles/spacetime_profile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/spacetime_profile.py b/lasy/profiles/spacetime_profile.py index b8e8dac3..731f2c81 100644 --- a/lasy/profiles/spacetime_profile.py +++ b/lasy/profiles/spacetime_profile.py @@ -4,7 +4,7 @@ class SpaceTimeProfile(Profile): - """ + r""" Class that can evaluate a pulse that has certain space-time couplings """ @@ -108,4 +108,4 @@ def evaluate(self, x, y, t): envelope = transverse*spacetime*oscillatory - return envelope \ No newline at end of file + return envelope From 9f8511fc5e728cf8c4824262896b953b1bbf425b Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Wed, 13 Sep 2023 14:08:15 +0200 Subject: [PATCH 03/55] Update spacetime_profile.py --- lasy/profiles/spacetime_profile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/spacetime_profile.py b/lasy/profiles/spacetime_profile.py index 731f2c81..dce388f6 100644 --- a/lasy/profiles/spacetime_profile.py +++ b/lasy/profiles/spacetime_profile.py @@ -4,12 +4,12 @@ class SpaceTimeProfile(Profile): - r""" + """ Class that can evaluate a pulse that has certain space-time couplings """ def __init__(self, wavelength, pol, laser_energy, w0, tau, sc, t_peak, cep_phase=0): - """ + r""" Defines a laser pulse. More precisely, the electric field corresponds to: From 54cba90602c0a74f378cbd559e15c3702b137fec Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Wed, 13 Sep 2023 14:11:01 +0200 Subject: [PATCH 04/55] Update spacetime_profile.py --- lasy/profiles/spacetime_profile.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lasy/profiles/spacetime_profile.py b/lasy/profiles/spacetime_profile.py index dce388f6..4646022c 100644 --- a/lasy/profiles/spacetime_profile.py +++ b/lasy/profiles/spacetime_profile.py @@ -4,15 +4,10 @@ class SpaceTimeProfile(Profile): - """ + r""" Class that can evaluate a pulse that has certain space-time couplings - """ - - def __init__(self, wavelength, pol, laser_energy, w0, tau, sc, t_peak, cep_phase=0): - r""" - Defines a laser pulse. - More precisely, the electric field corresponds to: + More precisely, the electric field corresponds to: .. math:: @@ -66,11 +61,11 @@ def __init__(self, wavelength, pol, laser_energy, w0, tau, sc, t_peak, cep_phase The Carrier Enveloppe Phase (CEP), i.e. :math:`\\phi_{cep}` in the above formula (i.e. the phase of the laser oscillation, at the time where the laser envelope is maximum) - """ + """ + + def __init__(self, wavelength, pol, laser_energy, w0, tau, sc, t_peak, cep_phase=0): super().__init__(wavelength, pol) - wavelength, - pol, - laser_energy, + self.laser_energy = laser_energy self.w0 = w0 self.tau = tau self.sc = sc From 5e26c58ea77ab2e4c90a5df723f833666cb9a9d3 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Wed, 13 Sep 2023 14:13:27 +0200 Subject: [PATCH 05/55] correct time variable name --- lasy/profiles/spacetime_profile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/spacetime_profile.py b/lasy/profiles/spacetime_profile.py index 4646022c..74da2e0c 100644 --- a/lasy/profiles/spacetime_profile.py +++ b/lasy/profiles/spacetime_profile.py @@ -93,12 +93,12 @@ def evaluate(self, x, y, t): tau_eff = np.sqrt(self.tau**2 + (2 * self.sc / self.w0)**2) spacetime = np.exp( - -(time - self.t_peak + -(t - self.t_peak + (2 * 1j * self.sc * x / self.w0**2))**2 / tau_eff**2 ) oscillatory = *np.exp( - 1.0j * (self.cep_phase - self.omega0 * (time - self.t_peak)) + 1.0j * (self.cep_phase - self.omega0 * (t - self.t_peak)) ) envelope = transverse*spacetime*oscillatory From 2f98d4307b0e0df927d50d9bfbcc33ccac78a3c9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 12:21:16 +0000 Subject: [PATCH 06/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/spacetime_profile.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lasy/profiles/spacetime_profile.py b/lasy/profiles/spacetime_profile.py index 74da2e0c..5bf783a0 100644 --- a/lasy/profiles/spacetime_profile.py +++ b/lasy/profiles/spacetime_profile.py @@ -90,17 +90,15 @@ def evaluate(self, x, y, t): """ transverse = np.exp(-(x**2 + y**2) / self.w0**2) - tau_eff = np.sqrt(self.tau**2 + (2 * self.sc / self.w0)**2) + tau_eff = np.sqrt(self.tau**2 + (2 * self.sc / self.w0) ** 2) spacetime = np.exp( - -(t - self.t_peak - + (2 * 1j * self.sc * x / self.w0**2))**2 / tau_eff**2 - ) + -((t - self.t_peak + (2 * 1j * self.sc * x / self.w0**2)) ** 2) + / tau_eff**2 + ) - oscillatory = *np.exp( - 1.0j * (self.cep_phase - self.omega0 * (t - self.t_peak)) - ) + oscillatory = *np.exp(1.0j * (self.cep_phase - self.omega0 * (t - self.t_peak))) - envelope = transverse*spacetime*oscillatory + envelope = transverse * spacetime * oscillatory return envelope From 8ae8c0984859aac10f16c892f84d2bc15e7491f0 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 18 Sep 2023 14:09:50 +0200 Subject: [PATCH 07/55] fix typos and remove mention of pft --- lasy/profiles/spacetime_profile.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lasy/profiles/spacetime_profile.py b/lasy/profiles/spacetime_profile.py index 5bf783a0..3ab75f66 100644 --- a/lasy/profiles/spacetime_profile.py +++ b/lasy/profiles/spacetime_profile.py @@ -49,9 +49,7 @@ class SpaceTimeProfile(Profile): sc: spatial chirp, b in the above formula, that results in a mixing of the longitudinal and transverse profiles. Must be in units - of [x/omega]. An imaginary value for this property is possible, - which would represent a pulse-front tilt in the focus. - A representative real value is b = w0 * tau. + of [x/omega]. A representative real value is b = w0 * tau. t_peak: float (in second) The time at which the laser envelope reaches its maximum amplitude, @@ -97,7 +95,7 @@ def evaluate(self, x, y, t): / tau_eff**2 ) - oscillatory = *np.exp(1.0j * (self.cep_phase - self.omega0 * (t - self.t_peak))) + oscillatory = np.exp(1.0j * (self.cep_phase - self.omega0 * (t - self.t_peak))) envelope = transverse * spacetime * oscillatory From e321db773ba277db50a43ba5672216638fb80bd2 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 18 Sep 2023 14:21:41 +0200 Subject: [PATCH 08/55] style changes --- lasy/profiles/spacetime_profile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/spacetime_profile.py b/lasy/profiles/spacetime_profile.py index 3ab75f66..5cf3abf5 100644 --- a/lasy/profiles/spacetime_profile.py +++ b/lasy/profiles/spacetime_profile.py @@ -5,7 +5,7 @@ class SpaceTimeProfile(Profile): r""" - Class that can evaluate a pulse that has certain space-time couplings + Class that can evaluate a pulse that has certain space-time couplings. More precisely, the electric field corresponds to: @@ -72,7 +72,7 @@ def __init__(self, wavelength, pol, laser_energy, w0, tau, sc, t_peak, cep_phase def evaluate(self, x, y, t): """ - Returns the envelope field of the laser + Return the envelope field of the laser. Parameters ---------- From 7553b763c74883d0f6067d6bcdfcb58312b5c1c8 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Wed, 20 Sep 2023 14:47:31 +0200 Subject: [PATCH 09/55] remove spurious indent --- lasy/profiles/spacetime_profile.py | 100 ++++++++++++++--------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/lasy/profiles/spacetime_profile.py b/lasy/profiles/spacetime_profile.py index 5cf3abf5..d4e9f6b8 100644 --- a/lasy/profiles/spacetime_profile.py +++ b/lasy/profiles/spacetime_profile.py @@ -9,56 +9,56 @@ class SpaceTimeProfile(Profile): More precisely, the electric field corresponds to: - .. math:: - - E_u(\\boldsymbol{x}_\\perp,t) = Re\\left[ E_0\\, - \\exp\\left(-\\frac{\\boldsymbol{x}_\\perp^2}{w_0^2} - - \\frac{(t-t_{peak}+2ibx/w_0^2)^2}{\\tau_{eff}^2} - - i\\omega_0(t-t_{peak}) + i\\phi_{cep}\\right) \\times p_u \\right] - - where :math:`u` is either :math:`x` or :math:`y`, :math:`p_u` is - the polarization vector, :math:`Re` represent the real part. - The other parameters in this formula are defined below. - - Parameters - ---------- - wavelength: float (in meter) - The main laser wavelength :math:`\\lambda_0` of the laser, which - defines :math:`\\omega_0` in the above formula, according to - :math:`\\omega_0 = 2\\pi c/\\lambda_0`. - - pol: list of 2 complex numbers (dimensionless) - Polarization vector. It corresponds to :math:`p_u` in the above - formula ; :math:`p_x` is the first element of the list and - :math:`p_y` is the second element of the list. Using complex - numbers enables elliptical polarizations. - - laser_energy: float (in Joule) - The total energy of the laser pulse. The amplitude of the laser - field (:math:`E_0` in the above formula) is automatically - calculated so that the pulse has the prescribed energy. - - tau: float (in second) - The duration of the laser pulse, i.e. :math:`\\tau` in the above - formula. Note that :math:`\\tau = \\tau_{FWHM}/\\sqrt{2\\log(2)}`, - where :math:`\\tau_{FWHM}` is the Full-Width-Half-Maximum duration - of the intensity distribution of the pulse. - - w0: float (in meter) - The waist of the laser pulse, i.e. :math:`w_0` in the above formula. - - sc: spatial chirp, b in the above formula, that results in a mixing - of the longitudinal and transverse profiles. Must be in units - of [x/omega]. A representative real value is b = w0 * tau. - - t_peak: float (in second) - The time at which the laser envelope reaches its maximum amplitude, - i.e. :math:`t_{peak}` in the above formula. - - cep_phase: float (in radian), optional - The Carrier Enveloppe Phase (CEP), i.e. :math:`\\phi_{cep}` - in the above formula (i.e. the phase of the laser - oscillation, at the time where the laser envelope is maximum) + .. math:: + + E_u(\\boldsymbol{x}_\\perp,t) = Re\\left[ E_0\\, + \\exp\\left(-\\frac{\\boldsymbol{x}_\\perp^2}{w_0^2} + - \\frac{(t-t_{peak}+2ibx/w_0^2)^2}{\\tau_{eff}^2} + - i\\omega_0(t-t_{peak}) + i\\phi_{cep}\\right) \\times p_u \\right] + + where :math:`u` is either :math:`x` or :math:`y`, :math:`p_u` is + the polarization vector, :math:`Re` represent the real part. + The other parameters in this formula are defined below. + + Parameters + ---------- + wavelength: float (in meter) + The main laser wavelength :math:`\\lambda_0` of the laser, which + defines :math:`\\omega_0` in the above formula, according to + :math:`\\omega_0 = 2\\pi c/\\lambda_0`. + + pol: list of 2 complex numbers (dimensionless) + Polarization vector. It corresponds to :math:`p_u` in the above + formula ; :math:`p_x` is the first element of the list and + :math:`p_y` is the second element of the list. Using complex + numbers enables elliptical polarizations. + + laser_energy: float (in Joule) + The total energy of the laser pulse. The amplitude of the laser + field (:math:`E_0` in the above formula) is automatically + calculated so that the pulse has the prescribed energy. + + tau: float (in second) + The duration of the laser pulse, i.e. :math:`\\tau` in the above + formula. Note that :math:`\\tau = \\tau_{FWHM}/\\sqrt{2\\log(2)}`, + where :math:`\\tau_{FWHM}` is the Full-Width-Half-Maximum duration + of the intensity distribution of the pulse. + + w0: float (in meter) + The waist of the laser pulse, i.e. :math:`w_0` in the above formula. + + sc: spatial chirp, b in the above formula, that results in a mixing + of the longitudinal and transverse profiles. Must be in units + of [x/omega]. A representative real value is b = w0 * tau. + + t_peak: float (in second) + The time at which the laser envelope reaches its maximum amplitude, + i.e. :math:`t_{peak}` in the above formula. + + cep_phase: float (in radian), optional + The Carrier Enveloppe Phase (CEP), i.e. :math:`\\phi_{cep}` + in the above formula (i.e. the phase of the laser + oscillation, at the time where the laser envelope is maximum) """ def __init__(self, wavelength, pol, laser_energy, w0, tau, sc, t_peak, cep_phase=0): From deeee9b6b5ed4695c2ee095753369f9951f618c9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 20 Sep 2023 12:47:40 +0000 Subject: [PATCH 10/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/spacetime_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/spacetime_profile.py b/lasy/profiles/spacetime_profile.py index d4e9f6b8..4c2e5bec 100644 --- a/lasy/profiles/spacetime_profile.py +++ b/lasy/profiles/spacetime_profile.py @@ -13,7 +13,7 @@ class SpaceTimeProfile(Profile): E_u(\\boldsymbol{x}_\\perp,t) = Re\\left[ E_0\\, \\exp\\left(-\\frac{\\boldsymbol{x}_\\perp^2}{w_0^2} - - \\frac{(t-t_{peak}+2ibx/w_0^2)^2}{\\tau_{eff}^2} + - \\frac{(t-t_{peak}+2ibx/w_0^2)^2}{\\tau_{eff}^2} - i\\omega_0(t-t_{peak}) + i\\phi_{cep}\\right) \\times p_u \\right] where :math:`u` is either :math:`x` or :math:`y`, :math:`p_u` is From d7ce0911d22e78b6dae1e44eb42564e68941d31b Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Fri, 1 Dec 2023 13:02:07 +0100 Subject: [PATCH 11/55] Update lasy/profiles/spacetime_profile.py update docstring Co-authored-by: Remi Lehe --- lasy/profiles/spacetime_profile.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lasy/profiles/spacetime_profile.py b/lasy/profiles/spacetime_profile.py index 4c2e5bec..b33557e6 100644 --- a/lasy/profiles/spacetime_profile.py +++ b/lasy/profiles/spacetime_profile.py @@ -47,9 +47,10 @@ class SpaceTimeProfile(Profile): w0: float (in meter) The waist of the laser pulse, i.e. :math:`w_0` in the above formula. - sc: spatial chirp, b in the above formula, that results in a mixing - of the longitudinal and transverse profiles. Must be in units - of [x/omega]. A representative real value is b = w0 * tau. + b: float (in meter.second) + Spatial chirp, i.e. :math:`b` in the above formula, that results in the laser frequency + varying as a function of `x`. A representative real value is b = w0 * tau. + t_peak: float (in second) The time at which the laser envelope reaches its maximum amplitude, From deaaee8becf1a127f7d49c51319e959b692b520f Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Fri, 1 Dec 2023 13:05:54 +0100 Subject: [PATCH 12/55] change sc to b in spacetime --- lasy/profiles/spacetime_profile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lasy/profiles/spacetime_profile.py b/lasy/profiles/spacetime_profile.py index b33557e6..eca5e3ee 100644 --- a/lasy/profiles/spacetime_profile.py +++ b/lasy/profiles/spacetime_profile.py @@ -67,7 +67,7 @@ def __init__(self, wavelength, pol, laser_energy, w0, tau, sc, t_peak, cep_phase self.laser_energy = laser_energy self.w0 = w0 self.tau = tau - self.sc = sc + self.b = b self.t_peak = t_peak self.cep_phase = cep_phase @@ -89,10 +89,10 @@ def evaluate(self, x, y, t): """ transverse = np.exp(-(x**2 + y**2) / self.w0**2) - tau_eff = np.sqrt(self.tau**2 + (2 * self.sc / self.w0) ** 2) + tau_eff = np.sqrt(self.tau**2 + (2 * self.b / self.w0) ** 2) spacetime = np.exp( - -((t - self.t_peak + (2 * 1j * self.sc * x / self.w0**2)) ** 2) + -((t - self.t_peak + (2 * 1j * self.b * x / self.w0**2)) ** 2) / tau_eff**2 ) From 6e0d7017802011217208c7a9d9a703769d5c1050 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Fri, 1 Dec 2023 13:19:27 +0100 Subject: [PATCH 13/55] change sc to b in spacetime --- lasy/profiles/spacetime_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/spacetime_profile.py b/lasy/profiles/spacetime_profile.py index eca5e3ee..221eac51 100644 --- a/lasy/profiles/spacetime_profile.py +++ b/lasy/profiles/spacetime_profile.py @@ -62,7 +62,7 @@ class SpaceTimeProfile(Profile): oscillation, at the time where the laser envelope is maximum) """ - def __init__(self, wavelength, pol, laser_energy, w0, tau, sc, t_peak, cep_phase=0): + def __init__(self, wavelength, pol, laser_energy, w0, tau, b, t_peak, cep_phase=0): super().__init__(wavelength, pol) self.laser_energy = laser_energy self.w0 = w0 From a3cae819daf43d1b79130ad2bff8e7567611b250 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Thu, 14 Dec 2023 20:36:34 +0100 Subject: [PATCH 14/55] Update gaussian_profile.py Move space-time effects to Gaussian profile --- lasy/profiles/gaussian_profile.py | 72 +++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 13 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index c5ca954f..5792cd44 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -7,14 +7,16 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): r""" Derived class for the analytic profile of a Gaussian laser pulse. + This includes space-time couplings: pulse-front tilt and spatial chirp + More precisely, the electric field corresponds to: .. math:: - E_u(\boldsymbol{x}_\perp,t) = Re\left[ E_0\, - \exp\left( -\frac{\boldsymbol{x}_\perp^2}{w_0^2} - - \frac{(t-t_{peak})^2}{\tau^2} -i\omega_0(t-t_{peak}) - + i\phi_{cep}\right) \times p_u \right] + E_u(\\boldsymbol{x}_\\perp,t) = Re\\left[ E_0\\, + \\exp\\left(-\\frac{\\boldsymbol{x}_\\perp^2}{w_0^2} + - \\frac{(t-t_{peak}-ax+2ibx/w_0^2)^2}{\\tau_{eff}^2} + - i\\omega_0(t-t_{peak}) + i\\phi_{cep}\\right) \\times p_u \\right] where :math:`u` is either :math:`x` or :math:`y`, :math:`p_u` is the polarization vector, :math:`Re` represent the real part, and @@ -43,12 +45,24 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): w0 : float (in meter) The waist of the laser pulse, i.e. :math:`w_0` in the above formula. + a: float (in second/meter) + Pulse-front tilt, i.e. :math:`a` in the above formula, that results in the laser arrival + time varying as a function of `x`. A representative real value is a = tau / w0. + + b: float (in meter.second) + Spatial chirp, i.e. :math:`b` in the above formula, that results in the laser frequency + varying as a function of `x`. A representative real value is b = w0 * tau. + tau : float (in second) The duration of the laser pulse, i.e. :math:`\tau` in the above formula. Note that :math:`\tau = \tau_{FWHM}/\sqrt{2\log(2)}`, where :math:`\tau_{FWHM}` is the Full-Width-Half-Maximum duration of the intensity distribution of the pulse. + GDD: float (in second.second) + Group-delay dispersion, i.e. :math:`gdd` in the formula for tau_eff, that results + in temporal chirp. A representative real value is gdd = tau * tau. + t_peak : float (in second) The time at which the laser envelope reaches its maximum amplitude, i.e. :math:`t_{peak}` in the above formula. @@ -103,13 +117,45 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): >>> plt.ylabel('r (µm)') """ - 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, z_foc, wavelength), + def __init__(self, wavelength, pol, laser_energy, w0, a, b, tau, gdd, t_peak, cep_phase=0, z_foc=0): + super().__init__(wavelength, pol) + self.laser_energy = laser_energy + self.w0 = w0 + self.a = a + self.b = b + self.tau = tau + self.gdd = gdd + self.t_peak = t_peak + self.cep_phase = cep_phase + self.z_foc = z_foc + + def evaluate(self, x, y, t): + """ + Return the envelope field of the laser. + + Parameters + ---------- + x, y, t: ndarrays of floats + Define points on which to evaluate the envelope + These arrays need to all have the same shape. + + Returns + ------- + envelope: ndarray of complex numbers + Contains the value of the envelope at the specified points + This array has the same shape as the arrays x, y, t + """ + transverse = np.exp(-(x**2 + y**2) / self.w0**2) + + tau_eff = np.sqrt(self.tau**2 + (2 * self.b / self.w0) ** 2 + 2 * 1j * self.gdd) + + spacetime = np.exp( + -((t - self.t_peak - self.a * x + (2 * 1j * self.b * x / self.w0**2)) ** 2) + / tau_eff**2 ) + + oscillatory = np.exp(1.0j * (self.cep_phase - self.omega0 * (t - self.t_peak))) + + envelope = transverse * spacetime * oscillatory + + return envelope From cf69c74c8217d118f3b9489f8e6b4d2528b73cb3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 14 Dec 2023 19:38:28 +0000 Subject: [PATCH 15/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 5792cd44..84a3d80e 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -117,7 +117,20 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): >>> plt.ylabel('r (µm)') """ - def __init__(self, wavelength, pol, laser_energy, w0, a, b, tau, gdd, t_peak, cep_phase=0, z_foc=0): + def __init__( + self, + wavelength, + pol, + laser_energy, + w0, + a, + b, + tau, + gdd, + t_peak, + cep_phase=0, + z_foc=0, + ): super().__init__(wavelength, pol) self.laser_energy = laser_energy self.w0 = w0 @@ -147,10 +160,15 @@ def evaluate(self, x, y, t): """ transverse = np.exp(-(x**2 + y**2) / self.w0**2) - tau_eff = np.sqrt(self.tau**2 + (2 * self.b / self.w0) ** 2 + 2 * 1j * self.gdd) + tau_eff = np.sqrt( + self.tau**2 + (2 * self.b / self.w0) ** 2 + 2 * 1j * self.gdd + ) spacetime = np.exp( - -((t - self.t_peak - self.a * x + (2 * 1j * self.b * x / self.w0**2)) ** 2) + -( + (t - self.t_peak - self.a * x + (2 * 1j * self.b * x / self.w0**2)) + ** 2 + ) / tau_eff**2 ) From 9602196dfa06dc9c000cc9e8ba7140027d53ac1e Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Thu, 14 Dec 2023 20:39:36 +0100 Subject: [PATCH 16/55] Update gaussian_profile.py Dependencies fix --- lasy/profiles/gaussian_profile.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 84a3d80e..ae5b3504 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -1,9 +1,9 @@ -from . import CombinedLongitudinalTransverseProfile -from .longitudinal import GaussianLongitudinalProfile -from .transverse import GaussianTransverseProfile +import numpy as np +from .profile import Profile -class GaussianProfile(CombinedLongitudinalTransverseProfile): + +class GaussianProfile(Profile): r""" Derived class for the analytic profile of a Gaussian laser pulse. From a37a7aaee769d8d3620444d1d2c97e119a2b1c98 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Thu, 14 Dec 2023 20:44:50 +0100 Subject: [PATCH 17/55] Update test_gaussian_propagator.py Update GaussianProfile call --- tests/test_gaussian_propagator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_gaussian_propagator.py b/tests/test_gaussian_propagator.py index b84237a4..5a30e9fa 100644 --- a/tests/test_gaussian_propagator.py +++ b/tests/test_gaussian_propagator.py @@ -16,7 +16,7 @@ def gaussian(): t_peak = 0.0e-15 # s tau = 30.0e-15 # s w0 = 5.0e-6 # m - profile = GaussianProfile(wavelength, pol, laser_energy, w0, tau, t_peak) + profile = GaussianProfile(wavelength, pol, laser_energy, w0, a=0, b=0, tau, gdd=0, t_peak) return profile From 3e172480b84b2bce3187a6eaf765399235b85723 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Thu, 14 Dec 2023 20:45:52 +0100 Subject: [PATCH 18/55] Update test_laser_profiles.py Update GaussianProfile call --- tests/test_laser_profiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_laser_profiles.py b/tests/test_laser_profiles.py index 2073743e..1cb78afc 100644 --- a/tests/test_laser_profiles.py +++ b/tests/test_laser_profiles.py @@ -41,7 +41,7 @@ def gaussian(): t_peak = 0.0e-15 # s tau = 30.0e-15 # s w0 = 5.0e-6 # m - profile = GaussianProfile(wavelength, pol, laser_energy, w0, tau, t_peak) + profile = GaussianProfile(wavelength, pol, laser_energy, w0, a=0, b=0, tau, gdd=0, t_peak) return profile From ae1f8019275750fc12eb2c32fe4936a88bd2b0e2 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Thu, 14 Dec 2023 20:48:38 +0100 Subject: [PATCH 19/55] Update test_laser_profiles.py re-order GaussianProfile arguments --- tests/test_laser_profiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_laser_profiles.py b/tests/test_laser_profiles.py index 1cb78afc..2f532b3e 100644 --- a/tests/test_laser_profiles.py +++ b/tests/test_laser_profiles.py @@ -41,7 +41,7 @@ def gaussian(): t_peak = 0.0e-15 # s tau = 30.0e-15 # s w0 = 5.0e-6 # m - profile = GaussianProfile(wavelength, pol, laser_energy, w0, a=0, b=0, tau, gdd=0, t_peak) + profile = GaussianProfile(wavelength, pol, laser_energy, w0, tau, t_peak, a=0, b=0, gdd=0) return profile From 7ace218099fe652b68c94a0d5a9dbfbfe9dcb89e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 14 Dec 2023 19:48:46 +0000 Subject: [PATCH 20/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_laser_profiles.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_laser_profiles.py b/tests/test_laser_profiles.py index 2f532b3e..7318e969 100644 --- a/tests/test_laser_profiles.py +++ b/tests/test_laser_profiles.py @@ -41,7 +41,9 @@ def gaussian(): t_peak = 0.0e-15 # s tau = 30.0e-15 # s w0 = 5.0e-6 # m - profile = GaussianProfile(wavelength, pol, laser_energy, w0, tau, t_peak, a=0, b=0, gdd=0) + profile = GaussianProfile( + wavelength, pol, laser_energy, w0, tau, t_peak, a=0, b=0, gdd=0 + ) return profile From 0fb6242963c52380958dbe66f632f439d8d097d1 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Thu, 14 Dec 2023 20:49:15 +0100 Subject: [PATCH 21/55] Update test_gaussian_propagator.py re-order GaussianProfile arguments --- tests/test_gaussian_propagator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_gaussian_propagator.py b/tests/test_gaussian_propagator.py index 5a30e9fa..1ed0d2c1 100644 --- a/tests/test_gaussian_propagator.py +++ b/tests/test_gaussian_propagator.py @@ -16,7 +16,7 @@ def gaussian(): t_peak = 0.0e-15 # s tau = 30.0e-15 # s w0 = 5.0e-6 # m - profile = GaussianProfile(wavelength, pol, laser_energy, w0, a=0, b=0, tau, gdd=0, t_peak) + profile = GaussianProfile(wavelength, pol, laser_energy, w0, tau, t_peak, a=0, b=0, gdd=0) return profile From 8da190a3e54b65e4338972b69cdf0b7fe8690d1f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 14 Dec 2023 19:49:24 +0000 Subject: [PATCH 22/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_gaussian_propagator.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_gaussian_propagator.py b/tests/test_gaussian_propagator.py index 1ed0d2c1..79400dc1 100644 --- a/tests/test_gaussian_propagator.py +++ b/tests/test_gaussian_propagator.py @@ -16,7 +16,9 @@ def gaussian(): t_peak = 0.0e-15 # s tau = 30.0e-15 # s w0 = 5.0e-6 # m - profile = GaussianProfile(wavelength, pol, laser_energy, w0, tau, t_peak, a=0, b=0, gdd=0) + profile = GaussianProfile( + wavelength, pol, laser_energy, w0, tau, t_peak, a=0, b=0, gdd=0 + ) return profile From b9405ee038fea6be79681f0db1590e6862b7ec70 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Thu, 14 Dec 2023 20:52:02 +0100 Subject: [PATCH 23/55] Update gaussian_profile.py re-order space-time arguments --- lasy/profiles/gaussian_profile.py | 34 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index ae5b3504..d0ac30e0 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -45,28 +45,28 @@ class GaussianProfile(Profile): w0 : float (in meter) The waist of the laser pulse, i.e. :math:`w_0` in the above formula. - a: float (in second/meter) - Pulse-front tilt, i.e. :math:`a` in the above formula, that results in the laser arrival - time varying as a function of `x`. A representative real value is a = tau / w0. - - b: float (in meter.second) - Spatial chirp, i.e. :math:`b` in the above formula, that results in the laser frequency - varying as a function of `x`. A representative real value is b = w0 * tau. - tau : float (in second) The duration of the laser pulse, i.e. :math:`\tau` in the above formula. Note that :math:`\tau = \tau_{FWHM}/\sqrt{2\log(2)}`, where :math:`\tau_{FWHM}` is the Full-Width-Half-Maximum duration of the intensity distribution of the pulse. - GDD: float (in second.second) - Group-delay dispersion, i.e. :math:`gdd` in the formula for tau_eff, that results - in temporal chirp. A representative real value is gdd = tau * tau. - t_peak : float (in second) The time at which the laser envelope reaches its maximum amplitude, i.e. :math:`t_{peak}` in the above formula. + a: float (in second/meter), optional + Pulse-front tilt, i.e. :math:`a` in the above formula, that results in the laser arrival + time varying as a function of `x`. A representative real value is a = tau / w0. + + b: float (in meter.second), optional + Spatial chirp, i.e. :math:`b` in the above formula, that results in the laser frequency + varying as a function of `x`. A representative real value is b = w0 * tau. + + GDD: float (in second.second), optional + Group-delay dispersion, i.e. :math:`gdd` in the formula for tau_eff, that results + in temporal chirp. A representative real value is gdd = tau * tau. + cep_phase : float (in radian), optional The Carrier Envelope Phase (CEP), i.e. :math:`\phi_{cep}` in the above formula (i.e. the phase of the laser @@ -123,22 +123,22 @@ def __init__( pol, laser_energy, w0, - a, - b, tau, - gdd, t_peak, + a=0, + b=0, + gdd=0, cep_phase=0, z_foc=0, ): super().__init__(wavelength, pol) self.laser_energy = laser_energy self.w0 = w0 + self.tau = tau + self.t_peak = t_peak self.a = a self.b = b - self.tau = tau self.gdd = gdd - self.t_peak = t_peak self.cep_phase = cep_phase self.z_foc = z_foc From 4654d155abf487253aac3e20aca30d3da0d1ca56 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Thu, 14 Dec 2023 20:56:31 +0100 Subject: [PATCH 24/55] Update test_gaussian_propagator.py remove trans_profile mention --- tests/test_gaussian_propagator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_gaussian_propagator.py b/tests/test_gaussian_propagator.py index 79400dc1..f61cf586 100644 --- a/tests/test_gaussian_propagator.py +++ b/tests/test_gaussian_propagator.py @@ -48,7 +48,7 @@ def check_gaussian_propagation( laser, propagation_distance=100e-6, propagation_step=10e-6 ): # Do the propagation and check evolution of waist with theory - w0 = laser.profile.trans_profile.w0 + w0 = laser.profile.w0 L_R = np.pi * w0**2 / laser.profile.lambda0 propagated_distance = 0.0 From a7a2bfd6d174488c61767ed744cd52e3b2e07e4e Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Thu, 14 Dec 2023 21:00:44 +0100 Subject: [PATCH 25/55] Update test_laser_utils.py remove long_profile mention --- tests/test_laser_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_laser_utils.py b/tests/test_laser_utils.py index 15e13f81..6c9cae50 100644 --- a/tests/test_laser_utils.py +++ b/tests/test_laser_utils.py @@ -48,7 +48,7 @@ def test_laser_analysis_utils(): # Check that laser duration agrees with the given one. tau_rms = get_duration(laser.grid, dim) np.testing.assert_approx_equal( - 2 * tau_rms, laser.profile.long_profile.tau, significant=3 + 2 * tau_rms, laser.profile.tau, significant=3 ) From 74dbf87428869c136339d36e99faacf5edf766da Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 14 Dec 2023 20:00:53 +0000 Subject: [PATCH 26/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_laser_utils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_laser_utils.py b/tests/test_laser_utils.py index 6c9cae50..1e5759cf 100644 --- a/tests/test_laser_utils.py +++ b/tests/test_laser_utils.py @@ -47,9 +47,7 @@ def test_laser_analysis_utils(): # Check that laser duration agrees with the given one. tau_rms = get_duration(laser.grid, dim) - np.testing.assert_approx_equal( - 2 * tau_rms, laser.profile.tau, significant=3 - ) + np.testing.assert_approx_equal(2 * tau_rms, laser.profile.tau, significant=3) if __name__ == "__main__": From 6085d7781296a240f926bfcf38aac99254fd1c1f Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Thu, 14 Dec 2023 21:02:18 +0100 Subject: [PATCH 27/55] Update test_t2z2t.py remove trans_profile and long_profile mentions --- tests/test_t2z2t.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_t2z2t.py b/tests/test_t2z2t.py index 6fc87134..2f4bc277 100644 --- a/tests/test_t2z2t.py +++ b/tests/test_t2z2t.py @@ -24,9 +24,9 @@ def gaussian(): def get_laser_z_analytic(profile, z_axis, r_axis): - w0 = profile.trans_profile.w0 - tau = profile.long_profile.tau - omega0 = profile.long_profile.omega0 + w0 = profile.w0 + tau = profile.tau + omega0 = profile.omega0 k0 = omega0 / c lambda0 = 2 * np.pi / k0 From ae50294f27822f31b6b1dacb02da756e444bf9d9 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Thu, 14 Dec 2023 21:03:57 +0100 Subject: [PATCH 28/55] Update test_t2z2t.py remove trans_profile and long_profile mentions --- tests/test_t2z2t.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_t2z2t.py b/tests/test_t2z2t.py index 2f4bc277..823274f0 100644 --- a/tests/test_t2z2t.py +++ b/tests/test_t2z2t.py @@ -67,8 +67,8 @@ def check_correctness(laser_t_in, laser_t_out, laser_z_analytic, z_axis): def test_RT_case(gaussian): dim = "rt" - w0 = gaussian.trans_profile.w0 - tau = gaussian.long_profile.tau + w0 = gaussian.w0 + tau = gaussian.tau lo = (0, -3.5 * tau) hi = (5 * w0, 3.5 * tau) npoints = (128, 65) @@ -90,8 +90,8 @@ def test_RT_case(gaussian): def test_3D_case(gaussian): # - 3D case dim = "xyt" - w0 = gaussian.trans_profile.w0 - tau = gaussian.long_profile.tau + w0 = gaussian.w0 + tau = gaussian.tau lo = (-5 * w0, -5 * w0, -3.5 * tau) hi = (5 * w0, 5 * w0, 3.5 * tau) npoints = (160, 160, 65) From ef8765deacab08ddb1d48f44366b700dbf24e3a8 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Fri, 12 Jan 2024 13:52:21 +0100 Subject: [PATCH 29/55] Update test_gaussian_propagator.py --- tests/test_gaussian_propagator.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_gaussian_propagator.py b/tests/test_gaussian_propagator.py index f61cf586..448423ab 100644 --- a/tests/test_gaussian_propagator.py +++ b/tests/test_gaussian_propagator.py @@ -16,9 +16,7 @@ def gaussian(): t_peak = 0.0e-15 # s tau = 30.0e-15 # s w0 = 5.0e-6 # m - profile = GaussianProfile( - wavelength, pol, laser_energy, w0, tau, t_peak, a=0, b=0, gdd=0 - ) + profile = GaussianProfile(wavelength, pol, laser_energy, w0, tau, t_peak) return profile From a3b1a54063fb05a4ae6ab7c4a44a6a38942ac5bc Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Fri, 12 Jan 2024 14:01:52 +0100 Subject: [PATCH 30/55] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index d0ac30e0..00373e96 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -125,11 +125,11 @@ def __init__( w0, tau, t_peak, - a=0, - b=0, - gdd=0, - cep_phase=0, - z_foc=0, + a=0.0, + b=0.0, + gdd=0.0, + cep_phase=0.0, + z_foc=0.0, ): super().__init__(wavelength, pol) self.laser_energy = laser_energy From c830f0823d6cbf0ff70749820ec5fac671176b2a Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Fri, 12 Jan 2024 14:22:34 +0100 Subject: [PATCH 31/55] Update laser_utils.py New function get_t_peak that calculates the average time of the intensity. Relevant for pulse-front tilt testing. --- lasy/utils/laser_utils.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 0bc7c663..0f39395c 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -458,6 +458,31 @@ def get_frequency( return omega, central_omega +def get_t_peak(grid, dim): + """Get centraltime of the intensity of the envelope, measured as an average. + + Parameters + ---------- + grid : Grid + The grid with the envelope to analyze. + dim : str + Dimensionality of the grid. + + Returns + ------- + float + average position of the envelope intensity in seconds. + """ + # Calculate weights of each grid cell (amplitude of the field). + dV = get_grid_cell_volume(grid, dim) + if dim == "xyt": + weights = np.abs(grid.field) ** 2 * dV + else: # dim == "rt": + weights = np.abs(grid.field) ** 2 * dV[np.newaxis, :, np.newaxis] + # project weights to longitudinal axes + weights = np.sum(weights, axis=(0, 1)) + return np.average(grid.axes[-1], weights=weights) + def get_duration(grid, dim): """Get duration of the intensity of the envelope, measured as RMS. From d118d42df4cbb1c00fefec5b57f4c7f64f9123b2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 12 Jan 2024 13:22:43 +0000 Subject: [PATCH 32/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 0f39395c..14c3867f 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -483,6 +483,7 @@ def get_t_peak(grid, dim): weights = np.sum(weights, axis=(0, 1)) return np.average(grid.axes[-1], weights=weights) + def get_duration(grid, dim): """Get duration of the intensity of the envelope, measured as RMS. From 78524b38354ab4c8575141a02ed03a316198d3b8 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:27:22 +0100 Subject: [PATCH 33/55] Update laser_utils.py --- lasy/utils/laser_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 14c3867f..4e8a7298 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -459,7 +459,7 @@ def get_frequency( def get_t_peak(grid, dim): - """Get centraltime of the intensity of the envelope, measured as an average. + """Get central time of the intensity of the envelope, measured as an average. Parameters ---------- From fb2f9ae7bce5a8fed1f803a4bc506db36c20631b Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:29:42 +0100 Subject: [PATCH 34/55] Update test_laser_utils.py Add t_peak test --- tests/test_laser_utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_laser_utils.py b/tests/test_laser_utils.py index 1e5759cf..e9dc9310 100644 --- a/tests/test_laser_utils.py +++ b/tests/test_laser_utils.py @@ -2,7 +2,7 @@ from lasy.laser import Laser from lasy.profiles.gaussian_profile import GaussianProfile -from lasy.utils.laser_utils import get_spectrum, compute_laser_energy, get_duration +from lasy.utils.laser_utils import get_spectrum, compute_laser_energy, get_t_peak, get_duration def get_gaussian_profile(): @@ -45,6 +45,10 @@ def test_laser_analysis_utils(): energy = compute_laser_energy(dim, laser.grid) np.testing.assert_approx_equal(spectrum_energy, energy, significant=10) + # Check that laser duration agrees with the given one. + t_peak_rms = get_t_peak(laser.grid, dim) + np.testing.assert_approx_equal(t_peak_rms, laser.profile.t_peak, significant=3) + # Check that laser duration agrees with the given one. tau_rms = get_duration(laser.grid, dim) np.testing.assert_approx_equal(2 * tau_rms, laser.profile.tau, significant=3) From 483fcf3d27cc82c2d6b1930361bee6c78da04b6b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 09:29:50 +0000 Subject: [PATCH 35/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_laser_utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_laser_utils.py b/tests/test_laser_utils.py index e9dc9310..ed285f2d 100644 --- a/tests/test_laser_utils.py +++ b/tests/test_laser_utils.py @@ -2,7 +2,12 @@ from lasy.laser import Laser from lasy.profiles.gaussian_profile import GaussianProfile -from lasy.utils.laser_utils import get_spectrum, compute_laser_energy, get_t_peak, get_duration +from lasy.utils.laser_utils import ( + get_spectrum, + compute_laser_energy, + get_t_peak, + get_duration, +) def get_gaussian_profile(): From 864f22c0ffeeac8e3863d0d58e5df8b433c5665b Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:52:01 +0100 Subject: [PATCH 36/55] Update test_laser_utils.py --- tests/test_laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_laser_utils.py b/tests/test_laser_utils.py index ed285f2d..efaf1991 100644 --- a/tests/test_laser_utils.py +++ b/tests/test_laser_utils.py @@ -28,11 +28,11 @@ def get_gaussian_laser(dim): if dim == "rt": lo = (0e-6, -60e-15) hi = (25e-6, +60e-15) - npoints = (100, 100) + npoints = (100, 200) else: # dim == "xyt": lo = (-25e-6, -25e-6, -60e-15) hi = (+25e-6, +25e-6, +60e-15) - npoints = (100, 100, 100) + npoints = (100, 100, 200) return Laser(dim, lo, hi, npoints, get_gaussian_profile()) From 0670864396b2659659464bb89d8c968824a05312 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:53:48 +0100 Subject: [PATCH 37/55] Update test_laser_utils.py --- tests/test_laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_laser_utils.py b/tests/test_laser_utils.py index efaf1991..dcad9a08 100644 --- a/tests/test_laser_utils.py +++ b/tests/test_laser_utils.py @@ -26,8 +26,8 @@ def get_gaussian_profile(): def get_gaussian_laser(dim): # - Cylindrical case if dim == "rt": - lo = (0e-6, -60e-15) - hi = (25e-6, +60e-15) + lo = (0e-6, -100e-15) + hi = (25e-6, +100e-15) npoints = (100, 200) else: # dim == "xyt": lo = (-25e-6, -25e-6, -60e-15) From afc1cffc88ef4c5ebb975bfdc72ce32b345a2e29 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:54:27 +0100 Subject: [PATCH 38/55] Update test_laser_utils.py --- tests/test_laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_laser_utils.py b/tests/test_laser_utils.py index dcad9a08..d0289186 100644 --- a/tests/test_laser_utils.py +++ b/tests/test_laser_utils.py @@ -30,8 +30,8 @@ def get_gaussian_laser(dim): hi = (25e-6, +100e-15) npoints = (100, 200) else: # dim == "xyt": - lo = (-25e-6, -25e-6, -60e-15) - hi = (+25e-6, +25e-6, +60e-15) + lo = (-25e-6, -25e-6, -100e-15) + hi = (+25e-6, +25e-6, +100e-15) npoints = (100, 100, 200) return Laser(dim, lo, hi, npoints, get_gaussian_profile()) From df0352268e843ca9436bdb3b1fd7560ead3ff54a Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:57:57 +0100 Subject: [PATCH 39/55] Update test_gaussian_propagator.py --- tests/test_gaussian_propagator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_gaussian_propagator.py b/tests/test_gaussian_propagator.py index 448423ab..5a4cb353 100644 --- a/tests/test_gaussian_propagator.py +++ b/tests/test_gaussian_propagator.py @@ -66,7 +66,7 @@ def test_3D_case(gaussian): dim = "xyt" lo = (-25e-6, -25e-6, -60e-15) hi = (+25e-6, +25e-6, +60e-15) - npoints = (100, 100, 100) + npoints = (200, 200, 100) laser = Laser(dim, lo, hi, npoints, gaussian) check_gaussian_propagation(laser) @@ -77,7 +77,7 @@ def test_RT_case(gaussian): dim = "rt" lo = (0e-6, -60e-15) hi = (25e-6, +60e-15) - npoints = (100, 100) + npoints = (200, 100) laser = Laser(dim, lo, hi, npoints, gaussian) check_gaussian_propagation(laser) From 08a73aeb9cdb694520088f4cdc60fc46cb28e702 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 15 Jan 2024 11:01:59 +0100 Subject: [PATCH 40/55] Update test_gaussian_propagator.py --- tests/test_gaussian_propagator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_gaussian_propagator.py b/tests/test_gaussian_propagator.py index 5a4cb353..3b692f81 100644 --- a/tests/test_gaussian_propagator.py +++ b/tests/test_gaussian_propagator.py @@ -64,8 +64,8 @@ def check_gaussian_propagation( def test_3D_case(gaussian): # - 3D case dim = "xyt" - lo = (-25e-6, -25e-6, -60e-15) - hi = (+25e-6, +25e-6, +60e-15) + lo = (-35e-6, -35e-6, -60e-15) + hi = (+35e-6, +35e-6, +60e-15) npoints = (200, 200, 100) laser = Laser(dim, lo, hi, npoints, gaussian) @@ -76,7 +76,7 @@ def test_RT_case(gaussian): # - Cylindrical case dim = "rt" lo = (0e-6, -60e-15) - hi = (25e-6, +60e-15) + hi = (35e-6, +60e-15) npoints = (200, 100) laser = Laser(dim, lo, hi, npoints, gaussian) From d849dde7a923b40cc64d051ffbe296ddf6024299 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 15 Jan 2024 11:04:23 +0100 Subject: [PATCH 41/55] Update test_gaussian_propagator.py --- tests/test_gaussian_propagator.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_gaussian_propagator.py b/tests/test_gaussian_propagator.py index 3b692f81..d8629e56 100644 --- a/tests/test_gaussian_propagator.py +++ b/tests/test_gaussian_propagator.py @@ -64,9 +64,9 @@ def check_gaussian_propagation( def test_3D_case(gaussian): # - 3D case dim = "xyt" - lo = (-35e-6, -35e-6, -60e-15) - hi = (+35e-6, +35e-6, +60e-15) - npoints = (200, 200, 100) + lo = (-25e-6, -25e-6, -100e-15) + hi = (+25e-6, +25e-6, +100e-15) + npoints = (100, 100, 200) laser = Laser(dim, lo, hi, npoints, gaussian) check_gaussian_propagation(laser) @@ -75,9 +75,9 @@ def test_3D_case(gaussian): def test_RT_case(gaussian): # - Cylindrical case dim = "rt" - lo = (0e-6, -60e-15) - hi = (35e-6, +60e-15) - npoints = (200, 100) + lo = (0e-6, -100e-15) + hi = (25e-6, +100e-15) + npoints = (100, 200) laser = Laser(dim, lo, hi, npoints, gaussian) check_gaussian_propagation(laser) From 5a2132354572d63b0e26359757763aafa625f22a Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 15 Jan 2024 11:06:18 +0100 Subject: [PATCH 42/55] Update test_gaussian_propagator.py --- tests/test_gaussian_propagator.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_gaussian_propagator.py b/tests/test_gaussian_propagator.py index d8629e56..448423ab 100644 --- a/tests/test_gaussian_propagator.py +++ b/tests/test_gaussian_propagator.py @@ -64,9 +64,9 @@ def check_gaussian_propagation( def test_3D_case(gaussian): # - 3D case dim = "xyt" - lo = (-25e-6, -25e-6, -100e-15) - hi = (+25e-6, +25e-6, +100e-15) - npoints = (100, 100, 200) + lo = (-25e-6, -25e-6, -60e-15) + hi = (+25e-6, +25e-6, +60e-15) + npoints = (100, 100, 100) laser = Laser(dim, lo, hi, npoints, gaussian) check_gaussian_propagation(laser) @@ -75,9 +75,9 @@ def test_3D_case(gaussian): def test_RT_case(gaussian): # - Cylindrical case dim = "rt" - lo = (0e-6, -100e-15) - hi = (25e-6, +100e-15) - npoints = (100, 200) + lo = (0e-6, -60e-15) + hi = (25e-6, +60e-15) + npoints = (100, 100) laser = Laser(dim, lo, hi, npoints, gaussian) check_gaussian_propagation(laser) From 46eb96a61f4e61f8eef09de01f0e9370b34a9493 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 15 Jan 2024 11:09:44 +0100 Subject: [PATCH 43/55] Update test_laser_utils.py --- tests/test_laser_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_laser_utils.py b/tests/test_laser_utils.py index d0289186..f374c4c2 100644 --- a/tests/test_laser_utils.py +++ b/tests/test_laser_utils.py @@ -50,7 +50,7 @@ def test_laser_analysis_utils(): energy = compute_laser_energy(dim, laser.grid) np.testing.assert_approx_equal(spectrum_energy, energy, significant=10) - # Check that laser duration agrees with the given one. + # Check that laser central time agrees with the given one. t_peak_rms = get_t_peak(laser.grid, dim) np.testing.assert_approx_equal(t_peak_rms, laser.profile.t_peak, significant=3) From 43250a6d4902d07099cc29166c2548ace30dfa49 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 15 Jan 2024 11:18:05 +0100 Subject: [PATCH 44/55] Update test_laser_profiles.py --- tests/test_laser_profiles.py | 55 +++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/tests/test_laser_profiles.py b/tests/test_laser_profiles.py index 7318e969..fbf23c65 100644 --- a/tests/test_laser_profiles.py +++ b/tests/test_laser_profiles.py @@ -42,11 +42,64 @@ def gaussian(): tau = 30.0e-15 # s w0 = 5.0e-6 # m profile = GaussianProfile( - wavelength, pol, laser_energy, w0, tau, t_peak, a=0, b=0, gdd=0 + wavelength, pol, laser_energy, w0, tau, t_peak, a=0.0, b=0.0, gdd=0.0 ) return profile +def spatial_chirp(): + # Cases with Gaussian laser having non-zero spatial chirp + wavelength = 0.8e-6 + pol = (1, 0) + laser_energy = 1.0 # J + t_peak = 0.0e-15 # s + tau = 30.0e-15 # s + w0 = 5.0e-6 # m + b = w0*tau/2 # m.s + profile = GaussianProfile( + wavelength, pol, laser_energy, w0, tau, t_peak, a=0.0, b, gdd=0.0 + ) + + return profile + +def test_profile_gaussian_spatial_chirp(spatial_chirp): + # - 3D Cartesian case + dim = "xyt" + lo = (-10e-6, -10e-6, -60e-15) + hi = (+10e-6, +10e-6, +60e-15) + npoints = (100, 100, 100) + + laser = Laser(dim, lo, hi, npoints, spatial_chirp) + laser.write_to_file("gaussianlaserSC") + laser.propagate(1e-6) + laser.write_to_file("gaussianlaserSC") + +def angular_dispersion(): + # Cases with Gaussian laser having non-zero angular dispersion + wavelength = 0.8e-6 + pol = (1, 0) + laser_energy = 1.0 # J + t_peak = 0.0e-15 # s + tau = 30.0e-15 # s + w0 = 5.0e-6 # m + a = tau/w0 # s/m + profile = GaussianProfile( + wavelength, pol, laser_energy, w0, tau, t_peak, a, b=0.0, gdd=0.0 + ) + + return profile + +def test_profile_gaussian_angular_dispersion(angular_dispersion): + # - 3D Cartesian case + dim = "xyt" + lo = (-10e-6, -10e-6, -60e-15) + hi = (+10e-6, +10e-6, +60e-15) + npoints = (100, 100, 100) + + laser = Laser(dim, lo, hi, npoints, angular_dispersion) + laser.write_to_file("gaussianlaserAD") + laser.propagate(1e-6) + laser.write_to_file("gaussianlaserAD") def test_transverse_profiles_rt(): npoints = 4000 From 15cc1586af993d6b0393dc22cb9c208de1726353 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 15 Jan 2024 11:21:39 +0100 Subject: [PATCH 45/55] Update test_laser_profiles.py --- tests/test_laser_profiles.py | 61 ++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/tests/test_laser_profiles.py b/tests/test_laser_profiles.py index fbf23c65..4528478f 100644 --- a/tests/test_laser_profiles.py +++ b/tests/test_laser_profiles.py @@ -47,21 +47,6 @@ def gaussian(): return profile -def spatial_chirp(): - # Cases with Gaussian laser having non-zero spatial chirp - wavelength = 0.8e-6 - pol = (1, 0) - laser_energy = 1.0 # J - t_peak = 0.0e-15 # s - tau = 30.0e-15 # s - w0 = 5.0e-6 # m - b = w0*tau/2 # m.s - profile = GaussianProfile( - wavelength, pol, laser_energy, w0, tau, t_peak, a=0.0, b, gdd=0.0 - ) - - return profile - def test_profile_gaussian_spatial_chirp(spatial_chirp): # - 3D Cartesian case dim = "xyt" @@ -74,21 +59,6 @@ def test_profile_gaussian_spatial_chirp(spatial_chirp): laser.propagate(1e-6) laser.write_to_file("gaussianlaserSC") -def angular_dispersion(): - # Cases with Gaussian laser having non-zero angular dispersion - wavelength = 0.8e-6 - pol = (1, 0) - laser_energy = 1.0 # J - t_peak = 0.0e-15 # s - tau = 30.0e-15 # s - w0 = 5.0e-6 # m - a = tau/w0 # s/m - profile = GaussianProfile( - wavelength, pol, laser_energy, w0, tau, t_peak, a, b=0.0, gdd=0.0 - ) - - return profile - def test_profile_gaussian_angular_dispersion(angular_dispersion): # - 3D Cartesian case dim = "xyt" @@ -212,6 +182,37 @@ def test_profile_gaussian_cylindrical(gaussian): laser.propagate(1e-6) laser.write_to_file("gaussianlaserRZ") +def spatial_chirp(): + # Cases with Gaussian laser having non-zero spatial chirp (b) + wavelength = 0.8e-6 + pol = (1, 0) + laser_energy = 1.0 # J + t_peak = 0.0e-15 # s + tau = 30.0e-15 # s + w0 = 5.0e-6 # m + a = 0.0 + b = w0*tau/2 # m.s + profile = GaussianProfile( + wavelength, pol, laser_energy, w0, tau, t_peak, a, b, gdd=0.0 + ) + + return profile + +def angular_dispersion(): + # Cases with Gaussian laser having non-zero angular dispersion (a) + wavelength = 0.8e-6 + pol = (1, 0) + laser_energy = 1.0 # J + t_peak = 0.0e-15 # s + tau = 30.0e-15 # s + w0 = 5.0e-6 # m + a = tau/w0 # s/m + b = 0.0 + profile = GaussianProfile( + wavelength, pol, laser_energy, w0, tau, t_peak, a, b, gdd=0.0 + ) + + return profile def test_from_array_profile(): # Create a 3D numpy array, use it to create a LASY profile, From 966329176cd6b28bdb094623ba0c7d5b0f1b9c84 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:21:47 +0000 Subject: [PATCH 46/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_laser_profiles.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_laser_profiles.py b/tests/test_laser_profiles.py index 4528478f..9e44673e 100644 --- a/tests/test_laser_profiles.py +++ b/tests/test_laser_profiles.py @@ -47,6 +47,7 @@ def gaussian(): return profile + def test_profile_gaussian_spatial_chirp(spatial_chirp): # - 3D Cartesian case dim = "xyt" @@ -59,6 +60,7 @@ def test_profile_gaussian_spatial_chirp(spatial_chirp): laser.propagate(1e-6) laser.write_to_file("gaussianlaserSC") + def test_profile_gaussian_angular_dispersion(angular_dispersion): # - 3D Cartesian case dim = "xyt" @@ -71,6 +73,7 @@ def test_profile_gaussian_angular_dispersion(angular_dispersion): laser.propagate(1e-6) laser.write_to_file("gaussianlaserAD") + def test_transverse_profiles_rt(): npoints = 4000 w0 = 10.0e-6 @@ -182,6 +185,7 @@ def test_profile_gaussian_cylindrical(gaussian): laser.propagate(1e-6) laser.write_to_file("gaussianlaserRZ") + def spatial_chirp(): # Cases with Gaussian laser having non-zero spatial chirp (b) wavelength = 0.8e-6 @@ -191,13 +195,14 @@ def spatial_chirp(): tau = 30.0e-15 # s w0 = 5.0e-6 # m a = 0.0 - b = w0*tau/2 # m.s + b = w0 * tau / 2 # m.s profile = GaussianProfile( wavelength, pol, laser_energy, w0, tau, t_peak, a, b, gdd=0.0 ) return profile + def angular_dispersion(): # Cases with Gaussian laser having non-zero angular dispersion (a) wavelength = 0.8e-6 @@ -206,7 +211,7 @@ def angular_dispersion(): t_peak = 0.0e-15 # s tau = 30.0e-15 # s w0 = 5.0e-6 # m - a = tau/w0 # s/m + a = tau / w0 # s/m b = 0.0 profile = GaussianProfile( wavelength, pol, laser_energy, w0, tau, t_peak, a, b, gdd=0.0 @@ -214,6 +219,7 @@ def angular_dispersion(): return profile + def test_from_array_profile(): # Create a 3D numpy array, use it to create a LASY profile, # and check that the resulting profile has the correct width From 41b17de0e4554397737b42c60d9f1037225234e4 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 15 Jan 2024 11:28:26 +0100 Subject: [PATCH 47/55] Update test_laser_profiles.py --- tests/test_laser_profiles.py | 103 +++++++++++++++++------------------ 1 file changed, 50 insertions(+), 53 deletions(-) diff --git a/tests/test_laser_profiles.py b/tests/test_laser_profiles.py index 9e44673e..d62f664a 100644 --- a/tests/test_laser_profiles.py +++ b/tests/test_laser_profiles.py @@ -47,32 +47,39 @@ def gaussian(): return profile +@pytest.fixture(scope="function") +def spatial_chirp(): + # Cases with Gaussian laser having non-zero spatial chirp (b) + wavelength = 0.8e-6 + pol = (1, 0) + laser_energy = 1.0 # J + t_peak = 0.0e-15 # s + tau = 30.0e-15 # s + w0 = 5.0e-6 # m + a = 0.0 + b = w0 * tau / 2 # m.s + profile = GaussianProfile( + wavelength, pol, laser_energy, w0, tau, t_peak, a, b, gdd=0.0 + ) -def test_profile_gaussian_spatial_chirp(spatial_chirp): - # - 3D Cartesian case - dim = "xyt" - lo = (-10e-6, -10e-6, -60e-15) - hi = (+10e-6, +10e-6, +60e-15) - npoints = (100, 100, 100) - - laser = Laser(dim, lo, hi, npoints, spatial_chirp) - laser.write_to_file("gaussianlaserSC") - laser.propagate(1e-6) - laser.write_to_file("gaussianlaserSC") - - -def test_profile_gaussian_angular_dispersion(angular_dispersion): - # - 3D Cartesian case - dim = "xyt" - lo = (-10e-6, -10e-6, -60e-15) - hi = (+10e-6, +10e-6, +60e-15) - npoints = (100, 100, 100) + return profile - laser = Laser(dim, lo, hi, npoints, angular_dispersion) - laser.write_to_file("gaussianlaserAD") - laser.propagate(1e-6) - laser.write_to_file("gaussianlaserAD") +@pytest.fixture(scope="function") +def angular_dispersion(): + # Cases with Gaussian laser having non-zero angular dispersion (a) + wavelength = 0.8e-6 + pol = (1, 0) + laser_energy = 1.0 # J + t_peak = 0.0e-15 # s + tau = 30.0e-15 # s + w0 = 5.0e-6 # m + a = tau / w0 # s/m + b = 0.0 + profile = GaussianProfile( + wavelength, pol, laser_energy, w0, tau, t_peak, a, b, gdd=0.0 + ) + return profile def test_transverse_profiles_rt(): npoints = 4000 @@ -185,40 +192,30 @@ def test_profile_gaussian_cylindrical(gaussian): laser.propagate(1e-6) laser.write_to_file("gaussianlaserRZ") +def test_profile_gaussian_spatial_chirp(spatial_chirp): + # - 3D Cartesian case + dim = "xyt" + lo = (-10e-6, -10e-6, -60e-15) + hi = (+10e-6, +10e-6, +60e-15) + npoints = (100, 100, 100) -def spatial_chirp(): - # Cases with Gaussian laser having non-zero spatial chirp (b) - wavelength = 0.8e-6 - pol = (1, 0) - laser_energy = 1.0 # J - t_peak = 0.0e-15 # s - tau = 30.0e-15 # s - w0 = 5.0e-6 # m - a = 0.0 - b = w0 * tau / 2 # m.s - profile = GaussianProfile( - wavelength, pol, laser_energy, w0, tau, t_peak, a, b, gdd=0.0 - ) - - return profile - + laser = Laser(dim, lo, hi, npoints, spatial_chirp) + laser.write_to_file("gaussianlaserSC") + laser.propagate(1e-6) + laser.write_to_file("gaussianlaserSC") -def angular_dispersion(): - # Cases with Gaussian laser having non-zero angular dispersion (a) - wavelength = 0.8e-6 - pol = (1, 0) - laser_energy = 1.0 # J - t_peak = 0.0e-15 # s - tau = 30.0e-15 # s - w0 = 5.0e-6 # m - a = tau / w0 # s/m - b = 0.0 - profile = GaussianProfile( - wavelength, pol, laser_energy, w0, tau, t_peak, a, b, gdd=0.0 - ) - return profile +def test_profile_gaussian_angular_dispersion(angular_dispersion): + # - 3D Cartesian case + dim = "xyt" + lo = (-10e-6, -10e-6, -60e-15) + hi = (+10e-6, +10e-6, +60e-15) + npoints = (100, 100, 100) + laser = Laser(dim, lo, hi, npoints, angular_dispersion) + laser.write_to_file("gaussianlaserAD") + laser.propagate(1e-6) + laser.write_to_file("gaussianlaserAD") def test_from_array_profile(): # Create a 3D numpy array, use it to create a LASY profile, From f525a8eead49d60da8ca5ea2263a146463bf9e14 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:28:34 +0000 Subject: [PATCH 48/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_laser_profiles.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_laser_profiles.py b/tests/test_laser_profiles.py index d62f664a..401448aa 100644 --- a/tests/test_laser_profiles.py +++ b/tests/test_laser_profiles.py @@ -47,6 +47,7 @@ def gaussian(): return profile + @pytest.fixture(scope="function") def spatial_chirp(): # Cases with Gaussian laser having non-zero spatial chirp (b) @@ -64,6 +65,7 @@ def spatial_chirp(): return profile + @pytest.fixture(scope="function") def angular_dispersion(): # Cases with Gaussian laser having non-zero angular dispersion (a) @@ -81,6 +83,7 @@ def angular_dispersion(): return profile + def test_transverse_profiles_rt(): npoints = 4000 w0 = 10.0e-6 @@ -192,6 +195,7 @@ def test_profile_gaussian_cylindrical(gaussian): laser.propagate(1e-6) laser.write_to_file("gaussianlaserRZ") + def test_profile_gaussian_spatial_chirp(spatial_chirp): # - 3D Cartesian case dim = "xyt" @@ -217,6 +221,7 @@ def test_profile_gaussian_angular_dispersion(angular_dispersion): laser.propagate(1e-6) laser.write_to_file("gaussianlaserAD") + def test_from_array_profile(): # Create a 3D numpy array, use it to create a LASY profile, # and check that the resulting profile has the correct width From d05ea4262879179596107383d388d4a21848e76a Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 15 Jan 2024 11:49:09 +0100 Subject: [PATCH 49/55] Update test_laser_utils.py --- tests/test_laser_utils.py | 61 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/tests/test_laser_utils.py b/tests/test_laser_utils.py index f374c4c2..d4b4242c 100644 --- a/tests/test_laser_utils.py +++ b/tests/test_laser_utils.py @@ -1,5 +1,6 @@ import numpy as np +from scipy.constants import c from lasy.laser import Laser from lasy.profiles.gaussian_profile import GaussianProfile from lasy.utils.laser_utils import ( @@ -22,6 +23,32 @@ def get_gaussian_profile(): return profile +def get_spatial_chirp_profile(): + # Cases with Gaussian laser + wavelength = 0.8e-6 + pol = (1, 0) + laser_energy = 1.0 # J + t_peak = 0.0e-15 # s + tau = 30.0e-15 # s + w0 = 5.0e-6 # m + a = 0.0 + b = tau*w0/2 # m.s + profile = GaussianProfile(wavelength, pol, laser_energy, w0, tau, t_peak, a, b) + + return profile + +def get_angular_dispersion_profile(): + # Cases with Gaussian laser + wavelength = 0.8e-6 + pol = (1, 0) + laser_energy = 1.0 # J + t_peak = 0.0e-15 # s + tau = 30.0e-15 # s + w0 = 5.0e-6 # m + a = tau/w0 # s/m + profile = GaussianProfile(wavelength, pol, laser_energy, w0, tau, t_peak, a) + + return profile def get_gaussian_laser(dim): # - Cylindrical case @@ -35,6 +62,29 @@ def get_gaussian_laser(dim): npoints = (100, 100, 200) return Laser(dim, lo, hi, npoints, get_gaussian_profile()) +def get_spatial_chirp_laser(dim): + # - Cylindrical case + if dim == "rt": + lo = (0e-6, -150e-15) + hi = (35e-6, +150e-15) + npoints = (200, 300) + else: # dim == "xyt": + lo = (-35e-6, -35e-6, -150e-15) + hi = (+35e-6, +35e-6, +150e-15) + npoints = (200, 200, 300) + return Laser(dim, lo, hi, npoints, get_spatial_chirp_profile()) + +def get_angular_dispersion_laser(dim): + # - Cylindrical case + if dim == "rt": + lo = (0e-6, -150e-15) + hi = (25e-6, +150e-15) + npoints = (100, 300) + else: # dim == "xyt": + lo = (-25e-6, -25e-6, -150e-15) + hi = (+25e-6, +25e-6, +150e-15) + npoints = (100, 100, 300) + return Laser(dim, lo, hi, npoints, get_angular_dispersion_profile()) def test_laser_analysis_utils(): """Test the different laser analysis utilities in both geometries.""" @@ -58,6 +108,17 @@ def test_laser_analysis_utils(): tau_rms = get_duration(laser.grid, dim) np.testing.assert_approx_equal(2 * tau_rms, laser.profile.tau, significant=3) + laser_sc = get_spatial_chirp_laser(dim) + # Check that laser central time agrees with the given one with angular dispersion + omega, freq_sc_rms = get_frequency(laser_sc.grid, dim) + omega0 = 2*np.pi*c/laser_sc.wavelength + # freq_sc_expected = 0.0 + # np.testing.assert_approx_equal(freq_sc_rms, freq_sc_expected, significant=3) + + laser_ad = get_angular_dispersion_laser(dim) + # Check that laser central time agrees with the given one with angular dispersion + t_peak_ad_rms = get_t_peak(laser_ad.grid, dim) + # np.testing.assert_approx_equal(t_peak_ad_rms, laser_ad.profile.a*laser_ad.profile.w0, significant=3) if __name__ == "__main__": test_laser_analysis_utils() From b4d6b9b18c3b1674a671ead5dac119dcaf3fe6d8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:49:17 +0000 Subject: [PATCH 50/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_laser_utils.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/test_laser_utils.py b/tests/test_laser_utils.py index d4b4242c..3148293a 100644 --- a/tests/test_laser_utils.py +++ b/tests/test_laser_utils.py @@ -23,6 +23,7 @@ def get_gaussian_profile(): return profile + def get_spatial_chirp_profile(): # Cases with Gaussian laser wavelength = 0.8e-6 @@ -32,11 +33,12 @@ def get_spatial_chirp_profile(): tau = 30.0e-15 # s w0 = 5.0e-6 # m a = 0.0 - b = tau*w0/2 # m.s + b = tau * w0 / 2 # m.s profile = GaussianProfile(wavelength, pol, laser_energy, w0, tau, t_peak, a, b) return profile + def get_angular_dispersion_profile(): # Cases with Gaussian laser wavelength = 0.8e-6 @@ -45,11 +47,12 @@ def get_angular_dispersion_profile(): t_peak = 0.0e-15 # s tau = 30.0e-15 # s w0 = 5.0e-6 # m - a = tau/w0 # s/m + a = tau / w0 # s/m profile = GaussianProfile(wavelength, pol, laser_energy, w0, tau, t_peak, a) return profile + def get_gaussian_laser(dim): # - Cylindrical case if dim == "rt": @@ -62,6 +65,7 @@ def get_gaussian_laser(dim): npoints = (100, 100, 200) return Laser(dim, lo, hi, npoints, get_gaussian_profile()) + def get_spatial_chirp_laser(dim): # - Cylindrical case if dim == "rt": @@ -74,6 +78,7 @@ def get_spatial_chirp_laser(dim): npoints = (200, 200, 300) return Laser(dim, lo, hi, npoints, get_spatial_chirp_profile()) + def get_angular_dispersion_laser(dim): # - Cylindrical case if dim == "rt": @@ -86,6 +91,7 @@ def get_angular_dispersion_laser(dim): npoints = (100, 100, 300) return Laser(dim, lo, hi, npoints, get_angular_dispersion_profile()) + def test_laser_analysis_utils(): """Test the different laser analysis utilities in both geometries.""" for dim in ["xyt", "rt"]: @@ -111,14 +117,15 @@ def test_laser_analysis_utils(): laser_sc = get_spatial_chirp_laser(dim) # Check that laser central time agrees with the given one with angular dispersion omega, freq_sc_rms = get_frequency(laser_sc.grid, dim) - omega0 = 2*np.pi*c/laser_sc.wavelength + omega0 = 2 * np.pi * c / laser_sc.wavelength # freq_sc_expected = 0.0 # np.testing.assert_approx_equal(freq_sc_rms, freq_sc_expected, significant=3) - + laser_ad = get_angular_dispersion_laser(dim) # Check that laser central time agrees with the given one with angular dispersion t_peak_ad_rms = get_t_peak(laser_ad.grid, dim) # np.testing.assert_approx_equal(t_peak_ad_rms, laser_ad.profile.a*laser_ad.profile.w0, significant=3) + if __name__ == "__main__": test_laser_analysis_utils() From 2f6b09174ee16b06a12b69afc760f37a1ad15a10 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 15 Jan 2024 12:04:36 +0100 Subject: [PATCH 51/55] Update test_laser_utils.py --- tests/test_laser_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_laser_utils.py b/tests/test_laser_utils.py index 3148293a..c4d78345 100644 --- a/tests/test_laser_utils.py +++ b/tests/test_laser_utils.py @@ -118,7 +118,8 @@ def test_laser_analysis_utils(): # Check that laser central time agrees with the given one with angular dispersion omega, freq_sc_rms = get_frequency(laser_sc.grid, dim) omega0 = 2 * np.pi * c / laser_sc.wavelength - # freq_sc_expected = 0.0 + # Expected central frequency, using the frequency gradient (Eq. 4 from Gu et al., Opt. Comm., 2004) + freq_sc_expected = omega0 + laser_sc.b / ( laser_sc.b**2 + ( laser_sc.tau * laser_sc.w0 / 2 )**2 ) # np.testing.assert_approx_equal(freq_sc_rms, freq_sc_expected, significant=3) laser_ad = get_angular_dispersion_laser(dim) From b675f8a0a429b2c8104bed0687c05727092f865c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 11:06:16 +0000 Subject: [PATCH 52/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_laser_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_laser_utils.py b/tests/test_laser_utils.py index c4d78345..1b20a6c7 100644 --- a/tests/test_laser_utils.py +++ b/tests/test_laser_utils.py @@ -119,7 +119,9 @@ def test_laser_analysis_utils(): omega, freq_sc_rms = get_frequency(laser_sc.grid, dim) omega0 = 2 * np.pi * c / laser_sc.wavelength # Expected central frequency, using the frequency gradient (Eq. 4 from Gu et al., Opt. Comm., 2004) - freq_sc_expected = omega0 + laser_sc.b / ( laser_sc.b**2 + ( laser_sc.tau * laser_sc.w0 / 2 )**2 ) + freq_sc_expected = omega0 + laser_sc.b / ( + laser_sc.b**2 + (laser_sc.tau * laser_sc.w0 / 2) ** 2 + ) # np.testing.assert_approx_equal(freq_sc_rms, freq_sc_expected, significant=3) laser_ad = get_angular_dispersion_laser(dim) From 02aa9272922206cb04b8e6a7fd86db782324ebcf Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 15 Jan 2024 12:09:00 +0100 Subject: [PATCH 53/55] Update test_laser_utils.py --- tests/test_laser_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_laser_utils.py b/tests/test_laser_utils.py index 1b20a6c7..a76b5cbe 100644 --- a/tests/test_laser_utils.py +++ b/tests/test_laser_utils.py @@ -8,6 +8,7 @@ compute_laser_energy, get_t_peak, get_duration, + get_frequency ) From b6f32e6aa9f6aa8bfd91a1083a2719bb32838c44 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 11:09:08 +0000 Subject: [PATCH 54/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_laser_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_laser_utils.py b/tests/test_laser_utils.py index a76b5cbe..daee65be 100644 --- a/tests/test_laser_utils.py +++ b/tests/test_laser_utils.py @@ -8,7 +8,7 @@ compute_laser_energy, get_t_peak, get_duration, - get_frequency + get_frequency, ) From 8717ea8dbc7ae0351c2dca6f4d645f0de8aa8fc0 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 15 Jan 2024 12:13:35 +0100 Subject: [PATCH 55/55] Update test_laser_utils.py --- tests/test_laser_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_laser_utils.py b/tests/test_laser_utils.py index daee65be..0b100a74 100644 --- a/tests/test_laser_utils.py +++ b/tests/test_laser_utils.py @@ -120,7 +120,7 @@ def test_laser_analysis_utils(): omega, freq_sc_rms = get_frequency(laser_sc.grid, dim) omega0 = 2 * np.pi * c / laser_sc.wavelength # Expected central frequency, using the frequency gradient (Eq. 4 from Gu et al., Opt. Comm., 2004) - freq_sc_expected = omega0 + laser_sc.b / ( + freq_sc_expected = omega0 + laser_sc.w0 * laser_sc.b / ( laser_sc.b**2 + (laser_sc.tau * laser_sc.w0 / 2) ** 2 ) # np.testing.assert_approx_equal(freq_sc_rms, freq_sc_expected, significant=3)