From 63dcc2d44179fc0294ff27d7630754d47952e79a Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 15 Oct 2024 21:04:05 +0200 Subject: [PATCH 001/362] add spatio_temperal parameters to class GaussianLongitudinalProfile(LongitudinalProfile) --- .../profiles/longitudinal/gaussian_profile.py | 76 +++++++++++++++++-- lasy/utils/grid.py | 2 +- 2 files changed, 71 insertions(+), 7 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 3d52131b..fb0ca1e6 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -1,4 +1,5 @@ import numpy as np +from scipy import constants as scc from .longitudinal_profile import LongitudinalProfile @@ -28,26 +29,74 @@ class GaussianLongitudinalProfile(LongitudinalProfile): 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 + cep_phase : float (in radian), optional(default '0') 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) + oscillation, at the time where the laser envelope is maximum). + + beta : float (in second), optional + The angular dispersion parameterized by + .. math:: + \beta = \frac{d\theta_0}{d\omega} + Here :math:`\theta_0` is the propagation angle of this component. + + phi2 : float (in second^2), optional (default '0') + The group-delay dispertion parameterized by + .. math:: + \phi^{(2)} = \frac{dt}{d\omega} + + zeta : float (in meter * second) optional (defalut '0') + The spatio-chirp parameterized by + .. math:: + \zeta = \frac{x_0}{d\omega} + Here :math:`x_0` is the beam center position. + + stc_theta : float (in rad) optional (default '0') + Transeverse direction along which spatio-temperal field couples. + 0 is along x axis. + + z_foc : float (in meter), necessary if beta is not 0 + Position of the focal plane. (The laser pulse is initialized at + ``z=0``.) + + w0 : float (in meter), necessary if beta is not 0 + The waist of the laser pulse. """ - def __init__(self, wavelength, tau, t_peak, cep_phase=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 self.cep_phase = cep_phase + self.beta = beta + self.phi2 = phi2 + self.zeta = zeta + 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" + 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 - def evaluate(self, t): + + def evaluate(self, t, x=None, y=None): """ Return the longitudinal envelope. Parameters ---------- t : ndarrays of floats - Define points on which to evaluate the envelope + Define longitudinal points on which to evaluate the envelope + + x,y : ndarrays of floats, necessray if spatio-temperal couling exists + Define transverse points on which to evaluate the envelope Returns ------- @@ -55,7 +104,22 @@ def evaluate(self, t): Contains the value of the longitudinal envelope at the specified points. This array has the same shape as the array t. """ - envelope = np.exp( + 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 + 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) ) diff --git a/lasy/utils/grid.py b/lasy/utils/grid.py index aea42266..f0650009 100644 --- a/lasy/utils/grid.py +++ b/lasy/utils/grid.py @@ -55,7 +55,7 @@ def __init__(self, dim, lo, hi, npoints, n_azimuthal_modes=None, is_envelope=Tru if dim == "rt": self.n_azimuthal_modes = n_azimuthal_modes self.azimuthal_modes = np.r_[ - np.arange(n_azimuthal_modes), np.arange(-n_azimuthal_modes + 1, 0, 1) + np.arainge(n_azimuthal_modes), np.arange(-n_azimuthal_modes + 1, 0, 1) ] # Data From 6bfff8ba44114b9cb3ba242a699748437e78a3bd Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 15 Oct 2024 21:07:13 +0200 Subject: [PATCH 002/362] fix typo --- lasy/profiles/longitudinal/gaussian_profile.py | 2 +- lasy/utils/grid.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index fb0ca1e6..cef8432a 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -95,7 +95,7 @@ def evaluate(self, t, x=None, y=None): t : ndarrays of floats Define longitudinal points on which to evaluate the envelope - x,y : ndarrays of floats, necessray if spatio-temperal couling exists + x,y : ndarrays of floats, necessray if spatio-temperal coulping exists Define transverse points on which to evaluate the envelope Returns diff --git a/lasy/utils/grid.py b/lasy/utils/grid.py index f0650009..aea42266 100644 --- a/lasy/utils/grid.py +++ b/lasy/utils/grid.py @@ -55,7 +55,7 @@ def __init__(self, dim, lo, hi, npoints, n_azimuthal_modes=None, is_envelope=Tru if dim == "rt": self.n_azimuthal_modes = n_azimuthal_modes self.azimuthal_modes = np.r_[ - np.arainge(n_azimuthal_modes), np.arange(-n_azimuthal_modes + 1, 0, 1) + np.arange(n_azimuthal_modes), np.arange(-n_azimuthal_modes + 1, 0, 1) ] # Data From d90e2cab64b132e24d0550b4b491815c5cc5c802 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 16 Oct 2024 11:01:58 +0200 Subject: [PATCH 003/362] add stc parameters sto GaussianProfile --- lasy/profiles/gaussian_profile.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 1105d2a2..8d0bdb78 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -61,6 +61,28 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): z_foc : float (in meter), optional Position of the focal plane. (The laser pulse is initialized at `z=0`.) + beta : float (in second), optional + The angular dispersion parameterized by + .. math:: + \beta = \frac{d\theta_0}{d\omega} + Here :math:`\theta_0` is the propagation angle of this component. + + phi2 : float (in second^2), optional (default '0') + The group-delay dispertion parameterized by + .. math:: + \phi^{(2)} = \frac{dt}{d\omega} + + zeta : float (in meter * second) optional (defalut '0') + The spatio-chirp parameterized by + .. math:: + \zeta = \frac{x_0}{d\omega} + Here :math:`x_0` is the beam center position. + + stc_theta : float (in rad) optional (default '0') + Transeverse direction along which spatio-temperal field couples. + 0 is along x axis. + + Examples -------- >>> import matplotlib.pyplot as plt @@ -104,12 +126,12 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): """ def __init__( - self, wavelength, pol, laser_energy, w0, tau, t_peak, cep_phase=0, z_foc=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), + GaussianLongitudinalProfile(wavelength, tau, t_peak, cep_phase, beta=0, phi2=0, zeta=0, stc_theta=0,w0=None, z_foc=0), GaussianTransverseProfile(w0, z_foc, wavelength), ) From 498cf622429b1fc54e1cca9337c6e6e6e40606ed Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 16 Oct 2024 11:07:59 +0200 Subject: [PATCH 004/362] pass the parameters to GaussianProfile --- lasy/profiles/combined_profile.py | 2 +- lasy/profiles/gaussian_profile.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/combined_profile.py b/lasy/profiles/combined_profile.py index ababc196..eb4b48d6 100644 --- a/lasy/profiles/combined_profile.py +++ b/lasy/profiles/combined_profile.py @@ -68,5 +68,5 @@ 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) + 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 8d0bdb78..9bdf8d55 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -132,6 +132,6 @@ def __init__( wavelength, pol, laser_energy, - GaussianLongitudinalProfile(wavelength, tau, t_peak, cep_phase, beta=0, phi2=0, zeta=0, stc_theta=0,w0=None, z_foc=0), + 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), ) From ed7eb7e9e152ff2133685b2a05d7fed383979a2d Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 16 Oct 2024 11:17:59 +0200 Subject: [PATCH 005/362] fix syntax error --- lasy/profiles/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 9bdf8d55..8f05dce8 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -126,7 +126,7 @@ 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, From efa417354376d1e911b9ee066aa086cd2f851d29 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 16 Oct 2024 11:46:56 +0200 Subject: [PATCH 006/362] fix doc error --- lasy/profiles/gaussian_profile.py | 8 +++++++- lasy/profiles/longitudinal/gaussian_profile.py | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 8f05dce8..4e1ffa41 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -63,18 +63,24 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): beta : float (in second), optional The angular dispersion parameterized by + .. math:: + \beta = \frac{d\theta_0}{d\omega} Here :math:`\theta_0` is the propagation angle of this component. phi2 : float (in second^2), optional (default '0') The group-delay dispertion parameterized by + .. math:: + \phi^{(2)} = \frac{dt}{d\omega} - zeta : float (in meter * second) optional (defalut '0') + zeta : float (in meter * second) optional (default '0') The spatio-chirp parameterized by + .. math:: + \zeta = \frac{x_0}{d\omega} Here :math:`x_0` is the beam center position. diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index cef8432a..4e455e12 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -73,6 +73,7 @@ def __init__(self, wavelength, tau, t_peak, cep_phase=0, beta=0, phi2=0, zeta=0, self.zeta = zeta self.w0 = w0 self.stc_theta = stc_theta + self.k0 = 2.0 * scc.pi/wavelength 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" @@ -83,7 +84,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 + def evaluate(self, t, x=None, y=None): From 4608356e5c7eaccf9acfd83586c3f7f3471133c1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:48:42 +0000 Subject: [PATCH 007/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/combined_profile.py | 4 +- lasy/profiles/gaussian_profile.py | 27 +++++- .../profiles/longitudinal/gaussian_profile.py | 84 ++++++++++++++----- 3 files changed, 89 insertions(+), 26 deletions(-) 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 4e1ffa41..34eeb279 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -132,12 +132,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 4e455e12..eebf4b5c 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 @@ -73,10 +85,11 @@ def __init__(self, wavelength, tau, t_peak, cep_phase=0, beta=0, phi2=0, zeta=0, self.zeta = zeta self.w0 = w0 self.stc_theta = stc_theta - self.k0 = 2.0 * scc.pi/wavelength + self.k0 = 2.0 * scc.pi / wavelength 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: @@ -85,8 +98,6 @@ def __init__(self, wavelength, tau, t_peak, cep_phase=0, beta=0, phi2=0, zeta=0, ), "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, t, x=None, y=None): """ Return the longitudinal envelope. @@ -106,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 From 4752ad19b3affc1e30420a36627f5f88871ac678 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 16 Oct 2024 12:27:47 +0200 Subject: [PATCH 008/362] cancel the if condition for longitudinal profile --- lasy/profiles/gaussian_profile.py | 4 +-- .../profiles/longitudinal/gaussian_profile.py | 34 ++++++------------- .../longitudinal/longitudinal_profile.py | 2 +- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 34eeb279..9cc94a38 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -158,9 +158,9 @@ def __init__( beta=beta, phi2=phi2, zeta=zeta, - stc_theta=0, + stc_theta=stc_theta, w0=w0, - z_foc=z_foc, + 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 eebf4b5c..77feb87c 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -73,7 +73,7 @@ def __init__( phi2=0, zeta=0, stc_theta=0, - w0=None, + w0=0, z_foc=0, ): super().__init__(wavelength) @@ -85,11 +85,6 @@ def __init__( self.zeta = zeta self.w0 = w0 self.stc_theta = stc_theta - self.k0 = 2.0 * scc.pi / wavelength - 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" if z_foc == 0: self.z_foc_over_zr = 0 else: @@ -98,7 +93,7 @@ def __init__( ), "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, t, x=None, y=None): + def evaluate(self, t, x, y): """ Return the longitudinal envelope. @@ -116,13 +111,11 @@ def evaluate(self, t, x=None, y=None): Contains the value of the longitudinal envelope at the 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 ( + assert ( x is not None and y is not None ), "transverse points should be specified if spatio-temperal coupling exits" - inv_complex_waist_2 = ( + inv_complex_waist_2 = ( 1.0 / ( self.w0**2 @@ -130,16 +123,17 @@ def evaluate(self, t, x=None, y=None): ) if self.beta else 0 - ) - stretch_factor += ( + ) + stretch_factor = ( + 1 + 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 = ( + ) + stc_exponent = ( 1.0 / stretch_factor * inv_tau2 @@ -155,12 +149,6 @@ def evaluate(self, t, x=None, y=None): * 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) - ) - + ) + envelope = np.exp(-stc_exponent + 1.0j * (self.cep_phase + self.omega0 * self.t_peak)) return envelope diff --git a/lasy/profiles/longitudinal/longitudinal_profile.py b/lasy/profiles/longitudinal/longitudinal_profile.py index 68a49c5f..33a58bca 100644 --- a/lasy/profiles/longitudinal/longitudinal_profile.py +++ b/lasy/profiles/longitudinal/longitudinal_profile.py @@ -13,7 +13,7 @@ class LongitudinalProfile(object): def __init__(self, wavelength): self.lambda0 = wavelength self.omega0 = 2 * pi * c / self.lambda0 - + self.k0 = 2.0 * scc.pi / wavelength def evaluate(self, t): """ Return the longitudinal envelope. From d2732b3590fd1ecd3a8a9daf722ed2fe818a261b Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 16 Oct 2024 12:29:16 +0200 Subject: [PATCH 009/362] fix syntax error --- lasy/profiles/longitudinal/gaussian_profile.py | 1 + lasy/profiles/longitudinal/longitudinal_profile.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 77feb87c..643155f3 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -85,6 +85,7 @@ def __init__( self.zeta = zeta self.w0 = w0 self.stc_theta = stc_theta + if z_foc == 0: self.z_foc_over_zr = 0 else: diff --git a/lasy/profiles/longitudinal/longitudinal_profile.py b/lasy/profiles/longitudinal/longitudinal_profile.py index 33a58bca..4a753dd8 100644 --- a/lasy/profiles/longitudinal/longitudinal_profile.py +++ b/lasy/profiles/longitudinal/longitudinal_profile.py @@ -13,7 +13,7 @@ class LongitudinalProfile(object): def __init__(self, wavelength): self.lambda0 = wavelength self.omega0 = 2 * pi * c / self.lambda0 - self.k0 = 2.0 * scc.pi / wavelength + self.k0 = 2.0 * pi / wavelength def evaluate(self, t): """ Return the longitudinal envelope. From 00a5c3943e1dc66d4e07ecb6a8b6165add238a3b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 16 Oct 2024 10:30:28 +0000 Subject: [PATCH 010/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 2 +- .../profiles/longitudinal/gaussian_profile.py | 64 +++++++++---------- .../longitudinal/longitudinal_profile.py | 1 + 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 9cc94a38..26137f74 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -160,7 +160,7 @@ def __init__( zeta=zeta, stc_theta=stc_theta, w0=w0, - z_foc=z_foc + 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 643155f3..662400af 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -1,5 +1,4 @@ import numpy as np -from scipy import constants as scc from .longitudinal_profile import LongitudinalProfile @@ -114,42 +113,41 @@ def evaluate(self, t, x, y): """ inv_tau2 = self.tau ** (-2) assert ( - x is not None and y is not None - ), "transverse points should be specified if spatio-temperal coupling exits" + 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 + 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 = ( - 1 + - 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 + 1 + + 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 + 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 + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) ) - envelope = np.exp(-stc_exponent + 1.0j * (self.cep_phase + self.omega0 * self.t_peak)) return envelope diff --git a/lasy/profiles/longitudinal/longitudinal_profile.py b/lasy/profiles/longitudinal/longitudinal_profile.py index 4a753dd8..767ffbcd 100644 --- a/lasy/profiles/longitudinal/longitudinal_profile.py +++ b/lasy/profiles/longitudinal/longitudinal_profile.py @@ -14,6 +14,7 @@ def __init__(self, wavelength): self.lambda0 = wavelength self.omega0 = 2 * pi * c / self.lambda0 self.k0 = 2.0 * pi / wavelength + def evaluate(self, t): """ Return the longitudinal envelope. From 70d97422e4fa1b90d12aa1a1a66b4445addb99a8 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 16 Oct 2024 17:08:36 +0200 Subject: [PATCH 011/362] Update gaussian_profile.py --- lasy/profiles/longitudinal/gaussian_profile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 662400af..08646d6e 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -84,7 +84,6 @@ def __init__( self.zeta = zeta self.w0 = w0 self.stc_theta = stc_theta - if z_foc == 0: self.z_foc_over_zr = 0 else: @@ -93,7 +92,7 @@ def __init__( ), "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, t, x, y): + def evaluate(self, t, x=None, y=None): """ Return the longitudinal envelope. From 98c20984c742745652d383e961127c2db1eed8f3 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 16 Oct 2024 20:59:49 +0200 Subject: [PATCH 012/362] Update gaussian_profile.py From ef692b4caa039b59bbd54a0cee8b50ff11602247 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Thu, 17 Oct 2024 14:05:26 +0200 Subject: [PATCH 013/362] imaginary part is pure zero, debug --- .../profiles/longitudinal/gaussian_profile.py | 7 +- lasy/utils/laser_utils.py | 103 ++++++++++++++++++ 2 files changed, 106 insertions(+), 4 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 662400af..ffcc193a 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -93,7 +93,7 @@ def __init__( ), "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, t, x, y): + def evaluate(self, t, x= None, y=None): """ Return the longitudinal envelope. @@ -112,9 +112,6 @@ def evaluate(self, t, x, y): specified points. This array has the same shape as the array t. """ inv_tau2 = self.tau ** (-2) - 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))) @@ -150,4 +147,6 @@ def evaluate(self, t, x, y): envelope = np.exp( -stc_exponent + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) ) + print("longitudinal field evaluate sucessfully and the imag part is \n") + print(envelope.imag) return envelope diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 399ab4d0..bc9f7327 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -873,3 +873,106 @@ def import_from_z(dim, grid, omega0, field_z, z_axis, z0=0.0, t0=0.0, backend="N field = np.moveaxis(prop.z2t(transform_data, t_axis, z0=z0, t0=t0), 0, -1) field *= np.exp(1j * (z0 / c + t_axis) * omega0) grid.set_temporal_field(field) + +def get_STC(laser): + omega0 = laser.profile.omega0 + env = laser.grid.get_temporal_field() + time_axis = laser.grid.axes[-1] + + if laser.dim == "rt": + beta = 0 + else: + nu = 0 + summ = 0 + laser_module = np.abs(env) + phi_envelop = np.array(np.arctan2(Ar.imag, Ar.real)) + # unwrap phi_envelop + phi_envelop = np.unwrap(np.unwrap(phi_envelop, axis=0), axis=1) + # calculate pphi_pz + z_diff = np.diff(m.z) + x_diff = np.diff(m.x) + pphi_pz = (np.diff(phi_envelop, axis=0)).T / (z_diff / scc.c) + pphi_pzpy = (np.diff(pphi_pz, axis=0)).T / x_diff + for i in range(len(m.z) - 2): + for j in range(len(m.x) - 2): + nu = nu + pphi_pzpy[i, j] * laser_module[i, j] + summ = summ + laser_module[i, j] + nu = nu / scc.c / summ + a = 4 * nu * w0**2 * L**4 + b = -4 * scc.c + c = nu * w0**2 * L**2 + zeta_roots = np.roots([a, b, c]) + zeta=np.min(zeta_roots) +# get temporal chirp phi2 + temp_chirp = 0 + summ = 0 + laser_module1 = np.abs(Ar) + phi_envelop = np.unwrap(np.array(np.arctan2(Ar.imag, Ar.real)), axis=0) + # calculate pphi_pz + z_diff = np.diff(m.z) + pphi_pz = (np.diff(phi_envelop, axis=0)).T/ (laser.grid.dt) + pphi_pz2 = ((np.diff(pphi_pz, axis=1)) / (laser.grid.dt).T + for i in range(len(m.z)-2): + for j in range(len(m.x)-2): + temp_chirp = temp_chirp + pphi_pz2[i,j] * laser_module1[i,j] + summ = summ + laser_module1[i,j] + x = temp_chirp * scc.c**2 / summ + a = 4 * x + b = -4 + c = tau**4 * x + zeta_roots = np.roots([a, b, c]) + return np.max(zeta_roots) + + + if Nt is not None: + Nr = env.shape[0] + time_axis_new = np.linspace(laser.grid.lo[-1], laser.grid.hi[-1], Nt) + env_new = np.zeros((Nr, Nt), dtype=env.dtype) + + for ir in range(Nr): + interp_fu_abs = interp1d(time_axis, np.abs(env[ir])) + slice_abs = interp_fu_abs(time_axis_new) + interp_fu_angl = interp1d(time_axis, np.unwrap(np.angle(env[ir]))) + slice_angl = interp_fu_angl(time_axis_new) + env_new[ir] = slice_abs * np.exp(1j * slice_angl) + + time_axis = time_axis_new + env = env_new + + env *= np.exp(-1j * omega0 * time_axis[None, :]) + env = np.real(env) + + if laser.dim == "rt": + ext = np.array( + [ + laser.grid.lo[-1], + laser.grid.hi[-1], + -laser.grid.hi[0], + laser.grid.hi[0], + ] + ) + else: + ext = np.array( + [ + laser.grid.lo[-1], + laser.grid.hi[-1], + laser.grid.lo[0], + laser.grid.hi[0], + ] + ) + + + + + + +def get_centroids(F, x, z): + index_array = np.mgrid[0:F.shape[0], 0:F.shape[1]][1] + centroids = np.sum(index_array * np.abs(F**2), axis=1) / np.sum(np.abs(F**2), axis=1) + return z[centroids.astype(int)] + +def get_beta(F, m, k0): + z_centroids = get_centroids(F.T, m.x, m.z) + weight = np.mean(np.abs(F.T)**2, axis = np.ndim(F) - 1) + derivative = np.gradient(z_centroids) / (m.x[1] - m.x[0]) + return (np.sum(derivative * weight) / np.sum(weight)) / k0 / scc.c \ No newline at end of file From 44ffdf2f4a9494c83acdff651ff50c3e222398f7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 17 Oct 2024 12:07:01 +0000 Subject: [PATCH 014/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- 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 bc9f7327..6597ff67 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -975,4 +975,4 @@ def get_beta(F, m, k0): z_centroids = get_centroids(F.T, m.x, m.z) weight = np.mean(np.abs(F.T)**2, axis = np.ndim(F) - 1) derivative = np.gradient(z_centroids) / (m.x[1] - m.x[0]) - return (np.sum(derivative * weight) / np.sum(weight)) / k0 / scc.c \ No newline at end of file + return (np.sum(derivative * weight) / np.sum(weight)) / k0 / scc.c From 9da26382c713ae6258173625c7a2f312178e1262 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Thu, 17 Oct 2024 14:08:06 +0200 Subject: [PATCH 015/362] cancel laser_utils --- lasy/utils/laser_utils.py | 105 +------------------------------------- 1 file changed, 1 insertion(+), 104 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index bc9f7327..f6fbb73a 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -872,107 +872,4 @@ def import_from_z(dim, grid, omega0, field_z, z_axis, z0=0.0, t0=0.0, backend="N transform_data *= np.exp(-1j * z_axis[0] * (k_z[:, None, None] - omega0 / c)) field = np.moveaxis(prop.z2t(transform_data, t_axis, z0=z0, t0=t0), 0, -1) field *= np.exp(1j * (z0 / c + t_axis) * omega0) - grid.set_temporal_field(field) - -def get_STC(laser): - omega0 = laser.profile.omega0 - env = laser.grid.get_temporal_field() - time_axis = laser.grid.axes[-1] - - if laser.dim == "rt": - beta = 0 - else: - nu = 0 - summ = 0 - laser_module = np.abs(env) - phi_envelop = np.array(np.arctan2(Ar.imag, Ar.real)) - # unwrap phi_envelop - phi_envelop = np.unwrap(np.unwrap(phi_envelop, axis=0), axis=1) - # calculate pphi_pz - z_diff = np.diff(m.z) - x_diff = np.diff(m.x) - pphi_pz = (np.diff(phi_envelop, axis=0)).T / (z_diff / scc.c) - pphi_pzpy = (np.diff(pphi_pz, axis=0)).T / x_diff - for i in range(len(m.z) - 2): - for j in range(len(m.x) - 2): - nu = nu + pphi_pzpy[i, j] * laser_module[i, j] - summ = summ + laser_module[i, j] - nu = nu / scc.c / summ - a = 4 * nu * w0**2 * L**4 - b = -4 * scc.c - c = nu * w0**2 * L**2 - zeta_roots = np.roots([a, b, c]) - zeta=np.min(zeta_roots) -# get temporal chirp phi2 - temp_chirp = 0 - summ = 0 - laser_module1 = np.abs(Ar) - phi_envelop = np.unwrap(np.array(np.arctan2(Ar.imag, Ar.real)), axis=0) - # calculate pphi_pz - z_diff = np.diff(m.z) - pphi_pz = (np.diff(phi_envelop, axis=0)).T/ (laser.grid.dt) - pphi_pz2 = ((np.diff(pphi_pz, axis=1)) / (laser.grid.dt).T - for i in range(len(m.z)-2): - for j in range(len(m.x)-2): - temp_chirp = temp_chirp + pphi_pz2[i,j] * laser_module1[i,j] - summ = summ + laser_module1[i,j] - x = temp_chirp * scc.c**2 / summ - a = 4 * x - b = -4 - c = tau**4 * x - zeta_roots = np.roots([a, b, c]) - return np.max(zeta_roots) - - - if Nt is not None: - Nr = env.shape[0] - time_axis_new = np.linspace(laser.grid.lo[-1], laser.grid.hi[-1], Nt) - env_new = np.zeros((Nr, Nt), dtype=env.dtype) - - for ir in range(Nr): - interp_fu_abs = interp1d(time_axis, np.abs(env[ir])) - slice_abs = interp_fu_abs(time_axis_new) - interp_fu_angl = interp1d(time_axis, np.unwrap(np.angle(env[ir]))) - slice_angl = interp_fu_angl(time_axis_new) - env_new[ir] = slice_abs * np.exp(1j * slice_angl) - - time_axis = time_axis_new - env = env_new - - env *= np.exp(-1j * omega0 * time_axis[None, :]) - env = np.real(env) - - if laser.dim == "rt": - ext = np.array( - [ - laser.grid.lo[-1], - laser.grid.hi[-1], - -laser.grid.hi[0], - laser.grid.hi[0], - ] - ) - else: - ext = np.array( - [ - laser.grid.lo[-1], - laser.grid.hi[-1], - laser.grid.lo[0], - laser.grid.hi[0], - ] - ) - - - - - - -def get_centroids(F, x, z): - index_array = np.mgrid[0:F.shape[0], 0:F.shape[1]][1] - centroids = np.sum(index_array * np.abs(F**2), axis=1) / np.sum(np.abs(F**2), axis=1) - return z[centroids.astype(int)] - -def get_beta(F, m, k0): - z_centroids = get_centroids(F.T, m.x, m.z) - weight = np.mean(np.abs(F.T)**2, axis = np.ndim(F) - 1) - derivative = np.gradient(z_centroids) / (m.x[1] - m.x[0]) - return (np.sum(derivative * weight) / np.sum(weight)) / k0 / scc.c \ No newline at end of file + grid.set_temporal_field(field) \ No newline at end of file From 671307a45ec343094e709ca0259cdd887efaca07 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 17 Oct 2024 14:10:25 +0200 Subject: [PATCH 016/362] Update gaussian_profile.py --- lasy/profiles/longitudinal/gaussian_profile.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 133f7593..8245f7fd 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -92,11 +92,7 @@ def __init__( ), "You need to pass the wavelength, when `z_foc` is non-zero." self.z_foc_over_zr = z_foc * wavelength / (np.pi * w0**2) -<<<<<<< HEAD - def evaluate(self, t, x= None, y=None): -======= def evaluate(self, t, x=None, y=None): ->>>>>>> 98c20984c742745652d383e961127c2db1eed8f3 """ Return the longitudinal envelope. From 5be684c6bedb88f5efc9924f0518dde19814d5ad Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 17 Oct 2024 14:12:11 +0200 Subject: [PATCH 017/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 107 -------------------------------------- 1 file changed, 107 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 494ac02a..399ab4d0 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -872,111 +872,4 @@ def import_from_z(dim, grid, omega0, field_z, z_axis, z0=0.0, t0=0.0, backend="N transform_data *= np.exp(-1j * z_axis[0] * (k_z[:, None, None] - omega0 / c)) field = np.moveaxis(prop.z2t(transform_data, t_axis, z0=z0, t0=t0), 0, -1) field *= np.exp(1j * (z0 / c + t_axis) * omega0) -<<<<<<< HEAD grid.set_temporal_field(field) -======= - grid.set_temporal_field(field) - -def get_STC(laser): - omega0 = laser.profile.omega0 - env = laser.grid.get_temporal_field() - time_axis = laser.grid.axes[-1] - - if laser.dim == "rt": - beta = 0 - else: - nu = 0 - summ = 0 - laser_module = np.abs(env) - phi_envelop = np.array(np.arctan2(Ar.imag, Ar.real)) - # unwrap phi_envelop - phi_envelop = np.unwrap(np.unwrap(phi_envelop, axis=0), axis=1) - # calculate pphi_pz - z_diff = np.diff(m.z) - x_diff = np.diff(m.x) - pphi_pz = (np.diff(phi_envelop, axis=0)).T / (z_diff / scc.c) - pphi_pzpy = (np.diff(pphi_pz, axis=0)).T / x_diff - for i in range(len(m.z) - 2): - for j in range(len(m.x) - 2): - nu = nu + pphi_pzpy[i, j] * laser_module[i, j] - summ = summ + laser_module[i, j] - nu = nu / scc.c / summ - a = 4 * nu * w0**2 * L**4 - b = -4 * scc.c - c = nu * w0**2 * L**2 - zeta_roots = np.roots([a, b, c]) - zeta=np.min(zeta_roots) -# get temporal chirp phi2 - temp_chirp = 0 - summ = 0 - laser_module1 = np.abs(Ar) - phi_envelop = np.unwrap(np.array(np.arctan2(Ar.imag, Ar.real)), axis=0) - # calculate pphi_pz - z_diff = np.diff(m.z) - pphi_pz = (np.diff(phi_envelop, axis=0)).T/ (laser.grid.dt) - pphi_pz2 = ((np.diff(pphi_pz, axis=1)) / (laser.grid.dt).T - for i in range(len(m.z)-2): - for j in range(len(m.x)-2): - temp_chirp = temp_chirp + pphi_pz2[i,j] * laser_module1[i,j] - summ = summ + laser_module1[i,j] - x = temp_chirp * scc.c**2 / summ - a = 4 * x - b = -4 - c = tau**4 * x - zeta_roots = np.roots([a, b, c]) - return np.max(zeta_roots) - - - if Nt is not None: - Nr = env.shape[0] - time_axis_new = np.linspace(laser.grid.lo[-1], laser.grid.hi[-1], Nt) - env_new = np.zeros((Nr, Nt), dtype=env.dtype) - - for ir in range(Nr): - interp_fu_abs = interp1d(time_axis, np.abs(env[ir])) - slice_abs = interp_fu_abs(time_axis_new) - interp_fu_angl = interp1d(time_axis, np.unwrap(np.angle(env[ir]))) - slice_angl = interp_fu_angl(time_axis_new) - env_new[ir] = slice_abs * np.exp(1j * slice_angl) - - time_axis = time_axis_new - env = env_new - - env *= np.exp(-1j * omega0 * time_axis[None, :]) - env = np.real(env) - - if laser.dim == "rt": - ext = np.array( - [ - laser.grid.lo[-1], - laser.grid.hi[-1], - -laser.grid.hi[0], - laser.grid.hi[0], - ] - ) - else: - ext = np.array( - [ - laser.grid.lo[-1], - laser.grid.hi[-1], - laser.grid.lo[0], - laser.grid.hi[0], - ] - ) - - - - - - -def get_centroids(F, x, z): - index_array = np.mgrid[0:F.shape[0], 0:F.shape[1]][1] - centroids = np.sum(index_array * np.abs(F**2), axis=1) / np.sum(np.abs(F**2), axis=1) - return z[centroids.astype(int)] - -def get_beta(F, m, k0): - z_centroids = get_centroids(F.T, m.x, m.z) - weight = np.mean(np.abs(F.T)**2, axis = np.ndim(F) - 1) - derivative = np.gradient(z_centroids) / (m.x[1] - m.x[0]) - return (np.sum(derivative * weight) / np.sum(weight)) / k0 / scc.c ->>>>>>> refs/remotes/huixingjian/add_diag_util From 54ead90d851cca3e3436774150bba3c096a28348 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Fri, 18 Oct 2024 17:23:50 +0200 Subject: [PATCH 018/362] add phi calculater in utils --- .../profiles/longitudinal/gaussian_profile.py | 4 - lasy/utils/laser_utils.py | 117 ++---------------- 2 files changed, 11 insertions(+), 110 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 133f7593..8245f7fd 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -92,11 +92,7 @@ def __init__( ), "You need to pass the wavelength, when `z_foc` is non-zero." self.z_foc_over_zr = z_foc * wavelength / (np.pi * w0**2) -<<<<<<< HEAD - def evaluate(self, t, x= None, y=None): -======= def evaluate(self, t, x=None, y=None): ->>>>>>> 98c20984c742745652d383e961127c2db1eed8f3 """ Return the longitudinal envelope. diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 494ac02a..a1f66ad5 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -872,111 +872,16 @@ def import_from_z(dim, grid, omega0, field_z, z_axis, z0=0.0, t0=0.0, backend="N transform_data *= np.exp(-1j * z_axis[0] * (k_z[:, None, None] - omega0 / c)) field = np.moveaxis(prop.z2t(transform_data, t_axis, z0=z0, t0=t0), 0, -1) field *= np.exp(1j * (z0 / c + t_axis) * omega0) -<<<<<<< HEAD grid.set_temporal_field(field) -======= - grid.set_temporal_field(field) - -def get_STC(laser): - omega0 = laser.profile.omega0 - env = laser.grid.get_temporal_field() - time_axis = laser.grid.axes[-1] - - if laser.dim == "rt": - beta = 0 - else: - nu = 0 - summ = 0 - laser_module = np.abs(env) - phi_envelop = np.array(np.arctan2(Ar.imag, Ar.real)) - # unwrap phi_envelop - phi_envelop = np.unwrap(np.unwrap(phi_envelop, axis=0), axis=1) - # calculate pphi_pz - z_diff = np.diff(m.z) - x_diff = np.diff(m.x) - pphi_pz = (np.diff(phi_envelop, axis=0)).T / (z_diff / scc.c) - pphi_pzpy = (np.diff(pphi_pz, axis=0)).T / x_diff - for i in range(len(m.z) - 2): - for j in range(len(m.x) - 2): - nu = nu + pphi_pzpy[i, j] * laser_module[i, j] - summ = summ + laser_module[i, j] - nu = nu / scc.c / summ - a = 4 * nu * w0**2 * L**4 - b = -4 * scc.c - c = nu * w0**2 * L**2 - zeta_roots = np.roots([a, b, c]) - zeta=np.min(zeta_roots) -# get temporal chirp phi2 - temp_chirp = 0 - summ = 0 - laser_module1 = np.abs(Ar) - phi_envelop = np.unwrap(np.array(np.arctan2(Ar.imag, Ar.real)), axis=0) - # calculate pphi_pz - z_diff = np.diff(m.z) - pphi_pz = (np.diff(phi_envelop, axis=0)).T/ (laser.grid.dt) - pphi_pz2 = ((np.diff(pphi_pz, axis=1)) / (laser.grid.dt).T - for i in range(len(m.z)-2): - for j in range(len(m.x)-2): - temp_chirp = temp_chirp + pphi_pz2[i,j] * laser_module1[i,j] - summ = summ + laser_module1[i,j] - x = temp_chirp * scc.c**2 / summ - a = 4 * x - b = -4 - c = tau**4 * x - zeta_roots = np.roots([a, b, c]) - return np.max(zeta_roots) - - - if Nt is not None: - Nr = env.shape[0] - time_axis_new = np.linspace(laser.grid.lo[-1], laser.grid.hi[-1], Nt) - env_new = np.zeros((Nr, Nt), dtype=env.dtype) - - for ir in range(Nr): - interp_fu_abs = interp1d(time_axis, np.abs(env[ir])) - slice_abs = interp_fu_abs(time_axis_new) - interp_fu_angl = interp1d(time_axis, np.unwrap(np.angle(env[ir]))) - slice_angl = interp_fu_angl(time_axis_new) - env_new[ir] = slice_abs * np.exp(1j * slice_angl) - - time_axis = time_axis_new - env = env_new - - env *= np.exp(-1j * omega0 * time_axis[None, :]) - env = np.real(env) - - if laser.dim == "rt": - ext = np.array( - [ - laser.grid.lo[-1], - laser.grid.hi[-1], - -laser.grid.hi[0], - laser.grid.hi[0], - ] - ) - else: - ext = np.array( - [ - laser.grid.lo[-1], - laser.grid.hi[-1], - laser.grid.lo[0], - laser.grid.hi[0], - ] - ) - - - - - - -def get_centroids(F, x, z): - index_array = np.mgrid[0:F.shape[0], 0:F.shape[1]][1] - centroids = np.sum(index_array * np.abs(F**2), axis=1) / np.sum(np.abs(F**2), axis=1) - return z[centroids.astype(int)] -def get_beta(F, m, k0): - z_centroids = get_centroids(F.T, m.x, m.z) - weight = np.mean(np.abs(F.T)**2, axis = np.ndim(F) - 1) - derivative = np.gradient(z_centroids) / (m.x[1] - m.x[0]) - return (np.sum(derivative * weight) / np.sum(weight)) / k0 / scc.c ->>>>>>> refs/remotes/huixingjian/add_diag_util + def get_STC(laser,dim,tau,w0): + env = laser.grid.get_temporal_field() + env_abs= np.abs(env) + phi_envelop =np.unwrap( np.array(np.arctan2(env.imag, env.real)),axis=2) + pphi_pz = (np.diff(phi_envelop, axis=2))/ (laser.grid.dx[-1]) + #calculate phi2 + pphi_pz2 = (np.diff(pphi_pz, axis=2))/ (laser.grid.dx[-1]) + temp_chirp = np.sum(pphi_pz2 * env_abs[:,:,:env_abs.shape[2]-2]) / \ + np.sum(env_abs[:,:,:env_abs.shape[2]-2]) + phi2= np.max(np.roots([4 * temp_chirp, -4, tau**4 * temp_chirp])) + return [temp_chirp,phi2] \ No newline at end of file From 2036c5d807e18c6dcd2011e06d000103806d2259 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 15:25:33 +0000 Subject: [PATCH 019/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index eff1ed0b..9c19d7f7 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -874,15 +874,16 @@ def import_from_z(dim, grid, omega0, field_z, z_axis, z0=0.0, t0=0.0, backend="N field *= np.exp(1j * (z0 / c + t_axis) * omega0) grid.set_temporal_field(field) -def get_STC(laser,dim,tau,w0): - env = laser.grid.get_temporal_field() - env_abs= np.abs(env) - phi_envelop =np.unwrap( np.array(np.arctan2(env.imag, env.real)),axis=2) - pphi_pz = (np.diff(phi_envelop, axis=2))/ (laser.grid.dx[-1]) - #calculate phi2 - pphi_pz2 = (np.diff(pphi_pz, axis=2))/ (laser.grid.dx[-1]) - temp_chirp = np.sum(pphi_pz2 * env_abs[:,:,:env_abs.shape[2]-2]) / \ - np.sum(env_abs[:,:,:env_abs.shape[2]-2]) - phi2= np.max(np.roots([4 * temp_chirp, -4, tau**4 * temp_chirp])) - return [temp_chirp,phi2] +def get_STC(laser, dim, tau, w0): + env = laser.grid.get_temporal_field() + env_abs = np.abs(env) + phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) + pphi_pz = (np.diff(phi_envelop, axis=2)) / (laser.grid.dx[-1]) + # calculate phi2 + pphi_pz2 = (np.diff(pphi_pz, axis=2)) / (laser.grid.dx[-1]) + temp_chirp = np.sum(pphi_pz2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( + env_abs[:, :, : env_abs.shape[2] - 2] + ) + phi2 = np.max(np.roots([4 * temp_chirp, -4, tau**4 * temp_chirp])) + return [temp_chirp, phi2] From ba9700ab849ffbf8b01afff205ec3ff0ccdbfa25 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Fri, 18 Oct 2024 18:38:50 +0200 Subject: [PATCH 020/362] add debug print --- lasy/profiles/longitudinal/gaussian_profile.py | 5 ++++- lasy/profiles/profile.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 8245f7fd..7622f3f5 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -117,6 +117,7 @@ def evaluate(self, t, x=None, y=None): if self.beta else 0 ) + print(inv_complex_waist_2 ) stretch_factor = ( 1 + 4.0 @@ -126,6 +127,7 @@ def evaluate(self, t, x=None, y=None): * (self.phi2 - self.beta**2 * self.k0 * self.z_foc_over_zr) * inv_tau2 ) + print(stretch_factor ) stc_exponent = ( 1.0 / stretch_factor @@ -143,8 +145,9 @@ def evaluate(self, t, x=None, y=None): ) ** 2 ) + print(stc_exponent ) envelope = np.exp( - -stc_exponent + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) + -stc_exponent + 1.0j * (self.cep_phase + self.omega0 * (t-self.t_peak)) ) print("longitudinal field evaluate sucessfully and the imag part is \n") print(envelope.imag) diff --git a/lasy/profiles/profile.py b/lasy/profiles/profile.py index 6266b1d8..2b9c18ac 100644 --- a/lasy/profiles/profile.py +++ b/lasy/profiles/profile.py @@ -1,4 +1,4 @@ -import numpy as np +catimport numpy as np from scipy.constants import c From 8c247a793844e072d03e845e5e9a292d5b7a11c6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 16:39:42 +0000 Subject: [PATCH 021/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/longitudinal/gaussian_profile.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 7622f3f5..b06ac0db 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -117,7 +117,7 @@ def evaluate(self, t, x=None, y=None): if self.beta else 0 ) - print(inv_complex_waist_2 ) + print(inv_complex_waist_2) stretch_factor = ( 1 + 4.0 @@ -127,7 +127,7 @@ def evaluate(self, t, x=None, y=None): * (self.phi2 - self.beta**2 * self.k0 * self.z_foc_over_zr) * inv_tau2 ) - print(stretch_factor ) + print(stretch_factor) stc_exponent = ( 1.0 / stretch_factor @@ -145,9 +145,9 @@ def evaluate(self, t, x=None, y=None): ) ** 2 ) - print(stc_exponent ) + print(stc_exponent) envelope = np.exp( - -stc_exponent + 1.0j * (self.cep_phase + self.omega0 * (t-self.t_peak)) + -stc_exponent + 1.0j * (self.cep_phase + self.omega0 * (t - self.t_peak)) ) print("longitudinal field evaluate sucessfully and the imag part is \n") print(envelope.imag) From 3244c55b3a066f663077ab14480e10cbba4a98c5 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Fri, 18 Oct 2024 18:40:20 +0200 Subject: [PATCH 022/362] typo --- lasy/profiles/profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/profile.py b/lasy/profiles/profile.py index 2b9c18ac..6266b1d8 100644 --- a/lasy/profiles/profile.py +++ b/lasy/profiles/profile.py @@ -1,4 +1,4 @@ -catimport numpy as np +import numpy as np from scipy.constants import c From 7248e5b5ac4c589567d0c87236f5773b746e1b5d Mon Sep 17 00:00:00 2001 From: huixingjian Date: Fri, 18 Oct 2024 18:43:35 +0200 Subject: [PATCH 023/362] cancel unreasonable if on inv_waist --- lasy/profiles/longitudinal/gaussian_profile.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index b06ac0db..44ad3c28 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -114,8 +114,6 @@ def evaluate(self, t, x=None, y=None): 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 ) print(inv_complex_waist_2) stretch_factor = ( @@ -124,7 +122,7 @@ def evaluate(self, t, x=None, y=None): * (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) + * (self.phi2 - self.beta**2 * self.k0 * self.z_foc_over_zr)vim c * inv_tau2 ) print(stretch_factor) From cb99b3209b42a9bb2d5088a3250cbc15bd67447d Mon Sep 17 00:00:00 2001 From: huixingjian Date: Fri, 18 Oct 2024 18:45:06 +0200 Subject: [PATCH 024/362] typo --- lasy/profiles/longitudinal/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 44ad3c28..3df9152a 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -122,7 +122,7 @@ def evaluate(self, t, x=None, y=None): * (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)vim c + * (self.phi2 - self.beta**2 * self.k0 * self.z_foc_over_zr) * inv_tau2 ) print(stretch_factor) From a267c3308e3d7c11a872147d512685bc08391172 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 16:46:19 +0000 Subject: [PATCH 025/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/longitudinal/gaussian_profile.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 3df9152a..25bbea3d 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -111,9 +111,8 @@ def evaluate(self, t, x=None, y=None): specified points. This array has the same shape as the array t. """ inv_tau2 = self.tau ** (-2) - inv_complex_waist_2 = ( - 1.0 - / (self.w0**2 * (1.0 + 2.0j * self.z_foc_over_zr / (self.k0 * self.w0**2))) + inv_complex_waist_2 = 1.0 / ( + self.w0**2 * (1.0 + 2.0j * self.z_foc_over_zr / (self.k0 * self.w0**2)) ) print(inv_complex_waist_2) stretch_factor = ( From 8e7b6148193b5d48d61c6ee88a2bfcd27ba4d2ac Mon Sep 17 00:00:00 2001 From: huixingjian Date: Fri, 18 Oct 2024 20:09:13 +0200 Subject: [PATCH 026/362] upadte get_STC for zeta and beta --- .../profiles/longitudinal/gaussian_profile.py | 5 +-- lasy/utils/laser_utils.py | 33 ++++++++++++++++++- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 3df9152a..f22b0b3d 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -92,7 +92,7 @@ def __init__( ), "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, t, x=None, y=None): + def evaluate(self, t, x=0, y=0): """ Return the longitudinal envelope. @@ -115,7 +115,6 @@ def evaluate(self, t, x=None, y=None): 1.0 / (self.w0**2 * (1.0 + 2.0j * self.z_foc_over_zr / (self.k0 * self.w0**2))) ) - print(inv_complex_waist_2) stretch_factor = ( 1 + 4.0 @@ -125,7 +124,6 @@ def evaluate(self, t, x=None, y=None): * (self.phi2 - self.beta**2 * self.k0 * self.z_foc_over_zr) * inv_tau2 ) - print(stretch_factor) stc_exponent = ( 1.0 / stretch_factor @@ -143,7 +141,6 @@ def evaluate(self, t, x=None, y=None): ) ** 2 ) - print(stc_exponent) envelope = np.exp( -stc_exponent + 1.0j * (self.cep_phase + self.omega0 * (t - self.t_peak)) ) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 9c19d7f7..f126481c 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -886,4 +886,35 @@ def get_STC(laser, dim, tau, w0): env_abs[:, :, : env_abs.shape[2] - 2] ) phi2 = np.max(np.roots([4 * temp_chirp, -4, tau**4 * temp_chirp])) - return [temp_chirp, phi2] + #calculate zeta + if dim == 'rt': + pphi_pzpr = (np.diff(pphi_pz, axis=1))/ laser.grid.dx[0] + nu = np.sum(pphi_pzpr * env_abs[:,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) / \ + np.sum(env_abs[:,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) + stc_theta = 0 + pft = 0 + if dim == 'xyt': + pphi_pzpy = (np.diff(pphi_pz, axis=1))/ laser.grid.dx[1] + pphi_pzpx = (np.diff(pphi_pz, axis=0))/ laser.grid.dx[0] + theta = np.arctan2(pphi_pzpy[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:], pphi_pzpx[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:]) + stc_theta = np.sum(theta * env_abs[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) / \ + np.sum(env_abs[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) + pphi_pzpr = (pphi_pzpy[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:]**2+pphi_pzpx[::env_abs.shape[0]-1,:env_abs.shape[1]-1,:]**2)**0.5 + nu = np.sum(pphi_pzpr * env_abs[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) / \ + np.sum(env_abs[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) + #calculate beta + index_array = np.mgrid[0:env.shape[0], 0:env.shape[1],0:env.shape[2]][1] + centroids = np.sum(index_array * env_abs, axis=2) / np.sum(env_abs, axis=2) + z_centroids= laser.grid.axes[-1][centroids.astype(int)] + weight = np.mean(env_abs**2, axis = 2) + derivative_x = np.gradient(z_centroids) / laser.grid.dx[0] + derivative_y = np.gradient(z_centroids) / laser.grid.dx[1] + k0= 2*scc.pi/0.6e-6 + pft_x=(np.sum(derivative_x * weight) / np.sum(weight)) + pft_y=(np.sum(derivative_x * weight) / np.sum(weight)) + beta_x= pft_x/k0/scc.c + beta_y= pft_y/k0/scc.c + + zeta= np.min(np.roots([4 * nu , -4, nu * w0**2 * tau**2])) + + return [temp_chirp, phi2], [nu, zeta,stc_theta] From dd908de849a9690a6515c4301f80a21c99d2b670 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Fri, 18 Oct 2024 20:09:56 +0200 Subject: [PATCH 027/362] cancel debug print --- lasy/profiles/longitudinal/gaussian_profile.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index f767cf71..a875e221 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -143,6 +143,4 @@ def evaluate(self, t, x=0, y=0): envelope = np.exp( -stc_exponent + 1.0j * (self.cep_phase + self.omega0 * (t - self.t_peak)) ) - print("longitudinal field evaluate sucessfully and the imag part is \n") - print(envelope.imag) return envelope From 4178f4e101251710fb0b0c5d4adbfb07a6151033 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 18:10:14 +0000 Subject: [PATCH 028/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 73 +++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 25 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index f126481c..fbb4db2a 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -886,35 +886,58 @@ def get_STC(laser, dim, tau, w0): env_abs[:, :, : env_abs.shape[2] - 2] ) phi2 = np.max(np.roots([4 * temp_chirp, -4, tau**4 * temp_chirp])) - #calculate zeta - if dim == 'rt': - pphi_pzpr = (np.diff(pphi_pz, axis=1))/ laser.grid.dx[0] - nu = np.sum(pphi_pzpr * env_abs[:,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) / \ - np.sum(env_abs[:,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) + # calculate zeta + if dim == "rt": + pphi_pzpr = (np.diff(pphi_pz, axis=1)) / laser.grid.dx[0] + nu = np.sum( + pphi_pzpr * env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1] + ) / np.sum(env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1]) stc_theta = 0 pft = 0 - if dim == 'xyt': - pphi_pzpy = (np.diff(pphi_pz, axis=1))/ laser.grid.dx[1] - pphi_pzpx = (np.diff(pphi_pz, axis=0))/ laser.grid.dx[0] - theta = np.arctan2(pphi_pzpy[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:], pphi_pzpx[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:]) - stc_theta = np.sum(theta * env_abs[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) / \ - np.sum(env_abs[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) - pphi_pzpr = (pphi_pzpy[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:]**2+pphi_pzpx[::env_abs.shape[0]-1,:env_abs.shape[1]-1,:]**2)**0.5 - nu = np.sum(pphi_pzpr * env_abs[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) / \ - np.sum(env_abs[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) - #calculate beta - index_array = np.mgrid[0:env.shape[0], 0:env.shape[1],0:env.shape[2]][1] + if dim == "xyt": + pphi_pzpy = (np.diff(pphi_pz, axis=1)) / laser.grid.dx[1] + pphi_pzpx = (np.diff(pphi_pz, axis=0)) / laser.grid.dx[0] + theta = np.arctan2( + pphi_pzpy[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :], + pphi_pzpx[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :], + ) + stc_theta = np.sum( + theta + * env_abs[ + : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 + ] + ) / np.sum( + env_abs[ + : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 + ] + ) + pphi_pzpr = ( + pphi_pzpy[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :] ** 2 + + pphi_pzpx[:: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :] ** 2 + ) ** 0.5 + nu = np.sum( + pphi_pzpr + * env_abs[ + : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 + ] + ) / np.sum( + env_abs[ + : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 + ] + ) + # calculate beta + index_array = np.mgrid[0 : env.shape[0], 0 : env.shape[1], 0 : env.shape[2]][1] centroids = np.sum(index_array * env_abs, axis=2) / np.sum(env_abs, axis=2) - z_centroids= laser.grid.axes[-1][centroids.astype(int)] - weight = np.mean(env_abs**2, axis = 2) + z_centroids = laser.grid.axes[-1][centroids.astype(int)] + weight = np.mean(env_abs**2, axis=2) derivative_x = np.gradient(z_centroids) / laser.grid.dx[0] derivative_y = np.gradient(z_centroids) / laser.grid.dx[1] - k0= 2*scc.pi/0.6e-6 - pft_x=(np.sum(derivative_x * weight) / np.sum(weight)) - pft_y=(np.sum(derivative_x * weight) / np.sum(weight)) - beta_x= pft_x/k0/scc.c - beta_y= pft_y/k0/scc.c + k0 = 2 * scc.pi / 0.6e-6 + pft_x = np.sum(derivative_x * weight) / np.sum(weight) + pft_y = np.sum(derivative_x * weight) / np.sum(weight) + beta_x = pft_x / k0 / scc.c + beta_y = pft_y / k0 / scc.c - zeta= np.min(np.roots([4 * nu , -4, nu * w0**2 * tau**2])) + zeta = np.min(np.roots([4 * nu, -4, nu * w0**2 * tau**2])) - return [temp_chirp, phi2], [nu, zeta,stc_theta] + return [temp_chirp, phi2], [nu, zeta, stc_theta] From fc5c3c83d7441c1a2ea80ec1ebf83875064ec388 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Fri, 18 Oct 2024 21:36:24 +0200 Subject: [PATCH 029/362] finish get_STC --- lasy/utils/laser_utils.py | 67 +++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index f126481c..4148e476 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -875,46 +875,71 @@ def import_from_z(dim, grid, omega0, field_z, z_axis, z0=0.0, t0=0.0, backend="N grid.set_temporal_field(field) -def get_STC(laser, dim, tau, w0): - env = laser.grid.get_temporal_field() +def get_STC(dim, grid, tau, w0, k0): + """ + Calculate the spatio-temperal coupling factors of the laser. + + Parameters + ---------- + laser: + dim : string + Dimensionality of the array. Options are: + - 'xyt': The laser pulse is represented on a 3D grid: + Cartesian (x,y) transversely, and temporal (t) longitudinally. + - 'rt' : The laser pulse is represented on a 2D grid: + Cylindrical (r) transversely, and temporal (t) longitudinally. + + grid : a Grid object. + It contains an ndarray (V/m) with + the value of the envelope field and the associated metadata + that defines the points at which the laser is defined. + + tau : scalar + Duration of the laser pulse in s. + + w0 : scalar + Waist of laser in m. + + k0 : scalar + Wavenumber of the field + """ + env = grid.get_temporal_field() env_abs = np.abs(env) phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) - pphi_pz = (np.diff(phi_envelop, axis=2)) / (laser.grid.dx[-1]) + pphi_pz = (np.diff(phi_envelop, axis=2)) / (grid.dx[-1]) # calculate phi2 - pphi_pz2 = (np.diff(pphi_pz, axis=2)) / (laser.grid.dx[-1]) + pphi_pz2 = (np.diff(pphi_pz, axis=2)) / (grid.dx[-1]) temp_chirp = np.sum(pphi_pz2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( env_abs[:, :, : env_abs.shape[2] - 2] ) phi2 = np.max(np.roots([4 * temp_chirp, -4, tau**4 * temp_chirp])) #calculate zeta if dim == 'rt': - pphi_pzpr = (np.diff(pphi_pz, axis=1))/ laser.grid.dx[0] + pphi_pzpr = (np.diff(pphi_pz, axis=1))/ grid.dx[0] nu = np.sum(pphi_pzpr * env_abs[:,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) / \ np.sum(env_abs[:,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) - stc_theta = 0 - pft = 0 + stc_theta_zeta = 0 + beta = 0 + pft_x=pft_y=0 + stc_theta_beta = 0 if dim == 'xyt': - pphi_pzpy = (np.diff(pphi_pz, axis=1))/ laser.grid.dx[1] - pphi_pzpx = (np.diff(pphi_pz, axis=0))/ laser.grid.dx[0] + pphi_pzpy = (np.diff(pphi_pz, axis=1))/ grid.dx[1] + pphi_pzpx = (np.diff(pphi_pz, axis=0))/ grid.dx[0] theta = np.arctan2(pphi_pzpy[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:], pphi_pzpx[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:]) - stc_theta = np.sum(theta * env_abs[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) / \ + stc_theta_zeta = np.sum(theta * env_abs[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) / \ np.sum(env_abs[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) pphi_pzpr = (pphi_pzpy[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:]**2+pphi_pzpx[::env_abs.shape[0]-1,:env_abs.shape[1]-1,:]**2)**0.5 nu = np.sum(pphi_pzpr * env_abs[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) / \ np.sum(env_abs[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) #calculate beta - index_array = np.mgrid[0:env.shape[0], 0:env.shape[1],0:env.shape[2]][1] - centroids = np.sum(index_array * env_abs, axis=2) / np.sum(env_abs, axis=2) - z_centroids= laser.grid.axes[-1][centroids.astype(int)] + z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) weight = np.mean(env_abs**2, axis = 2) - derivative_x = np.gradient(z_centroids) / laser.grid.dx[0] - derivative_y = np.gradient(z_centroids) / laser.grid.dx[1] - k0= 2*scc.pi/0.6e-6 + derivative_x = np.gradient(z_centroids,axis=0) / grid.dx[0] + derivative_y = np.gradient(z_centroids,axis=1) / grid.dx[1] pft_x=(np.sum(derivative_x * weight) / np.sum(weight)) - pft_y=(np.sum(derivative_x * weight) / np.sum(weight)) - beta_x= pft_x/k0/scc.c - beta_y= pft_y/k0/scc.c + pft_y=(np.sum(derivative_y * weight) / np.sum(weight)) + stc_theta_beta=np.arctan2(pft_y,pft_x) + beta = (np.sqrt((pft_x**2 + pft_y**2)) -temp_chirp*nu)/ k0 zeta= np.min(np.roots([4 * nu , -4, nu * w0**2 * tau**2])) - - return [temp_chirp, phi2], [nu, zeta,stc_theta] + return [temp_chirp, phi2], [nu, zeta,stc_theta_zeta], [beta, np.sqrt((pft_x**2 + pft_y**2)), stc_theta_beta] From 8b0e8d6016ee7d3616d1d0e9659d7d67af36ea64 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 19:37:51 +0000 Subject: [PATCH 030/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 80 ++++++++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 27 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index a343dbc6..33d7db5a 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -913,34 +913,60 @@ def get_STC(dim, grid, tau, w0, k0): env_abs[:, :, : env_abs.shape[2] - 2] ) phi2 = np.max(np.roots([4 * temp_chirp, -4, tau**4 * temp_chirp])) - #calculate zeta - if dim == 'rt': - pphi_pzpr = (np.diff(pphi_pz, axis=1))/ grid.dx[0] - nu = np.sum(pphi_pzpr * env_abs[:,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) / \ - np.sum(env_abs[:,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) + # calculate zeta + if dim == "rt": + pphi_pzpr = (np.diff(pphi_pz, axis=1)) / grid.dx[0] + nu = np.sum( + pphi_pzpr * env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1] + ) / np.sum(env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1]) stc_theta_zeta = 0 beta = 0 - pft_x=pft_y=0 + pft_x = pft_y = 0 stc_theta_beta = 0 - if dim == 'xyt': - pphi_pzpy = (np.diff(pphi_pz, axis=1))/ grid.dx[1] - pphi_pzpx = (np.diff(pphi_pz, axis=0))/ grid.dx[0] - theta = np.arctan2(pphi_pzpy[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:], pphi_pzpx[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:]) - stc_theta_zeta = np.sum(theta * env_abs[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) / \ - np.sum(env_abs[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) - pphi_pzpr = (pphi_pzpy[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:]**2+pphi_pzpx[::env_abs.shape[0]-1,:env_abs.shape[1]-1,:]**2)**0.5 - nu = np.sum(pphi_pzpr * env_abs[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) / \ - np.sum(env_abs[:env_abs.shape[0]-1,:env_abs.shape[1]-1,:env_abs.shape[2]-1]) - #calculate beta + if dim == "xyt": + pphi_pzpy = (np.diff(pphi_pz, axis=1)) / grid.dx[1] + pphi_pzpx = (np.diff(pphi_pz, axis=0)) / grid.dx[0] + theta = np.arctan2( + pphi_pzpy[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :], + pphi_pzpx[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :], + ) + stc_theta_zeta = np.sum( + theta + * env_abs[ + : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 + ] + ) / np.sum( + env_abs[ + : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 + ] + ) + pphi_pzpr = ( + pphi_pzpy[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :] ** 2 + + pphi_pzpx[:: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :] ** 2 + ) ** 0.5 + nu = np.sum( + pphi_pzpr + * env_abs[ + : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 + ] + ) / np.sum( + env_abs[ + : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 + ] + ) + # calculate beta z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) - weight = np.mean(env_abs**2, axis = 2) - derivative_x = np.gradient(z_centroids,axis=0) / grid.dx[0] - derivative_y = np.gradient(z_centroids,axis=1) / grid.dx[1] - pft_x=(np.sum(derivative_x * weight) / np.sum(weight)) - pft_y=(np.sum(derivative_y * weight) / np.sum(weight)) - stc_theta_beta=np.arctan2(pft_y,pft_x) - beta = (np.sqrt((pft_x**2 + pft_y**2)) -temp_chirp*nu)/ k0 - - zeta= np.min(np.roots([4 * nu , -4, nu * w0**2 * tau**2])) - return [temp_chirp, phi2], [nu, zeta,stc_theta_zeta], [beta, np.sqrt((pft_x**2 + pft_y**2)), stc_theta_beta] - + weight = np.mean(env_abs**2, axis=2) + derivative_x = np.gradient(z_centroids, axis=0) / grid.dx[0] + derivative_y = np.gradient(z_centroids, axis=1) / grid.dx[1] + pft_x = np.sum(derivative_x * weight) / np.sum(weight) + pft_y = np.sum(derivative_y * weight) / np.sum(weight) + stc_theta_beta = np.arctan2(pft_y, pft_x) + beta = (np.sqrt((pft_x**2 + pft_y**2)) - temp_chirp * nu) / k0 + + zeta = np.min(np.roots([4 * nu, -4, nu * w0**2 * tau**2])) + return ( + [temp_chirp, phi2], + [nu, zeta, stc_theta_zeta], + [beta, np.sqrt((pft_x**2 + pft_y**2)), stc_theta_beta], + ) From b5bf12600fb49e6c1cc44d1132048bbc345b2817 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Fri, 18 Oct 2024 21:51:23 +0200 Subject: [PATCH 031/362] upadte the comments of the functions --- lasy/profiles/longitudinal/gaussian_profile.py | 3 +++ lasy/utils/laser_utils.py | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index a875e221..a76cb9b3 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -60,6 +60,9 @@ class GaussianLongitudinalProfile(LongitudinalProfile): w0 : float (in meter), necessary if beta is not 0 The waist of the laser pulse. + + All those above STC units and definiations are taken from `S. Akturk + et al., Optics Express 12, 4399 (2004) `__. """ def __init__( diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 33d7db5a..3317fc33 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -902,6 +902,15 @@ def get_STC(dim, grid, tau, w0, k0): k0 : scalar Wavenumber of the field + + Return value + ---------- + [temperal_chirp,phi2] Group-delayed dispersion in :math:`\Phi^{(2)}=d(\omega_0)/dt` and :math:`\phi^{(2)}=dt_0/d(\omega) ` + [nu, zeta, stc_theta_zeta] Spatio-chirp in :math:`\nu=d(\omega_0)/dx` and `\zeta=dx_0/d(\omega_0)`, stc_theta_zeta refers to + the direction of the linear spatial chirp on xoy plane in rad (0 is along x) + [beta, pft, stc_theta_beta] Angular dispersion in :math:` \beta = d\theta_0/d\omega`, and pulse front tilt in :math:` p=dt/dx`, + stc_theta_beta refers to the direction of the linear angular chirp on xoy plane in rad (0 is along x) + All those above units and definiations are taken from `S. Akturk et al., Optics Express 12, 4399 (2004) `__. """ env = grid.get_temporal_field() env_abs = np.abs(env) @@ -961,12 +970,12 @@ def get_STC(dim, grid, tau, w0, k0): derivative_y = np.gradient(z_centroids, axis=1) / grid.dx[1] pft_x = np.sum(derivative_x * weight) / np.sum(weight) pft_y = np.sum(derivative_y * weight) / np.sum(weight) + pft = np.sqrt((pft_x**2 + pft_y**2)) stc_theta_beta = np.arctan2(pft_y, pft_x) beta = (np.sqrt((pft_x**2 + pft_y**2)) - temp_chirp * nu) / k0 - zeta = np.min(np.roots([4 * nu, -4, nu * w0**2 * tau**2])) return ( [temp_chirp, phi2], [nu, zeta, stc_theta_zeta], - [beta, np.sqrt((pft_x**2 + pft_y**2)), stc_theta_beta], + [beta,pft, stc_theta_beta], ) From 1035d8666df8dcc4e2185fa8434fbda06d18c306 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 19:51:55 +0000 Subject: [PATCH 032/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- 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 3317fc33..cd88b585 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -977,5 +977,5 @@ def get_STC(dim, grid, tau, w0, k0): return ( [temp_chirp, phi2], [nu, zeta, stc_theta_zeta], - [beta,pft, stc_theta_beta], + [beta, pft, stc_theta_beta], ) From 3bec6328166b97ac82aed422c4ff138e1f237700 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Fri, 18 Oct 2024 21:56:22 +0200 Subject: [PATCH 033/362] update the comment --- lasy/utils/laser_utils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 3317fc33..516b7235 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -916,25 +916,27 @@ def get_STC(dim, grid, tau, w0, k0): env_abs = np.abs(env) phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pz = (np.diff(phi_envelop, axis=2)) / (grid.dx[-1]) - # calculate phi2 + # Calculate goup-delayed dispersion pphi_pz2 = (np.diff(pphi_pz, axis=2)) / (grid.dx[-1]) temp_chirp = np.sum(pphi_pz2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( env_abs[:, :, : env_abs.shape[2] - 2] ) phi2 = np.max(np.roots([4 * temp_chirp, -4, tau**4 * temp_chirp])) - # calculate zeta + # Calculate spatio- and angular dispersion if dim == "rt": pphi_pzpr = (np.diff(pphi_pz, axis=1)) / grid.dx[0] nu = np.sum( pphi_pzpr * env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1] ) / np.sum(env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1]) + # No angular dispersion in 2D and the direction of spatio-chirp is certain stc_theta_zeta = 0 beta = 0 - pft_x = pft_y = 0 + pft = 0 stc_theta_beta = 0 if dim == "xyt": pphi_pzpy = (np.diff(pphi_pz, axis=1)) / grid.dx[1] pphi_pzpx = (np.diff(pphi_pz, axis=0)) / grid.dx[0] + # Calculate the STC angle in XOY for spatio coupling theta = np.arctan2( pphi_pzpy[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :], pphi_pzpx[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :], @@ -963,7 +965,7 @@ def get_STC(dim, grid, tau, w0, k0): : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 ] ) - # calculate beta + # calculate anglur dispersion and pulse front tilt z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) weight = np.mean(env_abs**2, axis=2) derivative_x = np.gradient(z_centroids, axis=0) / grid.dx[0] @@ -973,6 +975,7 @@ def get_STC(dim, grid, tau, w0, k0): pft = np.sqrt((pft_x**2 + pft_y**2)) stc_theta_beta = np.arctan2(pft_y, pft_x) beta = (np.sqrt((pft_x**2 + pft_y**2)) - temp_chirp * nu) / k0 + #Transfer the unit from nu to zeta zeta = np.min(np.roots([4 * nu, -4, nu * w0**2 * tau**2])) return ( [temp_chirp, phi2], From 9d7d6bf83c03d770c572002a01423dd25b210c5a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 19:56:58 +0000 Subject: [PATCH 034/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- 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 63a2b043..6998f94c 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -975,7 +975,7 @@ def get_STC(dim, grid, tau, w0, k0): pft = np.sqrt((pft_x**2 + pft_y**2)) stc_theta_beta = np.arctan2(pft_y, pft_x) beta = (np.sqrt((pft_x**2 + pft_y**2)) - temp_chirp * nu) / k0 - #Transfer the unit from nu to zeta + # Transfer the unit from nu to zeta zeta = np.min(np.roots([4 * nu, -4, nu * w0**2 * tau**2])) return ( [temp_chirp, phi2], From 70dffcd6a40ca63fef180e2e1e7c9f1332bc0246 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:01:50 +0200 Subject: [PATCH 035/362] Update longitudinal_profile.py --- lasy/profiles/longitudinal/longitudinal_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/longitudinal/longitudinal_profile.py b/lasy/profiles/longitudinal/longitudinal_profile.py index 767ffbcd..591234c2 100644 --- a/lasy/profiles/longitudinal/longitudinal_profile.py +++ b/lasy/profiles/longitudinal/longitudinal_profile.py @@ -15,7 +15,7 @@ def __init__(self, wavelength): self.omega0 = 2 * pi * c / self.lambda0 self.k0 = 2.0 * pi / wavelength - def evaluate(self, t): + def evaluate(self, t, x=0, y=0): """ Return the longitudinal envelope. From 6fb52a8fcf284b19e49ca38d67de60706eda7495 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Fri, 18 Oct 2024 22:05:29 +0200 Subject: [PATCH 036/362] fix auto-check error --- lasy/utils/laser_utils.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 63a2b043..66449f15 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -928,11 +928,14 @@ def get_STC(dim, grid, tau, w0, k0): nu = np.sum( pphi_pzpr * env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1] ) / np.sum(env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1]) + #Transfer the unit from nu to zeta + zeta = np.min(np.roots([4 * nu, -4, nu * w0**2 * tau**2])) # No angular dispersion in 2D and the direction of spatio-chirp is certain - stc_theta_zeta = 0 - beta = 0 - pft = 0 - stc_theta_beta = 0 + return ( + [temp_chirp, phi2], + [nu, zeta, stc_theta_zeta = 0], + [beta = 0, pft = 0,stc_theta_beta = 0], + ) if dim == "xyt": pphi_pzpy = (np.diff(pphi_pz, axis=1)) / grid.dx[1] pphi_pzpx = (np.diff(pphi_pz, axis=0)) / grid.dx[0] @@ -975,9 +978,8 @@ def get_STC(dim, grid, tau, w0, k0): pft = np.sqrt((pft_x**2 + pft_y**2)) stc_theta_beta = np.arctan2(pft_y, pft_x) beta = (np.sqrt((pft_x**2 + pft_y**2)) - temp_chirp * nu) / k0 - #Transfer the unit from nu to zeta - zeta = np.min(np.roots([4 * nu, -4, nu * w0**2 * tau**2])) - return ( + zeta = np.min(np.roots([4 * nu, -4, nu * w0**2 * tau**2])) + return ( [temp_chirp, phi2], [nu, zeta, stc_theta_zeta], [beta, pft, stc_theta_beta], From 9a7edc18a7e8c66e0f2d0d4c3f58dbef4d0ee50d Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:11:12 +0200 Subject: [PATCH 037/362] 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 66449f15..adb8ef88 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -983,4 +983,4 @@ def get_STC(dim, grid, tau, w0, k0): [temp_chirp, phi2], [nu, zeta, stc_theta_zeta], [beta, pft, stc_theta_beta], - ) + ) From ce26fdd7f202222f99a2346b2fb055554d9f34a1 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:26:01 +0200 Subject: [PATCH 038/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 68 +++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index adb8ef88..92ecab09 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -903,39 +903,54 @@ def get_STC(dim, grid, tau, w0, k0): k0 : scalar Wavenumber of the field - Return value + Return ---------- - [temperal_chirp,phi2] Group-delayed dispersion in :math:`\Phi^{(2)}=d(\omega_0)/dt` and :math:`\phi^{(2)}=dt_0/d(\omega) ` - [nu, zeta, stc_theta_zeta] Spatio-chirp in :math:`\nu=d(\omega_0)/dx` and `\zeta=dx_0/d(\omega_0)`, stc_theta_zeta refers to - the direction of the linear spatial chirp on xoy plane in rad (0 is along x) - [beta, pft, stc_theta_beta] Angular dispersion in :math:` \beta = d\theta_0/d\omega`, and pulse front tilt in :math:` p=dt/dx`, - stc_theta_beta refers to the direction of the linear angular chirp on xoy plane in rad (0 is along x) - All those above units and definiations are taken from `S. Akturk et al., Optics Express 12, 4399 (2004) `__. + STC_fac : dict of floats + A dictionary of floats corresponding to the STC factors. The keys are: + Phi2: Group-delayed dispersion in :math:`\Phi^{(2)}=d(\omega_0)/dt` + phi2: Group-delayed dispersion in :math:`\phi^{(2)}=dt_0/d(\omega)` + nu: Spatio-chirp in :math:`\nu=d(\omega_0)/dx` + zeta: Spatio-chirp in :math:`\zeta=dx_0/d(\omega_0)` + stc_theta_zeta: The direction of the linear spatial chirp on xoy plane\ + in rad (0 is along x) + beta: Angular dispersion in :math:` \beta = d\theta_0/d\omega` + pft: Pulse front tilt in :math:` p=dt/dx` + stc_theta_beta: The direction of the linear angular chirp on xoy plane\ + in rad (0 is along x) + All those above units and definiations are taken from `S. Akturk et al., Optics\ + Express 12, 4399 (2004) `__. """ + #Initialise the returned dictional + STC_fac = { + 'Phi2': 0, + 'phi2': 0, + 'nu': 0, + 'zeta': 0, + 'stc_theta_zeta': 0, + 'beta': 0, + 'pft': 0, + 'stc_theta_beta': 0 + } env = grid.get_temporal_field() env_abs = np.abs(env) phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pz = (np.diff(phi_envelop, axis=2)) / (grid.dx[-1]) # Calculate goup-delayed dispersion pphi_pz2 = (np.diff(pphi_pz, axis=2)) / (grid.dx[-1]) - temp_chirp = np.sum(pphi_pz2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( + STC_fac['Phi2'] = np.sum(pphi_pz2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( env_abs[:, :, : env_abs.shape[2] - 2] ) - phi2 = np.max(np.roots([4 * temp_chirp, -4, tau**4 * temp_chirp])) + STC_fac['phi2'] = np.max(np.roots([4 * Phi2, -4, tau**4 * Phi2])) # Calculate spatio- and angular dispersion if dim == "rt": pphi_pzpr = (np.diff(pphi_pz, axis=1)) / grid.dx[0] - nu = np.sum( + STC_fac['nu'] = np.sum( pphi_pzpr * env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1] ) / np.sum(env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1]) #Transfer the unit from nu to zeta - zeta = np.min(np.roots([4 * nu, -4, nu * w0**2 * tau**2])) + STC_fac['zeta'] = np.min(np.roots([4 * nu, -4, nu * w0**2 * tau**2])) # No angular dispersion in 2D and the direction of spatio-chirp is certain - return ( - [temp_chirp, phi2], - [nu, zeta, stc_theta_zeta = 0], - [beta = 0, pft = 0,stc_theta_beta = 0], - ) + return STC_fac if dim == "xyt": pphi_pzpy = (np.diff(pphi_pz, axis=1)) / grid.dx[1] pphi_pzpx = (np.diff(pphi_pz, axis=0)) / grid.dx[0] @@ -944,7 +959,7 @@ def get_STC(dim, grid, tau, w0, k0): pphi_pzpy[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :], pphi_pzpx[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :], ) - stc_theta_zeta = np.sum( + STC_fac['stc_theta_zeta'] = np.sum( theta * env_abs[ : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 @@ -958,7 +973,7 @@ def get_STC(dim, grid, tau, w0, k0): pphi_pzpy[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :] ** 2 + pphi_pzpx[:: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :] ** 2 ) ** 0.5 - nu = np.sum( + STC_fac['nu'] = np.sum( pphi_pzpr * env_abs[ : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 @@ -968,19 +983,16 @@ def get_STC(dim, grid, tau, w0, k0): : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 ] ) - # calculate anglur dispersion and pulse front tilt + STC_fac['zeta'] = np.min(np.roots([4 * nu, -4, nu * w0**2 * tau**2])) + # calculate angular dispersion and pulse front tilt z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) weight = np.mean(env_abs**2, axis=2) derivative_x = np.gradient(z_centroids, axis=0) / grid.dx[0] derivative_y = np.gradient(z_centroids, axis=1) / grid.dx[1] pft_x = np.sum(derivative_x * weight) / np.sum(weight) pft_y = np.sum(derivative_y * weight) / np.sum(weight) - pft = np.sqrt((pft_x**2 + pft_y**2)) - stc_theta_beta = np.arctan2(pft_y, pft_x) - beta = (np.sqrt((pft_x**2 + pft_y**2)) - temp_chirp * nu) / k0 - zeta = np.min(np.roots([4 * nu, -4, nu * w0**2 * tau**2])) - return ( - [temp_chirp, phi2], - [nu, zeta, stc_theta_zeta], - [beta, pft, stc_theta_beta], - ) + STC_fac['pft'] = np.sqrt((pft_x**2 + pft_y**2)) + STC_fac['stc_theta_beta'] = np.arctan2(pft_y, pft_x) + STC_fac['beta'] = (np.sqrt((pft_x**2 + pft_y**2)) - temp_chirp * nu) / k0 + + return STC_fac From 633c324ba9f4ac909cc1c0c6d44afc1ad4f02a63 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 20:26:13 +0000 Subject: [PATCH 039/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 92ecab09..93859fc7 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -907,8 +907,8 @@ def get_STC(dim, grid, tau, w0, k0): ---------- STC_fac : dict of floats A dictionary of floats corresponding to the STC factors. The keys are: - Phi2: Group-delayed dispersion in :math:`\Phi^{(2)}=d(\omega_0)/dt` - phi2: Group-delayed dispersion in :math:`\phi^{(2)}=dt_0/d(\omega)` + Phi2: Group-delayed dispersion in :math:`\Phi^{(2)}=d(\omega_0)/dt` + phi2: Group-delayed dispersion in :math:`\phi^{(2)}=dt_0/d(\omega)` nu: Spatio-chirp in :math:`\nu=d(\omega_0)/dx` zeta: Spatio-chirp in :math:`\zeta=dx_0/d(\omega_0)` stc_theta_zeta: The direction of the linear spatial chirp on xoy plane\ @@ -930,7 +930,7 @@ def get_STC(dim, grid, tau, w0, k0): 'beta': 0, 'pft': 0, 'stc_theta_beta': 0 - } + } env = grid.get_temporal_field() env_abs = np.abs(env) phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) @@ -994,5 +994,5 @@ def get_STC(dim, grid, tau, w0, k0): STC_fac['pft'] = np.sqrt((pft_x**2 + pft_y**2)) STC_fac['stc_theta_beta'] = np.arctan2(pft_y, pft_x) STC_fac['beta'] = (np.sqrt((pft_x**2 + pft_y**2)) - temp_chirp * nu) / k0 - + return STC_fac From 6fb6078766c397e8dca8883e3c4058ffa7860a9c Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:26:37 +0200 Subject: [PATCH 040/362] 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 93859fc7..77cd0f2f 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -920,7 +920,7 @@ def get_STC(dim, grid, tau, w0, k0): All those above units and definiations are taken from `S. Akturk et al., Optics\ Express 12, 4399 (2004) `__. """ - #Initialise the returned dictional + #Initialise the returned dictionary STC_fac = { 'Phi2': 0, 'phi2': 0, From 25fe152b7c69761052388fb0331fff4e216cded9 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:27:07 +0200 Subject: [PATCH 041/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 77cd0f2f..1d2be898 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -994,5 +994,4 @@ def get_STC(dim, grid, tau, w0, k0): STC_fac['pft'] = np.sqrt((pft_x**2 + pft_y**2)) STC_fac['stc_theta_beta'] = np.arctan2(pft_y, pft_x) STC_fac['beta'] = (np.sqrt((pft_x**2 + pft_y**2)) - temp_chirp * nu) / k0 - return STC_fac From d595d2dba25207dc781dda92c6e3c78ff81a9e5b Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:30:27 +0200 Subject: [PATCH 042/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 1d2be898..009ff875 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -921,15 +921,15 @@ def get_STC(dim, grid, tau, w0, k0): Express 12, 4399 (2004) `__. """ #Initialise the returned dictionary - STC_fac = { - 'Phi2': 0, - 'phi2': 0, - 'nu': 0, - 'zeta': 0, - 'stc_theta_zeta': 0, - 'beta': 0, - 'pft': 0, - 'stc_theta_beta': 0 + STC_fac = { + 'Phi2': 0, + 'phi2': 0, + 'nu': 0, + 'zeta': 0, + 'stc_theta_zeta': 0, + 'beta': 0, + 'pft': 0, + 'stc_theta_beta': 0 } env = grid.get_temporal_field() env_abs = np.abs(env) From 87c0b5e6c35b526bfa5b097475abf36238027a07 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 20:30:43 +0000 Subject: [PATCH 043/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 40 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 009ff875..38d7b063 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -920,16 +920,16 @@ def get_STC(dim, grid, tau, w0, k0): All those above units and definiations are taken from `S. Akturk et al., Optics\ Express 12, 4399 (2004) `__. """ - #Initialise the returned dictionary + # Initialise the returned dictionary STC_fac = { - 'Phi2': 0, - 'phi2': 0, - 'nu': 0, - 'zeta': 0, - 'stc_theta_zeta': 0, - 'beta': 0, - 'pft': 0, - 'stc_theta_beta': 0 + "Phi2": 0, + "phi2": 0, + "nu": 0, + "zeta": 0, + "stc_theta_zeta": 0, + "beta": 0, + "pft": 0, + "stc_theta_beta": 0, } env = grid.get_temporal_field() env_abs = np.abs(env) @@ -937,18 +937,18 @@ def get_STC(dim, grid, tau, w0, k0): pphi_pz = (np.diff(phi_envelop, axis=2)) / (grid.dx[-1]) # Calculate goup-delayed dispersion pphi_pz2 = (np.diff(pphi_pz, axis=2)) / (grid.dx[-1]) - STC_fac['Phi2'] = np.sum(pphi_pz2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( + STC_fac["Phi2"] = np.sum(pphi_pz2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( env_abs[:, :, : env_abs.shape[2] - 2] ) - STC_fac['phi2'] = np.max(np.roots([4 * Phi2, -4, tau**4 * Phi2])) + STC_fac["phi2"] = np.max(np.roots([4 * Phi2, -4, tau**4 * Phi2])) # Calculate spatio- and angular dispersion if dim == "rt": pphi_pzpr = (np.diff(pphi_pz, axis=1)) / grid.dx[0] - STC_fac['nu'] = np.sum( + STC_fac["nu"] = np.sum( pphi_pzpr * env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1] ) / np.sum(env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1]) - #Transfer the unit from nu to zeta - STC_fac['zeta'] = np.min(np.roots([4 * nu, -4, nu * w0**2 * tau**2])) + # Transfer the unit from nu to zeta + STC_fac["zeta"] = np.min(np.roots([4 * nu, -4, nu * w0**2 * tau**2])) # No angular dispersion in 2D and the direction of spatio-chirp is certain return STC_fac if dim == "xyt": @@ -959,7 +959,7 @@ def get_STC(dim, grid, tau, w0, k0): pphi_pzpy[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :], pphi_pzpx[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :], ) - STC_fac['stc_theta_zeta'] = np.sum( + STC_fac["stc_theta_zeta"] = np.sum( theta * env_abs[ : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 @@ -973,7 +973,7 @@ def get_STC(dim, grid, tau, w0, k0): pphi_pzpy[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :] ** 2 + pphi_pzpx[:: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :] ** 2 ) ** 0.5 - STC_fac['nu'] = np.sum( + STC_fac["nu"] = np.sum( pphi_pzpr * env_abs[ : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 @@ -983,7 +983,7 @@ def get_STC(dim, grid, tau, w0, k0): : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 ] ) - STC_fac['zeta'] = np.min(np.roots([4 * nu, -4, nu * w0**2 * tau**2])) + STC_fac["zeta"] = np.min(np.roots([4 * nu, -4, nu * w0**2 * tau**2])) # calculate angular dispersion and pulse front tilt z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) weight = np.mean(env_abs**2, axis=2) @@ -991,7 +991,7 @@ def get_STC(dim, grid, tau, w0, k0): derivative_y = np.gradient(z_centroids, axis=1) / grid.dx[1] pft_x = np.sum(derivative_x * weight) / np.sum(weight) pft_y = np.sum(derivative_y * weight) / np.sum(weight) - STC_fac['pft'] = np.sqrt((pft_x**2 + pft_y**2)) - STC_fac['stc_theta_beta'] = np.arctan2(pft_y, pft_x) - STC_fac['beta'] = (np.sqrt((pft_x**2 + pft_y**2)) - temp_chirp * nu) / k0 + STC_fac["pft"] = np.sqrt((pft_x**2 + pft_y**2)) + STC_fac["stc_theta_beta"] = np.arctan2(pft_y, pft_x) + STC_fac["beta"] = (np.sqrt((pft_x**2 + pft_y**2)) - temp_chirp * nu) / k0 return STC_fac From be71e13111a3c346a17603a5f0020b002bb736d6 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:36:22 +0200 Subject: [PATCH 044/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 38d7b063..220e291d 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -876,7 +876,7 @@ def import_from_z(dim, grid, omega0, field_z, z_axis, z0=0.0, t0=0.0, backend="N def get_STC(dim, grid, tau, w0, k0): - """ + r""" Calculate the spatio-temperal coupling factors of the laser. Parameters @@ -940,7 +940,7 @@ def get_STC(dim, grid, tau, w0, k0): STC_fac["Phi2"] = np.sum(pphi_pz2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( env_abs[:, :, : env_abs.shape[2] - 2] ) - STC_fac["phi2"] = np.max(np.roots([4 * Phi2, -4, tau**4 * Phi2])) + STC_fac["phi2"] = np.max(np.roots([4 * STC_fac["Phi2"], -4, tau**4 * STC_fac["Phi2"]])) # Calculate spatio- and angular dispersion if dim == "rt": pphi_pzpr = (np.diff(pphi_pz, axis=1)) / grid.dx[0] @@ -948,7 +948,7 @@ def get_STC(dim, grid, tau, w0, k0): pphi_pzpr * env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1] ) / np.sum(env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1]) # Transfer the unit from nu to zeta - STC_fac["zeta"] = np.min(np.roots([4 * nu, -4, nu * w0**2 * tau**2])) + STC_fac["zeta"] = np.min(np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2])) # No angular dispersion in 2D and the direction of spatio-chirp is certain return STC_fac if dim == "xyt": @@ -983,7 +983,7 @@ def get_STC(dim, grid, tau, w0, k0): : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 ] ) - STC_fac["zeta"] = np.min(np.roots([4 * nu, -4, nu * w0**2 * tau**2])) + STC_fac["zeta"] = np.min(np.roots([4 * STC_fac["nu"] , -4, STC_fac["nu"] * w0**2 * tau**2])) # calculate angular dispersion and pulse front tilt z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) weight = np.mean(env_abs**2, axis=2) @@ -993,5 +993,5 @@ def get_STC(dim, grid, tau, w0, k0): pft_y = np.sum(derivative_y * weight) / np.sum(weight) STC_fac["pft"] = np.sqrt((pft_x**2 + pft_y**2)) STC_fac["stc_theta_beta"] = np.arctan2(pft_y, pft_x) - STC_fac["beta"] = (np.sqrt((pft_x**2 + pft_y**2)) - temp_chirp * nu) / k0 + STC_fac["beta"] = (np.sqrt((pft_x**2 + pft_y**2)) - STC_fac["Phi2"] * STC_fac["nu"]) / k0 return STC_fac From 10eb8171ee1b5e958e32f70665d19a4dad49c005 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 20:36:30 +0000 Subject: [PATCH 045/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 220e291d..b1cf5cb6 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -940,7 +940,9 @@ def get_STC(dim, grid, tau, w0, k0): STC_fac["Phi2"] = np.sum(pphi_pz2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( env_abs[:, :, : env_abs.shape[2] - 2] ) - STC_fac["phi2"] = np.max(np.roots([4 * STC_fac["Phi2"], -4, tau**4 * STC_fac["Phi2"]])) + STC_fac["phi2"] = np.max( + np.roots([4 * STC_fac["Phi2"], -4, tau**4 * STC_fac["Phi2"]]) + ) # Calculate spatio- and angular dispersion if dim == "rt": pphi_pzpr = (np.diff(pphi_pz, axis=1)) / grid.dx[0] @@ -948,7 +950,9 @@ def get_STC(dim, grid, tau, w0, k0): pphi_pzpr * env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1] ) / np.sum(env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1]) # Transfer the unit from nu to zeta - STC_fac["zeta"] = np.min(np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2])) + STC_fac["zeta"] = np.min( + np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) + ) # No angular dispersion in 2D and the direction of spatio-chirp is certain return STC_fac if dim == "xyt": @@ -983,7 +987,9 @@ def get_STC(dim, grid, tau, w0, k0): : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 ] ) - STC_fac["zeta"] = np.min(np.roots([4 * STC_fac["nu"] , -4, STC_fac["nu"] * w0**2 * tau**2])) + STC_fac["zeta"] = np.min( + np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) + ) # calculate angular dispersion and pulse front tilt z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) weight = np.mean(env_abs**2, axis=2) @@ -993,5 +999,7 @@ def get_STC(dim, grid, tau, w0, k0): pft_y = np.sum(derivative_y * weight) / np.sum(weight) STC_fac["pft"] = np.sqrt((pft_x**2 + pft_y**2)) STC_fac["stc_theta_beta"] = np.arctan2(pft_y, pft_x) - STC_fac["beta"] = (np.sqrt((pft_x**2 + pft_y**2)) - STC_fac["Phi2"] * STC_fac["nu"]) / k0 + STC_fac["beta"] = ( + np.sqrt((pft_x**2 + pft_y**2)) - STC_fac["Phi2"] * STC_fac["nu"] + ) / k0 return STC_fac From 68cd2b3117cca7a0e2c5847150ec0f72f9522580 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:38:27 +0200 Subject: [PATCH 046/362] Update gaussian_profile.py --- lasy/profiles/longitudinal/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index a76cb9b3..cc1c315f 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -28,7 +28,7 @@ class GaussianLongitudinalProfile(LongitudinalProfile): 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(default '0') + 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). From 08a70606296770e4ac8d2eddbff99eba89c6a194 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:38:48 +0200 Subject: [PATCH 047/362] Update gaussian_profile.py --- lasy/profiles/longitudinal/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index cc1c315f..f50cb000 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -58,7 +58,7 @@ class GaussianLongitudinalProfile(LongitudinalProfile): Position of the focal plane. (The laser pulse is initialized at ``z=0``.) - w0 : float (in meter), necessary if beta is not 0 + w0 : float (in meter), necessary if beta is not 0 The waist of the laser pulse. All those above STC units and definiations are taken from `S. Akturk From 6834e36c34ee65c286eeb7e29139a0316b74645b Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:44:05 +0200 Subject: [PATCH 048/362] Update gaussian_profile.py --- lasy/profiles/longitudinal/gaussian_profile.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index f50cb000..d1ed5d9d 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -35,13 +35,13 @@ class GaussianLongitudinalProfile(LongitudinalProfile): beta : float (in second), optional The angular dispersion parameterized by - .. math:: + .. math:: \beta = \frac{d\theta_0}{d\omega} Here :math:`\theta_0` is the propagation angle of this component. phi2 : float (in second^2), optional (default '0') The group-delay dispertion parameterized by - .. math:: + .. math:: \phi^{(2)} = \frac{dt}{d\omega} zeta : float (in meter * second) optional (defalut '0') @@ -61,8 +61,8 @@ class GaussianLongitudinalProfile(LongitudinalProfile): w0 : float (in meter), necessary if beta is not 0 The waist of the laser pulse. - All those above STC units and definiations are taken from `S. Akturk - et al., Optics Express 12, 4399 (2004) `__. + All those above STC units and definiations are taken from + `S. Akturk et al., Optics Express 12, 4399 (2004) `__. """ def __init__( From 28f45a0270db26b57b3a682d319a251571a0c239 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 20:44:12 +0000 Subject: [PATCH 049/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/longitudinal/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index d1ed5d9d..cb9eab81 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -61,7 +61,7 @@ class GaussianLongitudinalProfile(LongitudinalProfile): w0 : float (in meter), necessary if beta is not 0 The waist of the laser pulse. - All those above STC units and definiations are taken from + All those above STC units and definiations are taken from `S. Akturk et al., Optics Express 12, 4399 (2004) `__. """ From 95c9fa43c9d8300b77d24c6db1455ae0486cf14d Mon Sep 17 00:00:00 2001 From: huixingjian Date: Fri, 18 Oct 2024 22:45:22 +0200 Subject: [PATCH 050/362] fix doc error --- 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 66449f15..1d28d6ee 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -934,7 +934,7 @@ def get_STC(dim, grid, tau, w0, k0): return ( [temp_chirp, phi2], [nu, zeta, stc_theta_zeta = 0], - [beta = 0, pft = 0,stc_theta_beta = 0], + [beta = 0, pft = 0, stc_theta_beta = 0], ) if dim == "xyt": pphi_pzpy = (np.diff(pphi_pz, axis=1)) / grid.dx[1] From 8969358b98d97d74730cfac34898e94d54654286 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:48:05 +0200 Subject: [PATCH 051/362] Update gaussian_profile.py --- lasy/profiles/longitudinal/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index cb9eab81..69b045f1 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -144,6 +144,6 @@ def evaluate(self, t, x=0, y=0): ** 2 ) envelope = np.exp( - -stc_exponent + 1.0j * (self.cep_phase + self.omega0 * (t - self.t_peak)) + -stc_exponent + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) ) return envelope From 19aa383d1b3dd07b61a220bf4cc1e848fbc463cd Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:56:02 +0200 Subject: [PATCH 052/362] Update gaussian_profile.py --- lasy/profiles/longitudinal/gaussian_profile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 69b045f1..0ee8eacd 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -146,4 +146,5 @@ def evaluate(self, t, x=0, y=0): envelope = np.exp( -stc_exponent + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) ) + return envelope From e8303e64614986a83968cf579ecc4eab1ee7eae7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 20:56:09 +0000 Subject: [PATCH 053/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/longitudinal/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 0ee8eacd..dcc3fbc5 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -146,5 +146,5 @@ def evaluate(self, t, x=0, y=0): envelope = np.exp( -stc_exponent + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) ) - + return envelope From 1d16dd16deb3c70c659c46a0f85fdf857aee493a Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 18 Oct 2024 23:12:16 +0200 Subject: [PATCH 054/362] Update gaussian_profile.py --- lasy/profiles/longitudinal/gaussian_profile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index dcc3fbc5..22f8d0a7 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -114,8 +114,9 @@ def evaluate(self, t, x=0, y=0): specified points. This array has the same shape as the array t. """ inv_tau2 = self.tau ** (-2) - inv_complex_waist_2 = 1.0 / ( - self.w0**2 * (1.0 + 2.0j * self.z_foc_over_zr / (self.k0 * self.w0**2)) + 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.w0 else 0 ) stretch_factor = ( 1 From a6625a69f768631c39ffad49510133935fe4f946 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 21:13:19 +0000 Subject: [PATCH 055/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/longitudinal/gaussian_profile.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 22f8d0a7..fd2399f8 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -115,8 +115,10 @@ def evaluate(self, t, x=0, y=0): """ inv_tau2 = self.tau ** (-2) 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.w0 else 0 + 1.0 + / (self.w0**2 * (1.0 + 2.0j * self.z_foc_over_zr / (self.k0 * self.w0**2))) + if self.w0 + else 0 ) stretch_factor = ( 1 From fccc205560bebeda0ca0a38a8979f251d0009dc5 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 00:08:56 +0200 Subject: [PATCH 056/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 26137f74..05ce80cd 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -64,24 +64,26 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): beta : float (in second), optional The angular dispersion parameterized by - .. math:: + .. math:: \beta = \frac{d\theta_0}{d\omega} + Here :math:`\theta_0` is the propagation angle of this component. phi2 : float (in second^2), optional (default '0') The group-delay dispertion parameterized by - .. math:: + .. math:: \phi^{(2)} = \frac{dt}{d\omega} zeta : float (in meter * second) optional (default '0') The spatio-chirp parameterized by - .. math:: + .. math:: \zeta = \frac{x_0}{d\omega} + Here :math:`x_0` is the beam center position. stc_theta : float (in rad) optional (default '0') From c2cb1dd4bbf317cae737886f76dca45ae692d5b9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:09:03 +0000 Subject: [PATCH 057/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 05ce80cd..bbc45a35 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -67,7 +67,7 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): .. math:: \beta = \frac{d\theta_0}{d\omega} - + Here :math:`\theta_0` is the propagation angle of this component. phi2 : float (in second^2), optional (default '0') @@ -83,7 +83,7 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): .. math:: \zeta = \frac{x_0}{d\omega} - + Here :math:`x_0` is the beam center position. stc_theta : float (in rad) optional (default '0') From fd755581006ef4698c7bf4c6c74d830aaf5b5e78 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 00:09:40 +0200 Subject: [PATCH 058/362] Update gaussian_profile.py --- lasy/profiles/longitudinal/gaussian_profile.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index fd2399f8..b3a62b69 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -36,18 +36,23 @@ class GaussianLongitudinalProfile(LongitudinalProfile): beta : float (in second), optional The angular dispersion parameterized by .. math:: + \beta = \frac{d\theta_0}{d\omega} + Here :math:`\theta_0` is the propagation angle of this component. phi2 : float (in second^2), optional (default '0') The group-delay dispertion parameterized by .. math:: + \phi^{(2)} = \frac{dt}{d\omega} zeta : float (in meter * second) optional (defalut '0') The spatio-chirp parameterized by - .. math:: + .. math:: + \zeta = \frac{x_0}{d\omega} + Here :math:`x_0` is the beam center position. stc_theta : float (in rad) optional (default '0') From 48012b125e651268fc7387a42328cac016531889 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:09:47 +0000 Subject: [PATCH 059/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/longitudinal/gaussian_profile.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index b3a62b69..ea30bd72 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -36,23 +36,23 @@ class GaussianLongitudinalProfile(LongitudinalProfile): beta : float (in second), optional The angular dispersion parameterized by .. math:: - + \beta = \frac{d\theta_0}{d\omega} - + Here :math:`\theta_0` is the propagation angle of this component. phi2 : float (in second^2), optional (default '0') The group-delay dispertion parameterized by .. math:: - + \phi^{(2)} = \frac{dt}{d\omega} zeta : float (in meter * second) optional (defalut '0') The spatio-chirp parameterized by .. math:: - + \zeta = \frac{x_0}{d\omega} - + Here :math:`x_0` is the beam center position. stc_theta : float (in rad) optional (default '0') From b755151d1e0f0b0c8e3d106cc048730e5b9dac13 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 00:10:23 +0200 Subject: [PATCH 060/362] Update gaussian_profile.py --- lasy/profiles/longitudinal/gaussian_profile.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index ea30bd72..60517d7b 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -35,6 +35,7 @@ class GaussianLongitudinalProfile(LongitudinalProfile): beta : float (in second), optional The angular dispersion parameterized by + .. math:: \beta = \frac{d\theta_0}{d\omega} @@ -43,12 +44,14 @@ class GaussianLongitudinalProfile(LongitudinalProfile): phi2 : float (in second^2), optional (default '0') The group-delay dispertion parameterized by + .. math:: \phi^{(2)} = \frac{dt}{d\omega} zeta : float (in meter * second) optional (defalut '0') The spatio-chirp parameterized by + .. math:: \zeta = \frac{x_0}{d\omega} From fdd64c94df43c22c960432af4e3004be3dce51b0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:10:35 +0000 Subject: [PATCH 061/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/longitudinal/gaussian_profile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 60517d7b..39715674 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -35,7 +35,7 @@ class GaussianLongitudinalProfile(LongitudinalProfile): beta : float (in second), optional The angular dispersion parameterized by - + .. math:: \beta = \frac{d\theta_0}{d\omega} @@ -44,14 +44,14 @@ class GaussianLongitudinalProfile(LongitudinalProfile): phi2 : float (in second^2), optional (default '0') The group-delay dispertion parameterized by - + .. math:: \phi^{(2)} = \frac{dt}{d\omega} zeta : float (in meter * second) optional (defalut '0') The spatio-chirp parameterized by - + .. math:: \zeta = \frac{x_0}{d\omega} From 3ecd91201e452014511135a7ab9e8ac568bf2097 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 00:11:01 +0200 Subject: [PATCH 062/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 72454fe2..7202a0b3 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -917,8 +917,8 @@ def get_STC(dim, grid, tau, w0, k0): pft: Pulse front tilt in :math:` p=dt/dx` stc_theta_beta: The direction of the linear angular chirp on xoy plane\ in rad (0 is along x) - All those above units and definiations are taken from `S. Akturk et al., Optics\ - Express 12, 4399 (2004) `__. + All those above units and definiations are taken from + `S. Akturk et al., Optics Express 12, 4399 (2004) `__. """ # Initialise the returned dictionary STC_fac = { From 54eefc35aa469ff1f979cdfd26604ecf71b58abc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:11:17 +0000 Subject: [PATCH 063/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- 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 7202a0b3..357946bb 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -917,7 +917,7 @@ def get_STC(dim, grid, tau, w0, k0): pft: Pulse front tilt in :math:` p=dt/dx` stc_theta_beta: The direction of the linear angular chirp on xoy plane\ in rad (0 is along x) - All those above units and definiations are taken from + All those above units and definiations are taken from `S. Akturk et al., Optics Express 12, 4399 (2004) `__. """ # Initialise the returned dictionary From c867f456dc4b78a23ec4ca7b76aa5adca128496d Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 00:16:10 +0200 Subject: [PATCH 064/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 357946bb..26a47e84 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -955,7 +955,6 @@ def get_STC(dim, grid, tau, w0, k0): np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) ) # No angular dispersion in 2D and the direction of spatio-chirp is certain - return STC_fac if dim == "xyt": pphi_pzpy = (np.diff(pphi_pz, axis=1)) / grid.dx[1] pphi_pzpx = (np.diff(pphi_pz, axis=0)) / grid.dx[0] @@ -1003,4 +1002,4 @@ def get_STC(dim, grid, tau, w0, k0): STC_fac["beta"] = ( np.sqrt((pft_x**2 + pft_y**2)) - STC_fac["Phi2"] * STC_fac["nu"] ) / k0 - return STC_fac +return STC_fac From e220fb97aec8c99fc0b286c51facd4b4851b619b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:16:17 +0000 Subject: [PATCH 065/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 26a47e84..3ccdea79 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1002,4 +1002,6 @@ def get_STC(dim, grid, tau, w0, k0): STC_fac["beta"] = ( np.sqrt((pft_x**2 + pft_y**2)) - STC_fac["Phi2"] * STC_fac["nu"] ) / k0 + + return STC_fac From cb19a8cad59ab4efbcd9318a95215b2a2b698dcb Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 00:16:56 +0200 Subject: [PATCH 066/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 3ccdea79..42a41304 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1003,5 +1003,4 @@ def get_STC(dim, grid, tau, w0, k0): np.sqrt((pft_x**2 + pft_y**2)) - STC_fac["Phi2"] * STC_fac["nu"] ) / k0 - -return STC_fac + return STC_fac From 3318dcf74ae3a0b4da30a3d93c3cde69e5721f34 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 00:17:51 +0200 Subject: [PATCH 067/362] 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 42a41304..5ef2a53e 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1003,4 +1003,4 @@ def get_STC(dim, grid, tau, w0, k0): np.sqrt((pft_x**2 + pft_y**2)) - STC_fac["Phi2"] * STC_fac["nu"] ) / k0 - return STC_fac + return STC_fac From 36b4ebcbb8d955d73bc6f79bb3d5ab0d24308c58 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 00:49:11 +0200 Subject: [PATCH 068/362] Update gaussian_profile.py --- lasy/profiles/longitudinal/gaussian_profile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 39715674..e46435b0 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -38,7 +38,7 @@ class GaussianLongitudinalProfile(LongitudinalProfile): .. math:: - \beta = \frac{d\theta_0}{d\omega} + \beta = \frac{d\theta_0}{d\omega} Here :math:`\theta_0` is the propagation angle of this component. @@ -47,14 +47,14 @@ class GaussianLongitudinalProfile(LongitudinalProfile): .. math:: - \phi^{(2)} = \frac{dt}{d\omega} + \phi^{(2)} = \frac{dt}{d\omega} zeta : float (in meter * second) optional (defalut '0') The spatio-chirp parameterized by .. math:: - \zeta = \frac{x_0}{d\omega} + \zeta = \frac{x_0}{d\omega} Here :math:`x_0` is the beam center position. From 320c81bc598ffd4518bfb7f4c18d617649831585 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 00:54:28 +0200 Subject: [PATCH 069/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index bbc45a35..898f72f9 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -62,27 +62,27 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): Position of the focal plane. (The laser pulse is initialized at `z=0`.) beta : float (in second), optional - The angular dispersion parameterized by + The angular dispersion parameterized by: - .. math:: + .. math:: \beta = \frac{d\theta_0}{d\omega} Here :math:`\theta_0` is the propagation angle of this component. phi2 : float (in second^2), optional (default '0') - The group-delay dispertion parameterized by + The group-delay dispertion parameterized by: - .. math:: + .. math:: \phi^{(2)} = \frac{dt}{d\omega} zeta : float (in meter * second) optional (default '0') - The spatio-chirp parameterized by + The spatio-chirp parameterized by: - .. math:: + .. math:: - \zeta = \frac{x_0}{d\omega} + \zeta = \frac{x_0}{d\omega} Here :math:`x_0` is the beam center position. From 4d7775318a9767aecf1a503c42f8a279bfa4451e Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 00:57:22 +0200 Subject: [PATCH 070/362] Update gaussian_profile.py --- lasy/profiles/longitudinal/gaussian_profile.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index e46435b0..1782280a 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -34,27 +34,27 @@ class GaussianLongitudinalProfile(LongitudinalProfile): oscillation, at the time where the laser envelope is maximum). beta : float (in second), optional - The angular dispersion parameterized by + The angular dispersion parameterized by: - .. math:: + .. math:: - \beta = \frac{d\theta_0}{d\omega} + \beta = \frac{d\theta_0}{d\omega} Here :math:`\theta_0` is the propagation angle of this component. phi2 : float (in second^2), optional (default '0') - The group-delay dispertion parameterized by + The group-delay dispertion parameterized by: - .. math:: + .. math:: - \phi^{(2)} = \frac{dt}{d\omega} + \phi^{(2)} = \frac{dt}{d\omega} zeta : float (in meter * second) optional (defalut '0') - The spatio-chirp parameterized by + The spatio-chirp parameterized by: - .. math:: + .. math:: - \zeta = \frac{x_0}{d\omega} + \zeta = \frac{x_0}{d\omega} Here :math:`x_0` is the beam center position. From f7451974f6f3c3df2d2b2db3a7f723e525dbfeea Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 00:59:58 +0200 Subject: [PATCH 071/362] Update gaussian_profile.py --- lasy/profiles/longitudinal/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 1782280a..1674eb62 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -54,7 +54,7 @@ class GaussianLongitudinalProfile(LongitudinalProfile): .. math:: - \zeta = \frac{x_0}{d\omega} + \zeta = \frac{dx_0}{d\omega} Here :math:`x_0` is the beam center position. From bb206fd0a1f2a5f48768e7a780fc7336b642f84a Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:00:57 +0200 Subject: [PATCH 072/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 898f72f9..9fee3cc0 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -82,7 +82,7 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): .. math:: - \zeta = \frac{x_0}{d\omega} + \zeta = \frac{dx_0}{d\omega} Here :math:`x_0` is the beam center position. From 0c6fc28d116f5eaf95923c18f33a520830978cbe Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:02:01 +0200 Subject: [PATCH 073/362] Update gaussian_profile.py --- lasy/profiles/longitudinal/gaussian_profile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 1674eb62..58685fe3 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -69,8 +69,7 @@ class GaussianLongitudinalProfile(LongitudinalProfile): w0 : float (in meter), necessary if beta is not 0 The waist of the laser pulse. - All those above STC units and definiations are taken from - `S. Akturk et al., Optics Express 12, 4399 (2004) `__. + All those above STC units and definiations are taken from """ def __init__( From b117d3350339c6287f4a4c53b4c8f59187c5ef2f Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:03:19 +0200 Subject: [PATCH 074/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 9fee3cc0..b914c272 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -89,7 +89,7 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): stc_theta : float (in rad) optional (default '0') Transeverse direction along which spatio-temperal field couples. 0 is along x axis. - + All those above STC units and definiations are taken from Examples -------- From cf738f5fee38ef45b4cdab2d48ced166ed4f74e9 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:06:04 +0200 Subject: [PATCH 075/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index b914c272..9c549aa3 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -89,7 +89,7 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): stc_theta : float (in rad) optional (default '0') Transeverse direction along which spatio-temperal field couples. 0 is along x axis. - All those above STC units and definiations are taken from + All those above STC units and definitions are taken from Examples -------- From 635f9a4b412cfed8a0dbdd9acd0e15a4a2d2f524 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:06:38 +0200 Subject: [PATCH 076/362] Update gaussian_profile.py --- lasy/profiles/longitudinal/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 58685fe3..5a875a77 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -69,7 +69,7 @@ class GaussianLongitudinalProfile(LongitudinalProfile): w0 : float (in meter), necessary if beta is not 0 The waist of the laser pulse. - All those above STC units and definiations are taken from + All those above STC units and definitions are taken from """ def __init__( From 67be6733e083f027e622f114cac574983a0c3362 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:13:23 +0200 Subject: [PATCH 077/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 5ef2a53e..c45134bf 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -881,7 +881,6 @@ def get_STC(dim, grid, tau, w0, k0): Parameters ---------- - laser: dim : string Dimensionality of the array. Options are: - 'xyt': The laser pulse is represented on a 3D grid: From 3ec6d4b696054a0ed10de70fe27c3a8cba63f5e2 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:16:27 +0200 Subject: [PATCH 078/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index c45134bf..3d5b6f24 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -933,10 +933,10 @@ def get_STC(dim, grid, tau, w0, k0): env = grid.get_temporal_field() env_abs = np.abs(env) phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) - pphi_pz = (np.diff(phi_envelop, axis=2)) / (grid.dx[-1]) + pphi_pt = (np.diff(phi_envelop, axis=2)) / (grid.dx[-1]) # Calculate goup-delayed dispersion - pphi_pz2 = (np.diff(pphi_pz, axis=2)) / (grid.dx[-1]) - STC_fac["Phi2"] = np.sum(pphi_pz2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( + pphi_pt2 = (np.diff(pphi_pz, axis=2)) / (grid.dx[-1]) + STC_fac["Phi2"] = np.sum(pphi_pt2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( env_abs[:, :, : env_abs.shape[2] - 2] ) STC_fac["phi2"] = np.max( @@ -944,9 +944,9 @@ def get_STC(dim, grid, tau, w0, k0): ) # Calculate spatio- and angular dispersion if dim == "rt": - pphi_pzpr = (np.diff(pphi_pz, axis=1)) / grid.dx[0] + pphi_ptpr = (np.diff(pphi_pt, axis=1)) / grid.dx[0] STC_fac["nu"] = np.sum( - pphi_pzpr * env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1] + pphi_ptpr * env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1] ) / np.sum(env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1]) # Transfer the unit from nu to zeta @@ -955,12 +955,12 @@ def get_STC(dim, grid, tau, w0, k0): ) # No angular dispersion in 2D and the direction of spatio-chirp is certain if dim == "xyt": - pphi_pzpy = (np.diff(pphi_pz, axis=1)) / grid.dx[1] - pphi_pzpx = (np.diff(pphi_pz, axis=0)) / grid.dx[0] + pphi_ptpy = (np.diff(pphi_pt, axis=1)) / grid.dx[1] + pphi_ptpx = (np.diff(pphi_pt, axis=0)) / grid.dx[0] # Calculate the STC angle in XOY for spatio coupling theta = np.arctan2( - pphi_pzpy[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :], - pphi_pzpx[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :], + pphi_ptpy[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :], + pphi_ptpx[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :], ) STC_fac["stc_theta_zeta"] = np.sum( theta @@ -972,12 +972,12 @@ def get_STC(dim, grid, tau, w0, k0): : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 ] ) - pphi_pzpr = ( - pphi_pzpy[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :] ** 2 - + pphi_pzpx[:: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :] ** 2 + pphi_ptpr = ( + pphi_ptpy[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :] ** 2 + + pphi_ptpx[:: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :] ** 2 ) ** 0.5 STC_fac["nu"] = np.sum( - pphi_pzpr + pphi_ptpr * env_abs[ : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 ] From eb92ac78c3d6000cd80e0c356a026b7e9504396f Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:18:14 +0200 Subject: [PATCH 079/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 3d5b6f24..dccb0760 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -972,10 +972,10 @@ def get_STC(dim, grid, tau, w0, k0): : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 ] ) - pphi_ptpr = ( + pphi_ptpr = np.sqrt( pphi_ptpy[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :] ** 2 + pphi_ptpx[:: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :] ** 2 - ) ** 0.5 + ) STC_fac["nu"] = np.sum( pphi_ptpr * env_abs[ From d22d37945666d95cd109fefb15d22dca774a2fe8 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:19:22 +0200 Subject: [PATCH 080/362] 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 dccb0760..289a9436 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -935,7 +935,7 @@ def get_STC(dim, grid, tau, w0, k0): phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = (np.diff(phi_envelop, axis=2)) / (grid.dx[-1]) # Calculate goup-delayed dispersion - pphi_pt2 = (np.diff(pphi_pz, axis=2)) / (grid.dx[-1]) + pphi_pt2 = (np.diff(pphi_pt, axis=2)) / (grid.dx[-1]) STC_fac["Phi2"] = np.sum(pphi_pt2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( env_abs[:, :, : env_abs.shape[2] - 2] ) From 1a37f084f3e2d73393c4e064a07983d179677c86 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:22:07 +0200 Subject: [PATCH 081/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 9c549aa3..b5a772a9 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -71,7 +71,7 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): Here :math:`\theta_0` is the propagation angle of this component. phi2 : float (in second^2), optional (default '0') - The group-delay dispertion parameterized by: + The group-delay dispersion parameterized by: .. math:: @@ -87,7 +87,7 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): Here :math:`x_0` is the beam center position. stc_theta : float (in rad) optional (default '0') - Transeverse direction along which spatio-temperal field couples. + Transverse direction along which spatio-temporal field couples. 0 is along x axis. All those above STC units and definitions are taken from From 9a0ba6f0c9f2b3936652fcd769efc0022d911442 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:22:41 +0200 Subject: [PATCH 082/362] Update gaussian_profile.py --- lasy/profiles/longitudinal/gaussian_profile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 5a875a77..77632960 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -43,7 +43,7 @@ class GaussianLongitudinalProfile(LongitudinalProfile): Here :math:`\theta_0` is the propagation angle of this component. phi2 : float (in second^2), optional (default '0') - The group-delay dispertion parameterized by: + The group-delay dispersion parameterized by: .. math:: @@ -59,7 +59,7 @@ class GaussianLongitudinalProfile(LongitudinalProfile): Here :math:`x_0` is the beam center position. stc_theta : float (in rad) optional (default '0') - Transeverse direction along which spatio-temperal field couples. + Transverse direction along which spatio-temporal field couples. 0 is along x axis. z_foc : float (in meter), necessary if beta is not 0 From 4e9d62f37815cdbed7bdd25937d4e0153fa00432 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:24:14 +0200 Subject: [PATCH 083/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 289a9436..38243fd3 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -877,7 +877,7 @@ def import_from_z(dim, grid, omega0, field_z, z_axis, z0=0.0, t0=0.0, backend="N def get_STC(dim, grid, tau, w0, k0): r""" - Calculate the spatio-temperal coupling factors of the laser. + Calculate the spatio-temporal coupling factors of the laser. Parameters ---------- @@ -916,7 +916,7 @@ def get_STC(dim, grid, tau, w0, k0): pft: Pulse front tilt in :math:` p=dt/dx` stc_theta_beta: The direction of the linear angular chirp on xoy plane\ in rad (0 is along x) - All those above units and definiations are taken from + All those above units and definitions are taken from `S. Akturk et al., Optics Express 12, 4399 (2004) `__. """ # Initialise the returned dictionary From 542b29de551d25b4bc0d6869c8b9c266c2d1291d Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 12:57:54 +0100 Subject: [PATCH 084/362] change np.diff to np.gradient --- lasy/utils/laser_utils.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 38243fd3..5493ebb2 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -933,9 +933,10 @@ def get_STC(dim, grid, tau, w0, k0): env = grid.get_temporal_field() env_abs = np.abs(env) phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) - pphi_pt = (np.diff(phi_envelop, axis=2)) / (grid.dx[-1]) - # Calculate goup-delayed dispersion - pphi_pt2 = (np.diff(pphi_pt, axis=2)) / (grid.dx[-1]) + pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) +# Calculate group-delayed dispersion + pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) + STC_fac["Phi2"] = np.sum(pphi_pt2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( env_abs[:, :, : env_abs.shape[2] - 2] ) @@ -955,8 +956,8 @@ def get_STC(dim, grid, tau, w0, k0): ) # No angular dispersion in 2D and the direction of spatio-chirp is certain if dim == "xyt": - pphi_ptpy = (np.diff(pphi_pt, axis=1)) / grid.dx[1] - pphi_ptpx = (np.diff(pphi_pt, axis=0)) / grid.dx[0] + pphi_ptpy = np.gradient(pphi_pt, grid.dx[1], axis=1) + pphi_ptpx = np.gradient(pphi_pt, grid.dx[0], axis=0) # Calculate the STC angle in XOY for spatio coupling theta = np.arctan2( pphi_ptpy[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :], From cd4bdf07038813b0e41457a8244f0783a38b0934 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 12:02:25 +0000 Subject: [PATCH 085/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- 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 5493ebb2..2ed2f0fa 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -934,7 +934,7 @@ def get_STC(dim, grid, tau, w0, k0): env_abs = np.abs(env) phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) -# Calculate group-delayed dispersion + # Calculate group-delayed dispersion pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) STC_fac["Phi2"] = np.sum(pphi_pt2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( From d20959e5dbe9133a1b8b0a684533ac26a73ea968 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 13:06:19 +0100 Subject: [PATCH 086/362] use numpy calculate weighed average --- lasy/utils/laser_utils.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 5493ebb2..f3f366e5 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -931,18 +931,20 @@ def get_STC(dim, grid, tau, w0, k0): "stc_theta_beta": 0, } env = grid.get_temporal_field() - env_abs = np.abs(env) + env_abs = np.abs(env**2) phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) -# Calculate group-delayed dispersion + # Calculate group-delayed dispersion pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) - - STC_fac["Phi2"] = np.sum(pphi_pt2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( - env_abs[:, :, : env_abs.shape[2] - 2] - ) - STC_fac["phi2"] = np.max( - np.roots([4 * STC_fac["Phi2"], -4, tau**4 * STC_fac["Phi2"]]) - ) + # Use the laser intensity to calculate the weighted average of Phi2 + STC_fac["Phi2"] = np.average(pphi_pt2, weights=env_abs) + + #STC_fac["Phi2"] = np.sum(pphi_pt2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( + # env_abs[:, :, : env_abs.shape[2] - 2] + #) + #STC_fac["phi2"] = np.max( + # np.roots([4 * STC_fac["Phi2"], -4, tau**4 * STC_fac["Phi2"]]) + #) # Calculate spatio- and angular dispersion if dim == "rt": pphi_ptpr = (np.diff(pphi_pt, axis=1)) / grid.dx[0] From 04a827d2caf1f8cd1dea8c010f23672812633c9e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 12:07:43 +0000 Subject: [PATCH 087/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index f3f366e5..b4dd28c2 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -939,12 +939,12 @@ def get_STC(dim, grid, tau, w0, k0): # Use the laser intensity to calculate the weighted average of Phi2 STC_fac["Phi2"] = np.average(pphi_pt2, weights=env_abs) - #STC_fac["Phi2"] = np.sum(pphi_pt2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( + # STC_fac["Phi2"] = np.sum(pphi_pt2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( # env_abs[:, :, : env_abs.shape[2] - 2] - #) - #STC_fac["phi2"] = np.max( + # ) + # STC_fac["phi2"] = np.max( # np.roots([4 * STC_fac["Phi2"], -4, tau**4 * STC_fac["Phi2"]]) - #) + # ) # Calculate spatio- and angular dispersion if dim == "rt": pphi_ptpr = (np.diff(pphi_pt, axis=1)) / grid.dx[0] From 4c91d5e2def0b07ebfe28bf5d6e140fc3b9e0699 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 13:15:47 +0100 Subject: [PATCH 088/362] fix the dimention of average calculation --- lasy/utils/laser_utils.py | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index f3f366e5..215093b9 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -961,34 +961,15 @@ def get_STC(dim, grid, tau, w0, k0): pphi_ptpy = np.gradient(pphi_pt, grid.dx[1], axis=1) pphi_ptpx = np.gradient(pphi_pt, grid.dx[0], axis=0) # Calculate the STC angle in XOY for spatio coupling - theta = np.arctan2( - pphi_ptpy[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :], - pphi_ptpx[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :], - ) + theta = np.arctan2(pphi_ptpy, pphi_ptpx) STC_fac["stc_theta_zeta"] = np.sum( theta * env_abs[ : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 ] - ) / np.sum( - env_abs[ - : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 - ] - ) - pphi_ptpr = np.sqrt( - pphi_ptpy[: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :] ** 2 - + pphi_ptpx[:: env_abs.shape[0] - 1, : env_abs.shape[1] - 1, :] ** 2 - ) - STC_fac["nu"] = np.sum( - pphi_ptpr - * env_abs[ - : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 - ] - ) / np.sum( - env_abs[ - : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 - ] - ) + ) / np.sum( env_abs ) + pphi_ptpr = np.sqrt(pphi_ptpy** 2 + pphi_ptpx**2) + STC_fac["nu"] = np.sum( pphi_ptpr* env_abs) / np.sum(env_abs) STC_fac["zeta"] = np.min( np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) ) From a8a204ff220da547537a595f91690f2fefd4b334 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 12:17:08 +0000 Subject: [PATCH 089/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index f4c6a9cf..adb3538c 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -967,9 +967,9 @@ def get_STC(dim, grid, tau, w0, k0): * env_abs[ : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 ] - ) / np.sum( env_abs ) - pphi_ptpr = np.sqrt(pphi_ptpy** 2 + pphi_ptpx**2) - STC_fac["nu"] = np.sum( pphi_ptpr* env_abs) / np.sum(env_abs) + ) / np.sum(env_abs) + pphi_ptpr = np.sqrt(pphi_ptpy**2 + pphi_ptpx**2) + STC_fac["nu"] = np.sum(pphi_ptpr * env_abs) / np.sum(env_abs) STC_fac["zeta"] = np.min( np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) ) From 2a96126096cd28635293133c9cff01b72c88c1f9 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 13:17:23 +0100 Subject: [PATCH 090/362] fix dimension again --- lasy/utils/laser_utils.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index f4c6a9cf..7b1c3968 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -962,12 +962,7 @@ def get_STC(dim, grid, tau, w0, k0): pphi_ptpx = np.gradient(pphi_pt, grid.dx[0], axis=0) # Calculate the STC angle in XOY for spatio coupling theta = np.arctan2(pphi_ptpy, pphi_ptpx) - STC_fac["stc_theta_zeta"] = np.sum( - theta - * env_abs[ - : env_abs.shape[0] - 1, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1 - ] - ) / np.sum( env_abs ) + STC_fac["stc_theta_zeta"] = np.sum(theta * env_abs ) / np.sum( env_abs ) pphi_ptpr = np.sqrt(pphi_ptpy** 2 + pphi_ptpx**2) STC_fac["nu"] = np.sum( pphi_ptpr* env_abs) / np.sum(env_abs) STC_fac["zeta"] = np.min( From b115b38f5a8369411249dc6b6193f8f5fe8d609b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 12:19:03 +0000 Subject: [PATCH 091/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index e66f6f42..57640938 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -962,9 +962,9 @@ def get_STC(dim, grid, tau, w0, k0): pphi_ptpx = np.gradient(pphi_pt, grid.dx[0], axis=0) # Calculate the STC angle in XOY for spatio coupling theta = np.arctan2(pphi_ptpy, pphi_ptpx) - STC_fac["stc_theta_zeta"] = np.sum(theta * env_abs ) / np.sum( env_abs ) - pphi_ptpr = np.sqrt(pphi_ptpy** 2 + pphi_ptpx**2) - STC_fac["nu"] = np.sum( pphi_ptpr* env_abs) / np.sum(env_abs) + STC_fac["stc_theta_zeta"] = np.sum(theta * env_abs) / np.sum(env_abs) + pphi_ptpr = np.sqrt(pphi_ptpy**2 + pphi_ptpx**2) + STC_fac["nu"] = np.sum(pphi_ptpr * env_abs) / np.sum(env_abs) STC_fac["zeta"] = np.min( np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) From 4c3b620e0377bf4764ad0e6e496c29069ad2548c Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 13:23:56 +0100 Subject: [PATCH 092/362] calculate phi2 --- lasy/utils/laser_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 57640938..0cd940c3 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -942,9 +942,9 @@ def get_STC(dim, grid, tau, w0, k0): # STC_fac["Phi2"] = np.sum(pphi_pt2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( # env_abs[:, :, : env_abs.shape[2] - 2] # ) - # STC_fac["phi2"] = np.max( - # np.roots([4 * STC_fac["Phi2"], -4, tau**4 * STC_fac["Phi2"]]) - # ) + STC_fac["phi2"] = np.max( + np.roots([4 * STC_fac["Phi2"], -4, tau**4 * STC_fac["Phi2"]]) + ) # Calculate spatio- and angular dispersion if dim == "rt": pphi_ptpr = (np.diff(pphi_pt, axis=1)) / grid.dx[0] From 2b64d4eebed2be79f6878f6196f6a187ea3e0319 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 13:27:40 +0100 Subject: [PATCH 093/362] change all the weighted average to mnumpy --- lasy/utils/laser_utils.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 0cd940c3..f2253673 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -938,20 +938,13 @@ def get_STC(dim, grid, tau, w0, k0): pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) # Use the laser intensity to calculate the weighted average of Phi2 STC_fac["Phi2"] = np.average(pphi_pt2, weights=env_abs) - - # STC_fac["Phi2"] = np.sum(pphi_pt2 * env_abs[:, :, : env_abs.shape[2] - 2]) / np.sum( - # env_abs[:, :, : env_abs.shape[2] - 2] - # ) STC_fac["phi2"] = np.max( np.roots([4 * STC_fac["Phi2"], -4, tau**4 * STC_fac["Phi2"]]) ) # Calculate spatio- and angular dispersion if dim == "rt": pphi_ptpr = (np.diff(pphi_pt, axis=1)) / grid.dx[0] - STC_fac["nu"] = np.sum( - pphi_ptpr * env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1] - ) / np.sum(env_abs[:, : env_abs.shape[1] - 1, : env_abs.shape[2] - 1]) - + STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) # Transfer the unit from nu to zeta STC_fac["zeta"] = np.min( np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) @@ -962,20 +955,18 @@ def get_STC(dim, grid, tau, w0, k0): pphi_ptpx = np.gradient(pphi_pt, grid.dx[0], axis=0) # Calculate the STC angle in XOY for spatio coupling theta = np.arctan2(pphi_ptpy, pphi_ptpx) - STC_fac["stc_theta_zeta"] = np.sum(theta * env_abs) / np.sum(env_abs) + STC_fac["stc_theta_zeta"] = np.average(theta, weights=env_abs) pphi_ptpr = np.sqrt(pphi_ptpy**2 + pphi_ptpx**2) - STC_fac["nu"] = np.sum(pphi_ptpr * env_abs) / np.sum(env_abs) - + STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) STC_fac["zeta"] = np.min( np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) ) # calculate angular dispersion and pulse front tilt - z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) - weight = np.mean(env_abs**2, axis=2) + z_centroids = np.average(grid.axes[2], weights=env_abs, axis=2) derivative_x = np.gradient(z_centroids, axis=0) / grid.dx[0] derivative_y = np.gradient(z_centroids, axis=1) / grid.dx[1] - pft_x = np.sum(derivative_x * weight) / np.sum(weight) - pft_y = np.sum(derivative_y * weight) / np.sum(weight) + pft_x = np.average(derivative_x, weights=env_abs) + pft_y = np.average(derivative_y, weights=env_abs) STC_fac["pft"] = np.sqrt((pft_x**2 + pft_y**2)) STC_fac["stc_theta_beta"] = np.arctan2(pft_y, pft_x) STC_fac["beta"] = ( From 750e005d6b446046745af903fbf31f446a5c5683 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 13:31:36 +0100 Subject: [PATCH 094/362] add comments --- lasy/utils/laser_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index f2253673..c3179d42 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -936,7 +936,7 @@ def get_STC(dim, grid, tau, w0, k0): pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) # Calculate group-delayed dispersion pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) - # Use the laser intensity to calculate the weighted average of Phi2 + # Use the normalised laser intensity to calculate the weighted average of Phi2 STC_fac["Phi2"] = np.average(pphi_pt2, weights=env_abs) STC_fac["phi2"] = np.max( np.roots([4 * STC_fac["Phi2"], -4, tau**4 * STC_fac["Phi2"]]) @@ -944,6 +944,7 @@ def get_STC(dim, grid, tau, w0, k0): # Calculate spatio- and angular dispersion if dim == "rt": pphi_ptpr = (np.diff(pphi_pt, axis=1)) / grid.dx[0] + # Use the normalised laser intensity to calculate the weighted average of nu STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) # Transfer the unit from nu to zeta STC_fac["zeta"] = np.min( @@ -955,6 +956,7 @@ def get_STC(dim, grid, tau, w0, k0): pphi_ptpx = np.gradient(pphi_pt, grid.dx[0], axis=0) # Calculate the STC angle in XOY for spatio coupling theta = np.arctan2(pphi_ptpy, pphi_ptpx) + # Use the normalised laser intensity to calculate the weighted average of theta STC_fac["stc_theta_zeta"] = np.average(theta, weights=env_abs) pphi_ptpr = np.sqrt(pphi_ptpy**2 + pphi_ptpx**2) STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) @@ -962,6 +964,7 @@ def get_STC(dim, grid, tau, w0, k0): np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) ) # calculate angular dispersion and pulse front tilt + # Use the normalised laser intensity to calculate the weighted average of PFT z_centroids = np.average(grid.axes[2], weights=env_abs, axis=2) derivative_x = np.gradient(z_centroids, axis=0) / grid.dx[0] derivative_y = np.gradient(z_centroids, axis=1) / grid.dx[1] From 98b14034f6f99aebddd376a625c6be9d33b9a6ec Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 14:35:20 +0100 Subject: [PATCH 095/362] transfer w0_tau calculation inside get_STC --- lasy/utils/laser_utils.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index c3179d42..5ffcc24d 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -874,8 +874,28 @@ def import_from_z(dim, grid, omega0, field_z, z_axis, z0=0.0, t0=0.0, backend="N field *= np.exp(1j * (z0 / c + t_axis) * omega0) grid.set_temporal_field(field) +def get_w0(grid, dim): + # Calculate the laser waist + field = grid.get_temporal_field() + if dim == "xyt": + Nx, Ny, Nt = field.shape + A2 = (np.abs(field[Nx // 2 - 1, :, :]) ** 2).sum(-1) + ax = grid.axes[1] + else: + A2 = (np.abs(field[0, :, :]) ** 2).sum(-1) + ax = grid.axes[0] + if ax[0] > 0: + A2 = np.r_[A2[::-1], A2] + ax = np.r_[-ax[::-1], ax] + else: + A2 = np.r_[A2[::-1][:-1], A2] + ax = np.r_[-ax[::-1][:-1], ax] -def get_STC(dim, grid, tau, w0, k0): + sigma = 2 * np.sqrt(np.average(ax**2, weights=A2)) + + return sigma + +def get_STC(dim, grid, k0): r""" Calculate the spatio-temporal coupling factors of the laser. @@ -893,12 +913,6 @@ def get_STC(dim, grid, tau, w0, k0): the value of the envelope field and the associated metadata that defines the points at which the laser is defined. - tau : scalar - Duration of the laser pulse in s. - - w0 : scalar - Waist of laser in m. - k0 : scalar Wavenumber of the field @@ -920,6 +934,8 @@ def get_STC(dim, grid, tau, w0, k0): `S. Akturk et al., Optics Express 12, 4399 (2004) `__. """ # Initialise the returned dictionary + tau = get_duration(grid, dim) + w0 = get_w0(grid, dim) STC_fac = { "Phi2": 0, "phi2": 0, From 4e486d8c4ade14344784a3012ef9304340af27f8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:35:51 +0000 Subject: [PATCH 096/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 5ffcc24d..12f5cc05 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -874,6 +874,7 @@ def import_from_z(dim, grid, omega0, field_z, z_axis, z0=0.0, t0=0.0, backend="N field *= np.exp(1j * (z0 / c + t_axis) * omega0) grid.set_temporal_field(field) + def get_w0(grid, dim): # Calculate the laser waist field = grid.get_temporal_field() @@ -895,6 +896,7 @@ def get_w0(grid, dim): return sigma + def get_STC(dim, grid, k0): r""" Calculate the spatio-temporal coupling factors of the laser. From 9af4b3fb22a76558eb97cde2cc703ccaa42304be Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 14:50:35 +0100 Subject: [PATCH 097/362] fix bug on 1D average --- lasy/utils/laser_utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 5ffcc24d..b2ce5831 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -981,11 +981,12 @@ def get_STC(dim, grid, k0): ) # calculate angular dispersion and pulse front tilt # Use the normalised laser intensity to calculate the weighted average of PFT - z_centroids = np.average(grid.axes[2], weights=env_abs, axis=2) + weight = np.mean(env_abs, axis=2) + z_centroids = np.average(grid.axes[2], weights=weight, axis=2) derivative_x = np.gradient(z_centroids, axis=0) / grid.dx[0] derivative_y = np.gradient(z_centroids, axis=1) / grid.dx[1] - pft_x = np.average(derivative_x, weights=env_abs) - pft_y = np.average(derivative_y, weights=env_abs) + pft_x = np.average(derivative_x, weights=weight) + pft_y = np.average(derivative_y, weights=weight) STC_fac["pft"] = np.sqrt((pft_x**2 + pft_y**2)) STC_fac["stc_theta_beta"] = np.arctan2(pft_y, pft_x) STC_fac["beta"] = ( From 926354122d454886dc3a3659103262e88f3a98f0 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 14:58:09 +0100 Subject: [PATCH 098/362] debug pft issue --- lasy/utils/laser_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 2b5960e7..1a29c599 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -984,7 +984,9 @@ def get_STC(dim, grid, k0): # calculate angular dispersion and pulse front tilt # Use the normalised laser intensity to calculate the weighted average of PFT weight = np.mean(env_abs, axis=2) - z_centroids = np.average(grid.axes[2], weights=weight, axis=2) + print(len(grid.axes[2])) + print(len(env_abs[2])) + z_centroids = np.average(grid.axes[2], weights=env_abs, axis=2) derivative_x = np.gradient(z_centroids, axis=0) / grid.dx[0] derivative_y = np.gradient(z_centroids, axis=1) / grid.dx[1] pft_x = np.average(derivative_x, weights=weight) From 61f0fb5b00f3f20816b7862882d81ba11cd0c483 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 15:01:55 +0100 Subject: [PATCH 099/362] change back to original --- lasy/utils/laser_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 1a29c599..ae57d8d4 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -986,7 +986,9 @@ def get_STC(dim, grid, k0): weight = np.mean(env_abs, axis=2) print(len(grid.axes[2])) print(len(env_abs[2])) - z_centroids = np.average(grid.axes[2], weights=env_abs, axis=2) + #z_centroids = np.average(grid.axes[2], weights=env_abs, axis=2) + z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) + weight = np.mean(env_abs**2, axis=2) derivative_x = np.gradient(z_centroids, axis=0) / grid.dx[0] derivative_y = np.gradient(z_centroids, axis=1) / grid.dx[1] pft_x = np.average(derivative_x, weights=weight) From 463ed364e38c9486ea8e591b4a008a5aa4e56abf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:02:20 +0000 Subject: [PATCH 100/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- 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 ae57d8d4..79573b67 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -986,7 +986,7 @@ def get_STC(dim, grid, k0): weight = np.mean(env_abs, axis=2) print(len(grid.axes[2])) print(len(env_abs[2])) - #z_centroids = np.average(grid.axes[2], weights=env_abs, axis=2) + # z_centroids = np.average(grid.axes[2], weights=env_abs, axis=2) z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) weight = np.mean(env_abs**2, axis=2) derivative_x = np.gradient(z_centroids, axis=0) / grid.dx[0] From df366a6aaeca899441c425bb3dd8b78d199ddd5b Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 15:08:05 +0100 Subject: [PATCH 101/362] change average of nu to original --- lasy/utils/laser_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index ae57d8d4..7bb54196 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -977,7 +977,8 @@ def get_STC(dim, grid, k0): # Use the normalised laser intensity to calculate the weighted average of theta STC_fac["stc_theta_zeta"] = np.average(theta, weights=env_abs) pphi_ptpr = np.sqrt(pphi_ptpy**2 + pphi_ptpx**2) - STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) + #STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) + STC_fac["nu"] = np.sum(pphi_ptpr * env_abs) / np.sum(env_abs) STC_fac["zeta"] = np.min( np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) ) @@ -988,7 +989,7 @@ def get_STC(dim, grid, k0): print(len(env_abs[2])) #z_centroids = np.average(grid.axes[2], weights=env_abs, axis=2) z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) - weight = np.mean(env_abs**2, axis=2) + eight = np.mean(env_abs**2, axis=2) derivative_x = np.gradient(z_centroids, axis=0) / grid.dx[0] derivative_y = np.gradient(z_centroids, axis=1) / grid.dx[1] pft_x = np.average(derivative_x, weights=weight) From 31ed7bc98bb162fead27cbce36af9d671ae223b5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:08:52 +0000 Subject: [PATCH 102/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- 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 4ae1b1e0..d7f2541b 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -977,7 +977,7 @@ def get_STC(dim, grid, k0): # Use the normalised laser intensity to calculate the weighted average of theta STC_fac["stc_theta_zeta"] = np.average(theta, weights=env_abs) pphi_ptpr = np.sqrt(pphi_ptpy**2 + pphi_ptpx**2) - #STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) + # STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) STC_fac["nu"] = np.sum(pphi_ptpr * env_abs) / np.sum(env_abs) STC_fac["zeta"] = np.min( np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) From e3fe00dabdb1286c0de0ad2edd04ae974f1e7d20 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 15:12:39 +0100 Subject: [PATCH 103/362] debug check tau and w0 --- lasy/utils/laser_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 4ae1b1e0..c61744b0 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -938,6 +938,8 @@ def get_STC(dim, grid, k0): # Initialise the returned dictionary tau = get_duration(grid, dim) w0 = get_w0(grid, dim) + print(tau) + print(w0) STC_fac = { "Phi2": 0, "phi2": 0, @@ -985,9 +987,7 @@ def get_STC(dim, grid, k0): # calculate angular dispersion and pulse front tilt # Use the normalised laser intensity to calculate the weighted average of PFT weight = np.mean(env_abs, axis=2) - print(len(grid.axes[2])) - print(len(env_abs[2])) - # z_centroids = np.average(grid.axes[2], weights=env_abs, axis=2) + np.average(grid.axes[2], weights=env_abs, axis=2) z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) eight = np.mean(env_abs**2, axis=2) derivative_x = np.gradient(z_centroids, axis=0) / grid.dx[0] From 681fbbdfc9e5351103e71f54034446a9595bbf3c Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 15:15:32 +0100 Subject: [PATCH 104/362] some debug --- lasy/utils/laser_utils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 90fb6d56..d249ef93 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -936,7 +936,7 @@ def get_STC(dim, grid, k0): `S. Akturk et al., Optics Express 12, 4399 (2004) `__. """ # Initialise the returned dictionary - tau = get_duration(grid, dim) + tau = 2 * get_duration(grid, dim) w0 = get_w0(grid, dim) print(tau) print(w0) @@ -987,9 +987,7 @@ def get_STC(dim, grid, k0): # calculate angular dispersion and pulse front tilt # Use the normalised laser intensity to calculate the weighted average of PFT weight = np.mean(env_abs, axis=2) - np.average(grid.axes[2], weights=env_abs, axis=2) z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) - eight = np.mean(env_abs**2, axis=2) derivative_x = np.gradient(z_centroids, axis=0) / grid.dx[0] derivative_y = np.gradient(z_centroids, axis=1) / grid.dx[1] pft_x = np.average(derivative_x, weights=weight) From b02591d4de51b884ad52bf5498c2414b7b3140f2 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 19:14:24 +0100 Subject: [PATCH 105/362] add document in get_w0 function --- lasy/utils/laser_utils.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index d249ef93..6da823fc 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -876,7 +876,21 @@ def import_from_z(dim, grid, omega0, field_z, z_axis, z0=0.0, t0=0.0, backend="N def get_w0(grid, dim): - # Calculate the laser waist + r""" + Calculate the laser waist + Parameters + ---------- + dim : string + Dimensionality of the array. Options are: + - 'xyt': The laser pulse is represented on a 3D grid: + Cartesian (x,y) transversely, and temporal (t) longitudinally. + - 'rt' : The laser pulse is represented on a 2D grid: + Cylindrical (r) transversely, and temporal (t) longitudinally. + Return + ---------- + sigma: Standard deviation of a**2 in m + """ + Calculate the laser waist field = grid.get_temporal_field() if dim == "xyt": Nx, Ny, Nt = field.shape From 8dea652c8e4b8605d81e2599d742bbf190531a3d Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 19:19:30 +0100 Subject: [PATCH 106/362] DOCUMENT syntax error --- lasy/utils/laser_utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 6da823fc..401c6cdb 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -877,7 +877,8 @@ def import_from_z(dim, grid, omega0, field_z, z_axis, z0=0.0, t0=0.0, backend="N def get_w0(grid, dim): r""" - Calculate the laser waist + Calculate the laser waist. + Parameters ---------- dim : string @@ -886,6 +887,12 @@ def get_w0(grid, dim): Cartesian (x,y) transversely, and temporal (t) longitudinally. - 'rt' : The laser pulse is represented on a 2D grid: Cylindrical (r) transversely, and temporal (t) longitudinally. + + grid : a Grid object. + It contains an ndarray (V/m) with + the value of the envelope field and the associated metadata + that defines the points at which the laser is defined. + Return ---------- sigma: Standard deviation of a**2 in m From 7af85739f65ca5804cff7c5bf8ed1c18d790dd52 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 19:21:59 +0100 Subject: [PATCH 107/362] typo --- lasy/utils/laser_utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 401c6cdb..1aeb41c7 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -897,7 +897,6 @@ def get_w0(grid, dim): ---------- sigma: Standard deviation of a**2 in m """ - Calculate the laser waist field = grid.get_temporal_field() if dim == "xyt": Nx, Ny, Nt = field.shape From 28c67ced17c4689908d6d2a8a2bd79f1eed51d5d Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 19:52:03 +0100 Subject: [PATCH 108/362] conver zeta to spectrum expression --- lasy/utils/laser_utils.py | 42 ++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 1aeb41c7..c7bcb6f9 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -972,6 +972,8 @@ def get_STC(dim, grid, k0): } env = grid.get_temporal_field() env_abs = np.abs(env**2) + env_spec = np.abs(grid.get_spectral_field()) + omega = 2 * np.pi * np.fft.fftfreq(len(grid.dx[-1]), grid.dx[-1] / c) + k0 * c phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) # Calculate group-delayed dispersion @@ -983,27 +985,39 @@ def get_STC(dim, grid, k0): ) # Calculate spatio- and angular dispersion if dim == "rt": - pphi_ptpr = (np.diff(pphi_pt, axis=1)) / grid.dx[0] + r_centroids = np.sum(grid.axes[0] * env_spec, axis=0) / np.sum(env_spec, axis=0) + derivative_r = np.gradient(r_centroids, omega,axis=0) + STC_fac["zeta"] = np.average(derivative_r, weights=env_spec) + #pphi_ptpr = (np.diff(pphi_pt, axis=1)) / grid.dx[0] # Use the normalised laser intensity to calculate the weighted average of nu - STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) + #STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) # Transfer the unit from nu to zeta - STC_fac["zeta"] = np.min( - np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) - ) + #STC_fac["zeta"] = np.min( + # np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) + #) # No angular dispersion in 2D and the direction of spatio-chirp is certain if dim == "xyt": - pphi_ptpy = np.gradient(pphi_pt, grid.dx[1], axis=1) - pphi_ptpx = np.gradient(pphi_pt, grid.dx[0], axis=0) + x_centroids = np.sum(grid.axes[0] * env_spec, axis=0) / np.sum(env_spec, axis=0) + y_centroids = np.sum(grid.axes[1] * env_spec, axis=1) / np.sum(env_spec, axis=1) + derivative_x = np.gradient(x_centroids, omega,axis=0) + derivative_y = np.gradient(y_centroids, omega,axis=1) + theta = np.arctan2(derivative_y, derivative_x ) + zeta_x = np.average(derivative_x, weights=env_spec) + zeta_y = np.average(derivative_y, weights=env_spec) + STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) + STC_fac["nu"] = 4*STC_fac["zeta"]/(w0**2*tau**2 + 4*STC_fac["zeta"]**2) + #pphi_ptpy = np.gradient(pphi_pt, grid.dx[1], axis=1) + #pphi_ptpx = np.gradient(pphi_pt, grid.dx[0], axis=0) # Calculate the STC angle in XOY for spatio coupling - theta = np.arctan2(pphi_ptpy, pphi_ptpx) + #theta = np.arctan2(pphi_ptpy, pphi_ptpx) # Use the normalised laser intensity to calculate the weighted average of theta - STC_fac["stc_theta_zeta"] = np.average(theta, weights=env_abs) - pphi_ptpr = np.sqrt(pphi_ptpy**2 + pphi_ptpx**2) + STC_fac["stc_theta_zeta"] = np.average(theta, weights=env_spec) + #pphi_ptpr = np.sqrt(pphi_ptpy**2 + pphi_ptpx**2) # STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) - STC_fac["nu"] = np.sum(pphi_ptpr * env_abs) / np.sum(env_abs) - STC_fac["zeta"] = np.min( - np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) - ) + #STC_fac["nu"] = np.sum(pphi_ptpr * env_abs) / np.sum(env_abs) + #STC_fac["zeta"] = np.min( + # np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) + #) # calculate angular dispersion and pulse front tilt # Use the normalised laser intensity to calculate the weighted average of PFT weight = np.mean(env_abs, axis=2) From 1a0a2e0da9153497a6b685f75c568b4afbe40df1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 18:52:53 +0000 Subject: [PATCH 109/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index c7bcb6f9..8e43e3f5 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -986,38 +986,40 @@ def get_STC(dim, grid, k0): # Calculate spatio- and angular dispersion if dim == "rt": r_centroids = np.sum(grid.axes[0] * env_spec, axis=0) / np.sum(env_spec, axis=0) - derivative_r = np.gradient(r_centroids, omega,axis=0) + derivative_r = np.gradient(r_centroids, omega, axis=0) STC_fac["zeta"] = np.average(derivative_r, weights=env_spec) - #pphi_ptpr = (np.diff(pphi_pt, axis=1)) / grid.dx[0] + # pphi_ptpr = (np.diff(pphi_pt, axis=1)) / grid.dx[0] # Use the normalised laser intensity to calculate the weighted average of nu - #STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) + # STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) # Transfer the unit from nu to zeta - #STC_fac["zeta"] = np.min( + # STC_fac["zeta"] = np.min( # np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) - #) + # ) # No angular dispersion in 2D and the direction of spatio-chirp is certain if dim == "xyt": x_centroids = np.sum(grid.axes[0] * env_spec, axis=0) / np.sum(env_spec, axis=0) y_centroids = np.sum(grid.axes[1] * env_spec, axis=1) / np.sum(env_spec, axis=1) - derivative_x = np.gradient(x_centroids, omega,axis=0) - derivative_y = np.gradient(y_centroids, omega,axis=1) - theta = np.arctan2(derivative_y, derivative_x ) + derivative_x = np.gradient(x_centroids, omega, axis=0) + derivative_y = np.gradient(y_centroids, omega, axis=1) + theta = np.arctan2(derivative_y, derivative_x) zeta_x = np.average(derivative_x, weights=env_spec) zeta_y = np.average(derivative_y, weights=env_spec) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) - STC_fac["nu"] = 4*STC_fac["zeta"]/(w0**2*tau**2 + 4*STC_fac["zeta"]**2) - #pphi_ptpy = np.gradient(pphi_pt, grid.dx[1], axis=1) - #pphi_ptpx = np.gradient(pphi_pt, grid.dx[0], axis=0) + STC_fac["nu"] = ( + 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) + ) + # pphi_ptpy = np.gradient(pphi_pt, grid.dx[1], axis=1) + # pphi_ptpx = np.gradient(pphi_pt, grid.dx[0], axis=0) # Calculate the STC angle in XOY for spatio coupling - #theta = np.arctan2(pphi_ptpy, pphi_ptpx) + # theta = np.arctan2(pphi_ptpy, pphi_ptpx) # Use the normalised laser intensity to calculate the weighted average of theta STC_fac["stc_theta_zeta"] = np.average(theta, weights=env_spec) - #pphi_ptpr = np.sqrt(pphi_ptpy**2 + pphi_ptpx**2) + # pphi_ptpr = np.sqrt(pphi_ptpy**2 + pphi_ptpx**2) # STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) - #STC_fac["nu"] = np.sum(pphi_ptpr * env_abs) / np.sum(env_abs) - #STC_fac["zeta"] = np.min( + # STC_fac["nu"] = np.sum(pphi_ptpr * env_abs) / np.sum(env_abs) + # STC_fac["zeta"] = np.min( # np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) - #) + # ) # calculate angular dispersion and pulse front tilt # Use the normalised laser intensity to calculate the weighted average of PFT weight = np.mean(env_abs, axis=2) From 52985ae30d4f5832faf44d5792e28ac50b798f0c Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 19:58:17 +0100 Subject: [PATCH 110/362] syntex error --- 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 c7bcb6f9..c1d8abc8 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -973,7 +973,7 @@ def get_STC(dim, grid, k0): env = grid.get_temporal_field() env_abs = np.abs(env**2) env_spec = np.abs(grid.get_spectral_field()) - omega = 2 * np.pi * np.fft.fftfreq(len(grid.dx[-1]), grid.dx[-1] / c) + k0 * c + omega = 2 * np.pi * np.fft.fftfreq(len(grid.axes[-1]), grid.dx[-1] / c) + k0 * c phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) # Calculate group-delayed dispersion From b889ed188414a000bab335d1654cb832dbdb915e Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:01:14 +0100 Subject: [PATCH 111/362] DEBUG --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 6ad1c127..5052909c 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -958,8 +958,8 @@ def get_STC(dim, grid, k0): # Initialise the returned dictionary tau = 2 * get_duration(grid, dim) w0 = get_w0(grid, dim) - print(tau) - print(w0) + print(env_abs.shape) + print(env_spec.shape) STC_fac = { "Phi2": 0, "phi2": 0, From 53ed71fa65638e31d58970197452bcbac3aeb1c7 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:02:13 +0100 Subject: [PATCH 112/362] DEBUG --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 5052909c..e4b28197 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -958,8 +958,6 @@ def get_STC(dim, grid, k0): # Initialise the returned dictionary tau = 2 * get_duration(grid, dim) w0 = get_w0(grid, dim) - print(env_abs.shape) - print(env_spec.shape) STC_fac = { "Phi2": 0, "phi2": 0, @@ -973,6 +971,8 @@ def get_STC(dim, grid, k0): env = grid.get_temporal_field() env_abs = np.abs(env**2) env_spec = np.abs(grid.get_spectral_field()) + print(env_abs.shape) + print(env_spec.shape) omega = 2 * np.pi * np.fft.fftfreq(len(grid.axes[-1]), grid.dx[-1] / c) + k0 * c phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) From 027272c07bed9cb6024764360f362aadf6a9da42 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:08:16 +0100 Subject: [PATCH 113/362] fix average axis --- lasy/utils/laser_utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index e4b28197..630ec7f6 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -971,7 +971,7 @@ def get_STC(dim, grid, k0): env = grid.get_temporal_field() env_abs = np.abs(env**2) env_spec = np.abs(grid.get_spectral_field()) - print(env_abs.shape) + print(len(env_abs)) print(env_spec.shape) omega = 2 * np.pi * np.fft.fftfreq(len(grid.axes[-1]), grid.dx[-1] / c) + k0 * c phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) @@ -997,8 +997,10 @@ def get_STC(dim, grid, k0): # ) # No angular dispersion in 2D and the direction of spatio-chirp is certain if dim == "xyt": - x_centroids = np.sum(grid.axes[0] * env_spec, axis=0) / np.sum(env_spec, axis=0) - y_centroids = np.sum(grid.axes[1] * env_spec, axis=1) / np.sum(env_spec, axis=1) + weight_x =np.transpose(env_spec, (1,2,0)) + weight_y =np.transpose(env_spec, (2,0,1)) + x_centroids = np.sum(grid.axes[0] * weight_x, axis=0) / np.sum(weight_x, axis=0) + y_centroids = np.sum(grid.axes[1] * weight_y, axis=1) / np.sum(weight_y, axis=1) derivative_x = np.gradient(x_centroids, omega, axis=0) derivative_y = np.gradient(y_centroids, omega, axis=1) theta = np.arctan2(derivative_y, derivative_x) From 8322337be259acec8cd25df9483b1a277e5e7d8a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 19:08:38 +0000 Subject: [PATCH 114/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 630ec7f6..0be36465 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -997,8 +997,8 @@ def get_STC(dim, grid, k0): # ) # No angular dispersion in 2D and the direction of spatio-chirp is certain if dim == "xyt": - weight_x =np.transpose(env_spec, (1,2,0)) - weight_y =np.transpose(env_spec, (2,0,1)) + weight_x = np.transpose(env_spec, (1, 2, 0)) + weight_y = np.transpose(env_spec, (2, 0, 1)) x_centroids = np.sum(grid.axes[0] * weight_x, axis=0) / np.sum(weight_x, axis=0) y_centroids = np.sum(grid.axes[1] * weight_y, axis=1) / np.sum(weight_y, axis=1) derivative_x = np.gradient(x_centroids, omega, axis=0) From ea38499dd93385b93fdc3167b358b49f586c61f7 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:11:11 +0100 Subject: [PATCH 115/362] dimension error --- lasy/utils/laser_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 630ec7f6..19266cfb 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -999,8 +999,9 @@ def get_STC(dim, grid, k0): if dim == "xyt": weight_x =np.transpose(env_spec, (1,2,0)) weight_y =np.transpose(env_spec, (2,0,1)) - x_centroids = np.sum(grid.axes[0] * weight_x, axis=0) / np.sum(weight_x, axis=0) - y_centroids = np.sum(grid.axes[1] * weight_y, axis=1) / np.sum(weight_y, axis=1) + x_centroids = np.sum(grid.axes[0] * weight_x, axis=1) / np.sum(weight_x, axis=1) + y_centroids = np.sum(grid.axes[1] * weight_y, axis=0) / np.sum(weight_y, axis=0) + print(len(x_centroids)) derivative_x = np.gradient(x_centroids, omega, axis=0) derivative_y = np.gradient(y_centroids, omega, axis=1) theta = np.arctan2(derivative_y, derivative_x) From 2a587bc47ce33ff858e7d5213ae1cda5bc4c0ae3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 19:12:29 +0000 Subject: [PATCH 116/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 19266cfb..1fe028e4 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -997,8 +997,8 @@ def get_STC(dim, grid, k0): # ) # No angular dispersion in 2D and the direction of spatio-chirp is certain if dim == "xyt": - weight_x =np.transpose(env_spec, (1,2,0)) - weight_y =np.transpose(env_spec, (2,0,1)) + weight_x = np.transpose(env_spec, (1, 2, 0)) + weight_y = np.transpose(env_spec, (2, 0, 1)) x_centroids = np.sum(grid.axes[0] * weight_x, axis=1) / np.sum(weight_x, axis=1) y_centroids = np.sum(grid.axes[1] * weight_y, axis=0) / np.sum(weight_y, axis=0) print(len(x_centroids)) From c444d65b0c0295eeb786301dc5ae6e3280cb4824 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:13:25 +0100 Subject: [PATCH 117/362] still dimension --- 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 19266cfb..945d43b2 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -999,7 +999,7 @@ def get_STC(dim, grid, k0): if dim == "xyt": weight_x =np.transpose(env_spec, (1,2,0)) weight_y =np.transpose(env_spec, (2,0,1)) - x_centroids = np.sum(grid.axes[0] * weight_x, axis=1) / np.sum(weight_x, axis=1) + x_centroids = np.sum(grid.axes[0] * weight_x, axis=2) / np.sum(weight_x, axis=2) y_centroids = np.sum(grid.axes[1] * weight_y, axis=0) / np.sum(weight_y, axis=0) print(len(x_centroids)) derivative_x = np.gradient(x_centroids, omega, axis=0) From 5183a4b7511eb2f0476b7af2f93f004b3afbae24 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 19:14:59 +0000 Subject: [PATCH 118/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 9c16802b..ebd3b7f5 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -997,8 +997,8 @@ def get_STC(dim, grid, k0): # ) # No angular dispersion in 2D and the direction of spatio-chirp is certain if dim == "xyt": - weight_x =np.transpose(env_spec, (1,2,0)) - weight_y =np.transpose(env_spec, (2,0,1)) + weight_x = np.transpose(env_spec, (1, 2, 0)) + weight_y = np.transpose(env_spec, (2, 0, 1)) x_centroids = np.sum(grid.axes[0] * weight_x, axis=2) / np.sum(weight_x, axis=2) y_centroids = np.sum(grid.axes[1] * weight_y, axis=0) / np.sum(weight_y, axis=0) From 951af576aaf4f8b0b8d7bd2fc0e80412ee2af3b3 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:16:49 +0100 Subject: [PATCH 119/362] debug --- lasy/utils/laser_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 9c16802b..52d5e801 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -999,6 +999,8 @@ def get_STC(dim, grid, k0): if dim == "xyt": weight_x =np.transpose(env_spec, (1,2,0)) weight_y =np.transpose(env_spec, (2,0,1)) + a = grid.axes[0] * weight_x + print(a.shape) x_centroids = np.sum(grid.axes[0] * weight_x, axis=2) / np.sum(weight_x, axis=2) y_centroids = np.sum(grid.axes[1] * weight_y, axis=0) / np.sum(weight_y, axis=0) From 63118816b162a9161948c1a0298702c3046d2b2f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 19:17:48 +0000 Subject: [PATCH 120/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index ff9edd70..3a3758a0 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -997,8 +997,8 @@ def get_STC(dim, grid, k0): # ) # No angular dispersion in 2D and the direction of spatio-chirp is certain if dim == "xyt": - weight_x =np.transpose(env_spec, (1,2,0)) - weight_y =np.transpose(env_spec, (2,0,1)) + weight_x = np.transpose(env_spec, (1, 2, 0)) + weight_y = np.transpose(env_spec, (2, 0, 1)) a = grid.axes[0] * weight_x print(a.shape) From 7fc7cbb44fd664615319e6f435d994c61b4082f6 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:20:38 +0100 Subject: [PATCH 121/362] FIX dimension --- lasy/utils/laser_utils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index ff9edd70..663e1539 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1006,11 +1006,11 @@ def get_STC(dim, grid, k0): y_centroids = np.sum(grid.axes[1] * weight_y, axis=0) / np.sum(weight_y, axis=0) print(len(x_centroids)) - derivative_x = np.gradient(x_centroids, omega, axis=0) - derivative_y = np.gradient(y_centroids, omega, axis=1) - theta = np.arctan2(derivative_y, derivative_x) - zeta_x = np.average(derivative_x, weights=env_spec) - zeta_y = np.average(derivative_y, weights=env_spec) + derivative_x = np.gradient(x_centroids, omega, axis=1) + derivative_y = np.gradient(y_centroids, omega, axis=0) + zeta_x = np.average(derivative_x, weights=weight_x) + zeta_y = np.average(derivative_y, weights=weight_y) + tSTC_fac["stc_theta_zeta"] = np.arctan2( zeta_y, zeta_x ) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) STC_fac["nu"] = ( 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) @@ -1020,7 +1020,7 @@ def get_STC(dim, grid, k0): # Calculate the STC angle in XOY for spatio coupling # theta = np.arctan2(pphi_ptpy, pphi_ptpx) # Use the normalised laser intensity to calculate the weighted average of theta - STC_fac["stc_theta_zeta"] = np.average(theta, weights=env_spec) + # STC_fac["stc_theta_zeta"] = np.average(theta, weights=env_spec) # pphi_ptpr = np.sqrt(pphi_ptpy**2 + pphi_ptpx**2) # STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) # STC_fac["nu"] = np.sum(pphi_ptpr * env_abs) / np.sum(env_abs) From 2ac2d8bc2461fa7df8470166ff46a003a371e53c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 19:21:07 +0000 Subject: [PATCH 122/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index c3184595..c35a2e6d 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1010,7 +1010,7 @@ def get_STC(dim, grid, k0): derivative_y = np.gradient(y_centroids, omega, axis=0) zeta_x = np.average(derivative_x, weights=weight_x) zeta_y = np.average(derivative_y, weights=weight_y) - tSTC_fac["stc_theta_zeta"] = np.arctan2( zeta_y, zeta_x ) + tSTC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) STC_fac["nu"] = ( 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) @@ -1020,7 +1020,7 @@ def get_STC(dim, grid, k0): # Calculate the STC angle in XOY for spatio coupling # theta = np.arctan2(pphi_ptpy, pphi_ptpx) # Use the normalised laser intensity to calculate the weighted average of theta - # STC_fac["stc_theta_zeta"] = np.average(theta, weights=env_spec) + # STC_fac["stc_theta_zeta"] = np.average(theta, weights=env_spec) # pphi_ptpr = np.sqrt(pphi_ptpy**2 + pphi_ptpx**2) # STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) # STC_fac["nu"] = np.sum(pphi_ptpr * env_abs) / np.sum(env_abs) From 3c8998eae7d3346073a687daf235cb85cfe75d85 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:23:56 +0100 Subject: [PATCH 123/362] fix axis of dx --- lasy/utils/laser_utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index c35a2e6d..4f40be20 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1005,12 +1005,12 @@ def get_STC(dim, grid, k0): x_centroids = np.sum(grid.axes[0] * weight_x, axis=2) / np.sum(weight_x, axis=2) y_centroids = np.sum(grid.axes[1] * weight_y, axis=0) / np.sum(weight_y, axis=0) - print(len(x_centroids)) - derivative_x = np.gradient(x_centroids, omega, axis=1) - derivative_y = np.gradient(y_centroids, omega, axis=0) + print(y_centroids.shape) + derivative_x = np.gradient(x_centroids, omega, axis=2) + derivative_y = np.gradient(y_centroids, omega, axis=2) zeta_x = np.average(derivative_x, weights=weight_x) zeta_y = np.average(derivative_y, weights=weight_y) - tSTC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) + tSTC_fac["stc_theta_zeta"] = np.arctan2( zeta_y, zeta_x ) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) STC_fac["nu"] = ( 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) @@ -1020,7 +1020,7 @@ def get_STC(dim, grid, k0): # Calculate the STC angle in XOY for spatio coupling # theta = np.arctan2(pphi_ptpy, pphi_ptpx) # Use the normalised laser intensity to calculate the weighted average of theta - # STC_fac["stc_theta_zeta"] = np.average(theta, weights=env_spec) + # STC_fac["stc_theta_zeta"] = np.average(theta, weights=env_spec) # pphi_ptpr = np.sqrt(pphi_ptpy**2 + pphi_ptpx**2) # STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) # STC_fac["nu"] = np.sum(pphi_ptpr * env_abs) / np.sum(env_abs) From 50b492e50b8fb7cfcf4f34a321ea7acb147e779e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 19:25:26 +0000 Subject: [PATCH 124/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 4f40be20..1be40f27 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1010,7 +1010,7 @@ def get_STC(dim, grid, k0): derivative_y = np.gradient(y_centroids, omega, axis=2) zeta_x = np.average(derivative_x, weights=weight_x) zeta_y = np.average(derivative_y, weights=weight_y) - tSTC_fac["stc_theta_zeta"] = np.arctan2( zeta_y, zeta_x ) + tSTC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) STC_fac["nu"] = ( 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) @@ -1020,7 +1020,7 @@ def get_STC(dim, grid, k0): # Calculate the STC angle in XOY for spatio coupling # theta = np.arctan2(pphi_ptpy, pphi_ptpx) # Use the normalised laser intensity to calculate the weighted average of theta - # STC_fac["stc_theta_zeta"] = np.average(theta, weights=env_spec) + # STC_fac["stc_theta_zeta"] = np.average(theta, weights=env_spec) # pphi_ptpr = np.sqrt(pphi_ptpy**2 + pphi_ptpx**2) # STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) # STC_fac["nu"] = np.sum(pphi_ptpr * env_abs) / np.sum(env_abs) From 859d320b808cdc282969cafa2ed96decd9dd592b Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:25:31 +0100 Subject: [PATCH 125/362] still unmatch --- lasy/utils/laser_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 4f40be20..1a4f70fc 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1002,9 +1002,10 @@ def get_STC(dim, grid, k0): a = grid.axes[0] * weight_x print(a.shape) - x_centroids = np.sum(grid.axes[0] * weight_x, axis=2) / np.sum(weight_x, axis=2) + x_centroids = np.sum(grid.axes[0] * weight_x, axis=0) / np.sum(weight_x, axis=0) - y_centroids = np.sum(grid.axes[1] * weight_y, axis=0) / np.sum(weight_y, axis=0) + y_centroids = np.sum(grid.axes[1] * weight_y, axis=1) / np.sum(weight_y, axis=1) + print(y_centroids.shape) print(y_centroids.shape) derivative_x = np.gradient(x_centroids, omega, axis=2) derivative_y = np.gradient(y_centroids, omega, axis=2) From 79a59983c841da0c43c8746820a3f4d97267a400 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:27:41 +0100 Subject: [PATCH 126/362] final fix --- lasy/utils/laser_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 1215def0..dd486ed2 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1002,10 +1002,10 @@ def get_STC(dim, grid, k0): a = grid.axes[0] * weight_x print(a.shape) - x_centroids = np.sum(grid.axes[0] * weight_x, axis=0) / np.sum(weight_x, axis=0) + x_centroids = np.sum(grid.axes[0] * weight_x, axis=1) / np.sum(weight_x, axis=1) - y_centroids = np.sum(grid.axes[1] * weight_y, axis=1) / np.sum(weight_y, axis=1) - print(y_centroids.shape) + y_centroids = np.sum(grid.axes[1] * weight_y, axis=0) / np.sum(weight_y, axis=0) + print(x_centroids.shape) print(y_centroids.shape) derivative_x = np.gradient(x_centroids, omega, axis=2) derivative_y = np.gradient(y_centroids, omega, axis=2) From 98fdabd7aebeafc4237c3e1c0da3061cc78e7177 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:28:43 +0100 Subject: [PATCH 127/362] try gain --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index dd486ed2..1a8b68d4 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1002,9 +1002,9 @@ def get_STC(dim, grid, k0): a = grid.axes[0] * weight_x print(a.shape) - x_centroids = np.sum(grid.axes[0] * weight_x, axis=1) / np.sum(weight_x, axis=1) + x_centroids = np.sum(grid.axes[0] * weight_x, axis=2) / np.sum(weight_x, axis=2) - y_centroids = np.sum(grid.axes[1] * weight_y, axis=0) / np.sum(weight_y, axis=0) + y_centroids = np.sum(grid.axes[1] * weight_y, axis=2) / np.sum(weight_y, axis=2) print(x_centroids.shape) print(y_centroids.shape) derivative_x = np.gradient(x_centroids, omega, axis=2) From c5c114abeda3c989eb0afd6240f4527cd2ea243a Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:29:41 +0100 Subject: [PATCH 128/362] fixed --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 1a8b68d4..08d22e8c 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1007,8 +1007,8 @@ def get_STC(dim, grid, k0): y_centroids = np.sum(grid.axes[1] * weight_y, axis=2) / np.sum(weight_y, axis=2) print(x_centroids.shape) print(y_centroids.shape) - derivative_x = np.gradient(x_centroids, omega, axis=2) - derivative_y = np.gradient(y_centroids, omega, axis=2) + derivative_x = np.gradient(x_centroids, omega, axis=1) + derivative_y = np.gradient(y_centroids, omega, axis=0) zeta_x = np.average(derivative_x, weights=weight_x) zeta_y = np.average(derivative_y, weights=weight_y) tSTC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) From 3bb6ee35f49daafdd2dc9b4a977677a409e13106 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:31:03 +0100 Subject: [PATCH 129/362] calculate zeta --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 08d22e8c..72c787c7 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1009,8 +1009,8 @@ def get_STC(dim, grid, k0): print(y_centroids.shape) derivative_x = np.gradient(x_centroids, omega, axis=1) derivative_y = np.gradient(y_centroids, omega, axis=0) - zeta_x = np.average(derivative_x, weights=weight_x) - zeta_y = np.average(derivative_y, weights=weight_y) + zeta_x = np.average(derivative_x.T, weights=weight_x) + zeta_y = np.average(derivative_y.T, weights=weight_y) tSTC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) STC_fac["nu"] = ( From 24a313f68e241ee435ad75f2727cebf81ede66e3 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:33:39 +0100 Subject: [PATCH 130/362] fix zeta --- lasy/utils/laser_utils.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 72c787c7..48b2272f 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1005,13 +1005,14 @@ def get_STC(dim, grid, k0): x_centroids = np.sum(grid.axes[0] * weight_x, axis=2) / np.sum(weight_x, axis=2) y_centroids = np.sum(grid.axes[1] * weight_y, axis=2) / np.sum(weight_y, axis=2) - print(x_centroids.shape) - print(y_centroids.shape) + derivative_x = np.gradient(x_centroids, omega, axis=1) derivative_y = np.gradient(y_centroids, omega, axis=0) - zeta_x = np.average(derivative_x.T, weights=weight_x) - zeta_y = np.average(derivative_y.T, weights=weight_y) - tSTC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) + print(derivative_x.shape) + print(y_centroids.shape) + zeta_x = np.average(derivative_x.T, weights=np.mean(weight_x, axis = 1)) + zeta_y = np.average(derivative_y.T, weights=np.mean(weight_y,axis=0)) + STC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) STC_fac["nu"] = ( 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) From 55b9db7156642c474cecaae90e07b0ade982a7af Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 19:33:57 +0000 Subject: [PATCH 131/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 48b2272f..c8855c2d 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1010,8 +1010,8 @@ def get_STC(dim, grid, k0): derivative_y = np.gradient(y_centroids, omega, axis=0) print(derivative_x.shape) print(y_centroids.shape) - zeta_x = np.average(derivative_x.T, weights=np.mean(weight_x, axis = 1)) - zeta_y = np.average(derivative_y.T, weights=np.mean(weight_y,axis=0)) + zeta_x = np.average(derivative_x.T, weights=np.mean(weight_x, axis=1)) + zeta_y = np.average(derivative_y.T, weights=np.mean(weight_y, axis=0)) STC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) STC_fac["nu"] = ( From 08e32a6e61bcf2ae16c54e79870d1ebf386d3a01 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:35:37 +0100 Subject: [PATCH 132/362] fix dxdw --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index c8855c2d..df8f32ac 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1010,8 +1010,8 @@ def get_STC(dim, grid, k0): derivative_y = np.gradient(y_centroids, omega, axis=0) print(derivative_x.shape) print(y_centroids.shape) - zeta_x = np.average(derivative_x.T, weights=np.mean(weight_x, axis=1)) - zeta_y = np.average(derivative_y.T, weights=np.mean(weight_y, axis=0)) + zeta_x = np.average(derivative_x, weights=np.mean(weight_x, axis = 1)) + zeta_y = np.average(derivative_y, weights=np.mean(weight_y,axis=0)) STC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) STC_fac["nu"] = ( From 335bc9ae24bc25abd57332bd1d56b9e1a3cbc528 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 19:36:00 +0000 Subject: [PATCH 133/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index df8f32ac..92f7c534 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1010,8 +1010,8 @@ def get_STC(dim, grid, k0): derivative_y = np.gradient(y_centroids, omega, axis=0) print(derivative_x.shape) print(y_centroids.shape) - zeta_x = np.average(derivative_x, weights=np.mean(weight_x, axis = 1)) - zeta_y = np.average(derivative_y, weights=np.mean(weight_y,axis=0)) + zeta_x = np.average(derivative_x, weights=np.mean(weight_x, axis=1)) + zeta_y = np.average(derivative_y, weights=np.mean(weight_y, axis=0)) STC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) STC_fac["nu"] = ( From 750c3957716b69431fb6098c0c380db904e88491 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:39:37 +0100 Subject: [PATCH 134/362] print the dimensions --- lasy/utils/laser_utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index df8f32ac..dc87c972 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1009,7 +1009,13 @@ def get_STC(dim, grid, k0): derivative_x = np.gradient(x_centroids, omega, axis=1) derivative_y = np.gradient(y_centroids, omega, axis=0) print(derivative_x.shape) - print(y_centroids.shape) + a =np.mean(weight_x, axis = 1) + b =np.mean(weight_x, axis = 0) + 2 =np.mean(weight_x, axis = 2) + print(a.shape) + print(b.shape) + print(c.shape) + print(derivative_x.shape) zeta_x = np.average(derivative_x, weights=np.mean(weight_x, axis = 1)) zeta_y = np.average(derivative_y, weights=np.mean(weight_y,axis=0)) STC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) From 40aab65c44075df0b0ba81e16b3f91bd071e8940 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:40:50 +0100 Subject: [PATCH 135/362] TYPO --- 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 dd409d15..f82178bb 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1012,7 +1012,7 @@ def get_STC(dim, grid, k0): a =np.mean(weight_x, axis = 1) b =np.mean(weight_x, axis = 0) - 2 =np.mean(weight_x, axis = 2) + c =np.mean(weight_x, axis = 2) print(a.shape) print(b.shape) print(c.shape) From ea013bce8bdd69ef4ac47b6e81c2a0bddf95fa94 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 19:41:10 +0000 Subject: [PATCH 136/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index f82178bb..1c66168d 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1010,15 +1010,15 @@ def get_STC(dim, grid, k0): derivative_y = np.gradient(y_centroids, omega, axis=0) print(derivative_x.shape) - a =np.mean(weight_x, axis = 1) - b =np.mean(weight_x, axis = 0) - c =np.mean(weight_x, axis = 2) + a = np.mean(weight_x, axis=1) + b = np.mean(weight_x, axis=0) + c = np.mean(weight_x, axis=2) print(a.shape) print(b.shape) print(c.shape) print(derivative_x.shape) - zeta_x = np.average(derivative_x, weights=np.mean(weight_x, axis = 1)) - zeta_y = np.average(derivative_y, weights=np.mean(weight_y,axis=0)) + zeta_x = np.average(derivative_x, weights=np.mean(weight_x, axis=1)) + zeta_y = np.average(derivative_y, weights=np.mean(weight_y, axis=0)) STC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) From 852f545850a4465509cd4b260610f0d347c44be5 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:41:35 +0100 Subject: [PATCH 137/362] name confliction --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index f82178bb..4da1c38f 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1012,10 +1012,10 @@ def get_STC(dim, grid, k0): a =np.mean(weight_x, axis = 1) b =np.mean(weight_x, axis = 0) - c =np.mean(weight_x, axis = 2) + cc =np.mean(weight_x, axis = 2) print(a.shape) print(b.shape) - print(c.shape) + print(cc.shape) print(derivative_x.shape) zeta_x = np.average(derivative_x, weights=np.mean(weight_x, axis = 1)) zeta_y = np.average(derivative_y, weights=np.mean(weight_y,axis=0)) From ee8128fc16a69a47f26c61b3a620f25abbe80ead Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 19:42:40 +0000 Subject: [PATCH 138/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index c68ed6b0..4ffbca24 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1010,9 +1010,9 @@ def get_STC(dim, grid, k0): derivative_y = np.gradient(y_centroids, omega, axis=0) print(derivative_x.shape) - a =np.mean(weight_x, axis = 1) - b =np.mean(weight_x, axis = 0) - cc =np.mean(weight_x, axis = 2) + a = np.mean(weight_x, axis=1) + b = np.mean(weight_x, axis=0) + cc = np.mean(weight_x, axis=2) print(a.shape) print(b.shape) From f236de3332fc9f999c85e5cfb0c88e933a8448b4 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:43:10 +0100 Subject: [PATCH 139/362] check y dir --- lasy/utils/laser_utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index c68ed6b0..eedd28f9 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1010,15 +1010,15 @@ def get_STC(dim, grid, k0): derivative_y = np.gradient(y_centroids, omega, axis=0) print(derivative_x.shape) - a =np.mean(weight_x, axis = 1) - b =np.mean(weight_x, axis = 0) - cc =np.mean(weight_x, axis = 2) + a =np.mean(weight_y, axis = 1) + b =np.mean(weight_y, axis = 0) + cc =np.mean(weight_y, axis = 2) print(a.shape) print(b.shape) print(cc.shape) - print(derivative_x.shape) - zeta_x = np.average(derivative_x, weights=np.mean(weight_x, axis=1)) + print(derivative_y.shape) + zeta_x = np.average(derivative_x, weights=np.mean(weight_x, axis=2)) zeta_y = np.average(derivative_y, weights=np.mean(weight_y, axis=0)) STC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) From f4866b390a2262444ade09e7b9f7bb35c4ca4293 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 20:44:11 +0100 Subject: [PATCH 140/362] SETTLE --- 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 03409fb8..732c8337 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1021,7 +1021,7 @@ def get_STC(dim, grid, k0): print(cc.shape) print(derivative_y.shape) zeta_x = np.average(derivative_x, weights=np.mean(weight_x, axis=2)) - zeta_y = np.average(derivative_y, weights=np.mean(weight_y, axis=0)) + zeta_y = np.average(derivative_y, weights=np.mean(weight_y, axis=2)) STC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) From 5ee8dfeb7b3eab03053e64247672600017555856 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 19:46:55 +0000 Subject: [PATCH 141/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 732c8337..9369d8d5 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1010,11 +1010,9 @@ def get_STC(dim, grid, k0): derivative_y = np.gradient(y_centroids, omega, axis=0) print(derivative_x.shape) - - a =np.mean(weight_y, axis = 1) - b =np.mean(weight_y, axis = 0) - cc =np.mean(weight_y, axis = 2) - + a = np.mean(weight_y, axis=1) + b = np.mean(weight_y, axis=0) + cc = np.mean(weight_y, axis=2) print(a.shape) print(b.shape) From 06975f5ce4faf61ea5689fd57262acc24be63ccb Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 22:57:01 +0100 Subject: [PATCH 142/362] update zeta calculation for rt --- lasy/laser.py | 1 - lasy/utils/laser_utils.py | 17 +++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lasy/laser.py b/lasy/laser.py index c56e1db4..e122631e 100644 --- a/lasy/laser.py +++ b/lasy/laser.py @@ -114,7 +114,6 @@ def __init__( dt = self.grid.dx[time_axis_indx] Nt = self.grid.shape[time_axis_indx] self.omega_1d = 2 * np.pi * np.fft.fftfreq(Nt, dt) + profile.omega0 - # Create the grid on which to evaluate the laser, evaluate it if self.dim == "xyt": x, y, t = np.meshgrid(*self.grid.axes, indexing="ij") diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 732c8337..8187dafd 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -971,9 +971,10 @@ def get_STC(dim, grid, k0): env = grid.get_temporal_field() env_abs = np.abs(env**2) env_spec = np.abs(grid.get_spectral_field()) - print(len(env_abs)) - print(env_spec.shape) - omega = 2 * np.pi * np.fft.fftfreq(len(grid.axes[-1]), grid.dx[-1] / c) + k0 * c + # Get the spectral axis + dt = grid.dx[time_axis_indx] + Nt = grid.shape[time_axis_indx] + omega_= 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0*c phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) # Calculate group-delayed dispersion @@ -985,9 +986,13 @@ def get_STC(dim, grid, k0): ) # Calculate spatio- and angular dispersion if dim == "rt": - r_centroids = np.sum(grid.axes[0] * env_spec, axis=0) / np.sum(env_spec, axis=0) - derivative_r = np.gradient(r_centroids, omega, axis=0) - STC_fac["zeta"] = np.average(derivative_r, weights=env_spec) + rda=np.sum(grid.axes[0]*env_spec[0,:,:].T,axis=1)/np.sum(env_spec,axis=1) + derivative_r = np.gradient(rda[0,:],omega, axis=0) + weight=np.mean(env_spec,axis=1) + STC_fac["zeta"] = -3*np.average(derivative_r, weights=weight[0]) + STC_fac["nu"] = ( + 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) + ) # pphi_ptpr = (np.diff(pphi_pt, axis=1)) / grid.dx[0] # Use the normalised laser intensity to calculate the weighted average of nu # STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) From f8b2b872b8741af2471c91bd228b17bb221801cd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 21:57:35 +0000 Subject: [PATCH 143/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 8f358df2..fb969d97 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -974,7 +974,7 @@ def get_STC(dim, grid, k0): # Get the spectral axis dt = grid.dx[time_axis_indx] Nt = grid.shape[time_axis_indx] - omega_= 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0*c + omega_ = 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0 * c phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) # Calculate group-delayed dispersion @@ -986,10 +986,12 @@ def get_STC(dim, grid, k0): ) # Calculate spatio- and angular dispersion if dim == "rt": - rda=np.sum(grid.axes[0]*env_spec[0,:,:].T,axis=1)/np.sum(env_spec,axis=1) - derivative_r = np.gradient(rda[0,:],omega, axis=0) - weight=np.mean(env_spec,axis=1) - STC_fac["zeta"] = -3*np.average(derivative_r, weights=weight[0]) + rda = np.sum(grid.axes[0] * env_spec[0, :, :].T, axis=1) / np.sum( + env_spec, axis=1 + ) + derivative_r = np.gradient(rda[0, :], omega, axis=0) + weight = np.mean(env_spec, axis=1) + STC_fac["zeta"] = -3 * np.average(derivative_r, weights=weight[0]) STC_fac["nu"] = ( 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) ) From 5657ae9069084974d0010e58690ef2cc3f32cc50 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 23:16:27 +0100 Subject: [PATCH 144/362] update zeta for xyt --- lasy/utils/laser_utils.py | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 8f358df2..c32a1a20 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -974,7 +974,7 @@ def get_STC(dim, grid, k0): # Get the spectral axis dt = grid.dx[time_axis_indx] Nt = grid.shape[time_axis_indx] - omega_= 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0*c + omega= 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0*c phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) # Calculate group-delayed dispersion @@ -1002,30 +1002,16 @@ def get_STC(dim, grid, k0): # ) # No angular dispersion in 2D and the direction of spatio-chirp is certain if dim == "xyt": - weight_x = np.transpose(env_spec, (1, 2, 0)) - weight_y = np.transpose(env_spec, (2, 0, 1)) - a = grid.axes[0] * weight_x - print(a.shape) - - x_centroids = np.sum(grid.axes[0] * weight_x, axis=2) / np.sum(weight_x, axis=2) - - y_centroids = np.sum(grid.axes[1] * weight_y, axis=2) / np.sum(weight_y, axis=2) - - derivative_x = np.gradient(x_centroids, omega, axis=1) - derivative_y = np.gradient(y_centroids, omega, axis=0) - print(derivative_x.shape) - - a = np.mean(weight_y, axis=1) - b = np.mean(weight_y, axis=0) - cc = np.mean(weight_y, axis=2) - - print(a.shape) - print(b.shape) - print(cc.shape) - print(derivative_y.shape) - zeta_x = np.average(derivative_x, weights=np.mean(weight_x, axis=2)) - zeta_y = np.average(derivative_y, weights=np.mean(weight_y, axis=2)) - + weight_x = np.transpose(env_spec, (2,1, 0)) + weight_y = np.transpose(env_spec, (2,0, 1)) + xda=np.sum(grid.axes[0]*weight_x,axis=2)/np.sum(weight_x,axis=2) + yda=np.sum(grid.axes[1]*weight_y,axis=2)/np.sum(weight_y,axis=2) + derivative_x = np.gradient(xda,omega, axis=0) + derivative_y = np.gradient(yda,omega, axis=0) + weight_x=np.mean(env_spec,axis=0) + weight_y=np.mean(env_spec,axis=1) + zeta_x=np.average(derivative_x.T, weights=weight_x) + zeta_y=np.average(derivative_y.T, weights=weight_y) STC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) STC_fac["nu"] = ( From 76a26fc8b7bf6db56dff8f58430ec68069ccc8b1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 22:17:28 +0000 Subject: [PATCH 145/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 9ff1f99e..502ac683 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1006,16 +1006,16 @@ def get_STC(dim, grid, k0): # ) # No angular dispersion in 2D and the direction of spatio-chirp is certain if dim == "xyt": - weight_x = np.transpose(env_spec, (2,1, 0)) - weight_y = np.transpose(env_spec, (2,0, 1)) - xda=np.sum(grid.axes[0]*weight_x,axis=2)/np.sum(weight_x,axis=2) - yda=np.sum(grid.axes[1]*weight_y,axis=2)/np.sum(weight_y,axis=2) - derivative_x = np.gradient(xda,omega, axis=0) - derivative_y = np.gradient(yda,omega, axis=0) - weight_x=np.mean(env_spec,axis=0) - weight_y=np.mean(env_spec,axis=1) - zeta_x=np.average(derivative_x.T, weights=weight_x) - zeta_y=np.average(derivative_y.T, weights=weight_y) + weight_x = np.transpose(env_spec, (2, 1, 0)) + weight_y = np.transpose(env_spec, (2, 0, 1)) + xda = np.sum(grid.axes[0] * weight_x, axis=2) / np.sum(weight_x, axis=2) + yda = np.sum(grid.axes[1] * weight_y, axis=2) / np.sum(weight_y, axis=2) + derivative_x = np.gradient(xda, omega, axis=0) + derivative_y = np.gradient(yda, omega, axis=0) + weight_x = np.mean(env_spec, axis=0) + weight_y = np.mean(env_spec, axis=1) + zeta_x = np.average(derivative_x.T, weights=weight_x) + zeta_y = np.average(derivative_y.T, weights=weight_y) STC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) STC_fac["nu"] = ( From d061713fd6c28ec67fa8e2e990c3c641d78602db Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 29 Oct 2024 23:20:31 +0100 Subject: [PATCH 146/362] fix bug --- lasy/utils/laser_utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 9ff1f99e..b98cf83a 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -972,9 +972,8 @@ def get_STC(dim, grid, k0): env_abs = np.abs(env**2) env_spec = np.abs(grid.get_spectral_field()) # Get the spectral axis - dt = grid.dx[time_axis_indx] - Nt = grid.shape[time_axis_indx] - + dt = grid.dx[-1] + Nt = grid.shape[-1] omega = 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0 * c phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) From 768842a49a35f5bd0163bfc103c03088f04a0d75 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 29 Oct 2024 23:49:21 +0100 Subject: [PATCH 147/362] 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 f7b6c9bd..d13f9944 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1043,7 +1043,7 @@ def get_STC(dim, grid, k0): STC_fac["pft"] = np.sqrt((pft_x**2 + pft_y**2)) STC_fac["stc_theta_beta"] = np.arctan2(pft_y, pft_x) STC_fac["beta"] = ( - np.sqrt((pft_x**2 + pft_y**2)) - STC_fac["Phi2"] * STC_fac["nu"] + np.sqrt((pft_x**2 + pft_y**2)) - STC_fac["phi2"] * STC_fac["nu"] ) / k0 return STC_fac From f39be57f7d909993b2f0ce86db4c2ae920bb7be7 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 30 Oct 2024 00:00:32 +0100 Subject: [PATCH 148/362] clean the comments --- lasy/utils/laser_utils.py | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index d13f9944..c232aa64 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -996,14 +996,6 @@ def get_STC(dim, grid, k0): STC_fac["nu"] = ( 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) ) - # pphi_ptpr = (np.diff(pphi_pt, axis=1)) / grid.dx[0] - # Use the normalised laser intensity to calculate the weighted average of nu - # STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) - # Transfer the unit from nu to zeta - # STC_fac["zeta"] = np.min( - # np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) - # ) - # No angular dispersion in 2D and the direction of spatio-chirp is certain if dim == "xyt": weight_x = np.transpose(env_spec, (2, 1, 0)) weight_y = np.transpose(env_spec, (2, 0, 1)) @@ -1020,30 +1012,18 @@ def get_STC(dim, grid, k0): STC_fac["nu"] = ( 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) ) - # pphi_ptpy = np.gradient(pphi_pt, grid.dx[1], axis=1) - # pphi_ptpx = np.gradient(pphi_pt, grid.dx[0], axis=0) - # Calculate the STC angle in XOY for spatio coupling - # theta = np.arctan2(pphi_ptpy, pphi_ptpx) - # Use the normalised laser intensity to calculate the weighted average of theta - # STC_fac["stc_theta_zeta"] = np.average(theta, weights=env_spec) - # pphi_ptpr = np.sqrt(pphi_ptpy**2 + pphi_ptpx**2) - # STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) - # STC_fac["nu"] = np.sum(pphi_ptpr * env_abs) / np.sum(env_abs) - # STC_fac["zeta"] = np.min( - # np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) - # ) - # calculate angular dispersion and pulse front tilt # Use the normalised laser intensity to calculate the weighted average of PFT weight = np.mean(env_abs, axis=2) z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) - derivative_x = np.gradient(z_centroids, axis=0) / grid.dx[0] - derivative_y = np.gradient(z_centroids, axis=1) / grid.dx[1] + derivative_x = (np.gradient(z_centroids, axis=0) / grid.dx[0]) + derivative_y = (np.gradient(z_centroids, axis=1) / grid.dx[1]) + pft_x = np.average(derivative_x, weights=weight) pft_y = np.average(derivative_y, weights=weight) STC_fac["pft"] = np.sqrt((pft_x**2 + pft_y**2)) STC_fac["stc_theta_beta"] = np.arctan2(pft_y, pft_x) STC_fac["beta"] = ( - np.sqrt((pft_x**2 + pft_y**2)) - STC_fac["phi2"] * STC_fac["nu"] + np.sqrt((pft_x**2 + pft_y**2)) - STC_fac["Phi2"] * STC_fac["nu"] ) / k0 return STC_fac From b4f920748506df4b2364f091b9d038fa1ccac7d7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 23:01:16 +0000 Subject: [PATCH 149/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index c232aa64..a2e4a517 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1015,8 +1015,8 @@ def get_STC(dim, grid, k0): # Use the normalised laser intensity to calculate the weighted average of PFT weight = np.mean(env_abs, axis=2) z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) - derivative_x = (np.gradient(z_centroids, axis=0) / grid.dx[0]) - derivative_y = (np.gradient(z_centroids, axis=1) / grid.dx[1]) + derivative_x = np.gradient(z_centroids, axis=0) / grid.dx[0] + derivative_y = np.gradient(z_centroids, axis=1) / grid.dx[1] pft_x = np.average(derivative_x, weights=weight) pft_y = np.average(derivative_y, weights=weight) From 29495d18a766d98de952ddb562237a80980b167e Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 30 Oct 2024 00:01:27 +0100 Subject: [PATCH 150/362] Update laser.py --- lasy/laser.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lasy/laser.py b/lasy/laser.py index e122631e..6d2aebbd 100644 --- a/lasy/laser.py +++ b/lasy/laser.py @@ -114,6 +114,7 @@ def __init__( dt = self.grid.dx[time_axis_indx] Nt = self.grid.shape[time_axis_indx] self.omega_1d = 2 * np.pi * np.fft.fftfreq(Nt, dt) + profile.omega0 + # Create the grid on which to evaluate the laser, evaluate it if self.dim == "xyt": x, y, t = np.meshgrid(*self.grid.axes, indexing="ij") From 7dba5cd90f2881d81fcef8bed4fa87ef88dc60cd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 23:02:05 +0000 Subject: [PATCH 151/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/laser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/laser.py b/lasy/laser.py index 6d2aebbd..c56e1db4 100644 --- a/lasy/laser.py +++ b/lasy/laser.py @@ -114,7 +114,7 @@ def __init__( dt = self.grid.dx[time_axis_indx] Nt = self.grid.shape[time_axis_indx] self.omega_1d = 2 * np.pi * np.fft.fftfreq(Nt, dt) + profile.omega0 - + # Create the grid on which to evaluate the laser, evaluate it if self.dim == "xyt": x, y, t = np.meshgrid(*self.grid.axes, indexing="ij") From 8bb4c42bf1ccc4f28fe9da0116ebfbc20d1d5cdf Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 30 Oct 2024 00:13:52 +0100 Subject: [PATCH 152/362] check the shape of phi2 and nu --- lasy/utils/laser_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index c232aa64..bb76a7cf 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -981,6 +981,8 @@ def get_STC(dim, grid, k0): # Calculate group-delayed dispersion pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) # Use the normalised laser intensity to calculate the weighted average of Phi2 + phi2 = np.roots([4 * pphi_pt2, -4, tau**4 *pphi_pt2]) + print(phi2.shape) STC_fac["Phi2"] = np.average(pphi_pt2, weights=env_abs) STC_fac["phi2"] = np.max( np.roots([4 * STC_fac["Phi2"], -4, tau**4 * STC_fac["Phi2"]]) @@ -1007,6 +1009,7 @@ def get_STC(dim, grid, k0): weight_y = np.mean(env_spec, axis=1) zeta_x = np.average(derivative_x.T, weights=weight_x) zeta_y = np.average(derivative_y.T, weights=weight_y) + print(derivative_x.shape) STC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) STC_fac["nu"] = ( @@ -1017,7 +1020,6 @@ def get_STC(dim, grid, k0): z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) derivative_x = (np.gradient(z_centroids, axis=0) / grid.dx[0]) derivative_y = (np.gradient(z_centroids, axis=1) / grid.dx[1]) - pft_x = np.average(derivative_x, weights=weight) pft_y = np.average(derivative_y, weights=weight) STC_fac["pft"] = np.sqrt((pft_x**2 + pft_y**2)) From e3c5e876af45862b70cd714d0c1263149f0d345c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 23:16:16 +0000 Subject: [PATCH 153/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- 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 75cd46d4..bef0c93e 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -981,7 +981,7 @@ def get_STC(dim, grid, k0): # Calculate group-delayed dispersion pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) # Use the normalised laser intensity to calculate the weighted average of Phi2 - phi2 = np.roots([4 * pphi_pt2, -4, tau**4 *pphi_pt2]) + phi2 = np.roots([4 * pphi_pt2, -4, tau**4 * pphi_pt2]) print(phi2.shape) STC_fac["Phi2"] = np.average(pphi_pt2, weights=env_abs) STC_fac["phi2"] = np.max( From 869c2709056cb3203110d0a827d695d0ee857e52 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 30 Oct 2024 00:20:35 +0100 Subject: [PATCH 154/362] calculate phi2 distribution --- lasy/utils/laser_utils.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 75cd46d4..5e095aee 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -981,8 +981,6 @@ def get_STC(dim, grid, k0): # Calculate group-delayed dispersion pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) # Use the normalised laser intensity to calculate the weighted average of Phi2 - phi2 = np.roots([4 * pphi_pt2, -4, tau**4 *pphi_pt2]) - print(phi2.shape) STC_fac["Phi2"] = np.average(pphi_pt2, weights=env_abs) STC_fac["phi2"] = np.max( np.roots([4 * STC_fac["Phi2"], -4, tau**4 * STC_fac["Phi2"]]) @@ -1010,6 +1008,18 @@ def get_STC(dim, grid, k0): zeta_x = np.average(derivative_x.T, weights=weight_x) zeta_y = np.average(derivative_y.T, weights=weight_y) print(derivative_x.shape) + # Get the shape of pphi_pt2 + shape = pphi_pt2.shape + phi2 = np.empty(shape, dtype=object) # Create an array to store roots + + # Loop through each element in pphi_pt2 + for i in range(shape[0]): + for j in range(shape[1]): + for k in range(shape[2]): + # Calculate roots for each element + coeffs = [4 * pphi_pt2[i, j, k], -4, tau**4 * pphi_pt2[i, j, k]] + phi2[i, j, k] = np.roots(coeffs) + print(phi2.shape) STC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) STC_fac["nu"] = ( From da2767a581ff686f4df9f7d88f36d544e027c53e Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 30 Oct 2024 00:21:19 +0100 Subject: [PATCH 155/362] phi2 --- lasy/utils/laser_utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 5e095aee..32a560ed 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1011,7 +1011,6 @@ def get_STC(dim, grid, k0): # Get the shape of pphi_pt2 shape = pphi_pt2.shape phi2 = np.empty(shape, dtype=object) # Create an array to store roots - # Loop through each element in pphi_pt2 for i in range(shape[0]): for j in range(shape[1]): From eece1ee86400eb93cadda2a1c7a7f1c57397e53f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 23:22:36 +0000 Subject: [PATCH 156/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- 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 32a560ed..6a364f5a 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1015,7 +1015,7 @@ def get_STC(dim, grid, k0): for i in range(shape[0]): for j in range(shape[1]): for k in range(shape[2]): - # Calculate roots for each element + # Calculate roots for each element coeffs = [4 * pphi_pt2[i, j, k], -4, tau**4 * pphi_pt2[i, j, k]] phi2[i, j, k] = np.roots(coeffs) print(phi2.shape) From 783a6e9ec6cb3c096d4a8b99a90810b1b2c339e7 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 30 Oct 2024 00:34:11 +0100 Subject: [PATCH 157/362] calculate weight phi2nu --- lasy/utils/laser_utils.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 32a560ed..3da91b6d 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1009,16 +1009,18 @@ def get_STC(dim, grid, k0): zeta_y = np.average(derivative_y.T, weights=weight_y) print(derivative_x.shape) # Get the shape of pphi_pt2 - shape = pphi_pt2.shape - phi2 = np.empty(shape, dtype=object) # Create an array to store roots + Phi2_mean= np.mean(pphi_pt2, axis=0).T + weight = np.mean(env_abs, axis=0) + phi2 = np.empty(Phi2_mean.shape, dtype=object) # Create an array to store roots # Loop through each element in pphi_pt2 - for i in range(shape[0]): - for j in range(shape[1]): - for k in range(shape[2]): + for i in range(Phi2_mean.shape[0]): + for j in range(Phi2_mean.shape[1]): # Calculate roots for each element - coeffs = [4 * pphi_pt2[i, j, k], -4, tau**4 * pphi_pt2[i, j, k]] - phi2[i, j, k] = np.roots(coeffs) - print(phi2.shape) + coeffs = [4 * pphi_pt2[i, j], -4, tau**4 * pphi_pt2[i, j]] + phi2[i, j] = np.roots(coeffs) + phi2nu=np.average(phi2*derivative_x, weights=weight) + print(phi2nu) + print(phi2nu.shape) STC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) STC_fac["nu"] = ( @@ -1029,7 +1031,6 @@ def get_STC(dim, grid, k0): z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) derivative_x = np.gradient(z_centroids, axis=0) / grid.dx[0] derivative_y = np.gradient(z_centroids, axis=1) / grid.dx[1] - print(derivative_x.shape) pft_x = np.average(derivative_x, weights=weight) pft_y = np.average(derivative_y, weights=weight) STC_fac["pft"] = np.sqrt((pft_x**2 + pft_y**2)) From 07ab81329970f111091e2e7b8e6485aa382dd380 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 30 Oct 2024 00:35:29 +0100 Subject: [PATCH 158/362] clearn the confliction --- lasy/utils/laser_utils.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 463272ae..2e91ce93 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1013,7 +1013,6 @@ def get_STC(dim, grid, k0): weight = np.mean(env_abs, axis=0) phi2 = np.empty(Phi2_mean.shape, dtype=object) # Create an array to store roots # Loop through each element in pphi_pt2 -<<<<<<< HEAD for i in range(Phi2_mean.shape[0]): for j in range(Phi2_mean.shape[1]): # Calculate roots for each element @@ -1022,15 +1021,7 @@ def get_STC(dim, grid, k0): phi2nu=np.average(phi2*derivative_x, weights=weight) print(phi2nu) print(phi2nu.shape) -======= - for i in range(shape[0]): - for j in range(shape[1]): - for k in range(shape[2]): - # Calculate roots for each element - coeffs = [4 * pphi_pt2[i, j, k], -4, tau**4 * pphi_pt2[i, j, k]] - phi2[i, j, k] = np.roots(coeffs) - print(phi2.shape) ->>>>>>> refs/remotes/huixingjian/add_diag_util + STC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) STC_fac["nu"] = ( From 2be543078d61b3d6f9c2215bf8b27c0adbe653b9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 23:35:51 +0000 Subject: [PATCH 159/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 2e91ce93..2d8798e9 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1009,16 +1009,16 @@ def get_STC(dim, grid, k0): zeta_y = np.average(derivative_y.T, weights=weight_y) print(derivative_x.shape) # Get the shape of pphi_pt2 - Phi2_mean= np.mean(pphi_pt2, axis=0).T + Phi2_mean = np.mean(pphi_pt2, axis=0).T weight = np.mean(env_abs, axis=0) phi2 = np.empty(Phi2_mean.shape, dtype=object) # Create an array to store roots # Loop through each element in pphi_pt2 for i in range(Phi2_mean.shape[0]): for j in range(Phi2_mean.shape[1]): - # Calculate roots for each element - coeffs = [4 * pphi_pt2[i, j], -4, tau**4 * pphi_pt2[i, j]] - phi2[i, j] = np.roots(coeffs) - phi2nu=np.average(phi2*derivative_x, weights=weight) + # Calculate roots for each element + coeffs = [4 * pphi_pt2[i, j], -4, tau**4 * pphi_pt2[i, j]] + phi2[i, j] = np.roots(coeffs) + phi2nu = np.average(phi2 * derivative_x, weights=weight) print(phi2nu) print(phi2nu.shape) From a8f314d7e5c9c75d16e57f2d50d5fc92391b4ec0 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 30 Oct 2024 00:36:37 +0100 Subject: [PATCH 160/362] syntx error --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 2e91ce93..a4c366eb 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1011,12 +1011,12 @@ def get_STC(dim, grid, k0): # Get the shape of pphi_pt2 Phi2_mean= np.mean(pphi_pt2, axis=0).T weight = np.mean(env_abs, axis=0) - phi2 = np.empty(Phi2_mean.shape, dtype=object) # Create an array to store roots + phi2 = np.zeros(Phi2_mean.shape) # Create an array to store roots # Loop through each element in pphi_pt2 for i in range(Phi2_mean.shape[0]): for j in range(Phi2_mean.shape[1]): # Calculate roots for each element - coeffs = [4 * pphi_pt2[i, j], -4, tau**4 * pphi_pt2[i, j]] + coeffs = [4 * Phi2_mean[i, j], -4, tau**4 * Phi2_mean[i, j]] phi2[i, j] = np.roots(coeffs) phi2nu=np.average(phi2*derivative_x, weights=weight) print(phi2nu) From 1930b61fe014a05db63cd74599dcebe68e051ea9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 23:37:37 +0000 Subject: [PATCH 161/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 41ed1a99..f70293e6 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1015,10 +1015,10 @@ def get_STC(dim, grid, k0): # Loop through each element in pphi_pt2 for i in range(Phi2_mean.shape[0]): for j in range(Phi2_mean.shape[1]): - # Calculate roots for each element - coeffs = [4 * Phi2_mean[i, j], -4, tau**4 * Phi2_mean[i, j]] - phi2[i, j] = np.roots(coeffs) - phi2nu=np.average(phi2*derivative_x, weights=weight) + # Calculate roots for each element + coeffs = [4 * Phi2_mean[i, j], -4, tau**4 * Phi2_mean[i, j]] + phi2[i, j] = np.roots(coeffs) + phi2nu = np.average(phi2 * derivative_x, weights=weight) print(phi2nu) print(phi2nu.shape) From fbeeab2365eb1c3d445bd357596dece5796ca3f2 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 30 Oct 2024 00:39:22 +0100 Subject: [PATCH 162/362] check phi2mean --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 41ed1a99..fe5bf9e9 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1010,14 +1010,14 @@ def get_STC(dim, grid, k0): print(derivative_x.shape) # Get the shape of pphi_pt2 Phi2_mean = np.mean(pphi_pt2, axis=0).T + print( Phi2_mean.shape) weight = np.mean(env_abs, axis=0) phi2 = np.zeros(Phi2_mean.shape) # Create an array to store roots # Loop through each element in pphi_pt2 for i in range(Phi2_mean.shape[0]): for j in range(Phi2_mean.shape[1]): # Calculate roots for each element - coeffs = [4 * Phi2_mean[i, j], -4, tau**4 * Phi2_mean[i, j]] - phi2[i, j] = np.roots(coeffs) + phi2[i, j] = np.roots([4 * Phi2_mean[i, j], -4, tau**4 * Phi2_mean[i, j]]) phi2nu=np.average(phi2*derivative_x, weights=weight) print(phi2nu) From 6e0729e3947ac6ae03272bcc61b554889c79c8b2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 23:40:20 +0000 Subject: [PATCH 163/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index fe5bf9e9..69248ff1 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1010,15 +1010,17 @@ def get_STC(dim, grid, k0): print(derivative_x.shape) # Get the shape of pphi_pt2 Phi2_mean = np.mean(pphi_pt2, axis=0).T - print( Phi2_mean.shape) + print(Phi2_mean.shape) weight = np.mean(env_abs, axis=0) phi2 = np.zeros(Phi2_mean.shape) # Create an array to store roots # Loop through each element in pphi_pt2 for i in range(Phi2_mean.shape[0]): for j in range(Phi2_mean.shape[1]): - # Calculate roots for each element - phi2[i, j] = np.roots([4 * Phi2_mean[i, j], -4, tau**4 * Phi2_mean[i, j]]) - phi2nu=np.average(phi2*derivative_x, weights=weight) + # Calculate roots for each element + phi2[i, j] = np.roots( + [4 * Phi2_mean[i, j], -4, tau**4 * Phi2_mean[i, j]] + ) + phi2nu = np.average(phi2 * derivative_x, weights=weight) print(phi2nu) print(phi2nu.shape) From 208d94816cc31de6000a3b925f719c8d1ce5a59d Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 30 Oct 2024 00:42:15 +0100 Subject: [PATCH 164/362] phi2 --- lasy/utils/laser_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index fe5bf9e9..1eecf5a4 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1012,7 +1012,8 @@ def get_STC(dim, grid, k0): Phi2_mean = np.mean(pphi_pt2, axis=0).T print( Phi2_mean.shape) weight = np.mean(env_abs, axis=0) - phi2 = np.zeros(Phi2_mean.shape) # Create an array to store roots + phi2 = np.zeros([Phi2_mean.shape]) # Create an array to store roots + print(phi2.shape) # Loop through each element in pphi_pt2 for i in range(Phi2_mean.shape[0]): for j in range(Phi2_mean.shape[1]): From 2ba338269c5e2f1056e219f274ed0bdc586c0e81 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 30 Oct 2024 00:44:08 +0100 Subject: [PATCH 165/362] phi2 matrix --- 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 4dde2307..7297dc54 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1012,7 +1012,7 @@ def get_STC(dim, grid, k0): Phi2_mean = np.mean(pphi_pt2, axis=0).T print(Phi2_mean.shape) weight = np.mean(env_abs, axis=0) - phi2 = np.zeros([Phi2_mean.shape]) # Create an array to store roots + phi2 = np.zeros_like(Phi2_mean) # Create an array to store roots print(phi2.shape) # Loop through each element in pphi_pt2 for i in range(Phi2_mean.shape[0]): From 539de755955a01b147fc2c4594a6944c639f6212 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 23:44:31 +0000 Subject: [PATCH 166/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- 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 7297dc54..103de42c 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1012,7 +1012,7 @@ def get_STC(dim, grid, k0): Phi2_mean = np.mean(pphi_pt2, axis=0).T print(Phi2_mean.shape) weight = np.mean(env_abs, axis=0) - phi2 = np.zeros_like(Phi2_mean) # Create an array to store roots + phi2 = np.zeros_like(Phi2_mean) # Create an array to store roots print(phi2.shape) # Loop through each element in pphi_pt2 for i in range(Phi2_mean.shape[0]): From 70260c395b292ff1eff71a311e56769da45d78cb Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 30 Oct 2024 00:46:09 +0100 Subject: [PATCH 167/362] add np.max --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 7297dc54..52130b8b 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1018,9 +1018,9 @@ def get_STC(dim, grid, k0): for i in range(Phi2_mean.shape[0]): for j in range(Phi2_mean.shape[1]): # Calculate roots for each element - phi2[i, j] = np.roots( + phi2[i, j] = np.max(np.roots( [4 * Phi2_mean[i, j], -4, tau**4 * Phi2_mean[i, j]] - ) + )) phi2nu = np.average(phi2 * derivative_x, weights=weight) print(phi2nu) From 10f7fb69f765e727c56038db9a450588ad9e9825 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 23:46:39 +0000 Subject: [PATCH 168/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 897b342e..93b24d2c 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1018,9 +1018,9 @@ def get_STC(dim, grid, k0): for i in range(Phi2_mean.shape[0]): for j in range(Phi2_mean.shape[1]): # Calculate roots for each element - phi2[i, j] = np.max(np.roots( - [4 * Phi2_mean[i, j], -4, tau**4 * Phi2_mean[i, j]] - )) + phi2[i, j] = np.max( + np.roots([4 * Phi2_mean[i, j], -4, tau**4 * Phi2_mean[i, j]]) + ) phi2nu = np.average(phi2 * derivative_x, weights=weight) print(phi2nu) From 56b9e1ca51edf69c1ad0c9056722bf493343e1f9 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 30 Oct 2024 00:47:25 +0100 Subject: [PATCH 169/362] fix averga weight --- 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 897b342e..beb11774 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1021,7 +1021,7 @@ def get_STC(dim, grid, k0): phi2[i, j] = np.max(np.roots( [4 * Phi2_mean[i, j], -4, tau**4 * Phi2_mean[i, j]] )) - phi2nu = np.average(phi2 * derivative_x, weights=weight) + phi2nu = np.average(phi2 * derivative_x, weights=weight.T) print(phi2nu) print(phi2nu.shape) From ff987234fe34af694192f8fdea65bdc2b0534369 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 23:48:07 +0000 Subject: [PATCH 170/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 82eff526..87bee85b 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1018,12 +1018,11 @@ def get_STC(dim, grid, k0): for i in range(Phi2_mean.shape[0]): for j in range(Phi2_mean.shape[1]): # Calculate roots for each element - phi2[i, j] = np.max(np.roots( - [4 * Phi2_mean[i, j], -4, tau**4 * Phi2_mean[i, j]] - )) + phi2[i, j] = np.max( + np.roots([4 * Phi2_mean[i, j], -4, tau**4 * Phi2_mean[i, j]]) + ) phi2nu = np.average(phi2 * derivative_x, weights=weight.T) - print(phi2nu) print(phi2nu.shape) From 620ebc1145096bd3967eecdb38acd9131d0d4a92 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 30 Oct 2024 00:49:39 +0100 Subject: [PATCH 171/362] screw beta, wont work --- lasy/utils/laser_utils.py | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 82eff526..51ccc87e 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1007,26 +1007,6 @@ def get_STC(dim, grid, k0): weight_y = np.mean(env_spec, axis=1) zeta_x = np.average(derivative_x.T, weights=weight_x) zeta_y = np.average(derivative_y.T, weights=weight_y) - print(derivative_x.shape) - # Get the shape of pphi_pt2 - Phi2_mean = np.mean(pphi_pt2, axis=0).T - print(Phi2_mean.shape) - weight = np.mean(env_abs, axis=0) - phi2 = np.zeros_like(Phi2_mean) # Create an array to store roots - print(phi2.shape) - # Loop through each element in pphi_pt2 - for i in range(Phi2_mean.shape[0]): - for j in range(Phi2_mean.shape[1]): - # Calculate roots for each element - phi2[i, j] = np.max(np.roots( - [4 * Phi2_mean[i, j], -4, tau**4 * Phi2_mean[i, j]] - )) - phi2nu = np.average(phi2 * derivative_x, weights=weight.T) - - - print(phi2nu) - print(phi2nu.shape) - STC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) STC_fac["nu"] = ( From 23b82f9f26664b1351ee8af669f19612e14977de Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 30 Oct 2024 01:07:33 +0100 Subject: [PATCH 172/362] add CI test --- tests/test_STC.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/test_STC.py diff --git a/tests/test_STC.py b/tests/test_STC.py new file mode 100644 index 00000000..0116e264 --- /dev/null +++ b/tests/test_STC.py @@ -0,0 +1,32 @@ +from lasy.laser import Laser +import numpy as np +import scipy.constants as scc +from lasy.profiles.gaussian_profile import GaussianProfile +from lasy.utils.laser_utils import get_STC + # Create profile. +profile = GaussianProfile( + wavelength=0.6e-6, # m + pol=(1, 0), + laser_energy=1.0, # J + w0=5e-6, # m + tau=5e-14, # s + t_peak=0.0, # s + beta=0, + zeta=2.4e-22, + phi2=2.4e-22, + stc_theta =scc.pi/2 + ) +# Create laser with given profile in `rt` geometry. +laser = Laser( + dim="xyt", + lo=(-10e-6,-10e-6,-10e-14), + hi=( 10e-6, 10e-6,+10e-14), + npoints=(50,60,70), + profile=profile, + ) +STC=get_STC( laser.dim,laser.grid, k0=2*scc.pi/0.6e-6) +np.testing.assert_approx_equal( + STC['phi2'],2.4e-22 , significant=3 + ) +np.testing.assert_approx_equal( + STC['zeta'], 2.4e-22 , significant=3) From 52e78abcdac44e4cd11a71bed1c9925862533dd9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 00:11:23 +0000 Subject: [PATCH 173/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 49 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 0116e264..ebe0b713 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -1,32 +1,31 @@ -from lasy.laser import Laser import numpy as np import scipy.constants as scc + +from lasy.laser import Laser from lasy.profiles.gaussian_profile import GaussianProfile from lasy.utils.laser_utils import get_STC - # Create profile. + +# Create profile. profile = GaussianProfile( - wavelength=0.6e-6, # m - pol=(1, 0), - laser_energy=1.0, # J - w0=5e-6, # m - tau=5e-14, # s - t_peak=0.0, # s - beta=0, - zeta=2.4e-22, - phi2=2.4e-22, - stc_theta =scc.pi/2 - ) + wavelength=0.6e-6, # m + pol=(1, 0), + laser_energy=1.0, # J + w0=5e-6, # m + tau=5e-14, # s + t_peak=0.0, # s + beta=0, + zeta=2.4e-22, + phi2=2.4e-22, + stc_theta=scc.pi / 2, +) # Create laser with given profile in `rt` geometry. laser = Laser( - dim="xyt", - lo=(-10e-6,-10e-6,-10e-14), - hi=( 10e-6, 10e-6,+10e-14), - npoints=(50,60,70), - profile=profile, - ) -STC=get_STC( laser.dim,laser.grid, k0=2*scc.pi/0.6e-6) -np.testing.assert_approx_equal( - STC['phi2'],2.4e-22 , significant=3 - ) -np.testing.assert_approx_equal( - STC['zeta'], 2.4e-22 , significant=3) + dim="xyt", + lo=(-10e-6, -10e-6, -10e-14), + hi=(10e-6, 10e-6, +10e-14), + npoints=(50, 60, 70), + profile=profile, +) +STC = get_STC(laser.dim, laser.grid, k0=2 * scc.pi / 0.6e-6) +np.testing.assert_approx_equal(STC["phi2"], 2.4e-22, significant=3) +np.testing.assert_approx_equal(STC["zeta"], 2.4e-22, significant=3) From 2c8a2c5242446d7c997b708ebd4d98975f340be0 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 30 Oct 2024 02:09:59 +0100 Subject: [PATCH 174/362] Update test_STC.py --- tests/test_STC.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index ebe0b713..4adc8a51 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -27,5 +27,5 @@ profile=profile, ) STC = get_STC(laser.dim, laser.grid, k0=2 * scc.pi / 0.6e-6) -np.testing.assert_approx_equal(STC["phi2"], 2.4e-22, significant=3) -np.testing.assert_approx_equal(STC["zeta"], 2.4e-22, significant=3) +np.testing.assert_approx_equal(STC["phi2"], 2.4e-22, significant=2) +np.testing.assert_approx_equal(STC["zeta"], 2.4e-22, significant=2) From 936d5b89bc6a6870f33eb3ac0526dca7bfc27dcd Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:30:07 +0100 Subject: [PATCH 175/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 51ccc87e..ffb921f3 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -948,7 +948,8 @@ def get_STC(dim, grid, k0): zeta: Spatio-chirp in :math:`\zeta=dx_0/d(\omega_0)` stc_theta_zeta: The direction of the linear spatial chirp on xoy plane\ in rad (0 is along x) - beta: Angular dispersion in :math:` \beta = d\theta_0/d\omega` + beta: Angular dispersion in :math:` \beta = d\theta_0/d\omega`(Important note: + for now beta is only correct when zeta and phi2 are 0!) pft: Pulse front tilt in :math:` p=dt/dx` stc_theta_beta: The direction of the linear angular chirp on xoy plane\ in rad (0 is along x) @@ -987,9 +988,11 @@ def get_STC(dim, grid, k0): ) # Calculate spatio- and angular dispersion if dim == "rt": + # Calculate derivitive of r in (x,y,omega) space rda = np.sum(grid.axes[0] * env_spec[0, :, :].T, axis=1) / np.sum( env_spec, axis=1 ) + #zeta is dr/domega derivative_r = np.gradient(rda[0, :], omega, axis=0) weight = np.mean(env_spec, axis=1) STC_fac["zeta"] = -3 * np.average(derivative_r, weights=weight[0]) @@ -997,32 +1000,34 @@ def get_STC(dim, grid, k0): 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) ) if dim == "xyt": - weight_x = np.transpose(env_spec, (2, 1, 0)) - weight_y = np.transpose(env_spec, (2, 0, 1)) - xda = np.sum(grid.axes[0] * weight_x, axis=2) / np.sum(weight_x, axis=2) - yda = np.sum(grid.axes[1] * weight_y, axis=2) / np.sum(weight_y, axis=2) - derivative_x = np.gradient(xda, omega, axis=0) - derivative_y = np.gradient(yda, omega, axis=0) - weight_x = np.mean(env_spec, axis=0) - weight_y = np.mean(env_spec, axis=1) - zeta_x = np.average(derivative_x.T, weights=weight_x) - zeta_y = np.average(derivative_y.T, weights=weight_y) + #Calculate dx and dy in spectrum space + weight_x_3d = np.transpose(env_spec, (2, 1, 0)) + weight_y_3d = np.transpose(env_spec, (2, 0, 1)) + xda = np.sum(grid.axes[0] * weight_x, axis=2) / np.sum(weight_x_3d, axis=2) + yda = np.sum(grid.axes[1] * weight_y, axis=2) / np.sum(weight_y_3d, axis=2) + #Calculate zeta_x and zeta_y + derivative_x_zeta = np.gradient(xda, omega, axis=0) + derivative_y_zeta = np.gradient(yda, omega, axis=0) + weight_x_2d = np.mean(env_spec, axis=0) + weight_y_2d = np.mean(env_spec, axis=1) + zeta_x = np.average(derivative_x_zeta.T, weights=weight_x_2d) + zeta_y = np.average(derivative_y_zeta.T, weights=weight_y_2d) STC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) STC_fac["nu"] = ( 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) ) # Use the normalised laser intensity to calculate the weighted average of PFT - weight = np.mean(env_abs, axis=2) + weight_xy_2d = np.mean(env_abs, axis=2) z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) - derivative_x = np.gradient(z_centroids, axis=0) / grid.dx[0] - derivative_y = np.gradient(z_centroids, axis=1) / grid.dx[1] - pft_x = np.average(derivative_x, weights=weight) - pft_y = np.average(derivative_y, weights=weight) + derivative_x_pft = np.gradient(z_centroids, axis=0) / grid.dx[0] + derivative_y_pft = np.gradient(z_centroids, axis=1) / grid.dx[1] + pft_x = np.average(derivative_x_pft, weights=weight_xy_2d) + pft_y = np.average(derivative_y_pft, weights=weight_xy_2d) STC_fac["pft"] = np.sqrt((pft_x**2 + pft_y**2)) STC_fac["stc_theta_beta"] = np.arctan2(pft_y, pft_x) STC_fac["beta"] = ( - np.sqrt((pft_x**2 + pft_y**2)) - STC_fac["Phi2"] * STC_fac["nu"] + np.sqrt((pft_x**2 + pft_y**2)) ) / k0 return STC_fac From d428c384ce9964af7f8f2f5942fd2bb856485c36 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:30:14 +0000 Subject: [PATCH 176/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index ffb921f3..d49c9f02 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -992,7 +992,7 @@ def get_STC(dim, grid, k0): rda = np.sum(grid.axes[0] * env_spec[0, :, :].T, axis=1) / np.sum( env_spec, axis=1 ) - #zeta is dr/domega + # zeta is dr/domega derivative_r = np.gradient(rda[0, :], omega, axis=0) weight = np.mean(env_spec, axis=1) STC_fac["zeta"] = -3 * np.average(derivative_r, weights=weight[0]) @@ -1000,12 +1000,12 @@ def get_STC(dim, grid, k0): 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) ) if dim == "xyt": - #Calculate dx and dy in spectrum space + # Calculate dx and dy in spectrum space weight_x_3d = np.transpose(env_spec, (2, 1, 0)) weight_y_3d = np.transpose(env_spec, (2, 0, 1)) xda = np.sum(grid.axes[0] * weight_x, axis=2) / np.sum(weight_x_3d, axis=2) yda = np.sum(grid.axes[1] * weight_y, axis=2) / np.sum(weight_y_3d, axis=2) - #Calculate zeta_x and zeta_y + # Calculate zeta_x and zeta_y derivative_x_zeta = np.gradient(xda, omega, axis=0) derivative_y_zeta = np.gradient(yda, omega, axis=0) weight_x_2d = np.mean(env_spec, axis=0) @@ -1026,8 +1026,6 @@ def get_STC(dim, grid, k0): pft_y = np.average(derivative_y_pft, weights=weight_xy_2d) STC_fac["pft"] = np.sqrt((pft_x**2 + pft_y**2)) STC_fac["stc_theta_beta"] = np.arctan2(pft_y, pft_x) - STC_fac["beta"] = ( - np.sqrt((pft_x**2 + pft_y**2)) - ) / k0 + STC_fac["beta"] = (np.sqrt((pft_x**2 + pft_y**2))) / k0 return STC_fac From ab04fd8df860ec85e702273a8ea5b3b784bf3329 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:32:30 +0100 Subject: [PATCH 177/362] Update test_STC.py --- tests/test_STC.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 4adc8a51..64c46b39 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -18,14 +18,25 @@ phi2=2.4e-22, stc_theta=scc.pi / 2, ) -# Create laser with given profile in `rt` geometry. -laser = Laser( +# Create laser with given profile in `xyt` geometry. +laser_3d = Laser( dim="xyt", lo=(-10e-6, -10e-6, -10e-14), hi=(10e-6, 10e-6, +10e-14), npoints=(50, 60, 70), profile=profile, ) -STC = get_STC(laser.dim, laser.grid, k0=2 * scc.pi / 0.6e-6) -np.testing.assert_approx_equal(STC["phi2"], 2.4e-22, significant=2) -np.testing.assert_approx_equal(STC["zeta"], 2.4e-22, significant=2) +# Create laser with given profile in `rt` geometry. +laser_2d = Laser( + dim="rt", + lo=(-10e-6, -10e-14), + hi=(10e-6, +10e-14), + npoints=(60, 70), + profile=profile, +) +STC_3d = get_STC(laser_3d.dim, laser_3d.grid, k0=2 * scc.pi / 0.6e-6) +STC_2d = get_STC(laser_2d.dim, laser_2d.grid, k0=2 * scc.pi / 0.6e-6) +np.testing.assert_approx_equal(STC_2d["phi2"], 2.4e-22, significant=2) +np.testing.assert_approx_equal(STC_2d["zeta"], 2.4e-22, significant=2) +np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-22, significant=2) +np.testing.assert_approx_equal(STC_3d["zeta"], 2.4e-22, significant=2) From 9d8ac04e3ad32a888d2f42c2f3c15d6a2df27d6e Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:37:48 +0100 Subject: [PATCH 178/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index d49c9f02..db5dfb7f 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1003,8 +1003,8 @@ def get_STC(dim, grid, k0): # Calculate dx and dy in spectrum space weight_x_3d = np.transpose(env_spec, (2, 1, 0)) weight_y_3d = np.transpose(env_spec, (2, 0, 1)) - xda = np.sum(grid.axes[0] * weight_x, axis=2) / np.sum(weight_x_3d, axis=2) - yda = np.sum(grid.axes[1] * weight_y, axis=2) / np.sum(weight_y_3d, axis=2) + xda = np.sum(grid.axes[0] * weight_x_3d, axis=2) / np.sum(weight_x_3d, axis=2) + yda = np.sum(grid.axes[1] * weight_y_3d, axis=2) / np.sum(weight_y_3d, axis=2) # Calculate zeta_x and zeta_y derivative_x_zeta = np.gradient(xda, omega, axis=0) derivative_y_zeta = np.gradient(yda, omega, axis=0) From 0d53cc5a1a5e9e2b9d9c909b730b17e38f03658d Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:38:37 +0100 Subject: [PATCH 179/362] 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 db5dfb7f..e523308e 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -988,7 +988,7 @@ def get_STC(dim, grid, k0): ) # Calculate spatio- and angular dispersion if dim == "rt": - # Calculate derivitive of r in (x,y,omega) space + # Calculate derivitive of r in (r,omega) space rda = np.sum(grid.axes[0] * env_spec[0, :, :].T, axis=1) / np.sum( env_spec, axis=1 ) From 77ba25410e493e1da4dfd24c2473e76a9bd156de Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:42:05 +0100 Subject: [PATCH 180/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index e523308e..ed0c879b 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -956,9 +956,9 @@ def get_STC(dim, grid, k0): All those above units and definitions are taken from `S. Akturk et al., Optics Express 12, 4399 (2004) `__. """ - # Initialise the returned dictionary tau = 2 * get_duration(grid, dim) w0 = get_w0(grid, dim) + # Initialise the returned dictionary STC_fac = { "Phi2": 0, "phi2": 0, @@ -979,13 +979,16 @@ def get_STC(dim, grid, k0): phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) + # Calculate group-delayed dispersion pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) + # Use the normalised laser intensity to calculate the weighted average of Phi2 STC_fac["Phi2"] = np.average(pphi_pt2, weights=env_abs) STC_fac["phi2"] = np.max( np.roots([4 * STC_fac["Phi2"], -4, tau**4 * STC_fac["Phi2"]]) ) + # Calculate spatio- and angular dispersion if dim == "rt": # Calculate derivitive of r in (r,omega) space @@ -999,12 +1002,14 @@ def get_STC(dim, grid, k0): STC_fac["nu"] = ( 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) ) - if dim == "xyt": - # Calculate dx and dy in spectrum space + + elif dim == "xyt": + # Calculate dx and dy in (x,y,omega) space weight_x_3d = np.transpose(env_spec, (2, 1, 0)) weight_y_3d = np.transpose(env_spec, (2, 0, 1)) xda = np.sum(grid.axes[0] * weight_x_3d, axis=2) / np.sum(weight_x_3d, axis=2) yda = np.sum(grid.axes[1] * weight_y_3d, axis=2) / np.sum(weight_y_3d, axis=2) + # Calculate zeta_x and zeta_y derivative_x_zeta = np.gradient(xda, omega, axis=0) derivative_y_zeta = np.gradient(yda, omega, axis=0) @@ -1017,6 +1022,7 @@ def get_STC(dim, grid, k0): STC_fac["nu"] = ( 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) ) + # Use the normalised laser intensity to calculate the weighted average of PFT weight_xy_2d = np.mean(env_abs, axis=2) z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) From 85d5ae043e7cd978025292b40e53fe8f6a7aa831 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:42:12 +0000 Subject: [PATCH 181/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index ed0c879b..a9686a2f 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -979,16 +979,16 @@ def get_STC(dim, grid, k0): phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) - + # Calculate group-delayed dispersion pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) - + # Use the normalised laser intensity to calculate the weighted average of Phi2 STC_fac["Phi2"] = np.average(pphi_pt2, weights=env_abs) STC_fac["phi2"] = np.max( np.roots([4 * STC_fac["Phi2"], -4, tau**4 * STC_fac["Phi2"]]) ) - + # Calculate spatio- and angular dispersion if dim == "rt": # Calculate derivitive of r in (r,omega) space @@ -1002,14 +1002,14 @@ def get_STC(dim, grid, k0): STC_fac["nu"] = ( 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) ) - + elif dim == "xyt": # Calculate dx and dy in (x,y,omega) space weight_x_3d = np.transpose(env_spec, (2, 1, 0)) weight_y_3d = np.transpose(env_spec, (2, 0, 1)) xda = np.sum(grid.axes[0] * weight_x_3d, axis=2) / np.sum(weight_x_3d, axis=2) yda = np.sum(grid.axes[1] * weight_y_3d, axis=2) / np.sum(weight_y_3d, axis=2) - + # Calculate zeta_x and zeta_y derivative_x_zeta = np.gradient(xda, omega, axis=0) derivative_y_zeta = np.gradient(yda, omega, axis=0) @@ -1022,7 +1022,7 @@ def get_STC(dim, grid, k0): STC_fac["nu"] = ( 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) ) - + # Use the normalised laser intensity to calculate the weighted average of PFT weight_xy_2d = np.mean(env_abs, axis=2) z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) From 7078e96dd4db4537051292ebce1d77259ec7c5c6 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:50:17 +0100 Subject: [PATCH 182/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index a9686a2f..c012f196 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -956,8 +956,10 @@ def get_STC(dim, grid, k0): All those above units and definitions are taken from `S. Akturk et al., Optics Express 12, 4399 (2004) `__. """ + tau = 2 * get_duration(grid, dim) w0 = get_w0(grid, dim) + # Initialise the returned dictionary STC_fac = { "Phi2": 0, @@ -969,18 +971,20 @@ def get_STC(dim, grid, k0): "pft": 0, "stc_theta_beta": 0, } + + # Get temporal and spectral field env = grid.get_temporal_field() env_abs = np.abs(env**2) env_spec = np.abs(grid.get_spectral_field()) + # Get the spectral axis dt = grid.dx[-1] Nt = grid.shape[-1] omega = 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0 * c + # Calculate group-delayed dispersion phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) - - # Calculate group-delayed dispersion pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) # Use the normalised laser intensity to calculate the weighted average of Phi2 From a404f53df6d99aa5d23d222859478f8a1f22808e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:50:45 +0000 Subject: [PATCH 183/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index c012f196..67ac5998 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -956,10 +956,9 @@ def get_STC(dim, grid, k0): All those above units and definitions are taken from `S. Akturk et al., Optics Express 12, 4399 (2004) `__. """ - tau = 2 * get_duration(grid, dim) w0 = get_w0(grid, dim) - + # Initialise the returned dictionary STC_fac = { "Phi2": 0, @@ -971,12 +970,12 @@ def get_STC(dim, grid, k0): "pft": 0, "stc_theta_beta": 0, } - + # Get temporal and spectral field env = grid.get_temporal_field() env_abs = np.abs(env**2) env_spec = np.abs(grid.get_spectral_field()) - + # Get the spectral axis dt = grid.dx[-1] Nt = grid.shape[-1] From 4f1ae2a683e7742e89e12523ec62f18b42916372 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 30 Oct 2024 16:09:55 +0100 Subject: [PATCH 184/362] use temporal profile to calculate nu in rt --- lasy/utils/laser_utils.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 67ac5998..f2bb73b0 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -995,16 +995,9 @@ def get_STC(dim, grid, k0): # Calculate spatio- and angular dispersion if dim == "rt": # Calculate derivitive of r in (r,omega) space - rda = np.sum(grid.axes[0] * env_spec[0, :, :].T, axis=1) / np.sum( - env_spec, axis=1 - ) - # zeta is dr/domega - derivative_r = np.gradient(rda[0, :], omega, axis=0) - weight = np.mean(env_spec, axis=1) - STC_fac["zeta"] = -3 * np.average(derivative_r, weights=weight[0]) - STC_fac["nu"] = ( - 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) - ) + pphi_pzpr = (np.gradient(pphi_pt, axis=1))/ grid.dx[0] + STC_fac["nu"] = np.average(pphi_pzpr * env_abs, weights=env_abs) + STC_fac["zeta"] = np.min(np.roots([4 * STC_fac["nu"] , -4, STC_fac["nu"] * w0**2 * tau**2])) elif dim == "xyt": # Calculate dx and dy in (x,y,omega) space From d9ceb7b6d2744072fd6fecc246501f08ce1b258d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:11:08 +0000 Subject: [PATCH 185/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index f2bb73b0..69a470b7 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -995,9 +995,11 @@ def get_STC(dim, grid, k0): # Calculate spatio- and angular dispersion if dim == "rt": # Calculate derivitive of r in (r,omega) space - pphi_pzpr = (np.gradient(pphi_pt, axis=1))/ grid.dx[0] + pphi_pzpr = (np.gradient(pphi_pt, axis=1)) / grid.dx[0] STC_fac["nu"] = np.average(pphi_pzpr * env_abs, weights=env_abs) - STC_fac["zeta"] = np.min(np.roots([4 * STC_fac["nu"] , -4, STC_fac["nu"] * w0**2 * tau**2])) + STC_fac["zeta"] = np.min( + np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) + ) elif dim == "xyt": # Calculate dx and dy in (x,y,omega) space From b2ed08224d89265e0dfc0a4d18c027851304a3a5 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 30 Oct 2024 16:19:45 +0100 Subject: [PATCH 186/362] update zeta calculation --- lasy/utils/laser_utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index f2bb73b0..6e83fb4c 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -995,9 +995,11 @@ def get_STC(dim, grid, k0): # Calculate spatio- and angular dispersion if dim == "rt": # Calculate derivitive of r in (r,omega) space - pphi_pzpr = (np.gradient(pphi_pt, axis=1))/ grid.dx[0] - STC_fac["nu"] = np.average(pphi_pzpr * env_abs, weights=env_abs) - STC_fac["zeta"] = np.min(np.roots([4 * STC_fac["nu"] , -4, STC_fac["nu"] * w0**2 * tau**2])) + pphi_ptpr = (np.gradient(pphi_pt, axis=1))/ grid.dx[0] + STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) + # Transfer the unit from nu to zeta + STC_fac["zeta"] = np.min( + np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) elif dim == "xyt": # Calculate dx and dy in (x,y,omega) space From b699d89fca9db8f7194e783bbbf851f64ed55de5 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 30 Oct 2024 16:21:45 +0100 Subject: [PATCH 187/362] syntax error --- lasy/utils/laser_utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 6e83fb4c..057fecf9 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1000,8 +1000,7 @@ def get_STC(dim, grid, k0): # Transfer the unit from nu to zeta STC_fac["zeta"] = np.min( np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) - - elif dim == "xyt": + if dim == "xyt": # Calculate dx and dy in (x,y,omega) space weight_x_3d = np.transpose(env_spec, (2, 1, 0)) weight_y_3d = np.transpose(env_spec, (2, 0, 1)) From 13972f0f2d1f78bbec15c14c602de6dfaace0d4e Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 30 Oct 2024 16:22:27 +0100 Subject: [PATCH 188/362] brackte --- 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 057fecf9..1ee454c3 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -999,7 +999,7 @@ def get_STC(dim, grid, k0): STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) # Transfer the unit from nu to zeta STC_fac["zeta"] = np.min( - np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) + np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2])) if dim == "xyt": # Calculate dx and dy in (x,y,omega) space weight_x_3d = np.transpose(env_spec, (2, 1, 0)) From bf389367e136651894f7a3bcc47837785ae566e9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:22:48 +0000 Subject: [PATCH 189/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 1ee454c3..eb58b652 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -995,11 +995,12 @@ def get_STC(dim, grid, k0): # Calculate spatio- and angular dispersion if dim == "rt": # Calculate derivitive of r in (r,omega) space - pphi_ptpr = (np.gradient(pphi_pt, axis=1))/ grid.dx[0] + pphi_ptpr = (np.gradient(pphi_pt, axis=1)) / grid.dx[0] STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) # Transfer the unit from nu to zeta STC_fac["zeta"] = np.min( - np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2])) + np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) + ) if dim == "xyt": # Calculate dx and dy in (x,y,omega) space weight_x_3d = np.transpose(env_spec, (2, 1, 0)) From 6c2c0451a88dec4d4cf6fb1509217ac5ea0b21b4 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 5 Nov 2024 13:00:16 +0100 Subject: [PATCH 190/362] Update test_STC.py --- tests/test_STC.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 64c46b39..07bc2f2a 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -39,4 +39,3 @@ np.testing.assert_approx_equal(STC_2d["phi2"], 2.4e-22, significant=2) np.testing.assert_approx_equal(STC_2d["zeta"], 2.4e-22, significant=2) np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-22, significant=2) -np.testing.assert_approx_equal(STC_3d["zeta"], 2.4e-22, significant=2) From f9a189f94a70836ceda6975e207f9c3eeab2f80f Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 5 Nov 2024 13:01:44 +0100 Subject: [PATCH 191/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index eb58b652..472120d3 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -994,13 +994,8 @@ def get_STC(dim, grid, k0): # Calculate spatio- and angular dispersion if dim == "rt": - # Calculate derivitive of r in (r,omega) space - pphi_ptpr = (np.gradient(pphi_pt, axis=1)) / grid.dx[0] - STC_fac["nu"] = np.average(pphi_ptpr, weights=env_abs) - # Transfer the unit from nu to zeta - STC_fac["zeta"] = np.min( - np.roots([4 * STC_fac["nu"], -4, STC_fac["nu"] * w0**2 * tau**2]) - ) + # No spatial chirp and angular chirp in 'rt' coordinate + return STC_fac if dim == "xyt": # Calculate dx and dy in (x,y,omega) space weight_x_3d = np.transpose(env_spec, (2, 1, 0)) @@ -1032,4 +1027,4 @@ def get_STC(dim, grid, k0): STC_fac["stc_theta_beta"] = np.arctan2(pft_y, pft_x) STC_fac["beta"] = (np.sqrt((pft_x**2 + pft_y**2))) / k0 - return STC_fac + return STC_fac From 2b1da7c33f554af58bc038589b5f733ceff97119 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 4 Dec 2024 12:52:24 +0100 Subject: [PATCH 192/362] add calculation on beta --- lasy/utils/laser_utils.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 472120d3..2e72f0f3 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -951,7 +951,7 @@ def get_STC(dim, grid, k0): beta: Angular dispersion in :math:` \beta = d\theta_0/d\omega`(Important note: for now beta is only correct when zeta and phi2 are 0!) pft: Pulse front tilt in :math:` p=dt/dx` - stc_theta_beta: The direction of the linear angular chirp on xoy plane\ + stc_theta_pft: The direction of the linear angular chirp on xoy plane\ in rad (0 is along x) All those above units and definitions are taken from `S. Akturk et al., Optics Express 12, 4399 (2004) `__. @@ -968,7 +968,7 @@ def get_STC(dim, grid, k0): "stc_theta_zeta": 0, "beta": 0, "pft": 0, - "stc_theta_beta": 0, + "stc_theta_pft": 0, } # Get temporal and spectral field @@ -1016,6 +1016,17 @@ def get_STC(dim, grid, k0): 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) ) + #Calculate propagating angle + pphi_py = np.gradient(env_spec, grid.dx[1], axis=1) + pphi_px = np.gradient(env_spec, grid.dx[0], axis=0) + angle_y = (np.sum(pphi_py * env_abs, axis=(0, 1)) / np.sum(env_abs, axis=(0, 1)))/k0 + angle_x = (np.sum(pphi_px * env_abs, axis=(0, 1)) / np.sum(env_abs, axis=(0, 1)))/k0 + beta_y = np.gradient(angle_y, omega) + beta_x = np.gradient(angle_x, omega) + STC_fac["stc_theta_beta"] = np.arctan2(beta_y, beta_x) + STC_fac["beta"] = np.sqrt(beta_x**2 + beta_y**2) + + # Use the normalised laser intensity to calculate the weighted average of PFT weight_xy_2d = np.mean(env_abs, axis=2) z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) @@ -1024,7 +1035,7 @@ def get_STC(dim, grid, k0): pft_x = np.average(derivative_x_pft, weights=weight_xy_2d) pft_y = np.average(derivative_y_pft, weights=weight_xy_2d) STC_fac["pft"] = np.sqrt((pft_x**2 + pft_y**2)) - STC_fac["stc_theta_beta"] = np.arctan2(pft_y, pft_x) - STC_fac["beta"] = (np.sqrt((pft_x**2 + pft_y**2))) / k0 + STC_fac["stc_theta_pft"] = np.arctan2(pft_y, pft_x) + return STC_fac From 7f66359b2c37c87f6b2bb237072c6050a850f69e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 11:53:12 +0000 Subject: [PATCH 193/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 2e72f0f3..acb5f3fc 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1016,17 +1016,20 @@ def get_STC(dim, grid, k0): 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) ) - #Calculate propagating angle + # Calculate propagating angle pphi_py = np.gradient(env_spec, grid.dx[1], axis=1) pphi_px = np.gradient(env_spec, grid.dx[0], axis=0) - angle_y = (np.sum(pphi_py * env_abs, axis=(0, 1)) / np.sum(env_abs, axis=(0, 1)))/k0 - angle_x = (np.sum(pphi_px * env_abs, axis=(0, 1)) / np.sum(env_abs, axis=(0, 1)))/k0 + angle_y = ( + np.sum(pphi_py * env_abs, axis=(0, 1)) / np.sum(env_abs, axis=(0, 1)) + ) / k0 + angle_x = ( + np.sum(pphi_px * env_abs, axis=(0, 1)) / np.sum(env_abs, axis=(0, 1)) + ) / k0 beta_y = np.gradient(angle_y, omega) beta_x = np.gradient(angle_x, omega) STC_fac["stc_theta_beta"] = np.arctan2(beta_y, beta_x) STC_fac["beta"] = np.sqrt(beta_x**2 + beta_y**2) - # Use the normalised laser intensity to calculate the weighted average of PFT weight_xy_2d = np.mean(env_abs, axis=2) z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) @@ -1037,5 +1040,4 @@ def get_STC(dim, grid, k0): STC_fac["pft"] = np.sqrt((pft_x**2 + pft_y**2)) STC_fac["stc_theta_pft"] = np.arctan2(pft_y, pft_x) - return STC_fac From b01e5f38c904edcf921f1e5ab5211d543425cf96 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 4 Dec 2024 13:00:27 +0100 Subject: [PATCH 194/362] average beta on omega axis --- lasy/utils/laser_utils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 2e72f0f3..4cda3c7b 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1019,10 +1019,13 @@ def get_STC(dim, grid, k0): #Calculate propagating angle pphi_py = np.gradient(env_spec, grid.dx[1], axis=1) pphi_px = np.gradient(env_spec, grid.dx[0], axis=0) - angle_y = (np.sum(pphi_py * env_abs, axis=(0, 1)) / np.sum(env_abs, axis=(0, 1)))/k0 - angle_x = (np.sum(pphi_px * env_abs, axis=(0, 1)) / np.sum(env_abs, axis=(0, 1)))/k0 - beta_y = np.gradient(angle_y, omega) - beta_x = np.gradient(angle_x, omega) + angle_y = (np.sum(pphi_py * env_spec, axis=(0, 1)) / np.sum(env_spec, axis=(0, 1)))/k0 + angle_x = (np.sum(pphi_px * env_spec, axis=(0, 1)) / np.sum(env_spec, axis=(0, 1)))/k0 + weight_omega_1d = np.mean(env_spec, axis=(0,1)) + derivative_x_beta = np.gradient(angle_y, omega) + derivative_y_beta = np.gradient(angle_x, omega) + beta_x=np.average(derivative_x_beta,weight_omega_1d) + beta_y=np.average(derivative_y_beta,weight_omega_1d) STC_fac["stc_theta_beta"] = np.arctan2(beta_y, beta_x) STC_fac["beta"] = np.sqrt(beta_x**2 + beta_y**2) From 6ecf5d720acb9428af6dc6711119d32a6d2a1b84 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 12:02:07 +0000 Subject: [PATCH 195/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index b412c21b..b640886c 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1020,13 +1020,17 @@ def get_STC(dim, grid, k0): pphi_py = np.gradient(env_spec, grid.dx[1], axis=1) pphi_px = np.gradient(env_spec, grid.dx[0], axis=0) - angle_y = (np.sum(pphi_py * env_spec, axis=(0, 1)) / np.sum(env_spec, axis=(0, 1)))/k0 - angle_x = (np.sum(pphi_px * env_spec, axis=(0, 1)) / np.sum(env_spec, axis=(0, 1)))/k0 - weight_omega_1d = np.mean(env_spec, axis=(0,1)) + angle_y = ( + np.sum(pphi_py * env_spec, axis=(0, 1)) / np.sum(env_spec, axis=(0, 1)) + ) / k0 + angle_x = ( + np.sum(pphi_px * env_spec, axis=(0, 1)) / np.sum(env_spec, axis=(0, 1)) + ) / k0 + weight_omega_1d = np.mean(env_spec, axis=(0, 1)) derivative_x_beta = np.gradient(angle_y, omega) derivative_y_beta = np.gradient(angle_x, omega) - beta_x=np.average(derivative_x_beta,weight_omega_1d) - beta_y=np.average(derivative_y_beta,weight_omega_1d) + beta_x = np.average(derivative_x_beta, weight_omega_1d) + beta_y = np.average(derivative_y_beta, weight_omega_1d) STC_fac["stc_theta_beta"] = np.arctan2(beta_y, beta_x) STC_fac["beta"] = np.sqrt(beta_x**2 + beta_y**2) From 681660f96c57d010e0c29fc846a728a6093a6170 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 4 Dec 2024 13:04:01 +0100 Subject: [PATCH 196/362] debug --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index b640886c..cbdead4b 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1029,8 +1029,8 @@ def get_STC(dim, grid, k0): weight_omega_1d = np.mean(env_spec, axis=(0, 1)) derivative_x_beta = np.gradient(angle_y, omega) derivative_y_beta = np.gradient(angle_x, omega) - beta_x = np.average(derivative_x_beta, weight_omega_1d) - beta_y = np.average(derivative_y_beta, weight_omega_1d) + beta_x=np.average(derivative_x_beta,weights=weight_omega_1d) + beta_y=np.average(derivative_y_beta,weights=weight_omega_1d) STC_fac["stc_theta_beta"] = np.arctan2(beta_y, beta_x) STC_fac["beta"] = np.sqrt(beta_x**2 + beta_y**2) From 493d5064977de73e341d17b9b16a82eec3d547ba Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 12:04:17 +0000 Subject: [PATCH 197/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index cbdead4b..b33831eb 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1029,8 +1029,8 @@ def get_STC(dim, grid, k0): weight_omega_1d = np.mean(env_spec, axis=(0, 1)) derivative_x_beta = np.gradient(angle_y, omega) derivative_y_beta = np.gradient(angle_x, omega) - beta_x=np.average(derivative_x_beta,weights=weight_omega_1d) - beta_y=np.average(derivative_y_beta,weights=weight_omega_1d) + beta_x = np.average(derivative_x_beta, weights=weight_omega_1d) + beta_y = np.average(derivative_y_beta, weights=weight_omega_1d) STC_fac["stc_theta_beta"] = np.arctan2(beta_y, beta_x) STC_fac["beta"] = np.sqrt(beta_x**2 + beta_y**2) From 0a89c81b8f00cbdb2461ce18701ff85712c6dffa Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 4 Dec 2024 13:29:30 +0100 Subject: [PATCH 198/362] fix beta calculation --- lasy/utils/laser_utils.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index cbdead4b..7a2d3f92 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -967,6 +967,7 @@ def get_STC(dim, grid, k0): "zeta": 0, "stc_theta_zeta": 0, "beta": 0, + "stc_theta_beta": 0, "pft": 0, "stc_theta_pft": 0, } @@ -974,7 +975,8 @@ def get_STC(dim, grid, k0): # Get temporal and spectral field env = grid.get_temporal_field() env_abs = np.abs(env**2) - env_spec = np.abs(grid.get_spectral_field()) + env_spec = grid.get_spectral_field() + env_spec_abs = np.abs(env_spec**2) # Get the spectral axis dt = grid.dx[-1] @@ -998,16 +1000,16 @@ def get_STC(dim, grid, k0): return STC_fac if dim == "xyt": # Calculate dx and dy in (x,y,omega) space - weight_x_3d = np.transpose(env_spec, (2, 1, 0)) - weight_y_3d = np.transpose(env_spec, (2, 0, 1)) + weight_x_3d = np.transpose(env_spec_abs, (2, 1, 0)) + weight_y_3d = np.transpose(env_spec_abs, (2, 0, 1)) xda = np.sum(grid.axes[0] * weight_x_3d, axis=2) / np.sum(weight_x_3d, axis=2) yda = np.sum(grid.axes[1] * weight_y_3d, axis=2) / np.sum(weight_y_3d, axis=2) # Calculate zeta_x and zeta_y derivative_x_zeta = np.gradient(xda, omega, axis=0) derivative_y_zeta = np.gradient(yda, omega, axis=0) - weight_x_2d = np.mean(env_spec, axis=0) - weight_y_2d = np.mean(env_spec, axis=1) + weight_x_2d = np.mean(env_spec_abs, axis=0) + weight_y_2d = np.mean(env_spec_abs, axis=1) zeta_x = np.average(derivative_x_zeta.T, weights=weight_x_2d) zeta_y = np.average(derivative_y_zeta.T, weights=weight_y_2d) STC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) @@ -1017,16 +1019,17 @@ def get_STC(dim, grid, k0): ) # Calculate propagating angle - pphi_py = np.gradient(env_spec, grid.dx[1], axis=1) - pphi_px = np.gradient(env_spec, grid.dx[0], axis=0) + phi_envelop_abs = np.unwrap(np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=2) + pphi_py = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) + pphi_px = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) angle_y = ( - np.sum(pphi_py * env_spec, axis=(0, 1)) / np.sum(env_spec, axis=(0, 1)) + np.sum(pphi_py * env_spec_abs, axis=(0, 1)) / np.sum(env_spec_abs, axis=(0, 1)) ) / k0 angle_x = ( - np.sum(pphi_px * env_spec, axis=(0, 1)) / np.sum(env_spec, axis=(0, 1)) + np.sum(pphi_px * env_spec_abs, axis=(0, 1)) / np.sum(env_spec_abs, axis=(0, 1)) ) / k0 - weight_omega_1d = np.mean(env_spec, axis=(0, 1)) + weight_omega_1d = np.mean(env_spec_abs, axis=(0, 1)) derivative_x_beta = np.gradient(angle_y, omega) derivative_y_beta = np.gradient(angle_x, omega) beta_x=np.average(derivative_x_beta,weights=weight_omega_1d) From e3412eda44a7fc03a31e0883ec5017be4d57e613 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 12:30:10 +0000 Subject: [PATCH 199/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 89528d2b..9f27043e 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1019,15 +1019,19 @@ def get_STC(dim, grid, k0): ) # Calculate propagating angle - phi_envelop_abs = np.unwrap(np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=2) + phi_envelop_abs = np.unwrap( + np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=2 + ) pphi_py = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) pphi_px = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) angle_y = ( - np.sum(pphi_py * env_spec_abs, axis=(0, 1)) / np.sum(env_spec_abs, axis=(0, 1)) + np.sum(pphi_py * env_spec_abs, axis=(0, 1)) + / np.sum(env_spec_abs, axis=(0, 1)) ) / k0 angle_x = ( - np.sum(pphi_px * env_spec_abs, axis=(0, 1)) / np.sum(env_spec_abs, axis=(0, 1)) + np.sum(pphi_px * env_spec_abs, axis=(0, 1)) + / np.sum(env_spec_abs, axis=(0, 1)) ) / k0 weight_omega_1d = np.mean(env_spec_abs, axis=(0, 1)) derivative_x_beta = np.gradient(angle_y, omega) From d6bd1b2558d864d791c3f75519f63ea547d23534 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 4 Dec 2024 14:02:03 +0100 Subject: [PATCH 200/362] make average consistency --- lasy/utils/laser_utils.py | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 89528d2b..9d279c44 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -982,7 +982,7 @@ def get_STC(dim, grid, k0): dt = grid.dx[-1] Nt = grid.shape[-1] omega = 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0 * c - + domg = omega[1]-omega[0] # Calculate group-delayed dispersion phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) @@ -1006,8 +1006,8 @@ def get_STC(dim, grid, k0): yda = np.sum(grid.axes[1] * weight_y_3d, axis=2) / np.sum(weight_y_3d, axis=2) # Calculate zeta_x and zeta_y - derivative_x_zeta = np.gradient(xda, omega, axis=0) - derivative_y_zeta = np.gradient(yda, omega, axis=0) + derivative_x_zeta = np.gradient(xda, domg, axis=0) + derivative_y_zeta = np.gradient(yda, domg, axis=0) weight_x_2d = np.mean(env_spec_abs, axis=0) weight_y_2d = np.mean(env_spec_abs, axis=1) zeta_x = np.average(derivative_x_zeta.T, weights=weight_x_2d) @@ -1020,20 +1020,13 @@ def get_STC(dim, grid, k0): # Calculate propagating angle phi_envelop_abs = np.unwrap(np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=2) - pphi_py = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) - pphi_px = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) - - angle_y = ( - np.sum(pphi_py * env_spec_abs, axis=(0, 1)) / np.sum(env_spec_abs, axis=(0, 1)) - ) / k0 - angle_x = ( - np.sum(pphi_px * env_spec_abs, axis=(0, 1)) / np.sum(env_spec_abs, axis=(0, 1)) - ) / k0 - weight_omega_1d = np.mean(env_spec_abs, axis=(0, 1)) - derivative_x_beta = np.gradient(angle_y, omega) - derivative_y_beta = np.gradient(angle_x, omega) - beta_x = np.average(derivative_x_beta, weights=weight_omega_1d) - beta_y = np.average(derivative_y_beta, weights=weight_omega_1d) + angle_y = np.gradient(phi_envelop_abs, grid.dx[1], axis=1)/k0 + angle_x = np.gradient(phi_envelop_abs, grid.dx[0], axis=0)/k0 + + derivative_x_beta = np.gradient(angle_y,domg ,axis=2) + derivative_y_beta = np.gradient(angle_x,domg,axis=2) + beta_x = np.average(derivative_x_beta, weights=env_spec_abs) + beta_y = np.average(derivative_y_beta, weights=env_spec_abs) STC_fac["stc_theta_beta"] = np.arctan2(beta_y, beta_x) STC_fac["beta"] = np.sqrt(beta_x**2 + beta_y**2) From ae870bf388052da0104d912b7ea028c6a3d63f29 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 4 Dec 2024 14:03:33 +0100 Subject: [PATCH 201/362] make 3D average --- lasy/utils/laser_utils.py | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index afceed30..671ea150 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1020,25 +1020,14 @@ def get_STC(dim, grid, k0): # Calculate propagating angle - phi_envelop_abs = np.unwrap( - np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=2 - ) - pphi_py = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) - pphi_px = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) - - angle_y = ( - np.sum(pphi_py * env_spec_abs, axis=(0, 1)) - / np.sum(env_spec_abs, axis=(0, 1)) - ) / k0 - angle_x = ( - np.sum(pphi_px * env_spec_abs, axis=(0, 1)) - / np.sum(env_spec_abs, axis=(0, 1)) - ) / k0 - weight_omega_1d = np.mean(env_spec_abs, axis=(0, 1)) - derivative_x_beta = np.gradient(angle_y, omega) - derivative_y_beta = np.gradient(angle_x, omega) - beta_x = np.average(derivative_x_beta, weights=weight_omega_1d) - beta_y = np.average(derivative_y_beta, weights=weight_omega_1d) + phi_envelop_abs = np.unwrap(np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=2) + angle_y = np.gradient(phi_envelop_abs, grid.dx[1], axis=1)/k0 + angle_x = np.gradient(phi_envelop_abs, grid.dx[0], axis=0)/k0 + + derivative_x_beta = np.gradient(angle_y,domg ,axis=2) + derivative_y_beta = np.gradient(angle_x,domg,axis=2) + beta_x = np.average(derivative_x_beta, weights=env_spec_abs) + beta_y = np.average(derivative_y_beta, weights=env_spec_abs) STC_fac["stc_theta_beta"] = np.arctan2(beta_y, beta_x) STC_fac["beta"] = np.sqrt(beta_x**2 + beta_y**2) From 5e424418c3b4552af42314d47c0acfbc38c7d833 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 13:05:28 +0000 Subject: [PATCH 202/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 671ea150..e7aa0392 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -982,7 +982,7 @@ def get_STC(dim, grid, k0): dt = grid.dx[-1] Nt = grid.shape[-1] omega = 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0 * c - domg = omega[1]-omega[0] + domg = omega[1] - omega[0] # Calculate group-delayed dispersion phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) @@ -1020,12 +1020,14 @@ def get_STC(dim, grid, k0): # Calculate propagating angle - phi_envelop_abs = np.unwrap(np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=2) - angle_y = np.gradient(phi_envelop_abs, grid.dx[1], axis=1)/k0 - angle_x = np.gradient(phi_envelop_abs, grid.dx[0], axis=0)/k0 + phi_envelop_abs = np.unwrap( + np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=2 + ) + angle_y = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) / k0 + angle_x = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) / k0 - derivative_x_beta = np.gradient(angle_y,domg ,axis=2) - derivative_y_beta = np.gradient(angle_x,domg,axis=2) + derivative_x_beta = np.gradient(angle_y, domg, axis=2) + derivative_y_beta = np.gradient(angle_x, domg, axis=2) beta_x = np.average(derivative_x_beta, weights=env_spec_abs) beta_y = np.average(derivative_y_beta, weights=env_spec_abs) From c68bdf7b8d58f623163622f4e8e218b8a87b067d Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 4 Dec 2024 16:45:58 +0100 Subject: [PATCH 203/362] try fix initialization --- lasy/profiles/longitudinal/gaussian_profile.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 77632960..bf38c33b 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -130,8 +130,10 @@ def evaluate(self, t, x=0, y=0): stretch_factor = ( 1 + 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) + * (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 From ca56108c0704dbce15018750566808443f1f6ec5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 15:46:37 +0000 Subject: [PATCH 204/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/longitudinal/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index bf38c33b..706e5547 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -130,7 +130,7 @@ def evaluate(self, t, x=0, y=0): stretch_factor = ( 1 + 4.0 - * (self.zeta + self.beta * self.z_foc_over_zr ) + * (self.zeta + self.beta * self.z_foc_over_zr) * inv_tau2 * (self.zeta + self.beta * self.z_foc_over_zr) * inv_complex_waist_2 From 01f20d9b6350c1bba80ab836f49552d589c06d73 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 4 Dec 2024 17:05:44 +0100 Subject: [PATCH 205/362] Update test_STC.py --- tests/test_STC.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 07bc2f2a..42a416e3 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -13,9 +13,9 @@ w0=5e-6, # m tau=5e-14, # s t_peak=0.0, # s - beta=0, - zeta=2.4e-22, - phi2=2.4e-22, + beta=3e-18, + zeta=2.4e-24, + phi2=2.4e-19, stc_theta=scc.pi / 2, ) # Create laser with given profile in `xyt` geometry. @@ -36,6 +36,9 @@ ) STC_3d = get_STC(laser_3d.dim, laser_3d.grid, k0=2 * scc.pi / 0.6e-6) STC_2d = get_STC(laser_2d.dim, laser_2d.grid, k0=2 * scc.pi / 0.6e-6) -np.testing.assert_approx_equal(STC_2d["phi2"], 2.4e-22, significant=2) -np.testing.assert_approx_equal(STC_2d["zeta"], 2.4e-22, significant=2) -np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-22, significant=2) +np.testing.assert_approx_equal(STC_2d["phi2"], 2.4e-19, significant=2) +np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) +np.testing.assert_approx_equal(STC_3d["beta"], 3e-18, significant=2) +np.testing.assert_approx_equal(STC_3d["zeta"], 2.4e-24, significant=2) +np.testing.assert_approx_equal(STC_3d["stc_theta_zeta"], scc.pi/2, significant=2) +np.testing.assert_approx_equal(STC_3d["stc_theta_beta"], scc.pi/2, significant=2) From d1ee329bbecdd503004e9650cbf4c63209a609a6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 16:09:34 +0000 Subject: [PATCH 206/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 42a416e3..1dbb865c 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -40,5 +40,5 @@ np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) np.testing.assert_approx_equal(STC_3d["beta"], 3e-18, significant=2) np.testing.assert_approx_equal(STC_3d["zeta"], 2.4e-24, significant=2) -np.testing.assert_approx_equal(STC_3d["stc_theta_zeta"], scc.pi/2, significant=2) -np.testing.assert_approx_equal(STC_3d["stc_theta_beta"], scc.pi/2, significant=2) +np.testing.assert_approx_equal(STC_3d["stc_theta_zeta"], scc.pi / 2, significant=2) +np.testing.assert_approx_equal(STC_3d["stc_theta_beta"], scc.pi / 2, significant=2) From f3433621a96972e7f594d9daed252158eb78fec9 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 4 Dec 2024 17:31:04 +0100 Subject: [PATCH 207/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index e7aa0392..f4ec44c7 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -987,25 +987,22 @@ def get_STC(dim, grid, k0): phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) - - # Use the normalised laser intensity to calculate the weighted average of Phi2 STC_fac["Phi2"] = np.average(pphi_pt2, weights=env_abs) STC_fac["phi2"] = np.max( np.roots([4 * STC_fac["Phi2"], -4, tau**4 * STC_fac["Phi2"]]) ) - - # Calculate spatio- and angular dispersion + # No spatial chirp and angular chirp in 'rt' coordinate if dim == "rt": - # No spatial chirp and angular chirp in 'rt' coordinate return STC_fac + # Calculate spatio- and angular dispersion if dim == "xyt": - # Calculate dx and dy in (x,y,omega) space + # Calculate dx0 and dy0 in (x,y,omega) space weight_x_3d = np.transpose(env_spec_abs, (2, 1, 0)) weight_y_3d = np.transpose(env_spec_abs, (2, 0, 1)) xda = np.sum(grid.axes[0] * weight_x_3d, axis=2) / np.sum(weight_x_3d, axis=2) yda = np.sum(grid.axes[1] * weight_y_3d, axis=2) / np.sum(weight_y_3d, axis=2) - # Calculate zeta_x and zeta_y + # Calculate spatial chirp zeta derivative_x_zeta = np.gradient(xda, domg, axis=0) derivative_y_zeta = np.gradient(yda, domg, axis=0) weight_x_2d = np.mean(env_spec_abs, axis=0) @@ -1018,23 +1015,20 @@ def get_STC(dim, grid, k0): 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) ) - # Calculate propagating angle - + # Calculate angular dispersion beta phi_envelop_abs = np.unwrap( np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=2 ) angle_y = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) / k0 angle_x = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) / k0 - derivative_x_beta = np.gradient(angle_y, domg, axis=2) derivative_y_beta = np.gradient(angle_x, domg, axis=2) beta_x = np.average(derivative_x_beta, weights=env_spec_abs) beta_y = np.average(derivative_y_beta, weights=env_spec_abs) - STC_fac["stc_theta_beta"] = np.arctan2(beta_y, beta_x) STC_fac["beta"] = np.sqrt(beta_x**2 + beta_y**2) - # Use the normalised laser intensity to calculate the weighted average of PFT + # Calculate pulse front tilt weight_xy_2d = np.mean(env_abs, axis=2) z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) derivative_x_pft = np.gradient(z_centroids, axis=0) / grid.dx[0] From 5f4b3d423fb939febd4b69c6250ed06c62055f5f Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 4 Dec 2024 18:10:45 +0100 Subject: [PATCH 208/362] Update test_STC.py --- tests/test_STC.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 1dbb865c..1917a301 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -40,5 +40,3 @@ np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) np.testing.assert_approx_equal(STC_3d["beta"], 3e-18, significant=2) np.testing.assert_approx_equal(STC_3d["zeta"], 2.4e-24, significant=2) -np.testing.assert_approx_equal(STC_3d["stc_theta_zeta"], scc.pi / 2, significant=2) -np.testing.assert_approx_equal(STC_3d["stc_theta_beta"], scc.pi / 2, significant=2) From f7a59745316b474bb8d5ea99cfe15e7212666073 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 4 Dec 2024 18:12:34 +0100 Subject: [PATCH 209/362] debug angle --- 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 e7aa0392..eeaf5c30 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1008,6 +1008,7 @@ def get_STC(dim, grid, k0): # Calculate zeta_x and zeta_y derivative_x_zeta = np.gradient(xda, domg, axis=0) derivative_y_zeta = np.gradient(yda, domg, axis=0) + print(domg) weight_x_2d = np.mean(env_spec_abs, axis=0) weight_y_2d = np.mean(env_spec_abs, axis=1) zeta_x = np.average(derivative_x_zeta.T, weights=weight_x_2d) From 9a5701d95b59feaabd0068c9ef21aae73d7e2da4 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 4 Dec 2024 18:42:41 +0100 Subject: [PATCH 210/362] correct theta calculation --- lasy/utils/laser_utils.py | 29 +++++++++++++++-------------- tests/test_STC.py | 3 +++ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 5c1d709d..9606b320 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -982,7 +982,6 @@ def get_STC(dim, grid, k0): dt = grid.dx[-1] Nt = grid.shape[-1] omega = 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0 * c - domg = omega[1] - omega[0] # Calculate group-delayed dispersion phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) @@ -1003,15 +1002,15 @@ def get_STC(dim, grid, k0): yda = np.sum(grid.axes[1] * weight_y_3d, axis=2) / np.sum(weight_y_3d, axis=2) # Calculate spatial chirp zeta - derivative_x_zeta = np.gradient(xda, domg, axis=0) - derivative_y_zeta = np.gradient(yda, domg, axis=0) - print(domg) + derivative_x_zeta = np.gradient(xda, omega, axis=0) + derivative_y_zeta = np.gradient(yda, omega, axis=0) weight_x_2d = np.mean(env_spec_abs, axis=0) weight_y_2d = np.mean(env_spec_abs, axis=1) zeta_x = np.average(derivative_x_zeta.T, weights=weight_x_2d) zeta_y = np.average(derivative_y_zeta.T, weights=weight_y_2d) - STC_fac["stc_theta_zeta"] = np.arctan2(zeta_y, zeta_x) - STC_fac["zeta"] = np.sqrt(zeta_x**2 + zeta_y**2) + zeta = np.sqrt(zeta_x**2 + zeta_y**2) + STC_fac["stc_theta_zeta"] = np.arcsin(zeta_y/zeta) + STC_fac["zeta"] = zeta STC_fac["nu"] = ( 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) ) @@ -1020,14 +1019,15 @@ def get_STC(dim, grid, k0): phi_envelop_abs = np.unwrap( np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=2 ) - angle_y = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) / k0 - angle_x = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) / k0 - derivative_x_beta = np.gradient(angle_y, domg, axis=2) - derivative_y_beta = np.gradient(angle_x, domg, axis=2) + angle_x = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) / k0 + angle_y = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) / k0 + derivative_x_beta = np.gradient(angle_y, omega, axis=2) + derivative_y_beta = np.gradient(angle_x, omega, axis=2) beta_x = np.average(derivative_x_beta, weights=env_spec_abs) beta_y = np.average(derivative_y_beta, weights=env_spec_abs) - STC_fac["stc_theta_beta"] = np.arctan2(beta_y, beta_x) - STC_fac["beta"] = np.sqrt(beta_x**2 + beta_y**2) + beta = np.sqrt(beta_x**2 + beta_y**2) + STC_fac["stc_theta_beta"] = np.arcsin(beta_y/beta) + STC_fac["beta"] = beta # Calculate pulse front tilt weight_xy_2d = np.mean(env_abs, axis=2) @@ -1036,7 +1036,8 @@ def get_STC(dim, grid, k0): derivative_y_pft = np.gradient(z_centroids, axis=1) / grid.dx[1] pft_x = np.average(derivative_x_pft, weights=weight_xy_2d) pft_y = np.average(derivative_y_pft, weights=weight_xy_2d) - STC_fac["pft"] = np.sqrt((pft_x**2 + pft_y**2)) - STC_fac["stc_theta_pft"] = np.arctan2(pft_y, pft_x) + pft = np.sqrt((pft_x**2 + pft_y**2)) + STC_fac["pft"] = pft + STC_fac["stc_theta_pft"] = np.arcsin(pft_y/pft) return STC_fac diff --git a/tests/test_STC.py b/tests/test_STC.py index 1917a301..7429679c 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -40,3 +40,6 @@ np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) np.testing.assert_approx_equal(STC_3d["beta"], 3e-18, significant=2) np.testing.assert_approx_equal(STC_3d["zeta"], 2.4e-24, significant=2) +np.testing.assert_approx_equal(STC_3d["zeta"], 2.4e-24, significant=2) +np.testing.assert_approx_equal(STC_3d["stc_theta_zeta"], scc.pi / 2, significant=2) +np.testing.assert_approx_equal(STC_3d["stc_theta_beta"], scc.pi / 2, significant=2) From 33b1a15c214b54c52aabede137fbe0e147223876 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 17:43:04 +0000 Subject: [PATCH 211/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 9606b320..68b5b3dc 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1009,7 +1009,7 @@ def get_STC(dim, grid, k0): zeta_x = np.average(derivative_x_zeta.T, weights=weight_x_2d) zeta_y = np.average(derivative_y_zeta.T, weights=weight_y_2d) zeta = np.sqrt(zeta_x**2 + zeta_y**2) - STC_fac["stc_theta_zeta"] = np.arcsin(zeta_y/zeta) + STC_fac["stc_theta_zeta"] = np.arcsin(zeta_y / zeta) STC_fac["zeta"] = zeta STC_fac["nu"] = ( 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) @@ -1026,7 +1026,7 @@ def get_STC(dim, grid, k0): beta_x = np.average(derivative_x_beta, weights=env_spec_abs) beta_y = np.average(derivative_y_beta, weights=env_spec_abs) beta = np.sqrt(beta_x**2 + beta_y**2) - STC_fac["stc_theta_beta"] = np.arcsin(beta_y/beta) + STC_fac["stc_theta_beta"] = np.arcsin(beta_y / beta) STC_fac["beta"] = beta # Calculate pulse front tilt @@ -1038,6 +1038,6 @@ def get_STC(dim, grid, k0): pft_y = np.average(derivative_y_pft, weights=weight_xy_2d) pft = np.sqrt((pft_x**2 + pft_y**2)) STC_fac["pft"] = pft - STC_fac["stc_theta_pft"] = np.arcsin(pft_y/pft) + STC_fac["stc_theta_pft"] = np.arcsin(pft_y / pft) return STC_fac From 4472c821c14383fc91ac09268e1cb17b8f533ba0 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 4 Dec 2024 18:48:51 +0100 Subject: [PATCH 212/362] Update test_STC.py --- tests/test_STC.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 7429679c..afca140e 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -41,5 +41,6 @@ np.testing.assert_approx_equal(STC_3d["beta"], 3e-18, significant=2) np.testing.assert_approx_equal(STC_3d["zeta"], 2.4e-24, significant=2) np.testing.assert_approx_equal(STC_3d["zeta"], 2.4e-24, significant=2) -np.testing.assert_approx_equal(STC_3d["stc_theta_zeta"], scc.pi / 2, significant=2) np.testing.assert_approx_equal(STC_3d["stc_theta_beta"], scc.pi / 2, significant=2) +np.testing.assert_approx_equal(STC_3d["stc_theta_zeta"], scc.pi / 2, significant=2) + From 9277e01be83ca94384f1ac265c063f0c650f7e3c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 17:50:35 +0000 Subject: [PATCH 213/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index afca140e..d17db487 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -43,4 +43,3 @@ np.testing.assert_approx_equal(STC_3d["zeta"], 2.4e-24, significant=2) np.testing.assert_approx_equal(STC_3d["stc_theta_beta"], scc.pi / 2, significant=2) np.testing.assert_approx_equal(STC_3d["stc_theta_zeta"], scc.pi / 2, significant=2) - From c68365ab92208fae8454b782db69ec623dad2503 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 4 Dec 2024 18:55:21 +0100 Subject: [PATCH 214/362] Update gaussian_profile.py --- lasy/profiles/longitudinal/gaussian_profile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 706e5547..397d9f54 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -130,9 +130,9 @@ def evaluate(self, t, x=0, y=0): stretch_factor = ( 1 + 4.0 - * (self.zeta + self.beta * self.z_foc_over_zr) + * (-self.zeta + self.beta * self.z_foc_over_zr) * inv_tau2 - * (self.zeta + self.beta * self.z_foc_over_zr) + * (-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) @@ -150,7 +150,7 @@ def evaluate(self, t, x=0, y=0): * (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) + * (-self.zeta - self.beta * self.z_foc_over_zr) * inv_complex_waist_2 ) ** 2 From a6e4274c85597607b38a13c15ea7bc86d97700ee Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 5 Dec 2024 15:10:09 +0100 Subject: [PATCH 215/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 49 ++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 68b5b3dc..ad1e019e 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -944,15 +944,11 @@ def get_STC(dim, grid, k0): A dictionary of floats corresponding to the STC factors. The keys are: Phi2: Group-delayed dispersion in :math:`\Phi^{(2)}=d(\omega_0)/dt` phi2: Group-delayed dispersion in :math:`\phi^{(2)}=dt_0/d(\omega)` - nu: Spatio-chirp in :math:`\nu=d(\omega_0)/dx` - zeta: Spatio-chirp in :math:`\zeta=dx_0/d(\omega_0)` - stc_theta_zeta: The direction of the linear spatial chirp on xoy plane\ - in rad (0 is along x) - beta: Angular dispersion in :math:` \beta = d\theta_0/d\omega`(Important note: + nu_x, nu_y: Spatio-chirp in :math:`\nu=d(\omega_0)/dx` + zeta_x, zeta_y: Spatio-chirp in :math:`\zeta=dx_0/d(\omega_0)` + beta_x, beta_y: Angular dispersion in :math:` \beta = d\theta_0/d\omega`(Important note: for now beta is only correct when zeta and phi2 are 0!) - pft: Pulse front tilt in :math:` p=dt/dx` - stc_theta_pft: The direction of the linear angular chirp on xoy plane\ - in rad (0 is along x) + pft_x, pft_y: Pulse front tilt in :math:` p=dt/dx` All those above units and definitions are taken from `S. Akturk et al., Optics Express 12, 4399 (2004) `__. """ @@ -963,13 +959,14 @@ def get_STC(dim, grid, k0): STC_fac = { "Phi2": 0, "phi2": 0, - "nu": 0, - "zeta": 0, - "stc_theta_zeta": 0, - "beta": 0, - "stc_theta_beta": 0, - "pft": 0, - "stc_theta_pft": 0, + "nu_x": 0, + "nu_y": 0, + "zeta_x": 0, + "zeta_y": 0, + "beta_x": 0, + "beta_y": 0, + "pft_x": 0, + "pft_y": 0, } # Get temporal and spectral field @@ -1008,11 +1005,13 @@ def get_STC(dim, grid, k0): weight_y_2d = np.mean(env_spec_abs, axis=1) zeta_x = np.average(derivative_x_zeta.T, weights=weight_x_2d) zeta_y = np.average(derivative_y_zeta.T, weights=weight_y_2d) - zeta = np.sqrt(zeta_x**2 + zeta_y**2) - STC_fac["stc_theta_zeta"] = np.arcsin(zeta_y / zeta) - STC_fac["zeta"] = zeta - STC_fac["nu"] = ( - 4 * STC_fac["zeta"] / (w0**2 * tau**2 + 4 * STC_fac["zeta"] ** 2) + STC_fac["zeta_x"] = zeta_x + STC_fac["zeta_y"] = zeta_y + STC_fac["nu_x"] = ( + 4 * STC_fac["zeta_x"] / (w0**2 * tau**2 + 4 * STC_fac["zeta_x"] ** 2) + ) + STC_fac["nu_y"] = ( + 4 * STC_fac["zeta_y"] / (w0**2 * tau**2 + 4 * STC_fac["zeta_y"] ** 2) ) # Calculate angular dispersion beta @@ -1025,10 +1024,8 @@ def get_STC(dim, grid, k0): derivative_y_beta = np.gradient(angle_x, omega, axis=2) beta_x = np.average(derivative_x_beta, weights=env_spec_abs) beta_y = np.average(derivative_y_beta, weights=env_spec_abs) - beta = np.sqrt(beta_x**2 + beta_y**2) - STC_fac["stc_theta_beta"] = np.arcsin(beta_y / beta) - STC_fac["beta"] = beta - + STC_fac["beta_x"] = beta_x + STC_fac["beta_y"] = beta_x # Calculate pulse front tilt weight_xy_2d = np.mean(env_abs, axis=2) z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) @@ -1037,7 +1034,7 @@ def get_STC(dim, grid, k0): pft_x = np.average(derivative_x_pft, weights=weight_xy_2d) pft_y = np.average(derivative_y_pft, weights=weight_xy_2d) pft = np.sqrt((pft_x**2 + pft_y**2)) - STC_fac["pft"] = pft - STC_fac["stc_theta_pft"] = np.arcsin(pft_y / pft) + STC_fac["pft_x"] = pft_x + STC_fac["pft_y"] = pft_y return STC_fac From b529497d39175b47bd1d3c6bfcd295d76229f138 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 5 Dec 2024 15:11:02 +0100 Subject: [PATCH 216/362] Update test_STC.py --- tests/test_STC.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index d17db487..ee471949 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -38,8 +38,5 @@ STC_2d = get_STC(laser_2d.dim, laser_2d.grid, k0=2 * scc.pi / 0.6e-6) np.testing.assert_approx_equal(STC_2d["phi2"], 2.4e-19, significant=2) np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) -np.testing.assert_approx_equal(STC_3d["beta"], 3e-18, significant=2) -np.testing.assert_approx_equal(STC_3d["zeta"], 2.4e-24, significant=2) -np.testing.assert_approx_equal(STC_3d["zeta"], 2.4e-24, significant=2) -np.testing.assert_approx_equal(STC_3d["stc_theta_beta"], scc.pi / 2, significant=2) -np.testing.assert_approx_equal(STC_3d["stc_theta_zeta"], scc.pi / 2, significant=2) +np.testing.assert_approx_equal(STC_3d["beta_y"], 3e-18, significant=2) +np.testing.assert_approx_equal(STC_3d["zeta_y"], 2.4e-24, significant=2) From 0c96a6ff6dde626d44fdec6356252f1547adcd5f Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 5 Dec 2024 15:12:05 +0100 Subject: [PATCH 217/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index ad1e019e..a46b039e 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1025,7 +1025,7 @@ def get_STC(dim, grid, k0): beta_x = np.average(derivative_x_beta, weights=env_spec_abs) beta_y = np.average(derivative_y_beta, weights=env_spec_abs) STC_fac["beta_x"] = beta_x - STC_fac["beta_y"] = beta_x + STC_fac["beta_y"] = beta_y # Calculate pulse front tilt weight_xy_2d = np.mean(env_abs, axis=2) z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) @@ -1033,7 +1033,6 @@ def get_STC(dim, grid, k0): derivative_y_pft = np.gradient(z_centroids, axis=1) / grid.dx[1] pft_x = np.average(derivative_x_pft, weights=weight_xy_2d) pft_y = np.average(derivative_y_pft, weights=weight_xy_2d) - pft = np.sqrt((pft_x**2 + pft_y**2)) STC_fac["pft_x"] = pft_x STC_fac["pft_y"] = pft_y From 29774809d67e7cb4c26f930c43d72b0f1f8caefa Mon Sep 17 00:00:00 2001 From: Maxence Thevenet Date: Wed, 11 Dec 2024 17:12:13 +0100 Subject: [PATCH 218/362] add short explanation --- lasy/profiles/gaussian_profile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index b5a772a9..e473163c 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -19,8 +19,9 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): where :math:`u` is either :math:`x` or :math:`y`, :math:`p_u` is the polarization vector, :math:`Re` represent the real part, and :math:`\boldsymbol{x}_\perp` is the transverse coordinate (orthogonal - to the propagation direction). The other parameters in this formula - are defined below. + to the propagation direction). + The other parameters in this formula are defined below. + This profile also supports some chirp parameters that are omitted in the expression above for clarity. Parameters ---------- From 3b9e7e345b6a2215d6e828140b478efe02174018 Mon Sep 17 00:00:00 2001 From: Maxence Thevenet Date: Wed, 11 Dec 2024 17:14:44 +0100 Subject: [PATCH 219/362] move sentence stc --- lasy/profiles/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index e473163c..9e096631 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -70,6 +70,7 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): \beta = \frac{d\theta_0}{d\omega} Here :math:`\theta_0` is the propagation angle of this component. + The definitions of beta, phi2 and zeta are taken from [S. Akturk et al., Optics Express 12, 4399 (2004)]. phi2 : float (in second^2), optional (default '0') The group-delay dispersion parameterized by: @@ -90,7 +91,6 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): stc_theta : float (in rad) optional (default '0') Transverse direction along which spatio-temporal field couples. 0 is along x axis. - All those above STC units and definitions are taken from Examples -------- From f7d6aa70be37380d3bcfa945aca5997cd62c4417 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Thu, 12 Dec 2024 15:36:15 +0100 Subject: [PATCH 220/362] create STCgaussian class --- lasy/profiles/gaussian_profile.py | 104 +++++++++++++++++- .../profiles/longitudinal/gaussian_profile.py | 3 +- 2 files changed, 104 insertions(+), 3 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 9e096631..e487ad57 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -1,7 +1,8 @@ from . import CombinedLongitudinalTransverseProfile from .longitudinal import GaussianLongitudinalProfile from .transverse import GaussianTransverseProfile - +from . import Profile +import numpy as np class GaussianProfile(CombinedLongitudinalTransverseProfile): r""" @@ -167,3 +168,104 @@ def __init__( ), GaussianTransverseProfile(w0, z_foc, wavelength), ) + +class STCGaussianProfile(Profile): + r""" + """ + 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, + ): + super().__init__(wavelength) + self.tau = tau + self.t_peak = t_peak + self.cep_phase = cep_phase + self.beta = beta + self.phi2 = phi2 + self.zeta = zeta + self.w0 = w0 + self.stc_theta = stc_theta + 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, t, x=0, y=0): + """ + Return the longitudinal envelope. + + Parameters + ---------- + t : ndarrays of floats + Define longitudinal points on which to evaluate the envelope + + x,y : ndarrays of floats, necessray if spatio-temperal coulping exists + Define transverse points on which to evaluate the envelope + + Returns + ------- + envelope : ndarray of complex numbers + Contains the value of the longitudinal envelope at the + specified points. This array has the same shape as the array t. + """ + inv_tau2 = self.tau ** (-2) + 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.w0 + else 0 + ) + stretch_factor = ( + 1 + + 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 + ) + # Term for wavefront curvature + Gouy phase + diffract_factor = 1.0 - 1j * self.z_foc_over_zr + # Calculate the argument of the complex exponential + exp_argument = -(x**2 + y**2) / (self.w0**2 * diffract_factor) + # Get the profile + envelope = np.exp( + -stc_exponent + + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) + +exp_argument + ) / diffract_factor + + return envelope \ No newline at end of file diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 397d9f54..b55dd4e2 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -2,7 +2,6 @@ from .longitudinal_profile import LongitudinalProfile - class GaussianLongitudinalProfile(LongitudinalProfile): r""" Class for the analytic profile of a longitudinally-Gaussian laser pulse. @@ -159,4 +158,4 @@ def evaluate(self, t, x=0, y=0): -stc_exponent + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) ) - return envelope + return envelope \ No newline at end of file From 3f32d0e6a9345dc1837c81c1b4a01440807a78c9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:39:04 +0000 Subject: [PATCH 221/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 29 +++++++++++-------- .../profiles/longitudinal/gaussian_profile.py | 3 +- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index e487ad57..129ab605 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -1,8 +1,9 @@ -from . import CombinedLongitudinalTransverseProfile +import numpy as np + +from . import CombinedLongitudinalTransverseProfile, Profile from .longitudinal import GaussianLongitudinalProfile from .transverse import GaussianTransverseProfile -from . import Profile -import numpy as np + class GaussianProfile(CombinedLongitudinalTransverseProfile): r""" @@ -169,9 +170,10 @@ def __init__( GaussianTransverseProfile(w0, z_foc, wavelength), ) + class STCGaussianProfile(Profile): - r""" - """ + r""" """ + def __init__( self, wavelength, @@ -257,15 +259,18 @@ def evaluate(self, t, x=0, y=0): ) ** 2 ) - # Term for wavefront curvature + Gouy phase + # Term for wavefront curvature + Gouy phase diffract_factor = 1.0 - 1j * self.z_foc_over_zr # Calculate the argument of the complex exponential exp_argument = -(x**2 + y**2) / (self.w0**2 * diffract_factor) # Get the profile - envelope = np.exp( - -stc_exponent - + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) - +exp_argument - ) / diffract_factor + envelope = ( + np.exp( + -stc_exponent + + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) + + exp_argument + ) + / diffract_factor + ) - return envelope \ No newline at end of file + return envelope diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index b55dd4e2..397d9f54 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -2,6 +2,7 @@ from .longitudinal_profile import LongitudinalProfile + class GaussianLongitudinalProfile(LongitudinalProfile): r""" Class for the analytic profile of a longitudinally-Gaussian laser pulse. @@ -158,4 +159,4 @@ def evaluate(self, t, x=0, y=0): -stc_exponent + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) ) - return envelope \ No newline at end of file + return envelope From 2a378de9534f4d8b6f1b562b5a9ede54fbc66d7c Mon Sep 17 00:00:00 2001 From: huixingjian Date: Thu, 12 Dec 2024 16:07:24 +0100 Subject: [PATCH 222/362] separate STC to several functions --- lasy/profiles/gaussian_profile.py | 4 +- lasy/utils/laser_utils.py | 95 +++++++++++++++++++++++++++++++ tests/test_STC.py | 4 +- 3 files changed, 99 insertions(+), 4 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index e487ad57..bbc04a93 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -1,7 +1,7 @@ from . import CombinedLongitudinalTransverseProfile from .longitudinal import GaussianLongitudinalProfile from .transverse import GaussianTransverseProfile -from . import Profile +from .profile import Profile import numpy as np class GaussianProfile(CombinedLongitudinalTransverseProfile): @@ -204,7 +204,7 @@ def __init__( ), "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, t, x=0, y=0): + def evaluate(self, t, x, y): """ Return the longitudinal envelope. diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index a46b039e..7b9b0878 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -916,6 +916,101 @@ def get_w0(grid, dim): return sigma +def get_Phi2(dim, grid): + + tau = 2 * get_duration(grid, dim) + env = grid.get_temporal_field() + env_abs = np.abs(env**2) + # Calculate group-delayed dispersion + phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) + pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) + pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) + Phi2= np.average(pphi_pt2, weights=env_abs) + phi2 = np.max( + np.roots([4 * Phi2, -4, tau**4 * Phi2]) + ) + return Phi2, phi2 + +def get_Zeta(dim, grid): + assert ( + dim == 'rt' + ), "No spatial chirp for axis-sysmetric dimension" + w0 = get_w0(grid, dim) + tau = 2 * get_duration(grid, dim) + env_spec = grid.get_spectral_field() + env_spec_abs2 = np.abs(env_spec**2) + + # Get the spectral axis + dt = grid.dx[-1] + Nt = grid.shape[-1] + omega = 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0 * c + # Calculate dx0 and dy0 in (x,y,omega) space + weight_x_3d = np.transpose(env_spec_abs2, (2, 1, 0)) + weight_y_3d = np.transpose(env_spec_abs2, (2, 0, 1)) + xda = np.sum(grid.axes[0] * weight_x_3d, axis=2) / np.sum(weight_x_3d, axis=2) + yda = np.sum(grid.axes[1] * weight_y_3d, axis=2) / np.sum(weight_y_3d, axis=2) + + # Calculate spatial chirp zeta + derivative_x_zeta = np.gradient(xda, omega, axis=0) + derivative_y_zeta = np.gradient(yda, omega, axis=0) + weight_x_2d = np.mean(env_spec_abs2, axis=0) + weight_y_2d = np.mean(env_spec_abs2, axis=1) + zeta_x = np.average(derivative_x_zeta.T, weights=weight_x_2d) + zeta_y = np.average(derivative_y_zeta.T, weights=weight_y_2d) + nu_x = ( + 4 * zeta_x / (w0**2 * tau**2 + 4 * zeta_x ** 2) + ) + nu_y = ( + 4 * zeta_y / (w0**2 * tau**2 + 4 * zeta_y ** 2) + ) + return [zeta_x,zeta_y], [nu_x, nu_y] + +def get_Beta(dim, grid, k0): + assert ( + dim == 'rt' + ), "No angular chirp for axis-sysmetric dimension" + env_spec = grid.get_spectral_field() + env_spec_abs2 = np.abs(env_spec**2) + # Get the spectral axis + dt = grid.dx[-1] + Nt = grid.shape[-1] + omega = 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0 * c + # Calculate angular dispersion beta + phi_envelop_abs = np.unwrap( + np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=2 + ) + angle_x = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) / k0 + angle_y = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) / k0 + derivative_x_beta = np.gradient(angle_y, omega, axis=2) + derivative_y_beta = np.gradient(angle_x, omega, axis=2) + beta_x = np.average(derivative_x_beta, weights=env_spec_abs2) + beta_y = np.average(derivative_y_beta, weights=env_spec_abs2) + return [beta_x, beta_y] + +def get_Pft(dim, grid): + assert ( + dim == 'rt' + ), "No pulse front tilt for axis-sysmetric dimension" + env = grid.get_temporal_field() + env_abs = np.abs(env**2) + weight_xy_2d = np.mean(env_abs, axis=2) + z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) + derivative_x_pft = np.gradient(z_centroids, axis=0) / grid.dx[0] + derivative_y_pft = np.gradient(z_centroids, axis=1) / grid.dx[1] + pft_x = np.average(derivative_x_pft, weights=weight_xy_2d) + pft_y = np.average(derivative_y_pft, weights=weight_xy_2d) + return [pft_x, pft_y] + +def get_prop_angle(dim,grid, k0): + assert ( + dim == 'rt' + ), "Propagation always on-axis axis-sysmetric dimension" + phi_envelop_abs = np.unwrap( + np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=2 + ) + angle_x = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) / k0 + angle_y = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) / k0 + return [angle_x, angle_y] def get_STC(dim, grid, k0): r""" diff --git a/tests/test_STC.py b/tests/test_STC.py index ee471949..193711dc 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -2,11 +2,11 @@ import scipy.constants as scc from lasy.laser import Laser -from lasy.profiles.gaussian_profile import GaussianProfile +from lasy.profiles.gaussian_profile import STCGaussianProfile from lasy.utils.laser_utils import get_STC # Create profile. -profile = GaussianProfile( +profile = STCGaussianProfile( wavelength=0.6e-6, # m pol=(1, 0), laser_energy=1.0, # J From a1d52ebc08b22df295386464f1b825b54e3e918d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:09:59 +0000 Subject: [PATCH 223/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 3 +- lasy/utils/laser_utils.py | 47 +++++++++++++------------------ 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 3fb9ca6e..044b2758 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -2,9 +2,8 @@ from . import CombinedLongitudinalTransverseProfile, Profile from .longitudinal import GaussianLongitudinalProfile -from .transverse import GaussianTransverseProfile from .profile import Profile -import numpy as np +from .transverse import GaussianTransverseProfile class GaussianProfile(CombinedLongitudinalTransverseProfile): diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 7b9b0878..6a64c242 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -916,8 +916,8 @@ def get_w0(grid, dim): return sigma -def get_Phi2(dim, grid): +def get_Phi2(dim, grid): tau = 2 * get_duration(grid, dim) env = grid.get_temporal_field() env_abs = np.abs(env**2) @@ -925,16 +925,13 @@ def get_Phi2(dim, grid): phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) - Phi2= np.average(pphi_pt2, weights=env_abs) - phi2 = np.max( - np.roots([4 * Phi2, -4, tau**4 * Phi2]) - ) + Phi2 = np.average(pphi_pt2, weights=env_abs) + phi2 = np.max(np.roots([4 * Phi2, -4, tau**4 * Phi2])) return Phi2, phi2 + def get_Zeta(dim, grid): - assert ( - dim == 'rt' - ), "No spatial chirp for axis-sysmetric dimension" + assert dim == "rt", "No spatial chirp for axis-sysmetric dimension" w0 = get_w0(grid, dim) tau = 2 * get_duration(grid, dim) env_spec = grid.get_spectral_field() @@ -957,27 +954,22 @@ def get_Zeta(dim, grid): weight_y_2d = np.mean(env_spec_abs2, axis=1) zeta_x = np.average(derivative_x_zeta.T, weights=weight_x_2d) zeta_y = np.average(derivative_y_zeta.T, weights=weight_y_2d) - nu_x = ( - 4 * zeta_x / (w0**2 * tau**2 + 4 * zeta_x ** 2) - ) - nu_y = ( - 4 * zeta_y / (w0**2 * tau**2 + 4 * zeta_y ** 2) - ) - return [zeta_x,zeta_y], [nu_x, nu_y] + nu_x = 4 * zeta_x / (w0**2 * tau**2 + 4 * zeta_x**2) + nu_y = 4 * zeta_y / (w0**2 * tau**2 + 4 * zeta_y**2) + return [zeta_x, zeta_y], [nu_x, nu_y] + def get_Beta(dim, grid, k0): - assert ( - dim == 'rt' - ), "No angular chirp for axis-sysmetric dimension" + assert dim == "rt", "No angular chirp for axis-sysmetric dimension" env_spec = grid.get_spectral_field() env_spec_abs2 = np.abs(env_spec**2) # Get the spectral axis dt = grid.dx[-1] Nt = grid.shape[-1] omega = 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0 * c - # Calculate angular dispersion beta + # Calculate angular dispersion beta phi_envelop_abs = np.unwrap( - np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=2 + np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=2 ) angle_x = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) / k0 angle_y = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) / k0 @@ -987,10 +979,9 @@ def get_Beta(dim, grid, k0): beta_y = np.average(derivative_y_beta, weights=env_spec_abs2) return [beta_x, beta_y] + def get_Pft(dim, grid): - assert ( - dim == 'rt' - ), "No pulse front tilt for axis-sysmetric dimension" + assert dim == "rt", "No pulse front tilt for axis-sysmetric dimension" env = grid.get_temporal_field() env_abs = np.abs(env**2) weight_xy_2d = np.mean(env_abs, axis=2) @@ -1001,17 +992,17 @@ def get_Pft(dim, grid): pft_y = np.average(derivative_y_pft, weights=weight_xy_2d) return [pft_x, pft_y] -def get_prop_angle(dim,grid, k0): - assert ( - dim == 'rt' - ), "Propagation always on-axis axis-sysmetric dimension" + +def get_prop_angle(dim, grid, k0): + assert dim == "rt", "Propagation always on-axis axis-sysmetric dimension" phi_envelop_abs = np.unwrap( - np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=2 + np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=2 ) angle_x = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) / k0 angle_y = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) / k0 return [angle_x, angle_y] + def get_STC(dim, grid, k0): r""" Calculate the spatio-temporal coupling factors of the laser. From d5e0cfc612648c53de95eba118f3a38bbfa55572 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:13:19 +0100 Subject: [PATCH 224/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 044b2758..c20b27cb 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -2,7 +2,6 @@ from . import CombinedLongitudinalTransverseProfile, Profile from .longitudinal import GaussianLongitudinalProfile -from .profile import Profile from .transverse import GaussianTransverseProfile From f0ca9f9dfea962b85d684b1f48bd647bf4e42572 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:19:35 +0100 Subject: [PATCH 225/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index c20b27cb..ed28b69d 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -189,7 +189,8 @@ def __init__( zeta=0, stc_theta=0, ): - super().__init__(wavelength) + super().__init__(wavelength, + pol) self.tau = tau self.t_peak = t_peak self.cep_phase = cep_phase From ebc57e613d2fb8f8aa2807cccf4aa7537d4a0b2e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:19:44 +0000 Subject: [PATCH 226/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index ed28b69d..f064d9d2 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -189,8 +189,7 @@ def __init__( zeta=0, stc_theta=0, ): - super().__init__(wavelength, - pol) + super().__init__(wavelength, pol) self.tau = tau self.t_peak = t_peak self.cep_phase = cep_phase From fc7eac0714feb5960a4b95c03b3d1b1cf114e235 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:20:39 +0100 Subject: [PATCH 227/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index f064d9d2..88608bfb 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -1,5 +1,4 @@ import numpy as np - from . import CombinedLongitudinalTransverseProfile, Profile from .longitudinal import GaussianLongitudinalProfile from .transverse import GaussianTransverseProfile @@ -190,6 +189,7 @@ def __init__( stc_theta=0, ): super().__init__(wavelength, pol) + self.laser_energy = laser_energy self.tau = tau self.t_peak = t_peak self.cep_phase = cep_phase From 07df652033f3987b09060bd489bb0f8ab1a7b54b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:20:47 +0000 Subject: [PATCH 228/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 88608bfb..d2b1ec5f 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -1,4 +1,5 @@ import numpy as np + from . import CombinedLongitudinalTransverseProfile, Profile from .longitudinal import GaussianLongitudinalProfile from .transverse import GaussianTransverseProfile From 197002af3a5ad0347f4edd0f4d122a1ebb814ab6 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:27:35 +0100 Subject: [PATCH 229/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index d2b1ec5f..d45f03b8 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -1,6 +1,6 @@ import numpy as np - -from . import CombinedLongitudinalTransverseProfile, Profile +from . import CombinedLongitudinalTransverseProfile +from . import Profile from .longitudinal import GaussianLongitudinalProfile from .transverse import GaussianTransverseProfile From 14221e84cd1081dda52e2ca09f2fdef3c128de91 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:29:52 +0000 Subject: [PATCH 230/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index d45f03b8..d2b1ec5f 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -1,6 +1,6 @@ import numpy as np -from . import CombinedLongitudinalTransverseProfile -from . import Profile + +from . import CombinedLongitudinalTransverseProfile, Profile from .longitudinal import GaussianLongitudinalProfile from .transverse import GaussianTransverseProfile From 1de89a440099ee51328bd965c51e25ec21b9adb0 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:31:27 +0100 Subject: [PATCH 231/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index d2b1ec5f..1aee8c03 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -1,6 +1,6 @@ import numpy as np - -from . import CombinedLongitudinalTransverseProfile, Profile +from .profile import Profile +from . import CombinedLongitudinalTransverseProfile from .longitudinal import GaussianLongitudinalProfile from .transverse import GaussianTransverseProfile From 52db34fa8ab158153d2adb709fb45246508aff44 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:31:43 +0000 Subject: [PATCH 232/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 1aee8c03..5c9439ad 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -1,7 +1,8 @@ import numpy as np -from .profile import Profile + from . import CombinedLongitudinalTransverseProfile from .longitudinal import GaussianLongitudinalProfile +from .profile import Profile from .transverse import GaussianTransverseProfile From b2791b8c7379433ae1df393d51af8ea710b78eb8 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:38:58 +0100 Subject: [PATCH 233/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 5c9439ad..683b7ca3 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -200,13 +200,11 @@ def __init__( self.zeta = zeta self.w0 = w0 self.stc_theta = stc_theta - 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.z_foc_over_zr = z_foc * wavelength / (np.pi * w0**2) + self.lambda0 = wavelength + self.omega0 = 2 * pi * c / self.lambda0 + self.k0 = 2.0 * pi / wavelength + def evaluate(self, t, x, y): """ From 365c70459a0b1bdcb9234f110d71107dcd20c676 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:39:08 +0000 Subject: [PATCH 234/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 683b7ca3..f7e78041 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -204,7 +204,6 @@ def __init__( self.lambda0 = wavelength self.omega0 = 2 * pi * c / self.lambda0 self.k0 = 2.0 * pi / wavelength - def evaluate(self, t, x, y): """ From a11c89cbed0057c5893589924a37bd86a26a7198 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:41:27 +0100 Subject: [PATCH 235/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index f7e78041..e8e42219 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -1,5 +1,5 @@ import numpy as np - +from scipy.constants import c, pi from . import CombinedLongitudinalTransverseProfile from .longitudinal import GaussianLongitudinalProfile from .profile import Profile From a468337286106b7fdb6563534487ce86046c02a8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:41:35 +0000 Subject: [PATCH 236/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index e8e42219..6761dab3 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -1,5 +1,6 @@ import numpy as np from scipy.constants import c, pi + from . import CombinedLongitudinalTransverseProfile from .longitudinal import GaussianLongitudinalProfile from .profile import Profile From a6761070c9be0094299f4d1c80b8b999e7bd32f3 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Thu, 12 Dec 2024 16:43:41 +0100 Subject: [PATCH 237/362] add k0 in profile --- lasy/profiles/gaussian_profile.py | 5 ----- lasy/profiles/profile.py | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 6761dab3..a320b114 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -1,6 +1,4 @@ import numpy as np -from scipy.constants import c, pi - from . import CombinedLongitudinalTransverseProfile from .longitudinal import GaussianLongitudinalProfile from .profile import Profile @@ -202,9 +200,6 @@ def __init__( self.w0 = w0 self.stc_theta = stc_theta self.z_foc_over_zr = z_foc * wavelength / (np.pi * w0**2) - self.lambda0 = wavelength - self.omega0 = 2 * pi * c / self.lambda0 - self.k0 = 2.0 * pi / wavelength def evaluate(self, t, x, y): """ diff --git a/lasy/profiles/profile.py b/lasy/profiles/profile.py index 6266b1d8..f52151ee 100644 --- a/lasy/profiles/profile.py +++ b/lasy/profiles/profile.py @@ -38,7 +38,7 @@ def __init__(self, wavelength, pol): self.pol = np.array([pol[0] / norm_pol, pol[1] / norm_pol]) self.lambda0 = wavelength self.omega0 = 2 * np.pi * c / self.lambda0 - + self.k0 = 2.0 * np.pi / wavelength def evaluate(self, x, y, t): """ Return the envelope field of the laser. From cca9570e595f4442104b784bf3fb8f5041514517 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:44:00 +0000 Subject: [PATCH 238/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 1 + lasy/profiles/profile.py | 1 + 2 files changed, 2 insertions(+) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index a320b114..c2997640 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -1,4 +1,5 @@ import numpy as np + from . import CombinedLongitudinalTransverseProfile from .longitudinal import GaussianLongitudinalProfile from .profile import Profile diff --git a/lasy/profiles/profile.py b/lasy/profiles/profile.py index f52151ee..f8d28bac 100644 --- a/lasy/profiles/profile.py +++ b/lasy/profiles/profile.py @@ -39,6 +39,7 @@ def __init__(self, wavelength, pol): self.lambda0 = wavelength self.omega0 = 2 * np.pi * c / self.lambda0 self.k0 = 2.0 * np.pi / wavelength + def evaluate(self, x, y, t): """ Return the envelope field of the laser. From 74b7489a8927d0142aa16f1344058e5e61148849 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 11:19:37 +0100 Subject: [PATCH 239/362] create std gaussian --- .../profiles/longitudinal/gaussian_profile.py | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 397d9f54..9608b073 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -1,9 +1,63 @@ import numpy as np from .longitudinal_profile import LongitudinalProfile +class GaussianLongitudinalProfile(LongitudinalProfile): + r""" + Class for the analytic profile of a longitudinally-Gaussian laser pulse. + More precisely, the longitudinal envelope + (to be used in the :class:`.CombinedLongitudinalTransverseProfile` class) + corresponds to: -class GaussianLongitudinalProfile(LongitudinalProfile): + .. math:: + + \mathcal{L}(t) = \exp\left( - \frac{(t-t_{peak})^2}{\tau^2} + + i\omega_0t_{peak} \right) + + Parameters + ---------- + 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. + + 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, tau, t_peak, cep_phase=0): + super().__init__(wavelength) + self.tau = tau + self.t_peak = t_peak + self.cep_phase = cep_phase + + def evaluate(self, t): + """ + Return the longitudinal envelope. + Parameters + ---------- + t : ndarrays of floats + Define longitudinal points on which to evaluate the envelope + + Returns + ------- + envelope : ndarray of complex numbers + Contains the value of the longitudinal envelope at the + specified points. This array has the same shape as the array t. + """ + envelope = np.exp( + -((t - self.t_peak) ** 2) / self.tau**2 + + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) + ) + return envelope + +class STCGaussianLongitudinalProfile(LongitudinalProfile): r""" Class for the analytic profile of a longitudinally-Gaussian laser pulse. From e839ef81df2e5417cf627671c0b3195495765143 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:19:45 +0100 Subject: [PATCH 240/362] Update test_STC.py --- tests/test_STC.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 193711dc..c183d9ff 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -6,7 +6,7 @@ from lasy.utils.laser_utils import get_STC # Create profile. -profile = STCGaussianProfile( +profile = GaussianProfile( wavelength=0.6e-6, # m pol=(1, 0), laser_energy=1.0, # J From 7b772f300fe111615e448181f73c6ba8df6bebd3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 11:19:57 +0000 Subject: [PATCH 241/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index c183d9ff..1172b6a8 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -2,7 +2,6 @@ import scipy.constants as scc from lasy.laser import Laser -from lasy.profiles.gaussian_profile import STCGaussianProfile from lasy.utils.laser_utils import get_STC # Create profile. From 2f6b19aa6e838149378f572f504862f55ffe93ee Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:32:14 +0100 Subject: [PATCH 242/362] Update test_STC.py --- tests/test_STC.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 1172b6a8..015e333b 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -1,6 +1,6 @@ import numpy as np import scipy.constants as scc - +from lasy.profiles.gaussian_profile import GaussianProfile, STCGaussianProfile from lasy.laser import Laser from lasy.utils.laser_utils import get_STC From b8dce993d8c36f1f6dc52495a7108937b3a15f68 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 11:33:26 +0000 Subject: [PATCH 243/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 015e333b..ee471949 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -1,7 +1,8 @@ import numpy as np import scipy.constants as scc -from lasy.profiles.gaussian_profile import GaussianProfile, STCGaussianProfile + from lasy.laser import Laser +from lasy.profiles.gaussian_profile import GaussianProfile from lasy.utils.laser_utils import get_STC # Create profile. From 6e979e28c50b6feba8bf49af899d013683d088fb Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 12:42:02 +0100 Subject: [PATCH 244/362] debug utils --- lasy/profiles/longitudinal/gaussian_profile.py | 2 +- lasy/utils/laser_utils.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 9608b073..1ba39ab7 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -156,7 +156,7 @@ def __init__( ), "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, t, x=0, y=0): + def evaluate(self, t, x, y): """ Return the longitudinal envelope. diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 6a64c242..8b9a0374 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -930,7 +930,7 @@ def get_Phi2(dim, grid): return Phi2, phi2 -def get_Zeta(dim, grid): +def get_Zeta(dim, grid, k0): assert dim == "rt", "No spatial chirp for axis-sysmetric dimension" w0 = get_w0(grid, dim) tau = 2 * get_duration(grid, dim) @@ -945,8 +945,7 @@ def get_Zeta(dim, grid): weight_x_3d = np.transpose(env_spec_abs2, (2, 1, 0)) weight_y_3d = np.transpose(env_spec_abs2, (2, 0, 1)) xda = np.sum(grid.axes[0] * weight_x_3d, axis=2) / np.sum(weight_x_3d, axis=2) - yda = np.sum(grid.axes[1] * weight_y_3d, axis=2) / np.sum(weight_y_3d, axis=2) - + yda = np.sum(grid.axes[1] * weight_y_3d, axis=2) / np.sum(weight_y_3d, axis=2 # Calculate spatial chirp zeta derivative_x_zeta = np.gradient(xda, omega, axis=0) derivative_y_zeta = np.gradient(yda, omega, axis=0) @@ -983,9 +982,9 @@ def get_Beta(dim, grid, k0): def get_Pft(dim, grid): assert dim == "rt", "No pulse front tilt for axis-sysmetric dimension" env = grid.get_temporal_field() - env_abs = np.abs(env**2) - weight_xy_2d = np.mean(env_abs, axis=2) - z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) + env_abs2 = np.abs(env**2) + weight_xy_2d = np.mean(env_spec_abs2, axis=2) + z_centroids = np.sum(grid.axes[2] * env_abs2, axis=2) / np.sum(env_spec_abs2, axis=2) derivative_x_pft = np.gradient(z_centroids, axis=0) / grid.dx[0] derivative_y_pft = np.gradient(z_centroids, axis=1) / grid.dx[1] pft_x = np.average(derivative_x_pft, weights=weight_xy_2d) @@ -995,8 +994,10 @@ def get_Pft(dim, grid): def get_prop_angle(dim, grid, k0): assert dim == "rt", "Propagation always on-axis axis-sysmetric dimension" + env = grid.get_temporal_field() + env_abs2 = np.abs(env**2) phi_envelop_abs = np.unwrap( - np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=2 + np.array(np.arctan2(env.imag, env.real)), axis=2 ) angle_x = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) / k0 angle_y = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) / k0 From 9defa15f1c4e003015b15799c468c54b10a74999 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 12:52:16 +0100 Subject: [PATCH 245/362] missing bracket --- 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 8b9a0374..d9a9bff0 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -945,7 +945,7 @@ def get_Zeta(dim, grid, k0): weight_x_3d = np.transpose(env_spec_abs2, (2, 1, 0)) weight_y_3d = np.transpose(env_spec_abs2, (2, 0, 1)) xda = np.sum(grid.axes[0] * weight_x_3d, axis=2) / np.sum(weight_x_3d, axis=2) - yda = np.sum(grid.axes[1] * weight_y_3d, axis=2) / np.sum(weight_y_3d, axis=2 + yda = np.sum(grid.axes[1] * weight_y_3d, axis=2) / np.sum(weight_y_3d, axis=2) # Calculate spatial chirp zeta derivative_x_zeta = np.gradient(xda, omega, axis=0) derivative_y_zeta = np.gradient(yda, omega, axis=0) From 99d80f4eceb324a9c99aa4ffd76e5d32f51582a8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 11:53:21 +0000 Subject: [PATCH 246/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index d9a9bff0..aa2e5479 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -984,7 +984,9 @@ def get_Pft(dim, grid): env = grid.get_temporal_field() env_abs2 = np.abs(env**2) weight_xy_2d = np.mean(env_spec_abs2, axis=2) - z_centroids = np.sum(grid.axes[2] * env_abs2, axis=2) / np.sum(env_spec_abs2, axis=2) + z_centroids = np.sum(grid.axes[2] * env_abs2, axis=2) / np.sum( + env_spec_abs2, axis=2 + ) derivative_x_pft = np.gradient(z_centroids, axis=0) / grid.dx[0] derivative_y_pft = np.gradient(z_centroids, axis=1) / grid.dx[1] pft_x = np.average(derivative_x_pft, weights=weight_xy_2d) @@ -996,9 +998,7 @@ def get_prop_angle(dim, grid, k0): assert dim == "rt", "Propagation always on-axis axis-sysmetric dimension" env = grid.get_temporal_field() env_abs2 = np.abs(env**2) - phi_envelop_abs = np.unwrap( - np.array(np.arctan2(env.imag, env.real)), axis=2 - ) + phi_envelop_abs = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) angle_x = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) / k0 angle_y = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) / k0 return [angle_x, angle_y] From 1d9863aca2a6fac72e9ffdd9a30d9869161f3b61 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:09:33 +0100 Subject: [PATCH 247/362] Update profile.py --- lasy/profiles/profile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lasy/profiles/profile.py b/lasy/profiles/profile.py index f8d28bac..6266b1d8 100644 --- a/lasy/profiles/profile.py +++ b/lasy/profiles/profile.py @@ -38,7 +38,6 @@ def __init__(self, wavelength, pol): self.pol = np.array([pol[0] / norm_pol, pol[1] / norm_pol]) self.lambda0 = wavelength self.omega0 = 2 * np.pi * c / self.lambda0 - self.k0 = 2.0 * np.pi / wavelength def evaluate(self, x, y, t): """ From d7f6a27b28e73e3555b159f782113ae35c8caa28 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 13:10:32 +0100 Subject: [PATCH 248/362] add k0 to profile --- lasy/profiles/gaussian_profile.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index c2997640..4460595e 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -192,15 +192,22 @@ def __init__( ): super().__init__(wavelength, pol) self.laser_energy = laser_energy + self.w0 = w0 self.tau = tau self.t_peak = t_peak self.cep_phase = cep_phase - self.beta = beta + 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.phi2 = phi2 + self.beta = beta self.zeta = zeta - self.w0 = w0 self.stc_theta = stc_theta - self.z_foc_over_zr = z_foc * wavelength / (np.pi * w0**2) + def evaluate(self, t, x, y): """ From 99cff492d36b1e55deb6aeaff7317c2530643d1d Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 13:13:43 +0100 Subject: [PATCH 249/362] add k0 to profile --- lasy/profiles/profile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lasy/profiles/profile.py b/lasy/profiles/profile.py index 6266b1d8..f8d28bac 100644 --- a/lasy/profiles/profile.py +++ b/lasy/profiles/profile.py @@ -38,6 +38,7 @@ def __init__(self, wavelength, pol): self.pol = np.array([pol[0] / norm_pol, pol[1] / norm_pol]) self.lambda0 = wavelength self.omega0 = 2 * np.pi * c / self.lambda0 + self.k0 = 2.0 * np.pi / wavelength def evaluate(self, x, y, t): """ From 4abf73c781b7413886adc8a2fd40d5bbd654e55a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:14:02 +0000 Subject: [PATCH 250/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 4460595e..a23a1af2 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -208,7 +208,6 @@ def __init__( self.zeta = zeta self.stc_theta = stc_theta - def evaluate(self, t, x, y): """ Return the longitudinal envelope. From 5432eed599623e462b46302788eb161b6e365f31 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 13:19:45 +0100 Subject: [PATCH 251/362] incident bug --- lasy/profiles/gaussian_profile.py | 5 ++--- lasy/profiles/longitudinal/gaussian_profile.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 4460595e..95a3166d 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -270,10 +270,9 @@ def evaluate(self, t, x, y): envelope = ( np.exp( -stc_exponent + +exp_argument + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) - + exp_argument + )/ diffract_factor ) - / diffract_factor - ) return envelope diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index 1ba39ab7..af01cf1f 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -2,7 +2,7 @@ from .longitudinal_profile import LongitudinalProfile class GaussianLongitudinalProfile(LongitudinalProfile): - r""" + r""" Class for the analytic profile of a longitudinally-Gaussian laser pulse. More precisely, the longitudinal envelope From 6ac3412a65c2883739c833f7543fd0e3e8c57b80 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:20:34 +0000 Subject: [PATCH 252/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 5 +++-- lasy/profiles/longitudinal/gaussian_profile.py | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index e2072529..67fdc330 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -269,9 +269,10 @@ def evaluate(self, t, x, y): envelope = ( np.exp( -stc_exponent - +exp_argument + + exp_argument + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) - )/ diffract_factor ) + / diffract_factor + ) return envelope diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index af01cf1f..bdffb22b 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -1,6 +1,8 @@ import numpy as np from .longitudinal_profile import LongitudinalProfile + + class GaussianLongitudinalProfile(LongitudinalProfile): r""" Class for the analytic profile of a longitudinally-Gaussian laser pulse. @@ -31,6 +33,7 @@ class GaussianLongitudinalProfile(LongitudinalProfile): 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, tau, t_peak, cep_phase=0): super().__init__(wavelength) self.tau = tau @@ -40,6 +43,7 @@ def __init__(self, wavelength, tau, t_peak, cep_phase=0): def evaluate(self, t): """ Return the longitudinal envelope. + Parameters ---------- t : ndarrays of floats @@ -52,11 +56,12 @@ def evaluate(self, t): specified points. This array has the same shape as the array t. """ envelope = np.exp( - -((t - self.t_peak) ** 2) / self.tau**2 + -((t - self.t_peak) ** 2) / self.tau**2 + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) ) return envelope + class STCGaussianLongitudinalProfile(LongitudinalProfile): r""" Class for the analytic profile of a longitudinally-Gaussian laser pulse. From baf2a691fed83001c23d964c9a376979325df63b Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:22:20 +0100 Subject: [PATCH 253/362] delete STC Longidutinal_profile.py --- .../profiles/longitudinal/gaussian_profile.py | 159 ------------------ 1 file changed, 159 deletions(-) diff --git a/lasy/profiles/longitudinal/gaussian_profile.py b/lasy/profiles/longitudinal/gaussian_profile.py index bdffb22b..226c68c5 100644 --- a/lasy/profiles/longitudinal/gaussian_profile.py +++ b/lasy/profiles/longitudinal/gaussian_profile.py @@ -60,162 +60,3 @@ def evaluate(self, t): + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) ) return envelope - - -class STCGaussianLongitudinalProfile(LongitudinalProfile): - r""" - Class for the analytic profile of a longitudinally-Gaussian laser pulse. - - More precisely, the longitudinal envelope - (to be used in the :class:`.CombinedLongitudinalTransverseProfile` class) - corresponds to: - - .. math:: - - \mathcal{L}(t) = \exp\left( - \frac{(t-t_{peak})^2}{\tau^2} - + i\omega_0t_{peak} \right) - - Parameters - ---------- - 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. - - 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). - - beta : float (in second), optional - The angular dispersion parameterized by: - - .. math:: - - \beta = \frac{d\theta_0}{d\omega} - - Here :math:`\theta_0` is the propagation angle of this component. - - phi2 : float (in second^2), optional (default '0') - The group-delay dispersion parameterized by: - - .. math:: - - \phi^{(2)} = \frac{dt}{d\omega} - - zeta : float (in meter * second) optional (defalut '0') - The spatio-chirp parameterized by: - - .. math:: - - \zeta = \frac{dx_0}{d\omega} - - Here :math:`x_0` is the beam center position. - - stc_theta : float (in rad) optional (default '0') - Transverse direction along which spatio-temporal field couples. - 0 is along x axis. - - z_foc : float (in meter), necessary if beta is not 0 - Position of the focal plane. (The laser pulse is initialized at - ``z=0``.) - - w0 : float (in meter), necessary if beta is not 0 - The waist of the laser pulse. - - All those above STC units and definitions are taken from - """ - - def __init__( - self, - wavelength, - tau, - t_peak, - cep_phase=0, - beta=0, - phi2=0, - zeta=0, - stc_theta=0, - w0=0, - z_foc=0, - ): - super().__init__(wavelength) - self.tau = tau - self.t_peak = t_peak - self.cep_phase = cep_phase - self.beta = beta - self.phi2 = phi2 - self.zeta = zeta - self.w0 = w0 - self.stc_theta = stc_theta - 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, t, x, y): - """ - Return the longitudinal envelope. - - Parameters - ---------- - t : ndarrays of floats - Define longitudinal points on which to evaluate the envelope - - x,y : ndarrays of floats, necessray if spatio-temperal coulping exists - Define transverse points on which to evaluate the envelope - - Returns - ------- - envelope : ndarray of complex numbers - Contains the value of the longitudinal envelope at the - specified points. This array has the same shape as the array t. - """ - inv_tau2 = self.tau ** (-2) - 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.w0 - else 0 - ) - stretch_factor = ( - 1 - + 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 + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) - ) - - return envelope From 805358cc06b56f94dd64469a94f6ac11f5b4703a Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 14:05:05 +0100 Subject: [PATCH 254/362] convert to STCGaussianProfile --- lasy/profiles/gaussian_profile.py | 6 ------ tests/test_STC.py | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 67fdc330..efb41519 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -161,12 +161,6 @@ def __init__( tau, t_peak, cep_phase, - beta=beta, - phi2=phi2, - zeta=zeta, - stc_theta=stc_theta, - w0=w0, - z_foc=z_foc, ), GaussianTransverseProfile(w0, z_foc, wavelength), ) diff --git a/tests/test_STC.py b/tests/test_STC.py index ee471949..193711dc 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -2,11 +2,11 @@ import scipy.constants as scc from lasy.laser import Laser -from lasy.profiles.gaussian_profile import GaussianProfile +from lasy.profiles.gaussian_profile import STCGaussianProfile from lasy.utils.laser_utils import get_STC # Create profile. -profile = GaussianProfile( +profile = STCGaussianProfile( wavelength=0.6e-6, # m pol=(1, 0), laser_energy=1.0, # J From 0e0b6af4526a0be84fc86399f005f4b421e0d9ad Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 14:09:12 +0100 Subject: [PATCH 255/362] change phi2 to smaller number --- tests/test_STC.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 193711dc..d6282000 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -15,7 +15,7 @@ t_peak=0.0, # s beta=3e-18, zeta=2.4e-24, - phi2=2.4e-19, + phi2=2.4e-27, stc_theta=scc.pi / 2, ) # Create laser with given profile in `xyt` geometry. From 14583d81557f33a78f1a303a74f51fcb21ce7d97 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 14:16:43 +0100 Subject: [PATCH 256/362] make beta and zeta to 0 --- lasy/profiles/gaussian_profile.py | 14 +------------- tests/test_STC.py | 5 +++-- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index efb41519..f65432bb 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -147,10 +147,6 @@ def __init__( t_peak, cep_phase=0, z_foc=0, - phi2=0, - beta=0, - zeta=0, - stc_theta=0, ): super().__init__( wavelength, @@ -190,13 +186,7 @@ def __init__( self.tau = tau self.t_peak = t_peak self.cep_phase = cep_phase - 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.z_foc_over_zr = z_foc * wavelength / (np.pi * w0**2) self.phi2 = phi2 self.beta = beta self.zeta = zeta @@ -224,8 +214,6 @@ def evaluate(self, t, x, y): 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.w0 - else 0 ) stretch_factor = ( 1 diff --git a/tests/test_STC.py b/tests/test_STC.py index d6282000..62005f0e 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -13,8 +13,8 @@ w0=5e-6, # m tau=5e-14, # s t_peak=0.0, # s - beta=3e-18, - zeta=2.4e-24, + beta=0, + zeta=0, phi2=2.4e-27, stc_theta=scc.pi / 2, ) @@ -36,6 +36,7 @@ ) STC_3d = get_STC(laser_3d.dim, laser_3d.grid, k0=2 * scc.pi / 0.6e-6) STC_2d = get_STC(laser_2d.dim, laser_2d.grid, k0=2 * scc.pi / 0.6e-6) +print(STC_2d["phi2"]) np.testing.assert_approx_equal(STC_2d["phi2"], 2.4e-19, significant=2) np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) np.testing.assert_approx_equal(STC_3d["beta_y"], 3e-18, significant=2) From d5f75362d72ff5b8b020772ae88de8686425778c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:18:14 +0000 Subject: [PATCH 257/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index f65432bb..024a06f6 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -211,9 +211,8 @@ def evaluate(self, t, x, y): specified points. This array has the same shape as the array t. """ inv_tau2 = self.tau ** (-2) - inv_complex_waist_2 = ( - 1.0 - / (self.w0**2 * (1.0 + 2.0j * self.z_foc_over_zr / (self.k0 * self.w0**2))) + inv_complex_waist_2 = 1.0 / ( + self.w0**2 * (1.0 + 2.0j * self.z_foc_over_zr / (self.k0 * self.w0**2)) ) stretch_factor = ( 1 From de7a88f487d2143468141a6ebb51e36f22ffb024 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 14:26:42 +0100 Subject: [PATCH 258/362] change argument order --- lasy/profiles/gaussian_profile.py | 2 +- lasy/profiles/longitudinal/longitudinal_profile.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index f65432bb..af5b94aa 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -192,7 +192,7 @@ def __init__( self.zeta = zeta self.stc_theta = stc_theta - def evaluate(self, t, x, y): + def evaluate(self, x, y, t): """ Return the longitudinal envelope. diff --git a/lasy/profiles/longitudinal/longitudinal_profile.py b/lasy/profiles/longitudinal/longitudinal_profile.py index 591234c2..767ffbcd 100644 --- a/lasy/profiles/longitudinal/longitudinal_profile.py +++ b/lasy/profiles/longitudinal/longitudinal_profile.py @@ -15,7 +15,7 @@ def __init__(self, wavelength): self.omega0 = 2 * pi * c / self.lambda0 self.k0 = 2.0 * pi / wavelength - def evaluate(self, t, x=0, y=0): + def evaluate(self, t): """ Return the longitudinal envelope. From 156e1ae7ba2915077b5c78925921bd7e1357dc15 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 14:31:12 +0100 Subject: [PATCH 259/362] check get_phi2 --- tests/test_STC.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 62005f0e..183902e3 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -3,7 +3,7 @@ from lasy.laser import Laser from lasy.profiles.gaussian_profile import STCGaussianProfile -from lasy.utils.laser_utils import get_STC +from lasy.utils.laser_utils import get_Phi2 # Create profile. profile = STCGaussianProfile( @@ -23,7 +23,7 @@ dim="xyt", lo=(-10e-6, -10e-6, -10e-14), hi=(10e-6, 10e-6, +10e-14), - npoints=(50, 60, 70), + npoints=(50, 60, 200), profile=profile, ) # Create laser with given profile in `rt` geometry. @@ -31,13 +31,13 @@ dim="rt", lo=(-10e-6, -10e-14), hi=(10e-6, +10e-14), - npoints=(60, 70), + npoints=(60, 200), profile=profile, ) -STC_3d = get_STC(laser_3d.dim, laser_3d.grid, k0=2 * scc.pi / 0.6e-6) -STC_2d = get_STC(laser_2d.dim, laser_2d.grid, k0=2 * scc.pi / 0.6e-6) -print(STC_2d["phi2"]) -np.testing.assert_approx_equal(STC_2d["phi2"], 2.4e-19, significant=2) -np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) -np.testing.assert_approx_equal(STC_3d["beta_y"], 3e-18, significant=2) -np.testing.assert_approx_equal(STC_3d["zeta_y"], 2.4e-24, significant=2) +Phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid, k0=2 * scc.pi / 0.6e-6) +#STC_2d = get_STC(laser_2d.dim, laser_2d.grid, k0=2 * scc.pi / 0.6e-6) +print(Phi2_3d) +np.testing.assert_approx_equal(Phi2_3d, 2.4e-27, significant=2) +#np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) +#np.testing.assert_approx_equal(STC_3d["beta_y"], 3e-18, significant=2) +#np.testing.assert_approx_equal(STC_3d["zeta_y"], 2.4e-24, significant=2) From a3a51ce0ea0c54ca40b96fb1e4a356967fa49604 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:31:27 +0000 Subject: [PATCH 260/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 183902e3..6431174b 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -35,9 +35,9 @@ profile=profile, ) Phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid, k0=2 * scc.pi / 0.6e-6) -#STC_2d = get_STC(laser_2d.dim, laser_2d.grid, k0=2 * scc.pi / 0.6e-6) +# STC_2d = get_STC(laser_2d.dim, laser_2d.grid, k0=2 * scc.pi / 0.6e-6) print(Phi2_3d) np.testing.assert_approx_equal(Phi2_3d, 2.4e-27, significant=2) -#np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) -#np.testing.assert_approx_equal(STC_3d["beta_y"], 3e-18, significant=2) -#np.testing.assert_approx_equal(STC_3d["zeta_y"], 2.4e-24, significant=2) +# np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) +# np.testing.assert_approx_equal(STC_3d["beta_y"], 3e-18, significant=2) +# np.testing.assert_approx_equal(STC_3d["zeta_y"], 2.4e-24, significant=2) From 6a1f06ca612474fb126959742b3b4170e8021bb8 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 14:33:09 +0100 Subject: [PATCH 261/362] check bigger phi2 --- tests/test_STC.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 183902e3..7c6ce33a 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -15,7 +15,7 @@ t_peak=0.0, # s beta=0, zeta=0, - phi2=2.4e-27, + phi2=2.4e-24, stc_theta=scc.pi / 2, ) # Create laser with given profile in `xyt` geometry. @@ -34,10 +34,10 @@ npoints=(60, 200), profile=profile, ) -Phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid, k0=2 * scc.pi / 0.6e-6) +Phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid) #STC_2d = get_STC(laser_2d.dim, laser_2d.grid, k0=2 * scc.pi / 0.6e-6) print(Phi2_3d) -np.testing.assert_approx_equal(Phi2_3d, 2.4e-27, significant=2) +np.testing.assert_approx_equal(Phi2_3d, 2.4e-24, significant=2) #np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) #np.testing.assert_approx_equal(STC_3d["beta_y"], 3e-18, significant=2) #np.testing.assert_approx_equal(STC_3d["zeta_y"], 2.4e-24, significant=2) From 1b26328713225bae238d7ac6fb5d0688b8dfe18b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:33:58 +0000 Subject: [PATCH 262/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 35919f32..ff302ea9 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -36,9 +36,9 @@ ) Phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid) -#STC_2d = get_STC(laser_2d.dim, laser_2d.grid, k0=2 * scc.pi / 0.6e-6) +# STC_2d = get_STC(laser_2d.dim, laser_2d.grid, k0=2 * scc.pi / 0.6e-6) print(Phi2_3d) np.testing.assert_approx_equal(Phi2_3d, 2.4e-24, significant=2) -#np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) -#np.testing.assert_approx_equal(STC_3d["beta_y"], 3e-18, significant=2) -#np.testing.assert_approx_equal(STC_3d["zeta_y"], 2.4e-24, significant=2) +# np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) +# np.testing.assert_approx_equal(STC_3d["beta_y"], 3e-18, significant=2) +# np.testing.assert_approx_equal(STC_3d["zeta_y"], 2.4e-24, significant=2) From 14b172309a1eb25500540e80be7c0c78b204d22f Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 14:38:52 +0100 Subject: [PATCH 263/362] check zeta --- tests/test_STC.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 35919f32..1012e629 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -3,7 +3,7 @@ from lasy.laser import Laser from lasy.profiles.gaussian_profile import STCGaussianProfile -from lasy.utils.laser_utils import get_Phi2 +from lasy.utils.laser_utils import get_Phi2, get_Zeta(dim, grid, k0) # Create profile. profile = STCGaussianProfile( @@ -14,7 +14,7 @@ tau=5e-14, # s t_peak=0.0, # s beta=0, - zeta=0, + zeta=2.4e-22, phi2=2.4e-24, stc_theta=scc.pi / 2, ) @@ -35,10 +35,12 @@ profile=profile, ) -Phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid) -#STC_2d = get_STC(laser_2d.dim, laser_2d.grid, k0=2 * scc.pi / 0.6e-6) -print(Phi2_3d) +Phi2_3d,phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid) +Phi2_2d,phi2_2d = get_Phi2(laser_2d.dim, laser_2d.grid) +Zeta,nu = get_Zeta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) np.testing.assert_approx_equal(Phi2_3d, 2.4e-24, significant=2) +np.testing.assert_approx_equal(Phi2_2d, 2.4e-24, significant=2) +np.testing.assert_approx_equal(Zeta[1], 2.4e-24, significant=2) #np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) #np.testing.assert_approx_equal(STC_3d["beta_y"], 3e-18, significant=2) #np.testing.assert_approx_equal(STC_3d["zeta_y"], 2.4e-24, significant=2) From 6a20671dbf90f94b8e6f414000f00f7b26ed08e9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:40:19 +0000 Subject: [PATCH 264/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index e9686249..1012e629 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -44,4 +44,3 @@ #np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) #np.testing.assert_approx_equal(STC_3d["beta_y"], 3e-18, significant=2) #np.testing.assert_approx_equal(STC_3d["zeta_y"], 2.4e-24, significant=2) - From 7041b433136b64e890b24e0f217aa3cab99623fc Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 14:41:27 +0100 Subject: [PATCH 265/362] typo --- tests/test_STC.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index e9686249..397fd729 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -3,7 +3,7 @@ from lasy.laser import Laser from lasy.profiles.gaussian_profile import STCGaussianProfile -from lasy.utils.laser_utils import get_Phi2, get_Zeta(dim, grid, k0) +from lasy.utils.laser_utils import get_Phi2, get_Zeta # Create profile. profile = STCGaussianProfile( From c6a36bfdb73cf9ebf50792578a3851c9fe064dc1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:42:04 +0000 Subject: [PATCH 266/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index a11dfa7a..2d289940 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -35,12 +35,12 @@ profile=profile, ) -Phi2_3d,phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid) -Phi2_2d,phi2_2d = get_Phi2(laser_2d.dim, laser_2d.grid) -Zeta,nu = get_Zeta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) +Phi2_3d, phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid) +Phi2_2d, phi2_2d = get_Phi2(laser_2d.dim, laser_2d.grid) +Zeta, nu = get_Zeta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) np.testing.assert_approx_equal(Phi2_3d, 2.4e-24, significant=2) np.testing.assert_approx_equal(Phi2_2d, 2.4e-24, significant=2) np.testing.assert_approx_equal(Zeta[1], 2.4e-24, significant=2) -#np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) -#np.testing.assert_approx_equal(STC_3d["beta_y"], 3e-18, significant=2) -#np.testing.assert_approx_equal(STC_3d["zeta_y"], 2.4e-24, significant=2) +# np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) +# np.testing.assert_approx_equal(STC_3d["beta_y"], 3e-18, significant=2) +# np.testing.assert_approx_equal(STC_3d["zeta_y"], 2.4e-24, significant=2) From 6ca62d5b6ac9cbd4f01d51d43f3d24b27d50a7e6 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 14:48:03 +0100 Subject: [PATCH 267/362] fix logic error for dim asser --- lasy/utils/laser_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index aa2e5479..fe47c980 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -931,7 +931,7 @@ def get_Phi2(dim, grid): def get_Zeta(dim, grid, k0): - assert dim == "rt", "No spatial chirp for axis-sysmetric dimension" + assert dim == "xyt", "No spatial chirp for axis-sysmetric dimension" w0 = get_w0(grid, dim) tau = 2 * get_duration(grid, dim) env_spec = grid.get_spectral_field() @@ -959,7 +959,7 @@ def get_Zeta(dim, grid, k0): def get_Beta(dim, grid, k0): - assert dim == "rt", "No angular chirp for axis-sysmetric dimension" + assert dim is "xyt", "No angular chirp for axis-sysmetric dimension" env_spec = grid.get_spectral_field() env_spec_abs2 = np.abs(env_spec**2) # Get the spectral axis @@ -980,7 +980,7 @@ def get_Beta(dim, grid, k0): def get_Pft(dim, grid): - assert dim == "rt", "No pulse front tilt for axis-sysmetric dimension" + assert dim == "xyt", "No pulse front tilt for axis-sysmetric dimension" env = grid.get_temporal_field() env_abs2 = np.abs(env**2) weight_xy_2d = np.mean(env_spec_abs2, axis=2) @@ -995,7 +995,7 @@ def get_Pft(dim, grid): def get_prop_angle(dim, grid, k0): - assert dim == "rt", "Propagation always on-axis axis-sysmetric dimension" + assert dim == "xyt", "Propagation always on-axis axis-sysmetric dimension" env = grid.get_temporal_field() env_abs2 = np.abs(env**2) phi_envelop_abs = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) From b061c132390fa8099bbeb73efde12f8c38d95dfd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:48:43 +0000 Subject: [PATCH 268/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- 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 fe47c980..79a58b97 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -959,7 +959,7 @@ def get_Zeta(dim, grid, k0): def get_Beta(dim, grid, k0): - assert dim is "xyt", "No angular chirp for axis-sysmetric dimension" + assert dim == "xyt", "No angular chirp for axis-sysmetric dimension" env_spec = grid.get_spectral_field() env_spec_abs2 = np.abs(env_spec**2) # Get the spectral axis From 8ad2a35f894473f2a6bd4bc68294f0e5f072b3fb Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 15:20:15 +0100 Subject: [PATCH 269/362] check zeta_y --- lasy/utils/laser_utils.py | 6 +++--- tests/test_STC.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index fe47c980..6311ae68 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -983,9 +983,9 @@ def get_Pft(dim, grid): assert dim == "xyt", "No pulse front tilt for axis-sysmetric dimension" env = grid.get_temporal_field() env_abs2 = np.abs(env**2) - weight_xy_2d = np.mean(env_spec_abs2, axis=2) + weight_xy_2d = np.mean(env_abs2, axis=2) z_centroids = np.sum(grid.axes[2] * env_abs2, axis=2) / np.sum( - env_spec_abs2, axis=2 + env_abs2, axis=2 ) derivative_x_pft = np.gradient(z_centroids, axis=0) / grid.dx[0] derivative_y_pft = np.gradient(z_centroids, axis=1) / grid.dx[1] @@ -994,7 +994,7 @@ def get_Pft(dim, grid): return [pft_x, pft_y] -def get_prop_angle(dim, grid, k0): +def get_Prop_angle(dim, grid, k0): assert dim == "xyt", "Propagation always on-axis axis-sysmetric dimension" env = grid.get_temporal_field() env_abs2 = np.abs(env**2) diff --git a/tests/test_STC.py b/tests/test_STC.py index 2d289940..4ece787d 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -37,10 +37,10 @@ Phi2_3d, phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid) Phi2_2d, phi2_2d = get_Phi2(laser_2d.dim, laser_2d.grid) -Zeta, nu = get_Zeta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) +[zeta_x, zeta_y], [nu_x, nu_y] = get_Zeta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) np.testing.assert_approx_equal(Phi2_3d, 2.4e-24, significant=2) np.testing.assert_approx_equal(Phi2_2d, 2.4e-24, significant=2) -np.testing.assert_approx_equal(Zeta[1], 2.4e-24, significant=2) +np.testing.assert_approx_equal(zeta_y, 2.4e-24, significant=2) # np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) # np.testing.assert_approx_equal(STC_3d["beta_y"], 3e-18, significant=2) -# np.testing.assert_approx_equal(STC_3d["zeta_y"], 2.4e-24, significant=2) +# np.testing.assert_approx_equal(STC_3d["zeta_y"], 2.4e-24, significant=2) \ No newline at end of file From d8922a586475531934031dc1bfbcdf0b3cfe7cbf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 14:20:56 +0000 Subject: [PATCH 270/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 4 +--- tests/test_STC.py | 6 ++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index f271b595..7d6b90c2 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -984,9 +984,7 @@ def get_Pft(dim, grid): env = grid.get_temporal_field() env_abs2 = np.abs(env**2) weight_xy_2d = np.mean(env_abs2, axis=2) - z_centroids = np.sum(grid.axes[2] * env_abs2, axis=2) / np.sum( - env_abs2, axis=2 - ) + z_centroids = np.sum(grid.axes[2] * env_abs2, axis=2) / np.sum(env_abs2, axis=2) derivative_x_pft = np.gradient(z_centroids, axis=0) / grid.dx[0] derivative_y_pft = np.gradient(z_centroids, axis=1) / grid.dx[1] pft_x = np.average(derivative_x_pft, weights=weight_xy_2d) diff --git a/tests/test_STC.py b/tests/test_STC.py index 4ece787d..d338c5e0 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -37,10 +37,12 @@ Phi2_3d, phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid) Phi2_2d, phi2_2d = get_Phi2(laser_2d.dim, laser_2d.grid) -[zeta_x, zeta_y], [nu_x, nu_y] = get_Zeta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) +[zeta_x, zeta_y], [nu_x, nu_y] = get_Zeta( + laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6 +) np.testing.assert_approx_equal(Phi2_3d, 2.4e-24, significant=2) np.testing.assert_approx_equal(Phi2_2d, 2.4e-24, significant=2) np.testing.assert_approx_equal(zeta_y, 2.4e-24, significant=2) # np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) # np.testing.assert_approx_equal(STC_3d["beta_y"], 3e-18, significant=2) -# np.testing.assert_approx_equal(STC_3d["zeta_y"], 2.4e-24, significant=2) \ No newline at end of file +# np.testing.assert_approx_equal(STC_3d["zeta_y"], 2.4e-24, significant=2) From cbfd1cd010919e8e324e29603a98b5164fcf7dd3 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 15:52:28 +0100 Subject: [PATCH 271/362] typoo in test_STC --- lasy/utils/laser_utils.py | 23 ++++++++++++++++++++++- tests/test_STC.py | 4 ++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index f271b595..546024bb 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -918,6 +918,28 @@ def get_w0(grid, dim): def get_Phi2(dim, grid): + r""" + Calculate the Group-delay dispersion of the laser. + + Parameters + ---------- + dim : string + Dimensionality of the array. Options are: + - 'xyt': The laser pulse is represented on a 3D grid: + Cartesian (x,y) transversely, and temporal (t) longitudinally. + - 'rt' : The laser pulse is represented on a 2D grid: + Cylindrical (r) transversely, and temporal (t) longitudinally. + + grid : a Grid object. + It contains an ndarray (V/m) with + the value of the envelope field and the associated metadata + that defines the points at which the laser is defined. + + Return + ---------- + Phi2: Group-delayed dispersion in :math:`\Phi^{(2)}=d(\omega_0)/dt` + phi2: Group-delayed dispersion in :math:`\phi^{(2)}=dt_0/d(\omega)` + """ tau = 2 * get_duration(grid, dim) env = grid.get_temporal_field() env_abs = np.abs(env**2) @@ -936,7 +958,6 @@ def get_Zeta(dim, grid, k0): tau = 2 * get_duration(grid, dim) env_spec = grid.get_spectral_field() env_spec_abs2 = np.abs(env_spec**2) - # Get the spectral axis dt = grid.dx[-1] Nt = grid.shape[-1] diff --git a/tests/test_STC.py b/tests/test_STC.py index 4ece787d..92443dfe 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -38,8 +38,8 @@ Phi2_3d, phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid) Phi2_2d, phi2_2d = get_Phi2(laser_2d.dim, laser_2d.grid) [zeta_x, zeta_y], [nu_x, nu_y] = get_Zeta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) -np.testing.assert_approx_equal(Phi2_3d, 2.4e-24, significant=2) -np.testing.assert_approx_equal(Phi2_2d, 2.4e-24, significant=2) +np.testing.assert_approx_equal(phi2_3d, 2.4e-24, significant=2) +np.testing.assert_approx_equal(phi2_2d, 2.4e-24, significant=2) np.testing.assert_approx_equal(zeta_y, 2.4e-24, significant=2) # np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) # np.testing.assert_approx_equal(STC_3d["beta_y"], 3e-18, significant=2) From 0ec4bbabd9639c4805703a91324211ed8665c473 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 14:53:25 +0000 Subject: [PATCH 272/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index efe355e8..0e3ec7b1 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -37,7 +37,9 @@ Phi2_3d, phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid) Phi2_2d, phi2_2d = get_Phi2(laser_2d.dim, laser_2d.grid) -[zeta_x, zeta_y], [nu_x, nu_y] = get_Zeta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) +[zeta_x, zeta_y], [nu_x, nu_y] = get_Zeta( + laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6 +) np.testing.assert_approx_equal(phi2_3d, 2.4e-24, significant=2) np.testing.assert_approx_equal(phi2_2d, 2.4e-24, significant=2) From 901a851324e5fceb7ef7838d866f9030fe619c58 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 16:03:06 +0100 Subject: [PATCH 273/362] check beta --- lasy/utils/laser_utils.py | 22 ++++++++++++++++++++++ tests/test_STC.py | 13 ++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 8f0774aa..9fc0597e 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -953,6 +953,28 @@ def get_Phi2(dim, grid): def get_Zeta(dim, grid, k0): + r""" + Calculate the Group-delay dispersion of the laser. + + Parameters + ---------- + dim : string + Dimensionality of the array. Options are: + - 'xyt': The laser pulse is represented on a 3D grid: + Cartesian (x,y) transversely, and temporal (t) longitudinally. + - 'rt' : The laser pulse is represented on a 2D grid: + Cylindrical (r) transversely, and temporal (t) longitudinally. + + grid : a Grid object. + It contains an ndarray (V/m) with + the value of the envelope field and the associated metadata + that defines the points at which the laser is defined. + + Return + ---------- + zeta_x, zeta_y: Spatio-chirp in :math:`\zeta=dx_0/d(\omega_0)` + nu_x, nu_y: Spatio-chirp in :math:`\nu=d(\omega_0)/dx` + """ assert dim == "xyt", "No spatial chirp for axis-sysmetric dimension" w0 = get_w0(grid, dim) tau = 2 * get_duration(grid, dim) diff --git a/tests/test_STC.py b/tests/test_STC.py index efe355e8..166e736a 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -3,7 +3,7 @@ from lasy.laser import Laser from lasy.profiles.gaussian_profile import STCGaussianProfile -from lasy.utils.laser_utils import get_Phi2, get_Zeta +from lasy.utils.laser_utils import get_Phi2, get_Zeta, get_Beta # Create profile. profile = STCGaussianProfile( @@ -13,7 +13,7 @@ w0=5e-6, # m tau=5e-14, # s t_peak=0.0, # s - beta=0, + beta=3e-18, zeta=2.4e-22, phi2=2.4e-24, stc_theta=scc.pi / 2, @@ -23,7 +23,7 @@ dim="xyt", lo=(-10e-6, -10e-6, -10e-14), hi=(10e-6, 10e-6, +10e-14), - npoints=(50, 60, 200), + npoints=(100, 100, 200), profile=profile, ) # Create laser with given profile in `rt` geometry. @@ -38,10 +38,9 @@ Phi2_3d, phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid) Phi2_2d, phi2_2d = get_Phi2(laser_2d.dim, laser_2d.grid) [zeta_x, zeta_y], [nu_x, nu_y] = get_Zeta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) +[beta_x, beta_y] = get_Beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) np.testing.assert_approx_equal(phi2_3d, 2.4e-24, significant=2) np.testing.assert_approx_equal(phi2_2d, 2.4e-24, significant=2) - -np.testing.assert_approx_equal(zeta_y, 2.4e-24, significant=2) -# np.testing.assert_approx_equal(STC_3d["phi2"], 2.4e-19, significant=2) -# np.testing.assert_approx_equal(STC_3d["beta_y"], 3e-18, significant=2) +np.testing.assert_approx_equal(zeta_y, 2.4e-22, significant=2) +np.testing.assert_approx_equal(beta_y, 3e-18, significant=2) # np.testing.assert_approx_equal(STC_3d["zeta_y"], 2.4e-24, significant=2) From b245c58107842d687a2e6762477cfe7dca7c0942 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 15:04:03 +0000 Subject: [PATCH 274/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 946ca423..e6e89305 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -3,7 +3,7 @@ from lasy.laser import Laser from lasy.profiles.gaussian_profile import STCGaussianProfile -from lasy.utils.laser_utils import get_Phi2, get_Zeta, get_Beta +from lasy.utils.laser_utils import get_Beta, get_Phi2, get_Zeta # Create profile. profile = STCGaussianProfile( @@ -38,8 +38,10 @@ Phi2_3d, phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid) Phi2_2d, phi2_2d = get_Phi2(laser_2d.dim, laser_2d.grid) -[zeta_x, zeta_y], [nu_x, nu_y] = get_Zeta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) -[beta_x, beta_y] = get_Beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) +[zeta_x, zeta_y], [nu_x, nu_y] = get_Zeta( + laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6 +) +[beta_x, beta_y] = get_Beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) np.testing.assert_approx_equal(phi2_3d, 2.4e-24, significant=2) np.testing.assert_approx_equal(phi2_2d, 2.4e-24, significant=2) From 93d14e559e78d8f7e7935ff5759ec0467cd5891f Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:09:04 +0100 Subject: [PATCH 275/362] Update combined_profile.py --- lasy/profiles/combined_profile.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lasy/profiles/combined_profile.py b/lasy/profiles/combined_profile.py index 8ffcca51..ababc196 100644 --- a/lasy/profiles/combined_profile.py +++ b/lasy/profiles/combined_profile.py @@ -68,7 +68,5 @@ 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) return envelope From d464e58ddf240e1df3e92393529a00ab991613ff Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 16:09:25 +0100 Subject: [PATCH 276/362] add description on the functions --- lasy/utils/laser_utils.py | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 9fc0597e..489e56ef 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -942,19 +942,19 @@ def get_Phi2(dim, grid): """ tau = 2 * get_duration(grid, dim) env = grid.get_temporal_field() - env_abs = np.abs(env**2) + env_abs2 = np.abs(env**2) # Calculate group-delayed dispersion phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) - Phi2 = np.average(pphi_pt2, weights=env_abs) + Phi2 = np.average(pphi_pt2, weights=env_abs2) phi2 = np.max(np.roots([4 * Phi2, -4, tau**4 * Phi2])) return Phi2, phi2 def get_Zeta(dim, grid, k0): r""" - Calculate the Group-delay dispersion of the laser. + Calculate the spatio-chirp of the laser. Parameters ---------- @@ -1002,6 +1002,27 @@ def get_Zeta(dim, grid, k0): def get_Beta(dim, grid, k0): + r""" + Calculate the angular dispersion of the laser. + + Parameters + ---------- + dim : string + Dimensionality of the array. Options are: + - 'xyt': The laser pulse is represented on a 3D grid: + Cartesian (x,y) transversely, and temporal (t) longitudinally. + - 'rt' : The laser pulse is represented on a 2D grid: + Cylindrical (r) transversely, and temporal (t) longitudinally. + + grid : a Grid object. + It contains an ndarray (V/m) with + the value of the envelope field and the associated metadata + that defines the points at which the laser is defined. + + Return + ---------- + beta_x, beta_y: Angular dispersion in :math:` \beta = d\theta_0/d\omega` + """ assert dim == "xyt", "No angular chirp for axis-sysmetric dimension" env_spec = grid.get_spectral_field() env_spec_abs2 = np.abs(env_spec**2) @@ -1040,8 +1061,10 @@ def get_Prop_angle(dim, grid, k0): env = grid.get_temporal_field() env_abs2 = np.abs(env**2) phi_envelop_abs = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) - angle_x = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) / k0 - angle_y = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) / k0 + pphi_px = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) + pphi_py = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) + angle_x=np.average(pphi_px , weights=env_abs2) / k0 + angle_y=np.average(pphi_py , weights=env_abs2) / k0 return [angle_x, angle_y] From d6fa08ce449b0f51fc29de52d00989c3068f624d Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 16:17:07 +0100 Subject: [PATCH 277/362] finalising everthing --- lasy/utils/laser_utils.py | 144 +++++++++----------------------------- tests/test_STC.py | 1 - 2 files changed, 32 insertions(+), 113 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 489e56ef..ab2cfc12 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1044,6 +1044,27 @@ def get_Beta(dim, grid, k0): def get_Pft(dim, grid): + r""" + Calculate the pulse-front-tilt dispersion of the laser. + + Parameters + ---------- + dim : string + Dimensionality of the array. Options are: + - 'xyt': The laser pulse is represented on a 3D grid: + Cartesian (x,y) transversely, and temporal (t) longitudinally. + - 'rt' : The laser pulse is represented on a 2D grid: + Cylindrical (r) transversely, and temporal (t) longitudinally. + + grid : a Grid object. + It contains an ndarray (V/m) with + the value of the envelope field and the associated metadata + that defines the points at which the laser is defined. + + Return + ---------- + pft_x, pft_y: Pulse front tilt in :math:` p=dt/dx` + """ assert dim == "xyt", "No pulse front tilt for axis-sysmetric dimension" env = grid.get_temporal_field() env_abs2 = np.abs(env**2) @@ -1057,20 +1078,8 @@ def get_Pft(dim, grid): def get_Prop_angle(dim, grid, k0): - assert dim == "xyt", "Propagation always on-axis axis-sysmetric dimension" - env = grid.get_temporal_field() - env_abs2 = np.abs(env**2) - phi_envelop_abs = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) - pphi_px = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) - pphi_py = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) - angle_x=np.average(pphi_px , weights=env_abs2) / k0 - angle_y=np.average(pphi_py , weights=env_abs2) / k0 - return [angle_x, angle_y] - - -def get_STC(dim, grid, k0): r""" - Calculate the spatio-temporal coupling factors of the laser. + Calculate the propagating angle of the laser. Parameters ---------- @@ -1086,105 +1095,16 @@ def get_STC(dim, grid, k0): the value of the envelope field and the associated metadata that defines the points at which the laser is defined. - k0 : scalar - Wavenumber of the field - - Return + Return ---------- - STC_fac : dict of floats - A dictionary of floats corresponding to the STC factors. The keys are: - Phi2: Group-delayed dispersion in :math:`\Phi^{(2)}=d(\omega_0)/dt` - phi2: Group-delayed dispersion in :math:`\phi^{(2)}=dt_0/d(\omega)` - nu_x, nu_y: Spatio-chirp in :math:`\nu=d(\omega_0)/dx` - zeta_x, zeta_y: Spatio-chirp in :math:`\zeta=dx_0/d(\omega_0)` - beta_x, beta_y: Angular dispersion in :math:` \beta = d\theta_0/d\omega`(Important note: - for now beta is only correct when zeta and phi2 are 0!) - pft_x, pft_y: Pulse front tilt in :math:` p=dt/dx` - All those above units and definitions are taken from - `S. Akturk et al., Optics Express 12, 4399 (2004) `__. + angle_x, angle_y: propagating angle in :math:` p=k_x or k_y/kz` """ - tau = 2 * get_duration(grid, dim) - w0 = get_w0(grid, dim) - - # Initialise the returned dictionary - STC_fac = { - "Phi2": 0, - "phi2": 0, - "nu_x": 0, - "nu_y": 0, - "zeta_x": 0, - "zeta_y": 0, - "beta_x": 0, - "beta_y": 0, - "pft_x": 0, - "pft_y": 0, - } - - # Get temporal and spectral field + assert dim == "xyt", "Propagation always on-axis axis-sysmetric dimension" env = grid.get_temporal_field() - env_abs = np.abs(env**2) - env_spec = grid.get_spectral_field() - env_spec_abs = np.abs(env_spec**2) - - # Get the spectral axis - dt = grid.dx[-1] - Nt = grid.shape[-1] - omega = 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0 * c - # Calculate group-delayed dispersion - phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) - pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) - pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) - STC_fac["Phi2"] = np.average(pphi_pt2, weights=env_abs) - STC_fac["phi2"] = np.max( - np.roots([4 * STC_fac["Phi2"], -4, tau**4 * STC_fac["Phi2"]]) - ) - # No spatial chirp and angular chirp in 'rt' coordinate - if dim == "rt": - return STC_fac - # Calculate spatio- and angular dispersion - if dim == "xyt": - # Calculate dx0 and dy0 in (x,y,omega) space - weight_x_3d = np.transpose(env_spec_abs, (2, 1, 0)) - weight_y_3d = np.transpose(env_spec_abs, (2, 0, 1)) - xda = np.sum(grid.axes[0] * weight_x_3d, axis=2) / np.sum(weight_x_3d, axis=2) - yda = np.sum(grid.axes[1] * weight_y_3d, axis=2) / np.sum(weight_y_3d, axis=2) - - # Calculate spatial chirp zeta - derivative_x_zeta = np.gradient(xda, omega, axis=0) - derivative_y_zeta = np.gradient(yda, omega, axis=0) - weight_x_2d = np.mean(env_spec_abs, axis=0) - weight_y_2d = np.mean(env_spec_abs, axis=1) - zeta_x = np.average(derivative_x_zeta.T, weights=weight_x_2d) - zeta_y = np.average(derivative_y_zeta.T, weights=weight_y_2d) - STC_fac["zeta_x"] = zeta_x - STC_fac["zeta_y"] = zeta_y - STC_fac["nu_x"] = ( - 4 * STC_fac["zeta_x"] / (w0**2 * tau**2 + 4 * STC_fac["zeta_x"] ** 2) - ) - STC_fac["nu_y"] = ( - 4 * STC_fac["zeta_y"] / (w0**2 * tau**2 + 4 * STC_fac["zeta_y"] ** 2) - ) - - # Calculate angular dispersion beta - phi_envelop_abs = np.unwrap( - np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=2 - ) - angle_x = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) / k0 - angle_y = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) / k0 - derivative_x_beta = np.gradient(angle_y, omega, axis=2) - derivative_y_beta = np.gradient(angle_x, omega, axis=2) - beta_x = np.average(derivative_x_beta, weights=env_spec_abs) - beta_y = np.average(derivative_y_beta, weights=env_spec_abs) - STC_fac["beta_x"] = beta_x - STC_fac["beta_y"] = beta_y - # Calculate pulse front tilt - weight_xy_2d = np.mean(env_abs, axis=2) - z_centroids = np.sum(grid.axes[2] * env_abs, axis=2) / np.sum(env_abs, axis=2) - derivative_x_pft = np.gradient(z_centroids, axis=0) / grid.dx[0] - derivative_y_pft = np.gradient(z_centroids, axis=1) / grid.dx[1] - pft_x = np.average(derivative_x_pft, weights=weight_xy_2d) - pft_y = np.average(derivative_y_pft, weights=weight_xy_2d) - STC_fac["pft_x"] = pft_x - STC_fac["pft_y"] = pft_y - - return STC_fac + env_abs2 = np.abs(env**2) + phi_envelop_abs = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) + pphi_px = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) + pphi_py = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) + angle_x=np.average(pphi_px , weights=env_abs2) / k0 + angle_y=np.average(pphi_py , weights=env_abs2) / k0 + return [angle_x, angle_y] \ No newline at end of file diff --git a/tests/test_STC.py b/tests/test_STC.py index e6e89305..95bceff0 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -47,4 +47,3 @@ np.testing.assert_approx_equal(phi2_2d, 2.4e-24, significant=2) np.testing.assert_approx_equal(zeta_y, 2.4e-22, significant=2) np.testing.assert_approx_equal(beta_y, 3e-18, significant=2) -# np.testing.assert_approx_equal(STC_3d["zeta_y"], 2.4e-24, significant=2) From 7a87ac10ae5a21b907fa71cb04d51c6808ff2d70 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 15:17:31 +0000 Subject: [PATCH 278/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index ab2cfc12..960ea7db 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1063,7 +1063,7 @@ def get_Pft(dim, grid): Return ---------- - pft_x, pft_y: Pulse front tilt in :math:` p=dt/dx` + pft_x, pft_y: Pulse front tilt in :math:` p=dt/dx` """ assert dim == "xyt", "No pulse front tilt for axis-sysmetric dimension" env = grid.get_temporal_field() @@ -1097,7 +1097,7 @@ def get_Prop_angle(dim, grid, k0): Return ---------- - angle_x, angle_y: propagating angle in :math:` p=k_x or k_y/kz` + angle_x, angle_y: propagating angle in :math:` p=k_x or k_y/kz` """ assert dim == "xyt", "Propagation always on-axis axis-sysmetric dimension" env = grid.get_temporal_field() @@ -1105,6 +1105,6 @@ def get_Prop_angle(dim, grid, k0): phi_envelop_abs = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_px = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) pphi_py = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) - angle_x=np.average(pphi_px , weights=env_abs2) / k0 - angle_y=np.average(pphi_py , weights=env_abs2) / k0 - return [angle_x, angle_y] \ No newline at end of file + angle_x = np.average(pphi_px, weights=env_abs2) / k0 + angle_y = np.average(pphi_py, weights=env_abs2) / k0 + return [angle_x, angle_y] From 20af8ed0ff81fa978528baea093509b16a41f3be Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 16:20:22 +0100 Subject: [PATCH 279/362] update the units --- lasy/utils/laser_utils.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index ab2cfc12..121b1c75 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -937,8 +937,8 @@ def get_Phi2(dim, grid): Return ---------- - Phi2: Group-delayed dispersion in :math:`\Phi^{(2)}=d(\omega_0)/dt` - phi2: Group-delayed dispersion in :math:`\phi^{(2)}=dt_0/d(\omega)` + Phi2: Group-delayed dispersion in :math:`\Phi^{(2)}=d(\omega_0)/dt` (second^-2) + phi2: Group-delayed dispersion in :math:`\phi^{(2)}=dt_0/d(\omega)` (second^2) """ tau = 2 * get_duration(grid, dim) env = grid.get_temporal_field() @@ -972,8 +972,8 @@ def get_Zeta(dim, grid, k0): Return ---------- - zeta_x, zeta_y: Spatio-chirp in :math:`\zeta=dx_0/d(\omega_0)` - nu_x, nu_y: Spatio-chirp in :math:`\nu=d(\omega_0)/dx` + zeta_x, zeta_y: Spatio-chirp in :math:`\zeta=dx_0/d(\omega_0)` (meter * second) + nu_x, nu_y: Spatio-chirp in :math:`\nu=d(\omega_0)/dx` (meter^-1 * second^-1) """ assert dim == "xyt", "No spatial chirp for axis-sysmetric dimension" w0 = get_w0(grid, dim) @@ -1021,7 +1021,7 @@ def get_Beta(dim, grid, k0): Return ---------- - beta_x, beta_y: Angular dispersion in :math:` \beta = d\theta_0/d\omega` + beta_x, beta_y: Angular dispersion in :math:` \beta = d\theta_0/d\omega` (second) """ assert dim == "xyt", "No angular chirp for axis-sysmetric dimension" env_spec = grid.get_spectral_field() @@ -1063,7 +1063,7 @@ def get_Pft(dim, grid): Return ---------- - pft_x, pft_y: Pulse front tilt in :math:` p=dt/dx` + pft_x, pft_y: Pulse front tilt in :math:` p=dt/dx` (second * meter^-1) """ assert dim == "xyt", "No pulse front tilt for axis-sysmetric dimension" env = grid.get_temporal_field() @@ -1097,7 +1097,7 @@ def get_Prop_angle(dim, grid, k0): Return ---------- - angle_x, angle_y: propagating angle in :math:` p=k_x or k_y/kz` + angle_x, angle_y: propagating angle in :math:` p=k_x or k_y/kz` (rad) """ assert dim == "xyt", "Propagation always on-axis axis-sysmetric dimension" env = grid.get_temporal_field() From 2709d611c76219916c46b971a42ce522d508a44a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 15:21:39 +0000 Subject: [PATCH 280/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/utils/laser_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 742d4cc4..ad59be68 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1097,11 +1097,11 @@ def get_Prop_angle(dim, grid, k0): Return ---------- -<<<<<<< HEAD - angle_x, angle_y: propagating angle in :math:` p=k_x or k_y/kz` (rad) -======= + <<<<<<< HEAD + angle_x, angle_y: propagating angle in :math:` p=k_x or k_y/kz` (rad) + ======= angle_x, angle_y: propagating angle in :math:` p=k_x or k_y/kz` ->>>>>>> refs/remotes/huixingjian/add_diag_util + >>>>>>> refs/remotes/huixingjian/add_diag_util """ assert dim == "xyt", "Propagation always on-axis axis-sysmetric dimension" env = grid.get_temporal_field() From 391aea13e66234254f89dbd373da3e376a513e92 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 16:23:57 +0100 Subject: [PATCH 281/362] update the description to the STC profile class --- lasy/profiles/gaussian_profile.py | 119 ++++++++++++++++++++++-------- 1 file changed, 88 insertions(+), 31 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index d005916b..230ef559 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -65,36 +65,6 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): z_foc : float (in meter), optional Position of the focal plane. (The laser pulse is initialized at `z=0`.) - beta : float (in second), optional - The angular dispersion parameterized by: - - .. math:: - - \beta = \frac{d\theta_0}{d\omega} - - Here :math:`\theta_0` is the propagation angle of this component. - The definitions of beta, phi2 and zeta are taken from [S. Akturk et al., Optics Express 12, 4399 (2004)]. - - phi2 : float (in second^2), optional (default '0') - The group-delay dispersion parameterized by: - - .. math:: - - \phi^{(2)} = \frac{dt}{d\omega} - - zeta : float (in meter * second) optional (default '0') - The spatio-chirp parameterized by: - - .. math:: - - \zeta = \frac{dx_0}{d\omega} - - Here :math:`x_0` is the beam center position. - - stc_theta : float (in rad) optional (default '0') - Transverse direction along which spatio-temporal field couples. - 0 is along x axis. - Examples -------- >>> import matplotlib.pyplot as plt @@ -163,7 +133,94 @@ def __init__( class STCGaussianProfile(Profile): - r""" """ + r""" + Class for the analytic profile of a Gaussian 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})^2}{\tau^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 + :math:`\boldsymbol{x}_\perp` is the transverse coordinate (orthogonal + to the propagation direction). + The other parameters in this formula are defined below. + This profile also supports some chirp parameters that are omitted in the expression above for clarity. + + 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. + + w0 : float (in meter) + The waist of the laser pulse, i.e. :math:`w_0` in the above formula. + + 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. + + 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 Envelope 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) + + z_foc : float (in meter), optional + Position of the focal plane. (The laser pulse is initialized at `z=0`.) + + beta : float (in second), optional (default '0') + The angular dispersion parameterized by: + + .. math:: + + \beta = \frac{d\theta_0}{d\omega} + + Here :math:`\theta_0` is the propagation angle of this component. + The definitions of beta, phi2 and zeta are taken from [S. Akturk et al., Optics Express 12, 4399 (2004)]. + + phi2 : float (in second^2), optional (default '0') + The group-delay dispersion parameterized by: + + .. math:: + + \phi^{(2)} = \frac{dt}{d\omega} + + zeta : float (in meter * second) optional (default '0') + The spatio-chirp parameterized by: + + .. math:: + + \zeta = \frac{dx_0}{d\omega} + + Here :math:`x_0` is the beam center position. + + stc_theta : float (in rad) optional (default '0') + Transverse direction along which spatio-temporal field couples. + 0 is along x axis. + """ def __init__( self, From b5fd9f999af6dfeda8494519696a29e5c189d605 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 16:27:10 +0100 Subject: [PATCH 282/362] update formating issue --- lasy/utils/laser_utils.py | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index ad59be68..69a0750e 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -889,9 +889,7 @@ def get_w0(grid, dim): Cylindrical (r) transversely, and temporal (t) longitudinally. grid : a Grid object. - It contains an ndarray (V/m) with - the value of the envelope field and the associated metadata - that defines the points at which the laser is defined. + It contains an ndarray (V/m) with the value of the envelope field and the associated metadata that defines the points at which the laser is defined. Return ---------- @@ -931,9 +929,7 @@ def get_Phi2(dim, grid): Cylindrical (r) transversely, and temporal (t) longitudinally. grid : a Grid object. - It contains an ndarray (V/m) with - the value of the envelope field and the associated metadata - that defines the points at which the laser is defined. + It contains an ndarray (V/m) with the value of the envelope field and the associated metadata that defines the points at which the laser is defined. Return ---------- @@ -966,9 +962,7 @@ def get_Zeta(dim, grid, k0): Cylindrical (r) transversely, and temporal (t) longitudinally. grid : a Grid object. - It contains an ndarray (V/m) with - the value of the envelope field and the associated metadata - that defines the points at which the laser is defined. + It contains an ndarray (V/m) with the value of the envelope field and the associated metadata that defines the points at which the laser is defined. Return ---------- @@ -1016,8 +1010,7 @@ def get_Beta(dim, grid, k0): grid : a Grid object. It contains an ndarray (V/m) with - the value of the envelope field and the associated metadata - that defines the points at which the laser is defined. + the value of the envelope field and the associated metadata that defines the points at which the laser is defined. Return ---------- @@ -1091,17 +1084,11 @@ def get_Prop_angle(dim, grid, k0): Cylindrical (r) transversely, and temporal (t) longitudinally. grid : a Grid object. - It contains an ndarray (V/m) with - the value of the envelope field and the associated metadata - that defines the points at which the laser is defined. + It contains an ndarray (V/m) with the value of the envelope field and the associated metadata that defines the points at which the laser is defined. Return ---------- - <<<<<<< HEAD angle_x, angle_y: propagating angle in :math:` p=k_x or k_y/kz` (rad) - ======= - angle_x, angle_y: propagating angle in :math:` p=k_x or k_y/kz` - >>>>>>> refs/remotes/huixingjian/add_diag_util """ assert dim == "xyt", "Propagation always on-axis axis-sysmetric dimension" env = grid.get_temporal_field() From 008edbee6e274c16b7055eab7e4c19b38c04d797 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 16:31:34 +0100 Subject: [PATCH 283/362] style consistency in test_STC file --- tests/test_STC.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 95bceff0..d2eab177 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -13,10 +13,10 @@ w0=5e-6, # m tau=5e-14, # s t_peak=0.0, # s - beta=3e-18, - zeta=2.4e-22, - phi2=2.4e-24, - stc_theta=scc.pi / 2, + beta=3e-18, # s + zeta=2.4e-22, # m * s + phi2=2.4e-24, # s ^ 2 + stc_theta=scc.pi / 2, # rad ) # Create laser with given profile in `xyt` geometry. laser_3d = Laser( From a53de8b4802e2a654984ffc41165b990aa38703a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 15:32:21 +0000 Subject: [PATCH 284/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index d2eab177..eaf43a14 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -16,7 +16,7 @@ beta=3e-18, # s zeta=2.4e-22, # m * s phi2=2.4e-24, # s ^ 2 - stc_theta=scc.pi / 2, # rad + stc_theta=scc.pi / 2, # rad ) # Create laser with given profile in `xyt` geometry. laser_3d = Laser( From 62b1dc2caff41ec02562d7ecedcd1c443b313fa0 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 17:50:53 +0100 Subject: [PATCH 285/362] format alignment --- lasy/profiles/gaussian_profile.py | 2 +- tests/test_STC.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 230ef559..f4f73ce3 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -306,7 +306,7 @@ def evaluate(self, x, y, t): # Get the profile envelope = ( np.exp( - -stc_exponent + - stc_exponent + exp_argument + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) ) diff --git a/tests/test_STC.py b/tests/test_STC.py index d2eab177..c37d061f 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -38,7 +38,7 @@ Phi2_3d, phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid) Phi2_2d, phi2_2d = get_Phi2(laser_2d.dim, laser_2d.grid) -[zeta_x, zeta_y], [nu_x, nu_y] = get_Zeta( +[zeta_x, zeta_y] = get_Zeta( laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6 ) [beta_x, beta_y] = get_Beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) From 8512dce99dbd46e15a2ecdfccaa1a0f0ce80ace2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:51:17 +0000 Subject: [PATCH 286/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 2 +- tests/test_STC.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index f4f73ce3..230ef559 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -306,7 +306,7 @@ def evaluate(self, x, y, t): # Get the profile envelope = ( np.exp( - - stc_exponent + -stc_exponent + exp_argument + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) ) diff --git a/tests/test_STC.py b/tests/test_STC.py index 114a878e..5ce19608 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -38,9 +38,7 @@ Phi2_3d, phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid) Phi2_2d, phi2_2d = get_Phi2(laser_2d.dim, laser_2d.grid) -[zeta_x, zeta_y] = get_Zeta( - laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6 -) +[zeta_x, zeta_y] = get_Zeta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) [beta_x, beta_y] = get_Beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) np.testing.assert_approx_equal(phi2_3d, 2.4e-24, significant=2) From bb9e06c9bf868fb3701e901a4a9d9825286ad55c Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 17:52:47 +0100 Subject: [PATCH 287/362] add comment on STCGAUSIAN --- lasy/profiles/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index f4f73ce3..121072ee 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -134,7 +134,7 @@ def __init__( class STCGaussianProfile(Profile): r""" - Class for the analytic profile of a Gaussian laser pulse. + Class for the analytic profile of a Gaussian laser pulse with spatio-temporal coupling. More precisely, the electric field corresponds to: From 4c439d959ee5ae0a43a509a19ca33b3de1ced546 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 17:54:07 +0100 Subject: [PATCH 288/362] lignment --- lasy/profiles/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index b6dd471d..121072ee 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -306,7 +306,7 @@ def evaluate(self, x, y, t): # Get the profile envelope = ( np.exp( - -stc_exponent + - stc_exponent + exp_argument + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) ) From da20481d4a907ddf90a53ac140382b56fbec0a79 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:54:28 +0000 Subject: [PATCH 289/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 121072ee..b6dd471d 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -306,7 +306,7 @@ def evaluate(self, x, y, t): # Get the profile envelope = ( np.exp( - - stc_exponent + -stc_exponent + exp_argument + 1.0j * (self.cep_phase + self.omega0 * self.t_peak) ) From e957928b0f75838a3f9aef53c97f288be7cb05be Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 16 Dec 2024 19:05:40 +0100 Subject: [PATCH 290/362] z_foc fixed --- lasy/profiles/gaussian_profile.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 121072ee..2712f3ba 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -243,6 +243,7 @@ def __init__( self.tau = tau self.t_peak = t_peak self.cep_phase = cep_phase + self.z_foc = z_foc self.z_foc_over_zr = z_foc * wavelength / (np.pi * w0**2) self.phi2 = phi2 self.beta = beta @@ -269,17 +270,17 @@ def evaluate(self, x, y, t): """ inv_tau2 = self.tau ** (-2) inv_complex_waist_2 = 1.0 / ( - self.w0**2 * (1.0 + 2.0j * self.z_foc_over_zr / (self.k0 * self.w0**2)) + self.w0**2 * (1.0 + 2.0j * self.z_foc/ (self.k0 * self.w0**2)) ) stretch_factor = ( 1 + 4.0 - * (-self.zeta + self.beta * self.z_foc_over_zr) + * (-self.zeta + self.beta * self.z_foc) * inv_tau2 - * (-self.zeta + self.beta * self.z_foc_over_zr) + * (-self.zeta + self.beta * self.z_foc) * inv_complex_waist_2 + 2.0j - * (self.phi2 - self.beta**2 * self.k0 * self.z_foc_over_zr) + * (self.phi2 - self.beta**2 * self.k0 * self.z_foc) * inv_tau2 ) stc_exponent = ( @@ -294,7 +295,7 @@ def evaluate(self, x, y, t): * (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) + * (-self.zeta - self.beta * self.z_foc) * inv_complex_waist_2 ) ** 2 From 4a1b3162310239efe43587035a47f2bb9ead5db9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 18:06:14 +0000 Subject: [PATCH 291/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 975568d5..8f74de03 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -270,7 +270,7 @@ def evaluate(self, x, y, t): """ inv_tau2 = self.tau ** (-2) inv_complex_waist_2 = 1.0 / ( - self.w0**2 * (1.0 + 2.0j * self.z_foc/ (self.k0 * self.w0**2)) + self.w0**2 * (1.0 + 2.0j * self.z_foc / (self.k0 * self.w0**2)) ) stretch_factor = ( 1 @@ -279,9 +279,7 @@ def evaluate(self, x, y, t): * inv_tau2 * (-self.zeta + self.beta * self.z_foc) * inv_complex_waist_2 - + 2.0j - * (self.phi2 - self.beta**2 * self.k0 * self.z_foc) - * inv_tau2 + + 2.0j * (self.phi2 - self.beta**2 * self.k0 * self.z_foc) * inv_tau2 ) stc_exponent = ( 1.0 From 47af7b00b2e1e832685f872a60862d4299f860ad Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:32:06 +0100 Subject: [PATCH 292/362] Update test_STC.py --- tests/test_STC.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 5ce19608..f69bd034 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -38,8 +38,8 @@ Phi2_3d, phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid) Phi2_2d, phi2_2d = get_Phi2(laser_2d.dim, laser_2d.grid) -[zeta_x, zeta_y] = get_Zeta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) -[beta_x, beta_y] = get_Beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) +[, zeta_y], = get_Zeta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) +[, beta_y] = get_Beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) np.testing.assert_approx_equal(phi2_3d, 2.4e-24, significant=2) np.testing.assert_approx_equal(phi2_2d, 2.4e-24, significant=2) From de93eda7809d987b60f36113ed916b7b5250b7f0 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:33:41 +0100 Subject: [PATCH 293/362] Update test_STC.py --- tests/test_STC.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index f69bd034..7f5e91f0 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -38,8 +38,8 @@ Phi2_3d, phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid) Phi2_2d, phi2_2d = get_Phi2(laser_2d.dim, laser_2d.grid) -[, zeta_y], = get_Zeta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) -[, beta_y] = get_Beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) +[zeta_x, zeta_y],[nu_x, nu_y] = get_Zeta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) +[beta_x, beta_y] = get_Beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) np.testing.assert_approx_equal(phi2_3d, 2.4e-24, significant=2) np.testing.assert_approx_equal(phi2_2d, 2.4e-24, significant=2) From 5ed174c5763ac27efb0321338ed0233f31c65c53 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:33:49 +0000 Subject: [PATCH 294/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 7f5e91f0..eaf43a14 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -38,7 +38,9 @@ Phi2_3d, phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid) Phi2_2d, phi2_2d = get_Phi2(laser_2d.dim, laser_2d.grid) -[zeta_x, zeta_y],[nu_x, nu_y] = get_Zeta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) +[zeta_x, zeta_y], [nu_x, nu_y] = get_Zeta( + laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6 +) [beta_x, beta_y] = get_Beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) np.testing.assert_approx_equal(phi2_3d, 2.4e-24, significant=2) From e703483e6fcc9b717e60134f75ea45a8cf3e1423 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 17 Dec 2024 15:09:11 +0100 Subject: [PATCH 295/362] merge STC and Gaussian class --- lasy/profiles/gaussian_profile.py | 149 +++++++----------------------- 1 file changed, 32 insertions(+), 117 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 975568d5..8e53e77f 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -6,9 +6,9 @@ from .transverse import GaussianTransverseProfile -class GaussianProfile(CombinedLongitudinalTransverseProfile): +class GaussianProfile(Profile): r""" - Class for the analytic profile of a Gaussian laser pulse. + Class for the analytic profile of a Gaussian laser pulse with spatio-temporal coupling. More precisely, the electric field corresponds to: @@ -65,6 +65,36 @@ class GaussianProfile(CombinedLongitudinalTransverseProfile): z_foc : float (in meter), optional Position of the focal plane. (The laser pulse is initialized at `z=0`.) + beta : float (in second), optional (default '0') + The angular dispersion parameterized by: + + .. math:: + + \beta = \frac{d\theta_0}{d\omega} + + Here :math:`\theta_0` is the propagation angle of this component. + The definitions of beta, phi2 and zeta are taken from [S. Akturk et al., Optics Express 12, 4399 (2004)]. + + phi2 : float (in second^2), optional (default '0') + The group-delay dispersion parameterized by: + + .. math:: + + \phi^{(2)} = \frac{dt}{d\omega} + + zeta : float (in meter * second) optional (default '0') + The spatio-chirp parameterized by: + + .. math:: + + \zeta = \frac{dx_0}{d\omega} + + Here :math:`x_0` is the beam center position. + + stc_theta : float (in rad) optional (default '0') + Transverse direction along which spatio-temporal field couples. + 0 is along x axis. + Examples -------- >>> import matplotlib.pyplot as plt @@ -107,121 +137,6 @@ 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), - ) - - -class STCGaussianProfile(Profile): - r""" - Class for the analytic profile of a Gaussian laser pulse with spatio-temporal coupling. - - 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] - - where :math:`u` is either :math:`x` or :math:`y`, :math:`p_u` is - the polarization vector, :math:`Re` represent the real part, and - :math:`\boldsymbol{x}_\perp` is the transverse coordinate (orthogonal - to the propagation direction). - The other parameters in this formula are defined below. - This profile also supports some chirp parameters that are omitted in the expression above for clarity. - - 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. - - w0 : float (in meter) - The waist of the laser pulse, i.e. :math:`w_0` in the above formula. - - 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. - - 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 Envelope 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) - - z_foc : float (in meter), optional - Position of the focal plane. (The laser pulse is initialized at `z=0`.) - - beta : float (in second), optional (default '0') - The angular dispersion parameterized by: - - .. math:: - - \beta = \frac{d\theta_0}{d\omega} - - Here :math:`\theta_0` is the propagation angle of this component. - The definitions of beta, phi2 and zeta are taken from [S. Akturk et al., Optics Express 12, 4399 (2004)]. - - phi2 : float (in second^2), optional (default '0') - The group-delay dispersion parameterized by: - - .. math:: - - \phi^{(2)} = \frac{dt}{d\omega} - - zeta : float (in meter * second) optional (default '0') - The spatio-chirp parameterized by: - - .. math:: - - \zeta = \frac{dx_0}{d\omega} - - Here :math:`x_0` is the beam center position. - - stc_theta : float (in rad) optional (default '0') - Transverse direction along which spatio-temporal field couples. - 0 is along x axis. - """ - def __init__( self, wavelength, From 76f7f856a08eb18b4bf626f77c708ab2f8a7b520 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:11:07 +0100 Subject: [PATCH 296/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index a39e2aaf..19427757 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -8,7 +8,7 @@ class GaussianProfile(Profile): r""" - Class for the analytic profile of a Gaussian laser pulse with spatio-temporal coupling. + Class for the analytic profile of a Gaussian laser pulse. More precisely, the electric field corresponds to: From 0f90aa40372b4edcb49ee4f65ff9cef131035baa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:11:08 +0000 Subject: [PATCH 297/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 19427757..0cfdd98d 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -1,9 +1,6 @@ import numpy as np -from . import CombinedLongitudinalTransverseProfile -from .longitudinal import GaussianLongitudinalProfile from .profile import Profile -from .transverse import GaussianTransverseProfile class GaussianProfile(Profile): From 87759d919ed3ec99c3cbde5d6d6bb2bb6ea2191c Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:11:51 +0100 Subject: [PATCH 298/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 0cfdd98d..c2be2c9e 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -2,7 +2,6 @@ from .profile import Profile - class GaussianProfile(Profile): r""" Class for the analytic profile of a Gaussian laser pulse. From 7dc6a0a16f8920a70821c9c940d510eef91ac3ed Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:12:10 +0000 Subject: [PATCH 299/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index c2be2c9e..0cfdd98d 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -2,6 +2,7 @@ from .profile import Profile + class GaussianProfile(Profile): r""" Class for the analytic profile of a Gaussian laser pulse. From 3cc9a526aeda693ac6f4e6a8f4543dd283d4b36e Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:12:23 +0100 Subject: [PATCH 300/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 0cfdd98d..cf3c2536 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -19,8 +19,7 @@ class GaussianProfile(Profile): where :math:`u` is either :math:`x` or :math:`y`, :math:`p_u` is the polarization vector, :math:`Re` represent the real part, and :math:`\boldsymbol{x}_\perp` is the transverse coordinate (orthogonal - to the propagation direction). - The other parameters in this formula are defined below. + to the propagation direction). The other parameters in this formula are defined below. This profile also supports some chirp parameters that are omitted in the expression above for clarity. Parameters From 84f530e709af0727f9b50e40785f37cab01a61a4 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:13:06 +0100 Subject: [PATCH 301/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index cf3c2536..fe54c710 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -79,7 +79,7 @@ class GaussianProfile(Profile): \phi^{(2)} = \frac{dt}{d\omega} zeta : float (in meter * second) optional (default '0') - The spatio-chirp parameterized by: + The spatial chirp parameterized by: .. math:: From 4111779acc08dbf6c6503481f6270b86834d1b38 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:13:31 +0100 Subject: [PATCH 302/362] Update lasy/profiles/gaussian_profile.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- lasy/profiles/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index fe54c710..7b797e79 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -88,7 +88,7 @@ class GaussianProfile(Profile): Here :math:`x_0` is the beam center position. stc_theta : float (in rad) optional (default '0') - Transverse direction along which spatio-temporal field couples. + Transverse direction along which there are chirps and spatio-temporal couplings. 0 is along x axis. Examples From 85bd98b5f1d5ff8128ed6f401520b9f90db335f2 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:15:39 +0100 Subject: [PATCH 303/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 7b797e79..b4a95e13 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -19,7 +19,8 @@ class GaussianProfile(Profile): where :math:`u` is either :math:`x` or :math:`y`, :math:`p_u` is the polarization vector, :math:`Re` represent the real part, and :math:`\boldsymbol{x}_\perp` is the transverse coordinate (orthogonal - to the propagation direction). The other parameters in this formula are defined below. + to the propagation direction). The other parameters in this formula + are defined below. This profile also supports some chirp parameters that are omitted in the expression above for clarity. Parameters From 975f4e81874a46eed130199ed02b4e079df7198f Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:19:46 +0100 Subject: [PATCH 304/362] Update test_STC.py --- tests/test_STC.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index eaf43a14..0bfff585 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -2,11 +2,11 @@ import scipy.constants as scc from lasy.laser import Laser -from lasy.profiles.gaussian_profile import STCGaussianProfile +from lasy.profiles.gaussian_profile import GaussianProfile from lasy.utils.laser_utils import get_Beta, get_Phi2, get_Zeta # Create profile. -profile = STCGaussianProfile( +profile = GaussianProfile( wavelength=0.6e-6, # m pol=(1, 0), laser_energy=1.0, # J From 908bd807575315d0f5e1d69ff469d67e01863394 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:22:51 +0100 Subject: [PATCH 305/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 69a0750e..ff7b1055 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -915,7 +915,7 @@ def get_w0(grid, dim): return sigma -def get_Phi2(dim, grid): +def get_phi2(dim, grid): r""" Calculate the Group-delay dispersion of the laser. @@ -933,8 +933,8 @@ def get_Phi2(dim, grid): Return ---------- - Phi2: Group-delayed dispersion in :math:`\Phi^{(2)}=d(\omega_0)/dt` (second^-2) - phi2: Group-delayed dispersion in :math:`\phi^{(2)}=dt_0/d(\omega)` (second^2) + phi2: Group-delayed dispersion in :math:`\Phi^{(2)}=d(\omega_0)/dt` (second^-2) + varphi2: Group-delayed dispersion in :math:`\varphi^{(2)}=dt_0/d(\omega)` (second^2) """ tau = 2 * get_duration(grid, dim) env = grid.get_temporal_field() @@ -943,12 +943,12 @@ def get_Phi2(dim, grid): phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) - Phi2 = np.average(pphi_pt2, weights=env_abs2) - phi2 = np.max(np.roots([4 * Phi2, -4, tau**4 * Phi2])) - return Phi2, phi2 + phi2 = np.average(pphi_pt2, weights=env_abs2) + varphi2 = np.max(np.roots([4 * Phi2, -4, tau**4 * Phi2])) + return phi2, varphi2 -def get_Zeta(dim, grid, k0): +def get_zeta(dim, grid, k0): r""" Calculate the spatio-chirp of the laser. @@ -995,7 +995,7 @@ def get_Zeta(dim, grid, k0): return [zeta_x, zeta_y], [nu_x, nu_y] -def get_Beta(dim, grid, k0): +def get_beta(dim, grid, k0): r""" Calculate the angular dispersion of the laser. @@ -1036,7 +1036,7 @@ def get_Beta(dim, grid, k0): return [beta_x, beta_y] -def get_Pft(dim, grid): +def get_pft(dim, grid): r""" Calculate the pulse-front-tilt dispersion of the laser. @@ -1070,7 +1070,7 @@ def get_Pft(dim, grid): return [pft_x, pft_y] -def get_Prop_angle(dim, grid, k0): +def get_propation_angle(dim, grid, k0): r""" Calculate the propagating angle of the laser. From 2fa7b172af43b806c39d27f2ea8a89db378b0557 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:23:59 +0100 Subject: [PATCH 306/362] 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 ff7b1055..30c8deed 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -944,7 +944,7 @@ def get_phi2(dim, grid): pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) phi2 = np.average(pphi_pt2, weights=env_abs2) - varphi2 = np.max(np.roots([4 * Phi2, -4, tau**4 * Phi2])) + varphi2 = np.max(np.roots([4 * phi2, -4, tau**4 * phi2])) return phi2, varphi2 From 420d7c9b97402218a9214fe5117beefb3d88fc94 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:25:54 +0100 Subject: [PATCH 307/362] Update test_STC.py --- tests/test_STC.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 0bfff585..340bbf38 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -3,7 +3,7 @@ from lasy.laser import Laser from lasy.profiles.gaussian_profile import GaussianProfile -from lasy.utils.laser_utils import get_Beta, get_Phi2, get_Zeta +from lasy.utils.laser_utils import get_beta, get_phi2, get_zeta # Create profile. profile = GaussianProfile( From 1c7e5239d08ac2d23378dcf7a5771db3ddc35cb9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:26:02 +0000 Subject: [PATCH 308/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 340bbf38..fac667c9 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -3,7 +3,6 @@ from lasy.laser import Laser from lasy.profiles.gaussian_profile import GaussianProfile -from lasy.utils.laser_utils import get_beta, get_phi2, get_zeta # Create profile. profile = GaussianProfile( From d9b00e726d95330aa9dfcc6392be2cd9a55440ce Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:29:35 +0100 Subject: [PATCH 309/362] Update test_STC.py --- tests/test_STC.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index fac667c9..ae059520 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -34,13 +34,13 @@ profile=profile, ) -Phi2_3d, phi2_3d = get_Phi2(laser_3d.dim, laser_3d.grid) -Phi2_2d, phi2_2d = get_Phi2(laser_2d.dim, laser_2d.grid) +Phi2_3d, phi2_3d = get_phi2(laser_3d.dim, laser_3d.grid) +Phi2_2d, phi2_2d = get_phi2(laser_2d.dim, laser_2d.grid) -[zeta_x, zeta_y], [nu_x, nu_y] = get_Zeta( +[zeta_x, zeta_y], [nu_x, nu_y] = get_zeta( laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6 ) -[beta_x, beta_y] = get_Beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) +[beta_x, beta_y] = get_beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) np.testing.assert_approx_equal(phi2_3d, 2.4e-24, significant=2) np.testing.assert_approx_equal(phi2_2d, 2.4e-24, significant=2) From 204568a8202590d30b5e6af7e30863a94202407a Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:35:59 +0100 Subject: [PATCH 310/362] Update test_STC.py --- tests/test_STC.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index ae059520..9f82737d 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -3,7 +3,7 @@ from lasy.laser import Laser from lasy.profiles.gaussian_profile import GaussianProfile - +from lasy.utils.laser_utils import get_phi2, get_zeta, get_beta # Create profile. profile = GaussianProfile( wavelength=0.6e-6, # m From d605e01e663f192da9070f2c06e06483f65eeea8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:36:07 +0000 Subject: [PATCH 311/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 9f82737d..8c2ce824 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -3,7 +3,8 @@ from lasy.laser import Laser from lasy.profiles.gaussian_profile import GaussianProfile -from lasy.utils.laser_utils import get_phi2, get_zeta, get_beta +from lasy.utils.laser_utils import get_beta, get_phi2, get_zeta + # Create profile. profile = GaussianProfile( wavelength=0.6e-6, # m From 2f1061e73c49b9373cb1fa803d4173959844f129 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 17 Dec 2024 15:41:54 +0100 Subject: [PATCH 312/362] admend the test_axisparabola import --- tests/test_axiparabola.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_axiparabola.py b/tests/test_axiparabola.py index 28095665..26891e4e 100644 --- a/tests/test_axiparabola.py +++ b/tests/test_axiparabola.py @@ -10,7 +10,7 @@ from lasy.laser import Laser from lasy.optical_elements import Axiparabola -from lasy.profiles.gaussian_profile import CombinedLongitudinalTransverseProfile +from lasy.profiles.combined_profile import CombinedLongitudinalTransverseProfile from lasy.profiles.longitudinal import GaussianLongitudinalProfile from lasy.profiles.transverse import SuperGaussianTransverseProfile From cc1070285479431818474d7bbd1ebc2dbc7cd3f8 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 17 Dec 2024 15:50:21 +0100 Subject: [PATCH 313/362] admend the test files --- tests/test_gaussian_propagator.py | 2 +- tests/test_laser_utils.py | 2 +- tests/test_t2z2t.py | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_gaussian_propagator.py b/tests/test_gaussian_propagator.py index e669eff6..d0c945e8 100644 --- a/tests/test_gaussian_propagator.py +++ b/tests/test_gaussian_propagator.py @@ -47,7 +47,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 diff --git a/tests/test_laser_utils.py b/tests/test_laser_utils.py index e50ad317..31e2fa7a 100644 --- a/tests/test_laser_utils.py +++ b/tests/test_laser_utils.py @@ -46,7 +46,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 ) diff --git a/tests/test_t2z2t.py b/tests/test_t2z2t.py index 4ad2c7f1..4fed7908 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 @@ -68,8 +68,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) @@ -91,8 +91,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, 164, 65) From b6d5a375c26d77bb2c036dc0d8803be6fb25a218 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:53:30 +0000 Subject: [PATCH 314/362] [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 31e2fa7a..0fbe926a 100644 --- a/tests/test_laser_utils.py +++ b/tests/test_laser_utils.py @@ -45,9 +45,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 1be3b906f4ed3332dfa6f1c36e0d4505c4b3ddb2 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 17 Dec 2024 15:57:34 +0100 Subject: [PATCH 315/362] admend doc --- docs/source/tutorials/axiparabola.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/tutorials/axiparabola.ipynb b/docs/source/tutorials/axiparabola.ipynb index 0b345265..9a36cf11 100644 --- a/docs/source/tutorials/axiparabola.ipynb +++ b/docs/source/tutorials/axiparabola.ipynb @@ -40,7 +40,7 @@ "outputs": [], "source": [ "from lasy.laser import Laser\n", - "from lasy.profiles.gaussian_profile import CombinedLongitudinalTransverseProfile\n", + "from lasy.profiles.combined_profile import CombinedLongitudinalTransverseProfile\n", "from lasy.profiles.longitudinal import GaussianLongitudinalProfile\n", "from lasy.profiles.transverse import SuperGaussianTransverseProfile\n", "\n", From 8921ee08e55e736cbb781305a1c19739e0183be9 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:05:34 +0100 Subject: [PATCH 316/362] Update test_STC.py --- tests/test_STC.py | 76 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 16 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 8c2ce824..e8a77f0a 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -1,23 +1,46 @@ +"""Test the implementation of the spatio-temporal coupling. + +Test checks the implementation of the initialization and diagnostics to spatio-temporal coupling gaussian lasers +by creating a gaussian pulse on focus and calculate the STC factors by the implemented functions in laser.utils. +The correctness is also checked through comparing the gaussian profile and a combined gaussian profile off-focus. + +""" import numpy as np import scipy.constants as scc from lasy.laser import Laser from lasy.profiles.gaussian_profile import GaussianProfile from lasy.utils.laser_utils import get_beta, get_phi2, get_zeta +from lasy.profiles.combined_profile import CombinedLongitudinalTransverseProfile +from lasy.profiles.longitudinal import GaussianLongitudinalProfile +from lasy.profiles.transverse import GaussianTransverseProfile -# Create profile. +wavelength=0.6e-6 # m +pol=(1, 0) +laser_energy=1.0 # J +w0=5e-6 # m +tau=5e-14 # s +t_peak=0.0 # s +beta=3e-18 # s +zeta=2.4e-22 # m * s +phi2=2.4e-24 # s ^ 2 +stc_theta=scc.pi / 2 # rad +z_r = (np.pi * w0**2)/wavelength +z_foc = 3*z_r +# Create STC profile. profile = GaussianProfile( - wavelength=0.6e-6, # m - pol=(1, 0), - laser_energy=1.0, # J - w0=5e-6, # m - tau=5e-14, # s - t_peak=0.0, # s - beta=3e-18, # s - zeta=2.4e-22, # m * s - phi2=2.4e-24, # s ^ 2 - stc_theta=scc.pi / 2, # rad + wavelength=wavelength, + pol=pol, + laser_energy=laser_energy, + w0=w0, + tau=tau, + t_peak=t_peak, + beta=beta, + zeta=zeta, + phi2=phi2, + stc_theta=stc_theta, ) + # Create laser with given profile in `xyt` geometry. laser_3d = Laser( dim="xyt", @@ -26,24 +49,45 @@ npoints=(100, 100, 200), profile=profile, ) + # Create laser with given profile in `rt` geometry. -laser_2d = Laser( +long_profile=GaussianLongitudinalProfile(wavelength, tau, t_peak) +trans_profile = GaussianTransverseProfile(w0, wavelength, z_foc) +combined_profile = CombinedLongitudinalTransverseProfile(wavelength, pol, laser_energy, long_profile, trans_profile) +profile_gaussian = GaussianProfile( + wavelength=wavelength, + pol=pol, + laser_energy=laser_energy, + w0=w0, + tau=tau, + t_peak=t_peak, + z_foc=z_foc +) +laser_2d_combined = Laser( dim="rt", lo=(-10e-6, -10e-14), hi=(10e-6, +10e-14), npoints=(60, 200), - profile=profile, + profile=combined_profile, ) +laser_2d_gaussian = Laser( + dim="rt", + lo=(-10e-6, -10e-14), + hi=(10e-6, +10e-14), + npoints=(60, 200), + profile=profile_gaussian, +) +env_combined = laser_2d_combined.grid.get_temporal_field() +env_gaussian = laser_2d_gaussian.grid.get_temporal_field() +err= np.average(env_combined - env_gaussian) Phi2_3d, phi2_3d = get_phi2(laser_3d.dim, laser_3d.grid) -Phi2_2d, phi2_2d = get_phi2(laser_2d.dim, laser_2d.grid) [zeta_x, zeta_y], [nu_x, nu_y] = get_zeta( laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6 ) [beta_x, beta_y] = get_beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) - +np.testing.assert_approx_equal(err, 1e-3, significant=1) np.testing.assert_approx_equal(phi2_3d, 2.4e-24, significant=2) -np.testing.assert_approx_equal(phi2_2d, 2.4e-24, significant=2) np.testing.assert_approx_equal(zeta_y, 2.4e-22, significant=2) np.testing.assert_approx_equal(beta_y, 3e-18, significant=2) From 059a778136184b6adf5e6ee7040ef02fc445d05f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:07:14 +0000 Subject: [PATCH 317/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index e8a77f0a..23ec51c8 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -5,28 +5,29 @@ The correctness is also checked through comparing the gaussian profile and a combined gaussian profile off-focus. """ + import numpy as np import scipy.constants as scc from lasy.laser import Laser -from lasy.profiles.gaussian_profile import GaussianProfile -from lasy.utils.laser_utils import get_beta, get_phi2, get_zeta from lasy.profiles.combined_profile import CombinedLongitudinalTransverseProfile +from lasy.profiles.gaussian_profile import GaussianProfile from lasy.profiles.longitudinal import GaussianLongitudinalProfile from lasy.profiles.transverse import GaussianTransverseProfile +from lasy.utils.laser_utils import get_beta, get_phi2, get_zeta -wavelength=0.6e-6 # m -pol=(1, 0) -laser_energy=1.0 # J -w0=5e-6 # m -tau=5e-14 # s -t_peak=0.0 # s -beta=3e-18 # s -zeta=2.4e-22 # m * s -phi2=2.4e-24 # s ^ 2 -stc_theta=scc.pi / 2 # rad -z_r = (np.pi * w0**2)/wavelength -z_foc = 3*z_r +wavelength = 0.6e-6 # m +pol = (1, 0) +laser_energy = 1.0 # J +w0 = 5e-6 # m +tau = 5e-14 # s +t_peak = 0.0 # s +beta = 3e-18 # s +zeta = 2.4e-22 # m * s +phi2 = 2.4e-24 # s ^ 2 +stc_theta = scc.pi / 2 # rad +z_r = (np.pi * w0**2) / wavelength +z_foc = 3 * z_r # Create STC profile. profile = GaussianProfile( wavelength=wavelength, @@ -51,17 +52,19 @@ ) # Create laser with given profile in `rt` geometry. -long_profile=GaussianLongitudinalProfile(wavelength, tau, t_peak) +long_profile = GaussianLongitudinalProfile(wavelength, tau, t_peak) trans_profile = GaussianTransverseProfile(w0, wavelength, z_foc) -combined_profile = CombinedLongitudinalTransverseProfile(wavelength, pol, laser_energy, long_profile, trans_profile) -profile_gaussian = GaussianProfile( +combined_profile = CombinedLongitudinalTransverseProfile( + wavelength, pol, laser_energy, long_profile, trans_profile +) +profile_gaussian = GaussianProfile( wavelength=wavelength, pol=pol, laser_energy=laser_energy, w0=w0, tau=tau, t_peak=t_peak, - z_foc=z_foc + z_foc=z_foc, ) laser_2d_combined = Laser( dim="rt", @@ -79,7 +82,7 @@ ) env_combined = laser_2d_combined.grid.get_temporal_field() env_gaussian = laser_2d_gaussian.grid.get_temporal_field() -err= np.average(env_combined - env_gaussian) +err = np.average(env_combined - env_gaussian) Phi2_3d, phi2_3d = get_phi2(laser_3d.dim, laser_3d.grid) From 97a9c3fd9e7f9e25f99781a2b40c614921b0ed43 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:10:49 +0100 Subject: [PATCH 318/362] Update test_STC.py --- tests/test_STC.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 23ec51c8..b019c8e5 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -3,7 +3,6 @@ Test checks the implementation of the initialization and diagnostics to spatio-temporal coupling gaussian lasers by creating a gaussian pulse on focus and calculate the STC factors by the implemented functions in laser.utils. The correctness is also checked through comparing the gaussian profile and a combined gaussian profile off-focus. - """ import numpy as np @@ -80,8 +79,8 @@ npoints=(60, 200), profile=profile_gaussian, ) -env_combined = laser_2d_combined.grid.get_temporal_field() -env_gaussian = laser_2d_gaussian.grid.get_temporal_field() +env_combined = np.abs(laser_2d_combined.grid.get_temporal_field()) +env_gaussian = np.abs(laser_2d_gaussian.grid.get_temporal_field()) err = np.average(env_combined - env_gaussian) Phi2_3d, phi2_3d = get_phi2(laser_3d.dim, laser_3d.grid) From ba01785e757bf142f89f2de4008b3db4c87999fc Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:13:36 +0100 Subject: [PATCH 319/362] Update test_STC.py --- tests/test_STC.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index b019c8e5..0cd495cf 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -56,6 +56,7 @@ combined_profile = CombinedLongitudinalTransverseProfile( wavelength, pol, laser_energy, long_profile, trans_profile ) + profile_gaussian = GaussianProfile( wavelength=wavelength, pol=pol, @@ -67,15 +68,15 @@ ) laser_2d_combined = Laser( dim="rt", - lo=(-10e-6, -10e-14), - hi=(10e-6, +10e-14), + lo=(0e-6, -10e-14), + hi=(50e-6, +10e-14), npoints=(60, 200), profile=combined_profile, ) laser_2d_gaussian = Laser( dim="rt", - lo=(-10e-6, -10e-14), - hi=(10e-6, +10e-14), + lo=(0e-6, -10e-14), + hi=(50e-6, +10e-14), npoints=(60, 200), profile=profile_gaussian, ) From 5ff16dbd0bf4dc859b047d15d85a88831060ff70 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:15:33 +0100 Subject: [PATCH 320/362] Update test_STC.py --- tests/test_STC.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 0cd495cf..c8cd5bae 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -82,7 +82,7 @@ ) env_combined = np.abs(laser_2d_combined.grid.get_temporal_field()) env_gaussian = np.abs(laser_2d_gaussian.grid.get_temporal_field()) -err = np.average(env_combined - env_gaussian) +err = np.average(env_combined) Phi2_3d, phi2_3d = get_phi2(laser_3d.dim, laser_3d.grid) From be187f947c8cb262f9c7d62105e456b9ad0f7c70 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:17:46 +0100 Subject: [PATCH 321/362] Update test_STC.py --- tests/test_STC.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index c8cd5bae..9200d10a 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -80,9 +80,9 @@ npoints=(60, 200), profile=profile_gaussian, ) -env_combined = np.abs(laser_2d_combined.grid.get_temporal_field()) -env_gaussian = np.abs(laser_2d_gaussian.grid.get_temporal_field()) -err = np.average(env_combined) +env_combined = (laser_2d_combined.grid.get_temporal_field()) +env_gaussian = (laser_2d_gaussian.grid.get_temporal_field()) +err_real = np.average(np.array(env_combined.real)-np.array(env_gaussian.real)) Phi2_3d, phi2_3d = get_phi2(laser_3d.dim, laser_3d.grid) @@ -90,7 +90,7 @@ laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6 ) [beta_x, beta_y] = get_beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) -np.testing.assert_approx_equal(err, 1e-3, significant=1) +np.testing.assert_approx_equal(err_real, 1e-3, significant=1) np.testing.assert_approx_equal(phi2_3d, 2.4e-24, significant=2) np.testing.assert_approx_equal(zeta_y, 2.4e-22, significant=2) np.testing.assert_approx_equal(beta_y, 3e-18, significant=2) From e2d7ad0ba0043c45c4ba9bdea589961009016294 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:17:53 +0000 Subject: [PATCH 322/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 9200d10a..9249322c 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -80,9 +80,9 @@ npoints=(60, 200), profile=profile_gaussian, ) -env_combined = (laser_2d_combined.grid.get_temporal_field()) -env_gaussian = (laser_2d_gaussian.grid.get_temporal_field()) -err_real = np.average(np.array(env_combined.real)-np.array(env_gaussian.real)) +env_combined = laser_2d_combined.grid.get_temporal_field() +env_gaussian = laser_2d_gaussian.grid.get_temporal_field() +err_real = np.average(np.array(env_combined.real) - np.array(env_gaussian.real)) Phi2_3d, phi2_3d = get_phi2(laser_3d.dim, laser_3d.grid) From d433e6aca65a2c8594f62ddb3ff980fc21a7a033 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:21:58 +0100 Subject: [PATCH 323/362] Update test_STC.py --- tests/test_STC.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 9249322c..cc18f173 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -82,7 +82,8 @@ ) env_combined = laser_2d_combined.grid.get_temporal_field() env_gaussian = laser_2d_gaussian.grid.get_temporal_field() -err_real = np.average(np.array(env_combined.real) - np.array(env_gaussian.real)) +err_real = np.average((np.array(env_combined.real) - np.array(env_gaussian.real))/(np.array(env_combined.real)) +err_imag = np.average(np.array(env_combined.imag) - np.array(env_gaussian.imag)/(np.array(env_combined.imag)) Phi2_3d, phi2_3d = get_phi2(laser_3d.dim, laser_3d.grid) @@ -90,7 +91,7 @@ laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6 ) [beta_x, beta_y] = get_beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) -np.testing.assert_approx_equal(err_real, 1e-3, significant=1) +assert (err_real+err_imag)<1e-6 np.testing.assert_approx_equal(phi2_3d, 2.4e-24, significant=2) np.testing.assert_approx_equal(zeta_y, 2.4e-22, significant=2) np.testing.assert_approx_equal(beta_y, 3e-18, significant=2) From 2ad209773d9196b79270b9cb941f0ef7a04f06b0 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:24:26 +0100 Subject: [PATCH 324/362] Update test_STC.py --- tests/test_STC.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index cc18f173..344cab01 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -82,8 +82,8 @@ ) env_combined = laser_2d_combined.grid.get_temporal_field() env_gaussian = laser_2d_gaussian.grid.get_temporal_field() -err_real = np.average((np.array(env_combined.real) - np.array(env_gaussian.real))/(np.array(env_combined.real)) -err_imag = np.average(np.array(env_combined.imag) - np.array(env_gaussian.imag)/(np.array(env_combined.imag)) +err_real = np.average((np.array(env_combined.real) - np.array(env_gaussian.real))/np.array(env_combined.real)) +err_imag = np.average(np.array(env_combined.imag) - np.array(env_gaussian.imag)/np.array(env_combined.imag)) Phi2_3d, phi2_3d = get_phi2(laser_3d.dim, laser_3d.grid) From 2b5eb39053a7700a9f5e3833c276f0f0a094e3ff Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:24:36 +0000 Subject: [PATCH 325/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 344cab01..ce475d0c 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -82,8 +82,14 @@ ) env_combined = laser_2d_combined.grid.get_temporal_field() env_gaussian = laser_2d_gaussian.grid.get_temporal_field() -err_real = np.average((np.array(env_combined.real) - np.array(env_gaussian.real))/np.array(env_combined.real)) -err_imag = np.average(np.array(env_combined.imag) - np.array(env_gaussian.imag)/np.array(env_combined.imag)) +err_real = np.average( + (np.array(env_combined.real) - np.array(env_gaussian.real)) + / np.array(env_combined.real) +) +err_imag = np.average( + np.array(env_combined.imag) + - np.array(env_gaussian.imag) / np.array(env_combined.imag) +) Phi2_3d, phi2_3d = get_phi2(laser_3d.dim, laser_3d.grid) @@ -91,7 +97,7 @@ laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6 ) [beta_x, beta_y] = get_beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) -assert (err_real+err_imag)<1e-6 +assert (err_real + err_imag) < 1e-6 np.testing.assert_approx_equal(phi2_3d, 2.4e-24, significant=2) np.testing.assert_approx_equal(zeta_y, 2.4e-22, significant=2) np.testing.assert_approx_equal(beta_y, 3e-18, significant=2) From de7c26ab8af7685d648a98e418667d66d1fa7240 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:27:04 +0100 Subject: [PATCH 326/362] Update test_STC.py --- tests/test_STC.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index ce475d0c..fcff693f 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -66,6 +66,7 @@ t_peak=t_peak, z_foc=z_foc, ) + laser_2d_combined = Laser( dim="rt", lo=(0e-6, -10e-14), @@ -73,6 +74,7 @@ npoints=(60, 200), profile=combined_profile, ) + laser_2d_gaussian = Laser( dim="rt", lo=(0e-6, -10e-14), @@ -80,15 +82,17 @@ npoints=(60, 200), profile=profile_gaussian, ) + env_combined = laser_2d_combined.grid.get_temporal_field() env_gaussian = laser_2d_gaussian.grid.get_temporal_field() + err_real = np.average( (np.array(env_combined.real) - np.array(env_gaussian.real)) / np.array(env_combined.real) ) -err_imag = np.average( +err_imag = np.average(( np.array(env_combined.imag) - - np.array(env_gaussian.imag) / np.array(env_combined.imag) + - np.array(env_gaussian.imag)) / np.array(env_combined.imag) ) Phi2_3d, phi2_3d = get_phi2(laser_3d.dim, laser_3d.grid) From 6f650f2b64cd49361528a41bab770bf46c770086 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:27:12 +0000 Subject: [PATCH 327/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index fcff693f..7d8f9a8c 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -90,9 +90,9 @@ (np.array(env_combined.real) - np.array(env_gaussian.real)) / np.array(env_combined.real) ) -err_imag = np.average(( - np.array(env_combined.imag) - - np.array(env_gaussian.imag)) / np.array(env_combined.imag) +err_imag = np.average( + (np.array(env_combined.imag) - np.array(env_gaussian.imag)) + / np.array(env_combined.imag) ) Phi2_3d, phi2_3d = get_phi2(laser_3d.dim, laser_3d.grid) From 5e8ce8bde80b4f75d5b256047e8ac646f53ab46e Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:33:56 +0100 Subject: [PATCH 328/362] Update test_STC.py --- tests/test_STC.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 7d8f9a8c..c18c3768 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -2,7 +2,7 @@ Test checks the implementation of the initialization and diagnostics to spatio-temporal coupling gaussian lasers by creating a gaussian pulse on focus and calculate the STC factors by the implemented functions in laser.utils. -The correctness is also checked through comparing the gaussian profile and a combined gaussian profile off-focus. +The correctness is also checked through comparing the gaussian profile and a combined gaussian profile out of focus. """ import numpy as np @@ -27,8 +27,9 @@ stc_theta = scc.pi / 2 # rad z_r = (np.pi * w0**2) / wavelength z_foc = 3 * z_r + # Create STC profile. -profile = GaussianProfile( +STCprofile = GaussianProfile( wavelength=wavelength, pol=pol, laser_energy=laser_energy, @@ -47,17 +48,18 @@ lo=(-10e-6, -10e-6, -10e-14), hi=(10e-6, 10e-6, +10e-14), npoints=(100, 100, 200), - profile=profile, + profile=STCprofile, ) -# Create laser with given profile in `rt` geometry. +# Create laser out of focus with given profile in `rt` geometry by combined and gaussian profile. long_profile = GaussianLongitudinalProfile(wavelength, tau, t_peak) trans_profile = GaussianTransverseProfile(w0, wavelength, z_foc) + combined_profile = CombinedLongitudinalTransverseProfile( wavelength, pol, laser_energy, long_profile, trans_profile ) -profile_gaussian = GaussianProfile( +gaussian_profile = GaussianProfile( wavelength=wavelength, pol=pol, laser_energy=laser_energy, @@ -80,9 +82,10 @@ lo=(0e-6, -10e-14), hi=(50e-6, +10e-14), npoints=(60, 200), - profile=profile_gaussian, + profile=gaussian_profile, ) +# calculate the error of gaussian profile env_combined = laser_2d_combined.grid.get_temporal_field() env_gaussian = laser_2d_gaussian.grid.get_temporal_field() @@ -96,11 +99,11 @@ ) Phi2_3d, phi2_3d = get_phi2(laser_3d.dim, laser_3d.grid) - [zeta_x, zeta_y], [nu_x, nu_y] = get_zeta( laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6 ) [beta_x, beta_y] = get_beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) + assert (err_real + err_imag) < 1e-6 np.testing.assert_approx_equal(phi2_3d, 2.4e-24, significant=2) np.testing.assert_approx_equal(zeta_y, 2.4e-22, significant=2) From 932eb03bee96daba67a2c31b0851ff1f54c130a5 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:14:28 +0100 Subject: [PATCH 329/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 30c8deed..baff0f4c 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -893,7 +893,7 @@ def get_w0(grid, dim): Return ---------- - sigma: Standard deviation of a**2 in m + sigma : Standard deviation of a**2 in m """ field = grid.get_temporal_field() if dim == "xyt": @@ -933,8 +933,8 @@ def get_phi2(dim, grid): Return ---------- - phi2: Group-delayed dispersion in :math:`\Phi^{(2)}=d(\omega_0)/dt` (second^-2) - varphi2: Group-delayed dispersion in :math:`\varphi^{(2)}=dt_0/d(\omega)` (second^2) + phi2 : Group-delayed dispersion in :math:`\Phi^{(2)}=d(\omega_0)/dt` (second^-2) + varphi2 : Group-delayed dispersion in :math:`\varphi^{(2)}=dt_0/d(\omega)` (second^2) """ tau = 2 * get_duration(grid, dim) env = grid.get_temporal_field() @@ -966,8 +966,8 @@ def get_zeta(dim, grid, k0): Return ---------- - zeta_x, zeta_y: Spatio-chirp in :math:`\zeta=dx_0/d(\omega_0)` (meter * second) - nu_x, nu_y: Spatio-chirp in :math:`\nu=d(\omega_0)/dx` (meter^-1 * second^-1) + zeta_x, zeta_y : Spatial chirp in :math:`\zeta=dx_0/d(\omega_0)` (meter * second) + nu_x, nu_y: Spatial chirp in :math:`\nu=d(\omega_0)/dx` (meter^-1 * second^-1) """ assert dim == "xyt", "No spatial chirp for axis-sysmetric dimension" w0 = get_w0(grid, dim) @@ -1014,7 +1014,7 @@ def get_beta(dim, grid, k0): Return ---------- - beta_x, beta_y: Angular dispersion in :math:` \beta = d\theta_0/d\omega` (second) + beta_x, beta_y : Angular dispersion in :math:` \beta = d\theta_0/d\omega` (second) """ assert dim == "xyt", "No angular chirp for axis-sysmetric dimension" env_spec = grid.get_spectral_field() @@ -1054,9 +1054,9 @@ def get_pft(dim, grid): the value of the envelope field and the associated metadata that defines the points at which the laser is defined. - Return + Return ---------- - pft_x, pft_y: Pulse front tilt in :math:` p=dt/dx` (second * meter^-1) + pft_x, pft_y : Pulse front tilt in :math:` p=dt/dx` (second * meter^-1). """ assert dim == "xyt", "No pulse front tilt for axis-sysmetric dimension" env = grid.get_temporal_field() @@ -1088,7 +1088,7 @@ def get_propation_angle(dim, grid, k0): Return ---------- - angle_x, angle_y: propagating angle in :math:` p=k_x or k_y/kz` (rad) + angle_x, angle_y : propagating angle in :math:`p = k_x / k_z` or :math:`p = k_y / k_z` (in radians). """ assert dim == "xyt", "Propagation always on-axis axis-sysmetric dimension" env = grid.get_temporal_field() From 69ac5a55cf582cbed3d49e4b090fada8b4935bbe Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:15:44 +0100 Subject: [PATCH 330/362] Update lasy/profiles/longitudinal/longitudinal_profile.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- lasy/profiles/longitudinal/longitudinal_profile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lasy/profiles/longitudinal/longitudinal_profile.py b/lasy/profiles/longitudinal/longitudinal_profile.py index 767ffbcd..68a49c5f 100644 --- a/lasy/profiles/longitudinal/longitudinal_profile.py +++ b/lasy/profiles/longitudinal/longitudinal_profile.py @@ -13,7 +13,6 @@ class LongitudinalProfile(object): def __init__(self, wavelength): self.lambda0 = wavelength self.omega0 = 2 * pi * c / self.lambda0 - self.k0 = 2.0 * pi / wavelength def evaluate(self, t): """ From 7c8d7b52b6bded5faa76c196dffb1f0270b4c1d9 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:18:04 +0100 Subject: [PATCH 331/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index baff0f4c..683e9089 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -917,7 +917,7 @@ def get_w0(grid, dim): def get_phi2(dim, grid): r""" - Calculate the Group-delay dispersion of the laser. + Calculate the group-delayed dispersion of the laser. Parameters ---------- @@ -950,7 +950,7 @@ def get_phi2(dim, grid): def get_zeta(dim, grid, k0): r""" - Calculate the spatio-chirp of the laser. + Calculate the spatial chirp of the laser. Parameters ---------- From 9d0e5e9d8341a1b571b8415e1fc6145f500a354c Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:19:06 +0100 Subject: [PATCH 332/362] Update lasy/utils/laser_utils.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- 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 683e9089..37a3519b 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -1038,7 +1038,7 @@ def get_beta(dim, grid, k0): def get_pft(dim, grid): r""" - Calculate the pulse-front-tilt dispersion of the laser. + Calculate the pulse front tilt (PFT) of the laser. Parameters ---------- From 070e7c08e4e997d054378c5d3bf56e0fea137191 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:21:55 +0100 Subject: [PATCH 333/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 37a3519b..b00ee7ea 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -940,7 +940,7 @@ def get_phi2(dim, grid): env = grid.get_temporal_field() env_abs2 = np.abs(env**2) # Calculate group-delayed dispersion - phi_envelop = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) + phi_envelop = np.unwrap(np.angle(env), axis=2) pphi_pt = np.gradient(phi_envelop, grid.dx[-1], axis=2) pphi_pt2 = np.gradient(pphi_pt, grid.dx[-1], axis=2) phi2 = np.average(pphi_pt2, weights=env_abs2) @@ -1093,7 +1093,7 @@ def get_propation_angle(dim, grid, k0): assert dim == "xyt", "Propagation always on-axis axis-sysmetric dimension" env = grid.get_temporal_field() env_abs2 = np.abs(env**2) - phi_envelop_abs = np.unwrap(np.array(np.arctan2(env.imag, env.real)), axis=2) + phi_envelop_abs = np.unwrap(np.angle(env), axis=2) pphi_px = np.gradient(phi_envelop_abs, grid.dx[1], axis=1) pphi_py = np.gradient(phi_envelop_abs, grid.dx[0], axis=0) angle_x = np.average(pphi_px, weights=env_abs2) / k0 From 7b4d70e9bfc6733940f35cb6df49301a0c5a4d31 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:26:25 +0100 Subject: [PATCH 334/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index b00ee7ea..0b989f94 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -917,7 +917,7 @@ def get_w0(grid, dim): def get_phi2(dim, grid): r""" - Calculate the group-delayed dispersion of the laser. + Calculate the group-delay dispersion of the laser. Parameters ---------- @@ -933,8 +933,8 @@ def get_phi2(dim, grid): Return ---------- - phi2 : Group-delayed dispersion in :math:`\Phi^{(2)}=d(\omega_0)/dt` (second^-2) - varphi2 : Group-delayed dispersion in :math:`\varphi^{(2)}=dt_0/d(\omega)` (second^2) + phi2 : Group-delay dispersion in :math:`\Phi^{(2)}=d(\omega_0)/dt` (second^-2) + varphi2 : Group-delay dispersion in :math:`\varphi^{(2)}=dt_0/d(\omega)` (second^2) """ tau = 2 * get_duration(grid, dim) env = grid.get_temporal_field() @@ -1056,7 +1056,7 @@ def get_pft(dim, grid): Return ---------- - pft_x, pft_y : Pulse front tilt in :math:` p=dt/dx` (second * meter^-1). + pft_x, pft_y : Pulse front tilt in :math:` p=dt_0/dx` (second * meter^-1). """ assert dim == "xyt", "No pulse front tilt for axis-sysmetric dimension" env = grid.get_temporal_field() From 16b858fda320e48a10c71324bc2885e803834fc7 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:29:48 +0100 Subject: [PATCH 335/362] Update test_STC.py --- tests/test_STC.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index c18c3768..66c54b15 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -1,8 +1,9 @@ -"""Test the implementation of the spatio-temporal coupling. +""" +Test the implementation of spatio-temporal coupling (STC). + +This test verifies the correct implementation of initialization and diagnostics for spatio-temporal coupling in Gaussian lasers. It does so by creating a Gaussian pulse at focus and calculating the STC factors using the implemented functions in `laser.utils`. -Test checks the implementation of the initialization and diagnostics to spatio-temporal coupling gaussian lasers -by creating a gaussian pulse on focus and calculate the STC factors by the implemented functions in laser.utils. -The correctness is also checked through comparing the gaussian profile and a combined gaussian profile out of focus. +Additionally, the correctness is validated by comparing the Gaussian profile at focus with a combined Gaussian profile out of focus. """ import numpy as np From 9f1b2202804537852b2ae9a20a551c9a27a13947 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:31:36 +0000 Subject: [PATCH 336/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_STC.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 66c54b15..08231629 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -1,7 +1,7 @@ """ Test the implementation of spatio-temporal coupling (STC). -This test verifies the correct implementation of initialization and diagnostics for spatio-temporal coupling in Gaussian lasers. It does so by creating a Gaussian pulse at focus and calculating the STC factors using the implemented functions in `laser.utils`. +This test verifies the correct implementation of initialization and diagnostics for spatio-temporal coupling in Gaussian lasers. It does so by creating a Gaussian pulse at focus and calculating the STC factors using the implemented functions in `laser.utils`. Additionally, the correctness is validated by comparing the Gaussian profile at focus with a combined Gaussian profile out of focus. """ From 89b15e9aace8130dd23b7215fbd4f483ec0e0ba9 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:47:24 +0100 Subject: [PATCH 337/362] Update laser_utils.py --- lasy/utils/laser_utils.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index 0b989f94..fc6fbab1 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -933,8 +933,8 @@ def get_phi2(dim, grid): Return ---------- - phi2 : Group-delay dispersion in :math:`\Phi^{(2)}=d(\omega_0)/dt` (second^-2) - varphi2 : Group-delay dispersion in :math:`\varphi^{(2)}=dt_0/d(\omega)` (second^2) + phi2 : Group-delay dispersion in :math:`\Phi^{(2)} = \frac{d\omega_0}{dt}` (second^-2) + varphi2 : Group-delay dispersion in :math:`\varphi^{(2)}=\frac{dt_0}{d\omega}` (second^2) """ tau = 2 * get_duration(grid, dim) env = grid.get_temporal_field() @@ -966,10 +966,10 @@ def get_zeta(dim, grid, k0): Return ---------- - zeta_x, zeta_y : Spatial chirp in :math:`\zeta=dx_0/d(\omega_0)` (meter * second) - nu_x, nu_y: Spatial chirp in :math:`\nu=d(\omega_0)/dx` (meter^-1 * second^-1) + zeta_x, zeta_y : Spatial chirp in :math:`\zeta=\frac{dx_0}{d\omega}` (meter * second) + nu_x, nu_y: Spatial chirp in :math:`\nu=\frac{d\omega_0}{dx}` (meter^-1 * second^-1) """ - assert dim == "xyt", "No spatial chirp for axis-sysmetric dimension" + assert dim == "xyt", "No spatial chirp for axis-symmetric dimension." w0 = get_w0(grid, dim) tau = 2 * get_duration(grid, dim) env_spec = grid.get_spectral_field() @@ -1012,11 +1012,11 @@ def get_beta(dim, grid, k0): It contains an ndarray (V/m) with the value of the envelope field and the associated metadata that defines the points at which the laser is defined. - Return + Return ---------- - beta_x, beta_y : Angular dispersion in :math:` \beta = d\theta_0/d\omega` (second) + beta_x, beta_y : Angular dispersion in :math:` \beta = \frac{d\theta_0}{d\omega}` (second) """ - assert dim == "xyt", "No angular chirp for axis-sysmetric dimension" + assert dim == "xyt", "No angular chirp for axis-symmetric dimension." env_spec = grid.get_spectral_field() env_spec_abs2 = np.abs(env_spec**2) # Get the spectral axis @@ -1056,9 +1056,9 @@ def get_pft(dim, grid): Return ---------- - pft_x, pft_y : Pulse front tilt in :math:` p=dt_0/dx` (second * meter^-1). + pft_x, pft_y : Pulse front tilt in :math:` p=\frac{dt_0}{dx}` (second * meter^-1). """ - assert dim == "xyt", "No pulse front tilt for axis-sysmetric dimension" + assert dim == "xyt", "No pulse front tilt for axis-symmetric dimension." env = grid.get_temporal_field() env_abs2 = np.abs(env**2) weight_xy_2d = np.mean(env_abs2, axis=2) @@ -1086,11 +1086,11 @@ def get_propation_angle(dim, grid, k0): grid : a Grid object. It contains an ndarray (V/m) with the value of the envelope field and the associated metadata that defines the points at which the laser is defined. - Return + Return ---------- - angle_x, angle_y : propagating angle in :math:`p = k_x / k_z` or :math:`p = k_y / k_z` (in radians). + angle_x, angle_y : Propagating angle in :math:`p = \frac{k_x}{k_z}` or :math:`p = \frac{k_y}{k_z}` (in radians). """ - assert dim == "xyt", "Propagation always on-axis axis-sysmetric dimension" + assert dim == "xyt", "Propagation is always on-axis for axis-symmetric dimension." env = grid.get_temporal_field() env_abs2 = np.abs(env**2) phi_envelop_abs = np.unwrap(np.angle(env), axis=2) From 065c6c8a0d719a68c587bb9e0f47ec233da15204 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:51:01 +0100 Subject: [PATCH 338/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 33 ++++++++++++------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index b4a95e13..f43fbb3c 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -62,35 +62,28 @@ class GaussianProfile(Profile): z_foc : float (in meter), optional Position of the focal plane. (The laser pulse is initialized at `z=0`.) - beta : float (in second), optional (default '0') - The angular dispersion parameterized by: - + phi2 : float (in seconds^2), optional (default: '0') + The group-delay dispersion defined as: + .. math:: + \phi^{(2)} = \frac{dt}{d\omega} + + beta : float (in seconds), optional (default: '0') + The angular dispersion defined as: .. math:: - \beta = \frac{d\theta_0}{d\omega} - Here :math:`\theta_0` is the propagation angle of this component. - The definitions of beta, phi2 and zeta are taken from [S. Akturk et al., Optics Express 12, 4399 (2004)]. - - phi2 : float (in second^2), optional (default '0') - The group-delay dispersion parameterized by: - - .. math:: - - \phi^{(2)} = \frac{dt}{d\omega} - - zeta : float (in meter * second) optional (default '0') - The spatial chirp parameterized by: + zeta : float (in meters * seconds), optional (default: '0') + A spatial chirp defined as: .. math:: - \zeta = \frac{dx_0}{d\omega} - Here :math:`x_0` is the beam center position. + The definitions of beta, phi2, and zeta are taken from [S. Akturk et al., Optics Express 12, 4399 (2004)]. - stc_theta : float (in rad) optional (default '0') + stc_theta : float (in radians), optional (default: '0') Transverse direction along which there are chirps and spatio-temporal couplings. - 0 is along x axis. + A value of 0 corresponds to the x-axis. + Examples -------- From 292509ade878abbb46fa3b4c0b84b5de7ae44d53 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:51:13 +0000 Subject: [PATCH 339/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index f43fbb3c..86eb3e04 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -66,7 +66,7 @@ class GaussianProfile(Profile): The group-delay dispersion defined as: .. math:: \phi^{(2)} = \frac{dt}{d\omega} - + beta : float (in seconds), optional (default: '0') The angular dispersion defined as: .. math:: From 5b69bf5fa80478d8ab876f365fc5dcee4282aec7 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:51:35 +0100 Subject: [PATCH 340/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 86eb3e04..5f72208e 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -65,7 +65,7 @@ class GaussianProfile(Profile): phi2 : float (in seconds^2), optional (default: '0') The group-delay dispersion defined as: .. math:: - \phi^{(2)} = \frac{dt}{d\omega} + \phi^{(2)} = \frac{dt_0}{d\omega} beta : float (in seconds), optional (default: '0') The angular dispersion defined as: From f51080c63bbe1511e19b97d63c4a72e573ba2fd6 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:52:50 +0100 Subject: [PATCH 341/362] Update gaussian_profile.py --- 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 5f72208e..cdf1ff5c 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -62,25 +62,25 @@ class GaussianProfile(Profile): z_foc : float (in meter), optional Position of the focal plane. (The laser pulse is initialized at `z=0`.) - phi2 : float (in seconds^2), optional (default: '0') + phi2 : float (in second^2), optional (default: '0') The group-delay dispersion defined as: .. math:: \phi^{(2)} = \frac{dt_0}{d\omega} - beta : float (in seconds), optional (default: '0') + beta : float (in second), optional (default: '0') The angular dispersion defined as: .. math:: \beta = \frac{d\theta_0}{d\omega} Here :math:`\theta_0` is the propagation angle of this component. - zeta : float (in meters * seconds), optional (default: '0') + zeta : float (in meter * second), optional (default: '0') A spatial chirp defined as: .. math:: \zeta = \frac{dx_0}{d\omega} Here :math:`x_0` is the beam center position. The definitions of beta, phi2, and zeta are taken from [S. Akturk et al., Optics Express 12, 4399 (2004)]. - stc_theta : float (in radians), optional (default: '0') + stc_theta : float (in radian), optional (default: '0') Transverse direction along which there are chirps and spatio-temporal couplings. A value of 0 corresponds to the x-axis. From 251e7f338ad993ed50894b71f04d55bc1c7f1c4e Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:58:22 +0100 Subject: [PATCH 342/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index cdf1ff5c..f8782385 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -84,7 +84,6 @@ class GaussianProfile(Profile): Transverse direction along which there are chirps and spatio-temporal couplings. A value of 0 corresponds to the x-axis. - Examples -------- >>> import matplotlib.pyplot as plt From 2d2faff4ec1810f4b003b33cc3eaf3c475ec9874 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:04:43 +0100 Subject: [PATCH 343/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index f8782385..bbc0250e 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -64,19 +64,19 @@ class GaussianProfile(Profile): phi2 : float (in second^2), optional (default: '0') The group-delay dispersion defined as: - .. math:: - \phi^{(2)} = \frac{dt_0}{d\omega} + .. math:: + \phi^{(2)} = \frac{dt_0}{d\omega} beta : float (in second), optional (default: '0') The angular dispersion defined as: - .. math:: - \beta = \frac{d\theta_0}{d\omega} + .. math:: + \beta = \frac{d\theta_0}{d\omega} Here :math:`\theta_0` is the propagation angle of this component. zeta : float (in meter * second), optional (default: '0') A spatial chirp defined as: - .. math:: - \zeta = \frac{dx_0}{d\omega} + .. math:: + \zeta = \frac{dx_0}{d\omega} Here :math:`x_0` is the beam center position. The definitions of beta, phi2, and zeta are taken from [S. Akturk et al., Optics Express 12, 4399 (2004)]. From 2b4e9e2dc0ee4b6342baec24588d65a100ba9c1b Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:05:27 +0100 Subject: [PATCH 344/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index bbc0250e..9b16c57a 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -64,18 +64,21 @@ class GaussianProfile(Profile): phi2 : float (in second^2), optional (default: '0') The group-delay dispersion defined as: - .. math:: + .. math:: + \phi^{(2)} = \frac{dt_0}{d\omega} beta : float (in second), optional (default: '0') The angular dispersion defined as: - .. math:: + .. math:: + \beta = \frac{d\theta_0}{d\omega} Here :math:`\theta_0` is the propagation angle of this component. zeta : float (in meter * second), optional (default: '0') A spatial chirp defined as: - .. math:: + .. math:: + \zeta = \frac{dx_0}{d\omega} Here :math:`x_0` is the beam center position. The definitions of beta, phi2, and zeta are taken from [S. Akturk et al., Optics Express 12, 4399 (2004)]. From 7fd3c84926b62cb017132edc01b2ae6fc8d14f7b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:05:36 +0000 Subject: [PATCH 345/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 9b16c57a..885dac3b 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -65,20 +65,20 @@ class GaussianProfile(Profile): phi2 : float (in second^2), optional (default: '0') The group-delay dispersion defined as: .. math:: - + \phi^{(2)} = \frac{dt_0}{d\omega} beta : float (in second), optional (default: '0') The angular dispersion defined as: .. math:: - + \beta = \frac{d\theta_0}{d\omega} Here :math:`\theta_0` is the propagation angle of this component. zeta : float (in meter * second), optional (default: '0') A spatial chirp defined as: .. math:: - + \zeta = \frac{dx_0}{d\omega} Here :math:`x_0` is the beam center position. The definitions of beta, phi2, and zeta are taken from [S. Akturk et al., Optics Express 12, 4399 (2004)]. From 98046a5b2d86f6760c5b3cb50811e8ba089bee6c Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:08:19 +0100 Subject: [PATCH 346/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 885dac3b..1b40f23e 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -73,6 +73,7 @@ class GaussianProfile(Profile): .. math:: \beta = \frac{d\theta_0}{d\omega} + Here :math:`\theta_0` is the propagation angle of this component. zeta : float (in meter * second), optional (default: '0') @@ -80,6 +81,7 @@ class GaussianProfile(Profile): .. math:: \zeta = \frac{dx_0}{d\omega} + Here :math:`x_0` is the beam center position. The definitions of beta, phi2, and zeta are taken from [S. Akturk et al., Optics Express 12, 4399 (2004)]. From 44c2421c1fa72160cb95e4d92a31bfe7e1eb8ef6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:08:26 +0000 Subject: [PATCH 347/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 1b40f23e..954041ff 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -73,7 +73,7 @@ class GaussianProfile(Profile): .. math:: \beta = \frac{d\theta_0}{d\omega} - + Here :math:`\theta_0` is the propagation angle of this component. zeta : float (in meter * second), optional (default: '0') @@ -81,7 +81,7 @@ class GaussianProfile(Profile): .. math:: \zeta = \frac{dx_0}{d\omega} - + Here :math:`x_0` is the beam center position. The definitions of beta, phi2, and zeta are taken from [S. Akturk et al., Optics Express 12, 4399 (2004)]. From d4200f4307bf1e6d89d78be2b53ca220702a4ffd Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:08:52 +0100 Subject: [PATCH 348/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 954041ff..c33da8a1 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -64,13 +64,13 @@ class GaussianProfile(Profile): phi2 : float (in second^2), optional (default: '0') The group-delay dispersion defined as: - .. math:: + .. math:: \phi^{(2)} = \frac{dt_0}{d\omega} beta : float (in second), optional (default: '0') The angular dispersion defined as: - .. math:: + .. math:: \beta = \frac{d\theta_0}{d\omega} @@ -78,7 +78,7 @@ class GaussianProfile(Profile): zeta : float (in meter * second), optional (default: '0') A spatial chirp defined as: - .. math:: + .. math:: \zeta = \frac{dx_0}{d\omega} From 8175dfc78926cdf697b1ec393821384a9e884d3f Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:12:26 +0100 Subject: [PATCH 349/362] Update test_STC.py --- tests/test_STC.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 08231629..206c6183 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -106,6 +106,6 @@ [beta_x, beta_y] = get_beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) assert (err_real + err_imag) < 1e-6 -np.testing.assert_approx_equal(phi2_3d, 2.4e-24, significant=2) -np.testing.assert_approx_equal(zeta_y, 2.4e-22, significant=2) -np.testing.assert_approx_equal(beta_y, 3e-18, significant=2) +np.testing.assert_approx_equal(phi2_3d, phi2, significant=2) +np.testing.assert_approx_equal(zeta_y, zeta, significant=2) +np.testing.assert_approx_equal(beta_y, beta, significant=2) From 6dfb498e8347f2a62c6c466f4da709419485dffb Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:13:57 +0100 Subject: [PATCH 350/362] Update test_STC.py --- tests/test_STC.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 206c6183..3c611634 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -3,7 +3,7 @@ This test verifies the correct implementation of initialization and diagnostics for spatio-temporal coupling in Gaussian lasers. It does so by creating a Gaussian pulse at focus and calculating the STC factors using the implemented functions in `laser.utils`. -Additionally, the correctness is validated by comparing the Gaussian profile at focus with a combined Gaussian profile out of focus. +Additionally, the correctness is validated by comparing the Gaussian profile with a combined Gaussian profile out of focus. """ import numpy as np From ef6266e4c69bcde7b3886cb2bb5169d456128775 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:14:21 +0100 Subject: [PATCH 351/362] Update test_STC.py --- tests/test_STC.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 3c611634..0159bc52 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -3,7 +3,7 @@ This test verifies the correct implementation of initialization and diagnostics for spatio-temporal coupling in Gaussian lasers. It does so by creating a Gaussian pulse at focus and calculating the STC factors using the implemented functions in `laser.utils`. -Additionally, the correctness is validated by comparing the Gaussian profile with a combined Gaussian profile out of focus. +Additionally, the correctness is validated by comparing the Gaussian profile with a combined Gaussian profile without STC out of focus. """ import numpy as np From 8f3c778531f86552398215d1628500fd742624ab Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:16:18 +0100 Subject: [PATCH 352/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index c33da8a1..5806f416 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -67,14 +67,14 @@ class GaussianProfile(Profile): .. math:: \phi^{(2)} = \frac{dt_0}{d\omega} - + Here :math:`t_0` is the temporal position of this freqency component. beta : float (in second), optional (default: '0') The angular dispersion defined as: .. math:: \beta = \frac{d\theta_0}{d\omega} - Here :math:`\theta_0` is the propagation angle of this component. + Here :math:`\theta_0` is the propagation angle of this freqency component. zeta : float (in meter * second), optional (default: '0') A spatial chirp defined as: @@ -82,7 +82,7 @@ class GaussianProfile(Profile): \zeta = \frac{dx_0}{d\omega} - Here :math:`x_0` is the beam center position. + Here :math:`x_0` is the transverse beam center position of this freqency component. The definitions of beta, phi2, and zeta are taken from [S. Akturk et al., Optics Express 12, 4399 (2004)]. stc_theta : float (in radian), optional (default: '0') From 5fbfa99580b7ef3341ee6f8f120d9d2276c25cc9 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:22:53 +0100 Subject: [PATCH 353/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 5806f416..4dd56133 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -67,6 +67,7 @@ class GaussianProfile(Profile): .. math:: \phi^{(2)} = \frac{dt_0}{d\omega} + Here :math:`t_0` is the temporal position of this freqency component. beta : float (in second), optional (default: '0') The angular dispersion defined as: From 9acbc4a6ebf8ffd683cc424ad3f2b270238d69ac Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:23:02 +0000 Subject: [PATCH 354/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 4dd56133..9fb4c188 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -67,7 +67,7 @@ class GaussianProfile(Profile): .. math:: \phi^{(2)} = \frac{dt_0}{d\omega} - + Here :math:`t_0` is the temporal position of this freqency component. beta : float (in second), optional (default: '0') The angular dispersion defined as: From 10ccbae7df249a904f606dc973021aaee568d525 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:26:39 +0100 Subject: [PATCH 355/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 9fb4c188..aeb43472 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -63,27 +63,12 @@ class GaussianProfile(Profile): Position of the focal plane. (The laser pulse is initialized at `z=0`.) phi2 : float (in second^2), optional (default: '0') - The group-delay dispersion defined as: - .. math:: - - \phi^{(2)} = \frac{dt_0}{d\omega} - - Here :math:`t_0` is the temporal position of this freqency component. + The group-delay dispersion defined as :math:`\phi^{(2)} = \frac{dt_0}{d\omega}. Here :math:`t_0` is the temporal position of this frequency component. beta : float (in second), optional (default: '0') - The angular dispersion defined as: - .. math:: - - \beta = \frac{d\theta_0}{d\omega} - - Here :math:`\theta_0` is the propagation angle of this freqency component. + The angular dispersion defined as :math:`\beta = \frac{d\theta_0}{d\omega}`. Here :math:`\theta_0` is the propagation angle of this frequency component. zeta : float (in meter * second), optional (default: '0') - A spatial chirp defined as: - .. math:: - - \zeta = \frac{dx_0}{d\omega} - - Here :math:`x_0` is the transverse beam center position of this freqency component. + A spatial chirp defined as: math:`\zeta = \frac{dx_0}{d\omega}`. Here :math:`x_0` is the transverse beam center position of this frequency component. The definitions of beta, phi2, and zeta are taken from [S. Akturk et al., Optics Express 12, 4399 (2004)]. stc_theta : float (in radian), optional (default: '0') From ece499fd68c486a7566a56fa164ef2d9b423e1e6 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:26:59 +0100 Subject: [PATCH 356/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index aeb43472..ef1e09af 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -64,6 +64,7 @@ class GaussianProfile(Profile): phi2 : float (in second^2), optional (default: '0') The group-delay dispersion defined as :math:`\phi^{(2)} = \frac{dt_0}{d\omega}. Here :math:`t_0` is the temporal position of this frequency component. + beta : float (in second), optional (default: '0') The angular dispersion defined as :math:`\beta = \frac{d\theta_0}{d\omega}`. Here :math:`\theta_0` is the propagation angle of this frequency component. From 82337bd00ed05871fa6c292f88529369a420644c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:27:10 +0000 Subject: [PATCH 357/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index ef1e09af..c4b7ce10 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -64,7 +64,7 @@ class GaussianProfile(Profile): phi2 : float (in second^2), optional (default: '0') The group-delay dispersion defined as :math:`\phi^{(2)} = \frac{dt_0}{d\omega}. Here :math:`t_0` is the temporal position of this frequency component. - + beta : float (in second), optional (default: '0') The angular dispersion defined as :math:`\beta = \frac{d\theta_0}{d\omega}`. Here :math:`\theta_0` is the propagation angle of this frequency component. From 9fa1a18de7e8e24835179dbc226d7371ab9b50ca Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:39:35 +0100 Subject: [PATCH 358/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index c4b7ce10..d692280c 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -2,7 +2,6 @@ from .profile import Profile - class GaussianProfile(Profile): r""" Class for the analytic profile of a Gaussian laser pulse. From c0df34195617d3af28bb599b8faa3db5a8732551 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:39:45 +0000 Subject: [PATCH 359/362] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lasy/profiles/gaussian_profile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index d692280c..c4b7ce10 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -2,6 +2,7 @@ from .profile import Profile + class GaussianProfile(Profile): r""" Class for the analytic profile of a Gaussian laser pulse. From 643c5519c3d10c0012979d11575f1c68cbc19108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxence=20Th=C3=A9venet?= Date: Thu, 19 Dec 2024 16:41:57 +0100 Subject: [PATCH 360/362] Apply suggestions from code review --- lasy/profiles/gaussian_profile.py | 2 +- lasy/utils/laser_utils.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index c4b7ce10..9df9b74f 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -155,7 +155,7 @@ def evaluate(self, x, y, t): t : ndarrays of floats Define longitudinal points on which to evaluate the envelope - x,y : ndarrays of floats, necessray if spatio-temperal coulping exists + x,y : ndarrays of floats, necessary if spatio-temporal coupling exists Define transverse points on which to evaluate the envelope Returns diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index fc6fbab1..751757cd 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -931,8 +931,8 @@ def get_phi2(dim, grid): grid : a Grid object. It contains an ndarray (V/m) with the value of the envelope field and the associated metadata that defines the points at which the laser is defined. - Return - ---------- + Returns + ------- phi2 : Group-delay dispersion in :math:`\Phi^{(2)} = \frac{d\omega_0}{dt}` (second^-2) varphi2 : Group-delay dispersion in :math:`\varphi^{(2)}=\frac{dt_0}{d\omega}` (second^2) """ @@ -1056,9 +1056,9 @@ def get_pft(dim, grid): Return ---------- - pft_x, pft_y : Pulse front tilt in :math:` p=\frac{dt_0}{dx}` (second * meter^-1). + pft_x, pft_y : Pulse front tilt in :math:`p=\frac{dt_0}{dx}` (second * meter^-1). """ - assert dim == "xyt", "No pulse front tilt for axis-symmetric dimension." + assert dim == "xyt", "No pulse front tilt for cylindrical symmetry." env = grid.get_temporal_field() env_abs2 = np.abs(env**2) weight_xy_2d = np.mean(env_abs2, axis=2) From 6852641724c4833784ea8ef4d2b4373bbfbb7ea1 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:42:51 +0100 Subject: [PATCH 361/362] Update gaussian_profile.py --- lasy/profiles/gaussian_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index 9df9b74f..a1d0fcc5 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -155,7 +155,7 @@ def evaluate(self, x, y, t): t : ndarrays of floats Define longitudinal points on which to evaluate the envelope - x,y : ndarrays of floats, necessary if spatio-temporal coupling exists + x,y : ndarrays of floats Define transverse points on which to evaluate the envelope Returns From fd604460e763634266fd76452433e9ebc2d96272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxence=20Th=C3=A9venet?= Date: Thu, 19 Dec 2024 16:52:05 +0100 Subject: [PATCH 362/362] Apply suggestions from code review --- lasy/profiles/gaussian_profile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lasy/profiles/gaussian_profile.py b/lasy/profiles/gaussian_profile.py index a1d0fcc5..c428cd62 100644 --- a/lasy/profiles/gaussian_profile.py +++ b/lasy/profiles/gaussian_profile.py @@ -63,13 +63,13 @@ class GaussianProfile(Profile): Position of the focal plane. (The laser pulse is initialized at `z=0`.) phi2 : float (in second^2), optional (default: '0') - The group-delay dispersion defined as :math:`\phi^{(2)} = \frac{dt_0}{d\omega}. Here :math:`t_0` is the temporal position of this frequency component. + The group-delay dispersion defined as :math:`\phi^{(2)} = \frac{dt_0}{d\omega}`. Here :math:`t_0` is the temporal position of this frequency component. beta : float (in second), optional (default: '0') The angular dispersion defined as :math:`\beta = \frac{d\theta_0}{d\omega}`. Here :math:`\theta_0` is the propagation angle of this frequency component. zeta : float (in meter * second), optional (default: '0') - A spatial chirp defined as: math:`\zeta = \frac{dx_0}{d\omega}`. Here :math:`x_0` is the transverse beam center position of this frequency component. + A spatial chirp defined as :math:`\zeta = \frac{dx_0}{d\omega}`. Here :math:`x_0` is the transverse beam center position of this frequency component. The definitions of beta, phi2, and zeta are taken from [S. Akturk et al., Optics Express 12, 4399 (2004)]. stc_theta : float (in radian), optional (default: '0')