From a2ef19ca232321718014459ec4b3c05658be30bc Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 16 Jul 2024 15:59:08 +0200 Subject: [PATCH 001/254] copy paste stretch factor from Warpx --- docs/source/run/parameters.rst | 29 +++++++++++++++++++++++++++++ src/laser/Laser.H | 4 ++++ src/laser/Laser.cpp | 3 +++ src/laser/MultiLaser.cpp | 13 ++++++++++++- 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index b4e32d2a4b..d8cb201421 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -877,6 +877,35 @@ Option: ``gaussian`` Pulse front tilt angle on yz plane - the angle between the pulse front (maximum intensity contour)and the propagation direction defined by [Selcuk Akturk Opt. Express 12 (2004)](pi/2 is no PFT) +* ``.beta`` (`float`) optinal (default `0.`) + Angular dispersion (or angular chirp) at focus defined by [Selcuk Akturk Opt. Express 12 (2004)] + +* ``.zeta`` (`float`) optinal (default `0.`) + Spatial chirp at focus defined by [Selcuk Akturk Opt. Express 12 (2004)] + +* ``.phi2`` (`float`) optinal (default `pi/2`) + The amount of temporal chirp :math:`\phi^{(2)}` at focus (in the lab frame). Namely, a wave packet + centered on the frequency :math:`(\omega_0 + \delta \omega)` will reach its peak intensity + at :math:`z(\delta \omega) = z_0 - c \phi^{(2)} \, \delta \omega`. Thus, a positive + :math:`\phi^{(2)}` corresponds to positive chirp, i.e. red part of the spectrum in the + front of the pulse and blue part of the spectrum in the back. More specifically, the electric + field in the focal plane is of the form: + + .. math:: + + E(\boldsymbol{x},t) \propto Re\left[ \exp\left( -\frac{(t-t_{peak})^2}{\tau^2 + 2i\phi^{(2)}} + i\omega_0 (t-t_{peak}) + i\phi_0 \right) \right] + + where :math:`\tau` is given by ``.tau`` and represents the + Fourier-limited duration of the laser pulse. Thus, the actual duration of the chirped laser pulse is: + + .. math:: + + \tau' = \sqrt{ \tau^2 + 4 (\phi^{(2)})^2/\tau^2 } + + See also the definition in [Selcuk Akturk Opt. Express 12 (2004)]. + + + Option: ``from_file`` * ``lasers.input_file`` (`string`) optional (default `""`) diff --git a/src/laser/Laser.H b/src/laser/Laser.H index cd4db39466..ab7b8e3c26 100644 --- a/src/laser/Laser.H +++ b/src/laser/Laser.H @@ -33,6 +33,10 @@ public: amrex::Real m_PFT_yz {MathConst::pi/2.0}; amrex::Real m_L0 {0.}; /**< Laser length (HW 1/e in amplitude) */ amrex::Real m_tau {0.}; /**< Laser duration (HW 1/e in amplitude) */ + /**Time stretching factors*/ + amrex::Real m_zeta {0.}; + amrex::Real m_beta {0.}; + amrex::Real m_phi2 {0.}; /** Focal distance of the laser pulse */ amrex::Real m_focal_distance {0.}; /** Average position of the Gaussian laser pulse */ diff --git a/src/laser/Laser.cpp b/src/laser/Laser.cpp index acee4a4316..dd7e7008ce 100644 --- a/src/laser/Laser.cpp +++ b/src/laser/Laser.cpp @@ -33,6 +33,9 @@ Laser::Laser (std::string name, bool laser_from_file) if (duration_is_specified) m_L0 = m_tau*get_phys_const().c; queryWithParser(pp, "focal_distance", m_focal_distance); queryWithParser(pp, "position_mean", m_position_mean); + queryWithParser(pp, "zeta", m_zeta); + queryWithParser(pp, "beta", m_beta); + queryWithParser(pp, "phi2", m_phi2); return; } else if (m_laser_init_type == "parser"){ diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 5e5cb79d30..8af380e6af 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -1170,7 +1170,12 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) const amrex::Real y0 = laser.m_position_mean[1]; const amrex::Real z0 = laser.m_position_mean[2]; const amrex::Real L0 = laser.m_L0; + const amrex::Real tau = laser.m_tau; const amrex::Real zfoc = laser.m_focal_distance; + const amrex::Real zeta = laser.m_zeta; + const amrex::Real beta = laser.m_beta; + const amrex::Real phi2 = laser.m_phi2; + const amrex::Real k0 = 2._rt*MathConst::pi/m_lambda0; amrex::ParallelFor( bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) @@ -1189,11 +1194,17 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) arr(i, j, k, comp + 1 ) = 0._rt; } // Compute envelope for time step 0 + Complex inv_tau2 = 1._rt /(tau * tau); Complex diffract_factor = 1._rt + I * ( zp - zfoc + z0 * std::cos( propagation_angle_yz ) ) \ * 2._rt/( k0 * w0 * w0 ); Complex inv_complex_waist_2 = 1._rt /( w0 * w0 * diffract_factor ); + // Time stretching due to STCs and phi2 complex envelope + // (1 if zeta=0, beta=0, phi2=0) + Complex stretch_factor = 1._rt + 4._rt * (zeta + beta * zfoc * inv_tau2) \ + * (zeta + beta * zfoc * inv_complex_waist_2) + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) \ + * inv_tau2; Complex prefactor = a0 / diffract_factor; - Complex time_exponent = zp * zp / ( L0 * L0 ); + Complex time_exponent = zp * zp / ( stretch_factor * L0 * L0 ); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; Complex envelope = stcfactor * amrex::exp( exp_argument ) * \ From 70c74894b9a4ef12769ade823a072f17c433f343 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 16 Jul 2024 16:32:52 +0200 Subject: [PATCH 002/254] reduce redundant defination of k0 --- src/laser/MultiLaser.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 8af380e6af..a74c3a8df2 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -1175,7 +1175,6 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) const amrex::Real zeta = laser.m_zeta; const amrex::Real beta = laser.m_beta; const amrex::Real phi2 = laser.m_phi2; - const amrex::Real k0 = 2._rt*MathConst::pi/m_lambda0; amrex::ParallelFor( bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) From ef1046a1b8c0180596a27dbb27fcdaa9162e8fca Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 16 Jul 2024 16:47:10 +0200 Subject: [PATCH 003/254] debug --- src/laser/MultiLaser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index a74c3a8df2..8469b2bba5 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -1203,7 +1203,7 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) * (zeta + beta * zfoc * inv_complex_waist_2) + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) \ * inv_tau2; Complex prefactor = a0 / diffract_factor; - Complex time_exponent = zp * zp / ( stretch_factor * L0 * L0 ); + Complex time_exponent = zp * zp / ( L0 * L0 ); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; Complex envelope = stcfactor * amrex::exp( exp_argument ) * \ From 9059a6709815098531f3a876a2de7d6db751660c Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 16 Jul 2024 17:07:02 +0200 Subject: [PATCH 004/254] amrex::print stretch factor --- src/laser/MultiLaser.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 8469b2bba5..16e88c73c2 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -1199,11 +1199,12 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) Complex inv_complex_waist_2 = 1._rt /( w0 * w0 * diffract_factor ); // Time stretching due to STCs and phi2 complex envelope // (1 if zeta=0, beta=0, phi2=0) - Complex stretch_factor = 1._rt + 4._rt * (zeta + beta * zfoc * inv_tau2) \ - * (zeta + beta * zfoc * inv_complex_waist_2) + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) \ - * inv_tau2; + Complex stretch_factor = 1._rt \ + + 4._rt * (zeta + beta * zfoc * inv_tau2) * (zeta + beta * zfoc * inv_complex_waist_2) \ + + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * inv_tau2; Complex prefactor = a0 / diffract_factor; - Complex time_exponent = zp * zp / ( L0 * L0 ); + amrex::Print()<< "Stretch factor is " << stretch_factor ; + Complex time_exponent = zp * zp / ( stretch_factor * L0 * L0 ); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; Complex envelope = stcfactor * amrex::exp( exp_argument ) * \ From 9d29777bcbb95d157a04925d5edf728fc5980d30 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 16 Jul 2024 17:22:39 +0200 Subject: [PATCH 005/254] found no problem. bug in test program? --- src/laser/MultiLaser.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 16e88c73c2..d09c87eb65 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -1203,7 +1203,6 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) + 4._rt * (zeta + beta * zfoc * inv_tau2) * (zeta + beta * zfoc * inv_complex_waist_2) \ + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * inv_tau2; Complex prefactor = a0 / diffract_factor; - amrex::Print()<< "Stretch factor is " << stretch_factor ; Complex time_exponent = zp * zp / ( stretch_factor * L0 * L0 ); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; From c5237bc2ba8be52446804dcd1959915c0eef7ee7 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 17 Jul 2024 10:19:19 +0200 Subject: [PATCH 006/254] set laser.tau no to be 0 --- src/laser/Laser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/laser/Laser.cpp b/src/laser/Laser.cpp index dd7e7008ce..6265dd55b4 100644 --- a/src/laser/Laser.cpp +++ b/src/laser/Laser.cpp @@ -30,7 +30,8 @@ Laser::Laser (std::string name, bool laser_from_file) bool duration_is_specified = queryWithParser(pp, "tau", m_tau); AMREX_ALWAYS_ASSERT_WITH_MESSAGE( length_is_specified + duration_is_specified == 1, "Please specify exlusively either the pulse length L0 or the duration tau of the laser"); - if (duration_is_specified) m_L0 = m_tau*get_phys_const().c; + if (duration_is_specified) m_L0 = m_tau * get_phys_const().c; + if (length_is_specified) m_tau = m_L0 / (get_phys_const().c); queryWithParser(pp, "focal_distance", m_focal_distance); queryWithParser(pp, "position_mean", m_position_mean); queryWithParser(pp, "zeta", m_zeta); From c0a364af3a7184d052d1455033ca95c1406bfe46 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 22 Jul 2024 15:59:11 +0200 Subject: [PATCH 007/254] add the spatial temperal coupling term --- src/laser/MultiLaser.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index d09c87eb65..6f4192afab 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -1203,7 +1203,9 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) + 4._rt * (zeta + beta * zfoc * inv_tau2) * (zeta + beta * zfoc * inv_complex_waist_2) \ + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * inv_tau2; Complex prefactor = a0 / diffract_factor; - Complex time_exponent = zp * zp / ( stretch_factor * L0 * L0 ); + Complex time_exponent = 1 / ( stretch_factor * L0 * L0 ) * + amrex::pow(zp - beta * k0 * (xp + yp) - 2._rt * I * (xp + yp)*(zeta - beta * zfoc) + * inv_waist_2,2); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; Complex envelope = stcfactor * amrex::exp( exp_argument ) * \ From 13745a79b32b55d137931e4efdf58da32015544a Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 22 Jul 2024 16:14:57 +0200 Subject: [PATCH 008/254] missing ._rt --- src/laser/MultiLaser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 6f4192afab..6833daed66 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -1203,7 +1203,7 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) + 4._rt * (zeta + beta * zfoc * inv_tau2) * (zeta + beta * zfoc * inv_complex_waist_2) \ + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * inv_tau2; Complex prefactor = a0 / diffract_factor; - Complex time_exponent = 1 / ( stretch_factor * L0 * L0 ) * + Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * amrex::pow(zp - beta * k0 * (xp + yp) - 2._rt * I * (xp + yp)*(zeta - beta * zfoc) * inv_waist_2,2); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); From 1dd365d40d3f1bf3fe5d46d7cf6ab38ad9f7ffd7 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 22 Jul 2024 16:29:55 +0200 Subject: [PATCH 009/254] fix typoo --- src/laser/MultiLaser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 6833daed66..5461286c17 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -1204,8 +1204,8 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * inv_tau2; Complex prefactor = a0 / diffract_factor; Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * - amrex::pow(zp - beta * k0 * (xp + yp) - 2._rt * I * (xp + yp)*(zeta - beta * zfoc) - * inv_waist_2,2); + amrex::pow(zp - beta * k0 * (x + yp) - 2._rt * I * (x + yp)*(zeta - beta * zfoc) + * inv_waist_2, 2); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; Complex envelope = stcfactor * amrex::exp( exp_argument ) * \ From 6e87829faaff2e53fd5f1f645587161ad4696444 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 22 Jul 2024 17:21:37 +0200 Subject: [PATCH 010/254] fix typoo again --- src/laser/MultiLaser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 5461286c17..e992d039f0 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -1205,7 +1205,7 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) Complex prefactor = a0 / diffract_factor; Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * amrex::pow(zp - beta * k0 * (x + yp) - 2._rt * I * (x + yp)*(zeta - beta * zfoc) - * inv_waist_2, 2); + * inv_complex_waist_2, 2); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; Complex envelope = stcfactor * amrex::exp( exp_argument ) * \ From c0c4fe676de54e286e0b4acbbdfe19b19be2986b Mon Sep 17 00:00:00 2001 From: huixingjian Date: Thu, 25 Jul 2024 15:56:58 +0200 Subject: [PATCH 011/254] Fix the dimension --- src/laser/MultiLaser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index e992d039f0..a3a315d411 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -1201,11 +1201,11 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) // (1 if zeta=0, beta=0, phi2=0) Complex stretch_factor = 1._rt \ + 4._rt * (zeta + beta * zfoc * inv_tau2) * (zeta + beta * zfoc * inv_complex_waist_2) \ - + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * inv_tau2; + + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) / (L0 * L0); Complex prefactor = a0 / diffract_factor; Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * - amrex::pow(zp - beta * k0 * (x + yp) - 2._rt * I * (x + yp)*(zeta - beta * zfoc) - * inv_complex_waist_2, 2); + amrex::pow(zp - beta * k0 * (x + yp) * PhysConstSI::c - 2._rt * I * (x + yp)*(zeta - beta * zfoc) + * PhysConstSI::c )* inv_complex_waist_2, 2); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; Complex envelope = stcfactor * amrex::exp( exp_argument ) * \ From 0bd06671b4cb93dbaac2b06eca1e5222a4d8b593 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Thu, 25 Jul 2024 16:24:31 +0200 Subject: [PATCH 012/254] typoo --- src/laser/MultiLaser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index a3a315d411..b26a34211b 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -1205,7 +1205,7 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) Complex prefactor = a0 / diffract_factor; Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * amrex::pow(zp - beta * k0 * (x + yp) * PhysConstSI::c - 2._rt * I * (x + yp)*(zeta - beta * zfoc) - * PhysConstSI::c )* inv_complex_waist_2, 2); + * PhysConstSI::c * inv_complex_waist_2, 2); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; Complex envelope = stcfactor * amrex::exp( exp_argument ) * \ From 349435d03d7f92b3398ff2537b05a2d7a2be4554 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Thu, 25 Jul 2024 16:36:41 +0200 Subject: [PATCH 013/254] debug --- src/laser/MultiLaser.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index b26a34211b..a63125553c 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -1175,6 +1175,7 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) const amrex::Real zeta = laser.m_zeta; const amrex::Real beta = laser.m_beta; const amrex::Real phi2 = laser.m_phi2; + const amrex::Real clight = PhysConstSI::c; amrex::ParallelFor( bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) @@ -1204,8 +1205,8 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) / (L0 * L0); Complex prefactor = a0 / diffract_factor; Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * - amrex::pow(zp - beta * k0 * (x + yp) * PhysConstSI::c - 2._rt * I * (x + yp)*(zeta - beta * zfoc) - * PhysConstSI::c * inv_complex_waist_2, 2); + amrex::pow(zp - beta * k0 * (x + yp) * clight - 2._rt * I * (x + yp)*(zeta - beta * zfoc) + * clight * inv_complex_waist_2, 2); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; Complex envelope = stcfactor * amrex::exp( exp_argument ) * \ From 27f22553ce652e6ff3f15e1ebf3d046b62dfa39c Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 29 Jul 2024 13:49:09 +0200 Subject: [PATCH 014/254] dimension error --- src/laser/MultiLaser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index a63125553c..46a2055ab2 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -1202,7 +1202,7 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) // (1 if zeta=0, beta=0, phi2=0) Complex stretch_factor = 1._rt \ + 4._rt * (zeta + beta * zfoc * inv_tau2) * (zeta + beta * zfoc * inv_complex_waist_2) \ - + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) / (L0 * L0); + + 2._rt * I * (phi2 * clight * clight- beta * beta * k0 * zfoc) / (L0 * L0); Complex prefactor = a0 / diffract_factor; Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * amrex::pow(zp - beta * k0 * (x + yp) * clight - 2._rt * I * (x + yp)*(zeta - beta * zfoc) From 0aab9f9d8155ec495edecde689ef8a321d858466 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 29 Jul 2024 16:43:02 +0200 Subject: [PATCH 015/254] debug when checking zeta --- src/laser/MultiLaser.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 46a2055ab2..c4f612964e 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -1194,18 +1194,17 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) arr(i, j, k, comp + 1 ) = 0._rt; } // Compute envelope for time step 0 - Complex inv_tau2 = 1._rt /(tau * tau); Complex diffract_factor = 1._rt + I * ( zp - zfoc + z0 * std::cos( propagation_angle_yz ) ) \ * 2._rt/( k0 * w0 * w0 ); Complex inv_complex_waist_2 = 1._rt /( w0 * w0 * diffract_factor ); // Time stretching due to STCs and phi2 complex envelope // (1 if zeta=0, beta=0, phi2=0) Complex stretch_factor = 1._rt \ - + 4._rt * (zeta + beta * zfoc * inv_tau2) * (zeta + beta * zfoc * inv_complex_waist_2) \ - + 2._rt * I * (phi2 * clight * clight- beta * beta * k0 * zfoc) / (L0 * L0); + + 4._rt * (zeta + beta * zfoc * clight * clight / (L0 * L0)) * (zeta + beta * zfoc * inv_complex_waist_2) \ + + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * clight * clight/ (L0 * L0); Complex prefactor = a0 / diffract_factor; Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * - amrex::pow(zp - beta * k0 * (x + yp) * clight - 2._rt * I * (x + yp)*(zeta - beta * zfoc) + amrex::pow(zp - beta * k0 * (x + yp) * clight - 2._rt * I * (x + yp)*(zeta - beta * zfoc) * clight * inv_complex_waist_2, 2); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; From fc1c93967f3ecdec13be4128e41ceeb9934922bc Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 12 Aug 2024 15:56:54 +0200 Subject: [PATCH 016/254] add CI test to varify chirp inits --- examples/laser/analysis_laser_init_chirp | 96 ++++++++++++++++++++++++ tests/laser_init_check_chirp.sh | 54 +++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 examples/laser/analysis_laser_init_chirp create mode 100644 tests/laser_init_check_chirp.sh diff --git a/examples/laser/analysis_laser_init_chirp b/examples/laser/analysis_laser_init_chirp new file mode 100644 index 0000000000..6b077c57b6 --- /dev/null +++ b/examples/laser/analysis_laser_init_chirp @@ -0,0 +1,96 @@ +#! /usr/bin/env python3 + +# Copyright 2022 +# +# This file is part of HiPACE++. +# +# Authors: MaxThevenet +# License: BSD-3-Clause-LBNL + + +import matplotlib.pyplot as plt +import matplotlib +import argparse +import numpy as np +import scipy.constants as scc +import scipy +from openpmd_viewer.addons import LpaDiagnostics + +def get_zeta(Ar,m, w0,L): + # get spatial chirp zeta + nu = 0 + sum=0 + laser_module1=np.abs(Ar**2) + z_coord1=np.array(m.z) + y_coord1=np.array(m.x) + phi_envelop=np.array(np.arctan2(Ar.imag, Ar.real)) +#unwrap phi_envelop + phi_envelop = np.unwrap(phi_envelop, axis=0) + phi_envelop = np.unwrap(phi_envelop, axis=1) + #calculate pphi_pz/ + z_diff = np.diff(z_coord1) + y_diff = np.diff(y_coord1) + pphi_pz = (np.diff(phi_envelop, axis=0)).T/ (z_diff) + pphi_pzpy = ((np.diff(pphi_pz, axis=0)).T/(y_diff)) + for i in range(len(z_coord1)-2): + for j in range(len(y_coord1)-2): + nu=nu+pphi_pzpy[i,j]*laser_module1[i,j] + sum=sum+laser_module1[i,j] + a = 4 * nu * w0**2 * L**4 + b = -4 * scc.c + c = nu * w0**2 * L**2 + zeta_solutions = np.roots([a, b, c]) + return np.min(zeta_solutions) + +def get_phi2(Ar,m,tau): + #get temporal chirp phi2 + temp_chirp = 0 + sum=0 + laser_module1=np.abs(Ar) + z_coord1=np.array(m.z) + phi_envelop=np.array(np.arctan2(Ar.imag, Ar.real)) +#unwrap phi_envelop + phi_envelop = np.unwrap(phi_envelop, axis=0) + #calculate pphi_pz/ + z_diff = np.diff(z_coord1) + pphi_pz = (np.diff(phi_envelop, axis=0)).T/ (z_diff/scc.c) + pphi_pz2 = ((np.diff(pphi_pz, axis=1))/(z_diff[:len(z_diff)-1])/scc.c).T + for i in range(len(z_coord1)-2): + for j in range(len(y_coord1)-2): + temp_chirp=temp_chirp+pphi_pz2[i,j]*laser_module1[i,j] + sum=sum+laser_module1[i,j] + x=temp_chirp*scc.c**2/sum + a=4*x + b=-4 + c=tau**4*x + return np.max([(-b-np.sqrt(b**2-4*a*c))/(2*a),(-b+np.sqrt(b**2-4*a*c))/(2*a)]) + +parser = argparse.ArgumentParser(description='Verify the chirp initialization') +parser.add_argument('--output-dir', + dest='output_dir', + default='diags/hdf5', + help='Path to the directory containing output files') +parser.add_argument('--chirp_type', + dest='chirp_type', + default='phi2', + help='the type of the initialised chirp') +args = parser.parse_args() + + + +ts = LpaDiagnostics(args.output_dir) + +Ar, m = ts.get_field(field='laserEnvelope', iteration=0) + + +lam=.8e-6 # Laser wavelength +w0 = 30.e-6 # Laser waist +L0 = 5e-6 +tau = L0 / scc.c # Laser duration + +if chirp_type == 'phi2' : + phi2 = get_phi2(Ar, m, tau); + assert(np.abs(phi2-2.4e-26)/2.4e-26 < 2e-3) +else if chirp_type == zeta : + zeta = get_zeta(Ar, m, L0) + assert(np.abs(zeta-2.4e-26)/2.4e-26 < 2e-3) diff --git a/tests/laser_init_check_chirp.sh b/tests/laser_init_check_chirp.sh new file mode 100644 index 0000000000..a260a10b5b --- /dev/null +++ b/tests/laser_init_check_chirp.sh @@ -0,0 +1,54 @@ +#! /usr/bin/env bash + +# Copyright 2022 +# +# This file is part of HiPACE++. +# +# Authors: Xingjian Hui +# License: BSD-3-Clause-LBNL + + +# This file is part of the HiPACE++ test suite. +# It runs a Hipace simulation of a laser propagating in vacuum +# and compares width and a0 with theory + +# abort on first encounted error +set -eu -o pipefail + +# Read input parameters +HIPACE_EXECUTABLE=$1 +HIPACE_SOURCE_DIR=$2 + +HIPACE_EXAMPLE_DIR=${HIPACE_SOURCE_DIR}/examples/laser +HIPACE_TEST_DIR=${HIPACE_SOURCE_DIR}/tests + +FILE_NAME=`basename "$0"` +TEST_NAME="${FILE_NAME%.*}" + +# Relative tolerance for checksum tests depends on the platform +RTOL=1e-12 && [[ "$HIPACE_EXECUTABLE" == *"hipace"*".CUDA."* ]] && RTOL=1e-7 + + +# Run the simulation with initial phi2 +mpiexec -n 2 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ + laser.phi2 = 2.4e-26 \ + hipace.file_prefix = $TEST_NAME + laser.w0 = 30e-6 + laser.L0 = 5e-6 +# Compare the result with theory +$HIPACE_EXAMPLE_DIR/analysis_laser_vacuum_chirp.py --output-dir=$TEST_NAME \ + --chirp_type = phi2 + +rm -rf $TEST_NAME + +# Run the simulation with initial zeta +mpiexec -n 2 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ + laser.zeta = 2.4e-26 \ + hipace.file_prefix = $TEST_NAME + laser.w0 = 30e-6 + laser.L0 = 5e-6 +# Compare the result with theory +$HIPACE_EXAMPLE_DIR/analysis_laser_vacuum_chirp.py --output-dir=$TEST_NAME + --chirp_type = zeta + +rm -rf $TEST_NAME \ No newline at end of file From 814892617742bc2b0905a573ce586b3b5b9e12f2 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 12 Aug 2024 16:58:16 +0200 Subject: [PATCH 017/254] typoo --- examples/laser/analysis_laser_init_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp b/examples/laser/analysis_laser_init_chirp index 6b077c57b6..f822574700 100644 --- a/examples/laser/analysis_laser_init_chirp +++ b/examples/laser/analysis_laser_init_chirp @@ -91,6 +91,6 @@ tau = L0 / scc.c # Laser duration if chirp_type == 'phi2' : phi2 = get_phi2(Ar, m, tau); assert(np.abs(phi2-2.4e-26)/2.4e-26 < 2e-3) -else if chirp_type == zeta : +else if chirp_type == 'zeta' : zeta = get_zeta(Ar, m, L0) assert(np.abs(zeta-2.4e-26)/2.4e-26 < 2e-3) From 09fe97fd173dd9dcfb3f94cd1abbb71104c36b6c Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 12 Aug 2024 16:59:33 +0200 Subject: [PATCH 018/254] rename python test file --- .../{analysis_laser_init_chirp => analysis_laser_init_chirp.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/laser/{analysis_laser_init_chirp => analysis_laser_init_chirp.py} (100%) diff --git a/examples/laser/analysis_laser_init_chirp b/examples/laser/analysis_laser_init_chirp.py similarity index 100% rename from examples/laser/analysis_laser_init_chirp rename to examples/laser/analysis_laser_init_chirp.py From 718621bb33f333075b46bd7feead9c37bb570bf8 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 12 Aug 2024 17:00:52 +0200 Subject: [PATCH 019/254] fix some typoos --- tests/laser_init_check_chirp.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/laser_init_check_chirp.sh b/tests/laser_init_check_chirp.sh index a260a10b5b..76b09aad29 100644 --- a/tests/laser_init_check_chirp.sh +++ b/tests/laser_init_check_chirp.sh @@ -36,7 +36,7 @@ mpiexec -n 2 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ laser.w0 = 30e-6 laser.L0 = 5e-6 # Compare the result with theory -$HIPACE_EXAMPLE_DIR/analysis_laser_vacuum_chirp.py --output-dir=$TEST_NAME \ +$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ --chirp_type = phi2 rm -rf $TEST_NAME @@ -48,7 +48,7 @@ mpiexec -n 2 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ laser.w0 = 30e-6 laser.L0 = 5e-6 # Compare the result with theory -$HIPACE_EXAMPLE_DIR/analysis_laser_vacuum_chirp.py --output-dir=$TEST_NAME +$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME --chirp_type = zeta rm -rf $TEST_NAME \ No newline at end of file From 2a0655a31856e0014eb4466b115578b656b359db Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 12 Aug 2024 17:02:11 +0200 Subject: [PATCH 020/254] add endline slash --- tests/laser_init_check_chirp.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/laser_init_check_chirp.sh b/tests/laser_init_check_chirp.sh index 76b09aad29..411b0a264e 100644 --- a/tests/laser_init_check_chirp.sh +++ b/tests/laser_init_check_chirp.sh @@ -32,8 +32,8 @@ RTOL=1e-12 && [[ "$HIPACE_EXECUTABLE" == *"hipace"*".CUDA."* ]] && RTOL=1e-7 # Run the simulation with initial phi2 mpiexec -n 2 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ laser.phi2 = 2.4e-26 \ - hipace.file_prefix = $TEST_NAME - laser.w0 = 30e-6 + hipace.file_prefix = $TEST_NAME \ + laser.w0 = 30e-6 \ laser.L0 = 5e-6 # Compare the result with theory $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ @@ -44,11 +44,11 @@ rm -rf $TEST_NAME # Run the simulation with initial zeta mpiexec -n 2 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ laser.zeta = 2.4e-26 \ - hipace.file_prefix = $TEST_NAME - laser.w0 = 30e-6 - laser.L0 = 5e-6 + hipace.file_prefix = $TEST_NAME \ + laser.w0 = 30e-6 \ + laser.L0 = 5e-6 \ # Compare the result with theory -$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME +$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ --chirp_type = zeta rm -rf $TEST_NAME \ No newline at end of file From 2e41451a75ad57e740de6c0eae5f8ea08cb9efc1 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 12 Aug 2024 17:03:24 +0200 Subject: [PATCH 021/254] missing argument --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index f822574700..d04dc1835d 100644 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -92,5 +92,5 @@ def get_phi2(Ar,m,tau): phi2 = get_phi2(Ar, m, tau); assert(np.abs(phi2-2.4e-26)/2.4e-26 < 2e-3) else if chirp_type == 'zeta' : - zeta = get_zeta(Ar, m, L0) + zeta = get_zeta(Ar, m, w0,L0) assert(np.abs(zeta-2.4e-26)/2.4e-26 < 2e-3) From 3538fdc0cde5af5863b89684bce74ba6c1a0107d Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 12 Aug 2024 17:03:52 +0200 Subject: [PATCH 022/254] cancel comma in py script --- examples/laser/analysis_laser_init_chirp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index d04dc1835d..429a813c5c 100644 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -89,8 +89,8 @@ def get_phi2(Ar,m,tau): tau = L0 / scc.c # Laser duration if chirp_type == 'phi2' : - phi2 = get_phi2(Ar, m, tau); + phi2 = get_phi2(Ar, m, tau) assert(np.abs(phi2-2.4e-26)/2.4e-26 < 2e-3) else if chirp_type == 'zeta' : - zeta = get_zeta(Ar, m, w0,L0) + zeta = get_zeta(Ar, m, w0, L0) assert(np.abs(zeta-2.4e-26)/2.4e-26 < 2e-3) From 73cb837226bae1c98d9ba7f94aa54b2366674786 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 12 Aug 2024 17:09:40 +0200 Subject: [PATCH 023/254] cancel redundant variables in laser_init_check_chirp.sh --- tests/laser_init_check_chirp.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/laser_init_check_chirp.sh b/tests/laser_init_check_chirp.sh index 411b0a264e..58677b237f 100644 --- a/tests/laser_init_check_chirp.sh +++ b/tests/laser_init_check_chirp.sh @@ -25,10 +25,6 @@ HIPACE_TEST_DIR=${HIPACE_SOURCE_DIR}/tests FILE_NAME=`basename "$0"` TEST_NAME="${FILE_NAME%.*}" -# Relative tolerance for checksum tests depends on the platform -RTOL=1e-12 && [[ "$HIPACE_EXECUTABLE" == *"hipace"*".CUDA."* ]] && RTOL=1e-7 - - # Run the simulation with initial phi2 mpiexec -n 2 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ laser.phi2 = 2.4e-26 \ From d04fb411939634584417d8f3f3785a20587844cd Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 2 Sep 2024 16:14:57 +0200 Subject: [PATCH 024/254] add to Cmakelists --- CMakeLists.txt | 6 ++++++ examples/laser/analysis_laser_init_chirp.py | 2 +- ..._init_check_chirp.sh => laser_init_check_chirp.1Rank.sh} | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) rename tests/{laser_init_check_chirp.sh => laser_init_check_chirp.1Rank.sh} (90%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c0aeef1056..b55a3b3a46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -349,6 +349,12 @@ if(BUILD_TESTING) WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) + add_test(NAME laser_init_check_chirp.1Rank + COMMAND bash ${HiPACE_SOURCE_DIR}/tests/laser_init_check_chirp.1Rank.sh + $ ${HiPACE_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + ) + if (NOT HiPACE_COMPUTE STREQUAL CUDA) # These tests only run on CPU diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 429a813c5c..3494b7e0fa 100644 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -83,7 +83,7 @@ def get_phi2(Ar,m,tau): Ar, m = ts.get_field(field='laserEnvelope', iteration=0) -lam=.8e-6 # Laser wavelength +lambda0=.8e-6 # Laser wavelength w0 = 30.e-6 # Laser waist L0 = 5e-6 tau = L0 / scc.c # Laser duration diff --git a/tests/laser_init_check_chirp.sh b/tests/laser_init_check_chirp.1Rank.sh similarity index 90% rename from tests/laser_init_check_chirp.sh rename to tests/laser_init_check_chirp.1Rank.sh index 58677b237f..854328ea3e 100644 --- a/tests/laser_init_check_chirp.sh +++ b/tests/laser_init_check_chirp.1Rank.sh @@ -26,7 +26,7 @@ FILE_NAME=`basename "$0"` TEST_NAME="${FILE_NAME%.*}" # Run the simulation with initial phi2 -mpiexec -n 2 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ +mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ laser.phi2 = 2.4e-26 \ hipace.file_prefix = $TEST_NAME \ laser.w0 = 30e-6 \ @@ -38,7 +38,7 @@ $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ rm -rf $TEST_NAME # Run the simulation with initial zeta -mpiexec -n 2 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ +mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ laser.zeta = 2.4e-26 \ hipace.file_prefix = $TEST_NAME \ laser.w0 = 30e-6 \ From 01ca26f47d8f3029be688dcefe4b7630951e0f90 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 2 Sep 2024 16:23:07 +0200 Subject: [PATCH 025/254] fix typo in .py file --- examples/laser/analysis_laser_init_chirp.py | 8 ++++---- tests/laser_init_check_chirp.1Rank.sh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 3494b7e0fa..aa65c771a0 100644 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -88,9 +88,9 @@ def get_phi2(Ar,m,tau): L0 = 5e-6 tau = L0 / scc.c # Laser duration -if chirp_type == 'phi2' : +if args.chirp_type == 'phi2' : phi2 = get_phi2(Ar, m, tau) - assert(np.abs(phi2-2.4e-26)/2.4e-26 < 2e-3) -else if chirp_type == 'zeta' : + assert(np.abs(phi2-2.4e-26)/2.4e-26 < 2e-2) +else if args.chirp_type == 'zeta' : zeta = get_zeta(Ar, m, w0, L0) - assert(np.abs(zeta-2.4e-26)/2.4e-26 < 2e-3) + assert(np.abs(zeta-2.4e-26)/2.4e-26 < 2e-2) diff --git a/tests/laser_init_check_chirp.1Rank.sh b/tests/laser_init_check_chirp.1Rank.sh index 854328ea3e..f2b0b3128a 100644 --- a/tests/laser_init_check_chirp.1Rank.sh +++ b/tests/laser_init_check_chirp.1Rank.sh @@ -30,7 +30,7 @@ mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ laser.phi2 = 2.4e-26 \ hipace.file_prefix = $TEST_NAME \ laser.w0 = 30e-6 \ - laser.L0 = 5e-6 + laser.L0 = 5e-6 \ # Compare the result with theory $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ --chirp_type = phi2 From 9a303bb0f2e0d513c62220bb186c13b6279f424d Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 2 Sep 2024 16:31:02 +0200 Subject: [PATCH 026/254] delete previous test result --- tests/laser_evolution.SI.2Rank.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/laser_evolution.SI.2Rank.sh b/tests/laser_evolution.SI.2Rank.sh index ab0a3e2b27..f91fa558a5 100755 --- a/tests/laser_evolution.SI.2Rank.sh +++ b/tests/laser_evolution.SI.2Rank.sh @@ -50,3 +50,5 @@ $HIPACE_TEST_DIR/checksum/checksumAPI.py \ --rtol $RTOL \ --file_name $TEST_NAME \ --test-name $TEST_NAME + +rm -rf $TEST_NAME From 5ea5bde151a23889731b2bbfbfc11a63e3fc13dc Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 2 Sep 2024 16:43:01 +0200 Subject: [PATCH 027/254] fix typo on filename --- tests/laser_init_check_chirp.1Rank.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/laser_init_check_chirp.1Rank.sh b/tests/laser_init_check_chirp.1Rank.sh index f2b0b3128a..b44b13c000 100644 --- a/tests/laser_init_check_chirp.1Rank.sh +++ b/tests/laser_init_check_chirp.1Rank.sh @@ -32,7 +32,7 @@ mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ laser.w0 = 30e-6 \ laser.L0 = 5e-6 \ # Compare the result with theory -$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ +$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.1Rank.py --output-dir=$TEST_NAME \ --chirp_type = phi2 rm -rf $TEST_NAME @@ -44,7 +44,7 @@ mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ laser.w0 = 30e-6 \ laser.L0 = 5e-6 \ # Compare the result with theory -$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ +$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.1Rank.py --output-dir=$TEST_NAME \ --chirp_type = zeta rm -rf $TEST_NAME \ No newline at end of file From 08b79c31ded985d0cb68a76399da7dcc21dc765b Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 2 Sep 2024 16:54:09 +0200 Subject: [PATCH 028/254] fix the typo --- tests/laser_init_check_chirp.1Rank.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/laser_init_check_chirp.1Rank.sh b/tests/laser_init_check_chirp.1Rank.sh index b44b13c000..f2b0b3128a 100644 --- a/tests/laser_init_check_chirp.1Rank.sh +++ b/tests/laser_init_check_chirp.1Rank.sh @@ -32,7 +32,7 @@ mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ laser.w0 = 30e-6 \ laser.L0 = 5e-6 \ # Compare the result with theory -$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.1Rank.py --output-dir=$TEST_NAME \ +$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ --chirp_type = phi2 rm -rf $TEST_NAME @@ -44,7 +44,7 @@ mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ laser.w0 = 30e-6 \ laser.L0 = 5e-6 \ # Compare the result with theory -$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.1Rank.py --output-dir=$TEST_NAME \ +$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ --chirp_type = zeta rm -rf $TEST_NAME \ No newline at end of file From 9c6e8a8cd561849f77e8e629190c8e8363df7ae1 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 2 Sep 2024 16:57:18 +0200 Subject: [PATCH 029/254] add two debug lines in py testfile --- examples/laser/analysis_laser_init_chirp.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index aa65c771a0..32a280b770 100644 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -87,9 +87,10 @@ def get_phi2(Ar,m,tau): w0 = 30.e-6 # Laser waist L0 = 5e-6 tau = L0 / scc.c # Laser duration - +print(args.chirp_type) if args.chirp_type == 'phi2' : phi2 = get_phi2(Ar, m, tau) + print(phi2) assert(np.abs(phi2-2.4e-26)/2.4e-26 < 2e-2) else if args.chirp_type == 'zeta' : zeta = get_zeta(Ar, m, w0, L0) From 32be993782d9ce4541eb55c3af2e6c807c12ef3d Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 2 Sep 2024 17:09:09 +0200 Subject: [PATCH 030/254] chmod the python file --- examples/laser/analysis_laser_init_chirp.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 examples/laser/analysis_laser_init_chirp.py diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py old mode 100644 new mode 100755 From 59089806a77296dcec3975df8b48a4a1169355ec Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 2 Sep 2024 17:17:24 +0200 Subject: [PATCH 031/254] syntax error fixed --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 examples/laser/analysis_laser_init_chirp.py diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py old mode 100755 new mode 100644 index 32a280b770..33300cbdff --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -92,6 +92,6 @@ def get_phi2(Ar,m,tau): phi2 = get_phi2(Ar, m, tau) print(phi2) assert(np.abs(phi2-2.4e-26)/2.4e-26 < 2e-2) -else if args.chirp_type == 'zeta' : +elif args.chirp_type == 'zeta' : zeta = get_zeta(Ar, m, w0, L0) assert(np.abs(zeta-2.4e-26)/2.4e-26 < 2e-2) From 4df10730cf98f9af29efb7f9d567e7bb44a1a99b Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 2 Sep 2024 17:23:54 +0200 Subject: [PATCH 032/254] chmod py file --- examples/laser/analysis_laser_init_chirp.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 examples/laser/analysis_laser_init_chirp.py diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py old mode 100644 new mode 100755 From 65fc3ceb026801c5167445fe31c4c36c79c44567 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 2 Sep 2024 17:29:49 +0200 Subject: [PATCH 033/254] fix syntax error --- tests/laser_init_check_chirp.1Rank.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/laser_init_check_chirp.1Rank.sh b/tests/laser_init_check_chirp.1Rank.sh index f2b0b3128a..99433e34ef 100644 --- a/tests/laser_init_check_chirp.1Rank.sh +++ b/tests/laser_init_check_chirp.1Rank.sh @@ -33,7 +33,7 @@ mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ laser.L0 = 5e-6 \ # Compare the result with theory $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ - --chirp_type = phi2 + --chirp_type = "phi2" rm -rf $TEST_NAME @@ -45,6 +45,6 @@ mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ laser.L0 = 5e-6 \ # Compare the result with theory $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ - --chirp_type = zeta + --chirp_type = "zeta" rm -rf $TEST_NAME \ No newline at end of file From f908df7b53d10c63cf22b5a6620882f2037923da Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 2 Sep 2024 17:51:46 +0200 Subject: [PATCH 034/254] cancel the space --- examples/laser/analysis_laser_init_chirp.py | 2 +- tests/laser_init_check_chirp.1Rank.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 33300cbdff..af4f099d1e 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -94,4 +94,4 @@ def get_phi2(Ar,m,tau): assert(np.abs(phi2-2.4e-26)/2.4e-26 < 2e-2) elif args.chirp_type == 'zeta' : zeta = get_zeta(Ar, m, w0, L0) - assert(np.abs(zeta-2.4e-26)/2.4e-26 < 2e-2) + assert(np.abs(zeta-2.4e-26)/2.4e-26 < 2e-2) \ No newline at end of file diff --git a/tests/laser_init_check_chirp.1Rank.sh b/tests/laser_init_check_chirp.1Rank.sh index 99433e34ef..60dfe5e7d8 100644 --- a/tests/laser_init_check_chirp.1Rank.sh +++ b/tests/laser_init_check_chirp.1Rank.sh @@ -33,7 +33,7 @@ mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ laser.L0 = 5e-6 \ # Compare the result with theory $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ - --chirp_type = "phi2" + --chirp_type="phi2" rm -rf $TEST_NAME @@ -45,6 +45,6 @@ mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ laser.L0 = 5e-6 \ # Compare the result with theory $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ - --chirp_type = "zeta" + --chirp_type="zeta" rm -rf $TEST_NAME \ No newline at end of file From 362fb055c51b3e811e77e873f66cd8e005811ebd Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 2 Sep 2024 17:56:50 +0200 Subject: [PATCH 035/254] fix bug in python --- examples/laser/analysis_laser_init_chirp.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index af4f099d1e..b18c236fcf 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -47,6 +47,7 @@ def get_phi2(Ar,m,tau): temp_chirp = 0 sum=0 laser_module1=np.abs(Ar) + y_coord1=np.array(m.x) z_coord1=np.array(m.z) phi_envelop=np.array(np.arctan2(Ar.imag, Ar.real)) #unwrap phi_envelop From 81d945f07aa50b9b68b2f10247afaa9e57cd694c Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 2 Sep 2024 18:08:49 +0200 Subject: [PATCH 036/254] debug on zeta --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index b18c236fcf..fb1b8254d2 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -88,7 +88,7 @@ def get_phi2(Ar,m,tau): w0 = 30.e-6 # Laser waist L0 = 5e-6 tau = L0 / scc.c # Laser duration -print(args.chirp_type) +print(get_zeta(Ar, m, w0, L0)) if args.chirp_type == 'phi2' : phi2 = get_phi2(Ar, m, tau) print(phi2) From 0dca6bc4d9f01484a0fb79778c987d925e37be93 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 3 Sep 2024 10:01:32 +0200 Subject: [PATCH 037/254] change the resolution on the CI input --- examples/laser/inputs_SI | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_SI b/examples/laser/inputs_SI index f8bf580a38..d7b9bee523 100644 --- a/examples/laser/inputs_SI +++ b/examples/laser/inputs_SI @@ -2,7 +2,7 @@ max_step = 30 hipace.dt = 70.e-6/clight hipace.verbose=3 -amr.n_cell = 128 128 50 # 128 128 100 +amr.n_cell = 512 512 100 # 128 128 100 my_constants.kp_inv = 10.e-6 From e89bba10e3ee7e7808dc3d033d8c3d22717d8e61 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 3 Sep 2024 10:39:20 +0200 Subject: [PATCH 038/254] debug on the py file --- examples/laser/analysis_laser_init_chirp.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index fb1b8254d2..25af6273ad 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -36,6 +36,7 @@ def get_zeta(Ar,m, w0,L): for j in range(len(y_coord1)-2): nu=nu+pphi_pzpy[i,j]*laser_module1[i,j] sum=sum+laser_module1[i,j] + nu = nu / sum / scc.c a = 4 * nu * w0**2 * L**4 b = -4 * scc.c c = nu * w0**2 * L**2 From 5a0f6da0e43207a9e6d7a1751b0383c0626cfe1f Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 3 Sep 2024 10:49:17 +0200 Subject: [PATCH 039/254] fix typo in py --- examples/laser/analysis_laser_init_chirp.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 25af6273ad..3ed307c903 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -17,26 +17,25 @@ from openpmd_viewer.addons import LpaDiagnostics def get_zeta(Ar,m, w0,L): - # get spatial chirp zeta nu = 0 sum=0 laser_module1=np.abs(Ar**2) z_coord1=np.array(m.z) y_coord1=np.array(m.x) phi_envelop=np.array(np.arctan2(Ar.imag, Ar.real)) -#unwrap phi_envelop + #unwrap phi_envelop phi_envelop = np.unwrap(phi_envelop, axis=0) phi_envelop = np.unwrap(phi_envelop, axis=1) #calculate pphi_pz/ z_diff = np.diff(z_coord1) y_diff = np.diff(y_coord1) - pphi_pz = (np.diff(phi_envelop, axis=0)).T/ (z_diff) + pphi_pz = (np.diff(phi_envelop, axis=0)).T/ (z_diff/scc.c) pphi_pzpy = ((np.diff(pphi_pz, axis=0)).T/(y_diff)) for i in range(len(z_coord1)-2): for j in range(len(y_coord1)-2): nu=nu+pphi_pzpy[i,j]*laser_module1[i,j] sum=sum+laser_module1[i,j] - nu = nu / sum / scc.c + nu= nu/scc.c/ sum a = 4 * nu * w0**2 * L**4 b = -4 * scc.c c = nu * w0**2 * L**2 From 8176a781b38436dfd01b61e904c9afe7f4549f41 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 3 Sep 2024 11:11:26 +0200 Subject: [PATCH 040/254] change the resolution try again --- examples/laser/analysis_laser_init_chirp.py | 3 +-- examples/laser/inputs_SI | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 3ed307c903..cfa9d3bfc8 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -35,7 +35,7 @@ def get_zeta(Ar,m, w0,L): for j in range(len(y_coord1)-2): nu=nu+pphi_pzpy[i,j]*laser_module1[i,j] sum=sum+laser_module1[i,j] - nu= nu/scc.c/ sum + nu= nu / scc.c / sum a = 4 * nu * w0**2 * L**4 b = -4 * scc.c c = nu * w0**2 * L**2 @@ -91,7 +91,6 @@ def get_phi2(Ar,m,tau): print(get_zeta(Ar, m, w0, L0)) if args.chirp_type == 'phi2' : phi2 = get_phi2(Ar, m, tau) - print(phi2) assert(np.abs(phi2-2.4e-26)/2.4e-26 < 2e-2) elif args.chirp_type == 'zeta' : zeta = get_zeta(Ar, m, w0, L0) diff --git a/examples/laser/inputs_SI b/examples/laser/inputs_SI index d7b9bee523..fd8e68b677 100644 --- a/examples/laser/inputs_SI +++ b/examples/laser/inputs_SI @@ -2,7 +2,7 @@ max_step = 30 hipace.dt = 70.e-6/clight hipace.verbose=3 -amr.n_cell = 512 512 100 # 128 128 100 +amr.n_cell = 512 512 1000 # 128 128 100 my_constants.kp_inv = 10.e-6 From 18658e42a105e3426b408c5f447b96dab175bf4d Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 3 Sep 2024 12:22:10 +0200 Subject: [PATCH 041/254] changer the resolution --- examples/laser/analysis_laser_init_chirp.py | 0 examples/laser/inputs_SI | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) mode change 100755 => 100644 examples/laser/analysis_laser_init_chirp.py diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py old mode 100755 new mode 100644 diff --git a/examples/laser/inputs_SI b/examples/laser/inputs_SI index fd8e68b677..848d466d6d 100644 --- a/examples/laser/inputs_SI +++ b/examples/laser/inputs_SI @@ -2,15 +2,15 @@ max_step = 30 hipace.dt = 70.e-6/clight hipace.verbose=3 -amr.n_cell = 512 512 1000 # 128 128 100 +amr.n_cell = 512 512 500 # 128 128 100 my_constants.kp_inv = 10.e-6 hipace.file_prefix = new hipace.do_tiling = 0 -geometry.prob_lo = -6.*kp_inv -6.*kp_inv -8.*kp_inv -geometry.prob_hi = 6.*kp_inv 6.*kp_inv 6.*kp_inv +geometry.prob_lo = -6.*kp_inv -6.*kp_inv -4.*kp_inv +geometry.prob_hi = 6.*kp_inv 6.*kp_inv 4.*kp_inv lasers.names = laser lasers.lambda0 = .8e-6 From b9e50f575f6729777b63f8c6d9a1c845285b6495 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 3 Sep 2024 12:22:29 +0200 Subject: [PATCH 042/254] give permisiion --- examples/laser/analysis_laser_init_chirp.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 examples/laser/analysis_laser_init_chirp.py diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py old mode 100644 new mode 100755 From 406c78a6fc576d13e96b8f44b2f9cdac783668a1 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 3 Sep 2024 12:34:23 +0200 Subject: [PATCH 043/254] change the resolution one more time --- examples/laser/inputs_SI | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_SI b/examples/laser/inputs_SI index 848d466d6d..919ad6d7d5 100644 --- a/examples/laser/inputs_SI +++ b/examples/laser/inputs_SI @@ -2,7 +2,7 @@ max_step = 30 hipace.dt = 70.e-6/clight hipace.verbose=3 -amr.n_cell = 512 512 500 # 128 128 100 +amr.n_cell = 256 256 1000 # 128 128 100 my_constants.kp_inv = 10.e-6 From 0d23f9714374b5799f697c877bde9905fe3e8c0e Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 3 Sep 2024 15:49:10 +0200 Subject: [PATCH 044/254] ad new input script for chirp test --- examples/laser/analysis_laser_init_chirp.py | 2 +- examples/laser/inputs_SI | 2 +- examples/laser/inputs_chirp | 31 +++++++++++++++++++++ tests/laser_init_check_chirp.1Rank.sh | 11 +++----- 4 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 examples/laser/inputs_chirp diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index cfa9d3bfc8..5b596f7d8f 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -94,4 +94,4 @@ def get_phi2(Ar,m,tau): assert(np.abs(phi2-2.4e-26)/2.4e-26 < 2e-2) elif args.chirp_type == 'zeta' : zeta = get_zeta(Ar, m, w0, L0) - assert(np.abs(zeta-2.4e-26)/2.4e-26 < 2e-2) \ No newline at end of file + assert(np.abs(zeta-2.4e-26)/2.4e-26 < 1e-1) \ No newline at end of file diff --git a/examples/laser/inputs_SI b/examples/laser/inputs_SI index 919ad6d7d5..2594baaa22 100644 --- a/examples/laser/inputs_SI +++ b/examples/laser/inputs_SI @@ -2,7 +2,7 @@ max_step = 30 hipace.dt = 70.e-6/clight hipace.verbose=3 -amr.n_cell = 256 256 1000 # 128 128 100 +amr.n_cell = 128 128 100 my_constants.kp_inv = 10.e-6 diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp new file mode 100644 index 0000000000..450885b7c2 --- /dev/null +++ b/examples/laser/inputs_chirp @@ -0,0 +1,31 @@ +max_step = 1 +hipace.dt = 70.e-6/clight +hipace.verbose=3 + +amr.n_cell = 1023 256 1000 # 128 128 100 + +my_constants.kp_inv = 10.e-6 + +hipace.file_prefix = new +hipace.do_tiling = 0 + +geometry.prob_lo = -15.*kp_inv -15.*kp_inv -2.*kp_inv +geometry.prob_hi = 15.*kp_inv 15.*kp_inv 2.*kp_inv + +lasers.names = laser +lasers.lambda0 = .8e-6 + +laser.a0 = 1 +laser.position_mean = 0. 0. 0 +laser.focal_distance = 0.0 +laser.w0 = 30e-6 \ +laser.L0 = 5e-6 \ +amr.max_level = 0 + +diagnostic.output_period = 1 + +hipace.depos_order_xy = 0 + +geometry.is_periodic = true true false # Is periodic? + +diagnostic.diag_type = xz diff --git a/tests/laser_init_check_chirp.1Rank.sh b/tests/laser_init_check_chirp.1Rank.sh index 60dfe5e7d8..2c049ca7f0 100644 --- a/tests/laser_init_check_chirp.1Rank.sh +++ b/tests/laser_init_check_chirp.1Rank.sh @@ -26,11 +26,9 @@ FILE_NAME=`basename "$0"` TEST_NAME="${FILE_NAME%.*}" # Run the simulation with initial phi2 -mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ +mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ laser.phi2 = 2.4e-26 \ hipace.file_prefix = $TEST_NAME \ - laser.w0 = 30e-6 \ - laser.L0 = 5e-6 \ # Compare the result with theory $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ --chirp_type="phi2" @@ -38,11 +36,10 @@ $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ rm -rf $TEST_NAME # Run the simulation with initial zeta -mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ - laser.zeta = 2.4e-26 \ +mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ + laser.zeta = 2.4e-19 \ hipace.file_prefix = $TEST_NAME \ - laser.w0 = 30e-6 \ - laser.L0 = 5e-6 \ + # Compare the result with theory $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ --chirp_type="zeta" From 27cc3e7634a1c5efa2e2796a2c03eb1955c45181 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 3 Sep 2024 15:50:48 +0200 Subject: [PATCH 045/254] change test value of zeta --- examples/laser/analysis_laser_init_chirp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 5b596f7d8f..12f6fe24a6 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -91,7 +91,7 @@ def get_phi2(Ar,m,tau): print(get_zeta(Ar, m, w0, L0)) if args.chirp_type == 'phi2' : phi2 = get_phi2(Ar, m, tau) - assert(np.abs(phi2-2.4e-26)/2.4e-26 < 2e-2) + assert(np.abs(phi2-2.4e-26)/2.4e-26 < 1e-2) elif args.chirp_type == 'zeta' : zeta = get_zeta(Ar, m, w0, L0) - assert(np.abs(zeta-2.4e-26)/2.4e-26 < 1e-1) \ No newline at end of file + assert(np.abs(zeta-2.4e-19)/2.4e-19 < 1e-2) \ No newline at end of file From dabe3894c9e1a7c61b38893703283652963884d4 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 3 Sep 2024 16:00:34 +0200 Subject: [PATCH 046/254] modify inputscripts --- examples/laser/inputs_SI | 6 +++--- examples/laser/inputs_chirp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/laser/inputs_SI b/examples/laser/inputs_SI index 2594baaa22..e3e02c3d3e 100644 --- a/examples/laser/inputs_SI +++ b/examples/laser/inputs_SI @@ -2,15 +2,15 @@ max_step = 30 hipace.dt = 70.e-6/clight hipace.verbose=3 -amr.n_cell = 128 128 100 +amr.n_cell = 128 128 50 my_constants.kp_inv = 10.e-6 hipace.file_prefix = new hipace.do_tiling = 0 -geometry.prob_lo = -6.*kp_inv -6.*kp_inv -4.*kp_inv -geometry.prob_hi = 6.*kp_inv 6.*kp_inv 4.*kp_inv +geometry.prob_lo = -6.*kp_inv -6.*kp_inv -8.*kp_inv +geometry.prob_hi = 6.*kp_inv 6.*kp_inv 6.*kp_inv lasers.names = laser lasers.lambda0 = .8e-6 diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 450885b7c2..e8ec753961 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,7 +2,7 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose=3 -amr.n_cell = 1023 256 1000 # 128 128 100 +amr.n_cell = 1023 255 1000 # 128 128 100 my_constants.kp_inv = 10.e-6 From 992cc79b751bf827fee83c5cadd5a28107a4ea0d Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 3 Sep 2024 16:10:44 +0200 Subject: [PATCH 047/254] reduce the resolution of chirp test --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index e8ec753961..4b54c4284b 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,7 +2,7 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose=3 -amr.n_cell = 1023 255 1000 # 128 128 100 +amr.n_cell = 511 255 500 # 128 128 100 my_constants.kp_inv = 10.e-6 From 51492ee06e802b99ffa7c19dcaed755f1f9c4674 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 3 Sep 2024 17:20:10 +0200 Subject: [PATCH 048/254] Further reduce the resoultion --- examples/laser/analysis_laser_init_chirp.py | 1 - examples/laser/inputs_chirp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 12f6fe24a6..51dd164a29 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -88,7 +88,6 @@ def get_phi2(Ar,m,tau): w0 = 30.e-6 # Laser waist L0 = 5e-6 tau = L0 / scc.c # Laser duration -print(get_zeta(Ar, m, w0, L0)) if args.chirp_type == 'phi2' : phi2 = get_phi2(Ar, m, tau) assert(np.abs(phi2-2.4e-26)/2.4e-26 < 1e-2) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 4b54c4284b..1197a96b8b 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,7 +2,7 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose=3 -amr.n_cell = 511 255 500 # 128 128 100 +amr.n_cell = 255 127 200 # 128 128 100 my_constants.kp_inv = 10.e-6 From 820ca99e8be5703ec7adf0632b74669ddf08780c Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 4 Sep 2024 15:11:07 +0200 Subject: [PATCH 049/254] change L/c to tau --- src/laser/MultiLaser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 7845f4ae1c..8cd7f2400b 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -1200,8 +1200,8 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) // Time stretching due to STCs and phi2 complex envelope // (1 if zeta=0, beta=0, phi2=0) Complex stretch_factor = 1._rt \ - + 4._rt * (zeta + beta * zfoc * clight * clight / (L0 * L0)) * (zeta + beta * zfoc * inv_complex_waist_2) \ - + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * clight * clight/ (L0 * L0); + + 4._rt * (zeta + beta * zfoc / (tau * tau)) * (zeta + beta * zfoc * inv_complex_waist_2) \ + + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) / (tau * tau); Complex prefactor = a0 / diffract_factor; Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * amrex::pow(zp - beta * k0 * (x + yp) * clight - 2._rt * I * (x + yp)*(zeta - beta * zfoc) From 2c7d30b8d059904e95f366ce488d86e6ab34f919 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 4 Sep 2024 16:21:58 +0200 Subject: [PATCH 050/254] FIXED input script --- examples/laser/inputs_chirp | 4 +++- src/laser/MultiLaser.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 1197a96b8b..e15ef7e381 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -26,6 +26,8 @@ diagnostic.output_period = 1 hipace.depos_order_xy = 0 -geometry.is_periodic = true true false # Is periodic? +geometry.is_periodic = 0 0 0 # Is periodic? +boundary.field = Dirichlet +boundary.particle = Absorbing diagnostic.diag_type = xz diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 8cd7f2400b..4e37add46b 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -1162,7 +1162,7 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) } else if (laser.m_laser_init_type == "gaussian") { const amrex::Real a0 = laser.m_a0; - const amrex::Real w0 = laser.m_w0; + const amrex::Real w0_2 = laser.m_w0 * laser.m_w0; const amrex::Real cep = laser.m_CEP; const amrex::Real propagation_angle_yz = laser.m_propagation_angle_yz; const amrex::Real PFT_yz = laser.m_PFT_yz - MathConst::pi/2.0; @@ -1170,7 +1170,7 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) const amrex::Real y0 = laser.m_position_mean[1]; const amrex::Real z0 = laser.m_position_mean[2]; const amrex::Real L0 = laser.m_L0; - const amrex::Real tau = laser.m_tau; + const amrex::Real inv_tau2 = 1/(laser.m_tau*laser.m_tau); const amrex::Real zfoc = laser.m_focal_distance; const amrex::Real zeta = laser.m_zeta; const amrex::Real beta = laser.m_beta; @@ -1195,13 +1195,13 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) } // Compute envelope for time step 0 Complex diffract_factor = 1._rt + I * ( zp - zfoc + z0 * std::cos( propagation_angle_yz ) ) \ - * 2._rt/( k0 * w0 * w0 ); - Complex inv_complex_waist_2 = 1._rt /( w0 * w0 * diffract_factor ); + * 2._rt/(k0 * w0_2); + Complex inv_complex_waist_2 = 1._rt /(w0_2 * diffract_factor); // Time stretching due to STCs and phi2 complex envelope // (1 if zeta=0, beta=0, phi2=0) Complex stretch_factor = 1._rt \ - + 4._rt * (zeta + beta * zfoc / (tau * tau)) * (zeta + beta * zfoc * inv_complex_waist_2) \ - + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) / (tau * tau); + + 4._rt * (zeta + beta * zfoc * inv_tau2) * (zeta + beta * zfoc * inv_complex_waist_2) \ + + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * inv_tau2; Complex prefactor = a0 / diffract_factor; Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * amrex::pow(zp - beta * k0 * (x + yp) * clight - 2._rt * I * (x + yp)*(zeta - beta * zfoc) From 554acf4baa9aece98e2d130c0d2324bb1317a5e5 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 4 Sep 2024 17:21:34 +0200 Subject: [PATCH 051/254] change the new boundary condition set --- examples/laser/inputs_chirp | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index e15ef7e381..9eda04016d 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -26,7 +26,6 @@ diagnostic.output_period = 1 hipace.depos_order_xy = 0 -geometry.is_periodic = 0 0 0 # Is periodic? boundary.field = Dirichlet boundary.particle = Absorbing From 1b2f2d796f9fd588f62b462bbc9fe17f9b53371d Mon Sep 17 00:00:00 2001 From: huixingjian Date: Thu, 5 Sep 2024 11:27:04 +0200 Subject: [PATCH 052/254] add check for beta --- examples/laser/analysis_laser_init_chirp.py | 33 ++++++++++++++++++++- tests/laser_init_check_chirp.1Rank.sh | 10 +++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 51dd164a29..898e5a4e93 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -65,6 +65,34 @@ def get_phi2(Ar,m,tau): b=-4 c=tau**4*x return np.max([(-b-np.sqrt(b**2-4*a*c))/(2*a),(-b+np.sqrt(b**2-4*a*c))/(2*a)]) +def get_centroids(F, x, z, dim='x'): + """Calculates centroids from matrix F. + dim = 'x' or 'y' + The laser must propagate along the last dimension. + Centroids are calculated along dimension dim """ + if dim == 'x': + idim_sum = 1 + elif dim == 'y': + idim_sum = 0 + if np.ndim(F) == 2: + 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) + elif np.ndim(F) == 3: + index_array = np.mgrid[0:F.shape[0],0:F.shape[1],0:F.shape[2]][2] + centroids = np.sum(np.sum(index_array * np.abs(F**2), axis=2), axis=idim_sum)/\ + np.sum(np.sum(np.abs(F**2),axis=2),axis=idim_sum) +def get_beta(F,m, dim='x'): + z_centroids = get_centroids(F.T, m.x, m.z) + if np.ndim(F.T) == 2: + weight = np.mean(np.abs(F.T)**2,axis=np.ndim(F)-1) + if np.ndim(F.T) == 3: + if dim == 'x': + idim_sum = 1 + elif dim == 'y': + idim_sum = 0 + weight = np.mean(np.abs(F.T)**2,axis=(np.ndim(F.T)-1, idim_sum)) + derivative = np.gradient(z_centroids) / ( m.x[1] - m.x[0] ) + return (np.sum(derivative * weight) / np.sum(weight))/k0/scc.c parser = argparse.ArgumentParser(description='Verify the chirp initialization') parser.add_argument('--output-dir', @@ -93,4 +121,7 @@ def get_phi2(Ar,m,tau): assert(np.abs(phi2-2.4e-26)/2.4e-26 < 1e-2) elif args.chirp_type == 'zeta' : zeta = get_zeta(Ar, m, w0, L0) - assert(np.abs(zeta-2.4e-19)/2.4e-19 < 1e-2) \ No newline at end of file + assert(np.abs(zeta-2.4e-19)/2.4e-19 < 1e-2) + elif args.chirp_type == 'beta' : +beta = get_beta(Ar, m) + assert(np.abs(beta-2e-17)/2e-17 < 1e-2) diff --git a/tests/laser_init_check_chirp.1Rank.sh b/tests/laser_init_check_chirp.1Rank.sh index 2c049ca7f0..89b8ea3ef0 100644 --- a/tests/laser_init_check_chirp.1Rank.sh +++ b/tests/laser_init_check_chirp.1Rank.sh @@ -44,4 +44,14 @@ mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ --chirp_type="zeta" +rm -rf $TEST_NAME + +mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ + laser.beta= 2e-17 \ + hipace.file_prefix = $TEST_NAME \ + +# Compare the result with theory +$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ + --chirp_type="beta" + rm -rf $TEST_NAME \ No newline at end of file From 97058f98f96e4727011f0718b37e4a0473deebb8 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Thu, 5 Sep 2024 12:33:31 +0200 Subject: [PATCH 053/254] DEBUG beta check --- examples/laser/analysis_laser_init_chirp.py | 52 ++++++++------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 898e5a4e93..9a88020488 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -19,22 +19,19 @@ def get_zeta(Ar,m, w0,L): nu = 0 sum=0 - laser_module1=np.abs(Ar**2) - z_coord1=np.array(m.z) - y_coord1=np.array(m.x) + laser_module=np.abs(Ar**2) phi_envelop=np.array(np.arctan2(Ar.imag, Ar.real)) #unwrap phi_envelop - phi_envelop = np.unwrap(phi_envelop, axis=0) - phi_envelop = np.unwrap(phi_envelop, axis=1) + phi_envelop = np.unwrap(np.unwrap(phi_envelop, axis=0),axis=1) #calculate pphi_pz/ - z_diff = np.diff(z_coord1) - y_diff = np.diff(y_coord1) + 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/(y_diff)) - for i in range(len(z_coord1)-2): - for j in range(len(y_coord1)-2): - nu=nu+pphi_pzpy[i,j]*laser_module1[i,j] - sum=sum+laser_module1[i,j] + 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] + sum=sum+laser_module[i,j] nu= nu / scc.c / sum a = 4 * nu * w0**2 * L**4 b = -4 * scc.c @@ -47,17 +44,13 @@ def get_phi2(Ar,m,tau): temp_chirp = 0 sum=0 laser_module1=np.abs(Ar) - y_coord1=np.array(m.x) - z_coord1=np.array(m.z) - phi_envelop=np.array(np.arctan2(Ar.imag, Ar.real)) -#unwrap phi_envelop - phi_envelop = np.unwrap(phi_envelop, axis=0) + phi_envelop=np.unwrap(np.array(np.arctan2(Ar.imag, Ar.real)),axis=0) #calculate pphi_pz/ z_diff = np.diff(z_coord1) pphi_pz = (np.diff(phi_envelop, axis=0)).T/ (z_diff/scc.c) pphi_pz2 = ((np.diff(pphi_pz, axis=1))/(z_diff[:len(z_diff)-1])/scc.c).T - for i in range(len(z_coord1)-2): - for j in range(len(y_coord1)-2): + 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] sum=sum+laser_module1[i,j] x=temp_chirp*scc.c**2/sum @@ -70,27 +63,20 @@ def get_centroids(F, x, z, dim='x'): dim = 'x' or 'y' The laser must propagate along the last dimension. Centroids are calculated along dimension dim """ - if dim == 'x': - idim_sum = 1 - elif dim == 'y': - idim_sum = 0 if np.ndim(F) == 2: 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) elif np.ndim(F) == 3: index_array = np.mgrid[0:F.shape[0],0:F.shape[1],0:F.shape[2]][2] - centroids = np.sum(np.sum(index_array * np.abs(F**2), axis=2), axis=idim_sum)/\ - np.sum(np.sum(np.abs(F**2),axis=2),axis=idim_sum) -def get_beta(F,m, dim='x'): + centroids = np.sum(np.sum(index_array * np.abs(F**2), axis=2), axis=1)/\ + np.sum(np.sum(np.abs(F**2),axis=2),axis=1) + return z[centroids.astype(int)] +def get_beta(F,m): z_centroids = get_centroids(F.T, m.x, m.z) if np.ndim(F.T) == 2: weight = np.mean(np.abs(F.T)**2,axis=np.ndim(F)-1) if np.ndim(F.T) == 3: - if dim == 'x': - idim_sum = 1 - elif dim == 'y': - idim_sum = 0 - weight = np.mean(np.abs(F.T)**2,axis=(np.ndim(F.T)-1, idim_sum)) + weight = np.mean(np.abs(F.T)**2,axis=(np.ndim(F.T)-1, 1)) derivative = np.gradient(z_centroids) / ( m.x[1] - m.x[0] ) return (np.sum(derivative * weight) / np.sum(weight))/k0/scc.c @@ -122,6 +108,6 @@ def get_beta(F,m, dim='x'): elif args.chirp_type == 'zeta' : zeta = get_zeta(Ar, m, w0, L0) assert(np.abs(zeta-2.4e-19)/2.4e-19 < 1e-2) - elif args.chirp_type == 'beta' : -beta = get_beta(Ar, m) +elif args.chirp_type == 'beta' : + beta = get_beta(Ar, m) assert(np.abs(beta-2e-17)/2e-17 < 1e-2) From bd13b8b0f4801fc70b3efc0370a6011e157c9652 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Thu, 5 Sep 2024 12:41:01 +0200 Subject: [PATCH 054/254] simplify the code --- examples/laser/analysis_laser_init_chirp.py | 30 +++++++-------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 9a88020488..8a23b81c49 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -22,7 +22,7 @@ def get_zeta(Ar,m, w0,L): laser_module=np.abs(Ar**2) 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) + 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) @@ -44,9 +44,9 @@ def get_phi2(Ar,m,tau): temp_chirp = 0 sum=0 laser_module1=np.abs(Ar) - phi_envelop=np.unwrap(np.array(np.arctan2(Ar.imag, Ar.real)),axis=0) + phi_envelop=np.unwrap(np.array(np.arctan2(Ar.imag, Ar.real)),axis=0) #calculate pphi_pz/ - z_diff = np.diff(z_coord1) + z_diff = np.diff(m.z) pphi_pz = (np.diff(phi_envelop, axis=0)).T/ (z_diff/scc.c) pphi_pz2 = ((np.diff(pphi_pz, axis=1))/(z_diff[:len(z_diff)-1])/scc.c).T for i in range(len(m.z)-2): @@ -57,26 +57,16 @@ def get_phi2(Ar,m,tau): a=4*x b=-4 c=tau**4*x - return np.max([(-b-np.sqrt(b**2-4*a*c))/(2*a),(-b+np.sqrt(b**2-4*a*c))/(2*a)]) -def get_centroids(F, x, z, dim='x'): - """Calculates centroids from matrix F. - dim = 'x' or 'y' - The laser must propagate along the last dimension. - Centroids are calculated along dimension dim """ - if np.ndim(F) == 2: - 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) - elif np.ndim(F) == 3: - index_array = np.mgrid[0:F.shape[0],0:F.shape[1],0:F.shape[2]][2] - centroids = np.sum(np.sum(index_array * np.abs(F**2), axis=2), axis=1)/\ - np.sum(np.sum(np.abs(F**2),axis=2),axis=1) + zeta_solutions = np.roots([a, b, c]) + return np.max(zeta_solutions) + +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): z_centroids = get_centroids(F.T, m.x, m.z) - if np.ndim(F.T) == 2: - weight = np.mean(np.abs(F.T)**2,axis=np.ndim(F)-1) - if np.ndim(F.T) == 3: - weight = np.mean(np.abs(F.T)**2,axis=(np.ndim(F.T)-1, 1)) + 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 From 8a689e7a162245ac049a079ec29f5347ab354384 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Thu, 5 Sep 2024 12:48:56 +0200 Subject: [PATCH 055/254] add k0 --- examples/laser/analysis_laser_init_chirp.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 8a23b81c49..bd117e5eef 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -19,7 +19,7 @@ def get_zeta(Ar,m, w0,L): nu = 0 sum=0 - laser_module=np.abs(Ar**2) + laser_module=np.abs(Ar) 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) @@ -65,6 +65,7 @@ def get_centroids(F, x, z): 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 = 2 *scc.pi / 800e-9 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] ) From 834842068c69a533d1051551cc5ea57333bf7110 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Fri, 6 Sep 2024 16:32:38 +0200 Subject: [PATCH 056/254] Standardize the code --- docs/source/run/parameters.rst | 12 ++++++------ examples/laser/analysis_laser_init_chirp.py | 19 ++++++++----------- examples/laser/inputs_chirp | 2 +- tests/laser_init_check_chirp.1Rank.sh | 2 +- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index 7c0b03ec69..7569f217f3 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -883,13 +883,13 @@ Option: ``gaussian`` Pulse front tilt angle on yz plane - the angle between the pulse front (maximum intensity contour)and the propagation direction defined by [Selcuk Akturk Opt. Express 12 (2004)](pi/2 is no PFT) -* ``.beta`` (`float`) optinal (default `0.`) - Angular dispersion (or angular chirp) at focus defined by [Selcuk Akturk Opt. Express 12 (2004)] +* ``.beta`` (`float`) optional (default `0.`) + Angular dispersion (or angular chirp) at focus defined by `S. Akturk et al., Optics Express 12, 4399 (2004) `__. -* ``.zeta`` (`float`) optinal (default `0.`) - Spatial chirp at focus defined by [Selcuk Akturk Opt. Express 12 (2004)] +* ``.zeta`` (`float`) optional (default `0.`) + Spatial chirp at focus defined by `S. Akturk et al., Optics Express 12, 4399 (2004) `__. -* ``.phi2`` (`float`) optinal (default `pi/2`) +* ``.phi2`` (`float`) optional (default `pi/2`) The amount of temporal chirp :math:`\phi^{(2)}` at focus (in the lab frame). Namely, a wave packet centered on the frequency :math:`(\omega_0 + \delta \omega)` will reach its peak intensity at :math:`z(\delta \omega) = z_0 - c \phi^{(2)} \, \delta \omega`. Thus, a positive @@ -908,7 +908,7 @@ Option: ``gaussian`` \tau' = \sqrt{ \tau^2 + 4 (\phi^{(2)})^2/\tau^2 } - See also the definition in [Selcuk Akturk Opt. Express 12 (2004)]. + See also the definition in `S. Akturk et al., Optics Express 12, 4399 (2004) `__. diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index bd117e5eef..7bb68cb597 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -4,7 +4,7 @@ # # This file is part of HiPACE++. # -# Authors: MaxThevenet +# Authors: Xingjian Hui # License: BSD-3-Clause-LBNL @@ -39,13 +39,13 @@ def get_zeta(Ar,m, w0,L): zeta_solutions = np.roots([a, b, c]) return np.min(zeta_solutions) -def get_phi2(Ar,m,tau): +def get_phi2 (Ar,m,tau): #get temporal chirp phi2 temp_chirp = 0 sum=0 laser_module1=np.abs(Ar) phi_envelop=np.unwrap(np.array(np.arctan2(Ar.imag, Ar.real)),axis=0) - #calculate pphi_pz/ + #calculate pphi_pz z_diff = np.diff(m.z) pphi_pz = (np.diff(phi_envelop, axis=0)).T/ (z_diff/scc.c) pphi_pz2 = ((np.diff(pphi_pz, axis=1))/(z_diff[:len(z_diff)-1])/scc.c).T @@ -60,11 +60,12 @@ def get_phi2(Ar,m,tau): zeta_solutions = np.roots([a, b, c]) return np.max(zeta_solutions) -def get_centroids(F, x, z): +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): + +def get_beta (F,m): k0 = 2 *scc.pi / 800e-9 z_centroids = get_centroids(F.T, m.x, m.z) weight = np.mean(np.abs(F.T)**2,axis=np.ndim(F)-1) @@ -82,17 +83,13 @@ def get_beta(F,m): help='the type of the initialised chirp') args = parser.parse_args() - - ts = LpaDiagnostics(args.output_dir) Ar, m = ts.get_field(field='laserEnvelope', iteration=0) - - lambda0=.8e-6 # Laser wavelength -w0 = 30.e-6 # Laser waist +w0 = 30.e-6 # Laser waist L0 = 5e-6 -tau = L0 / scc.c # Laser duration +tau = L0 / scc.c # Laser duration if args.chirp_type == 'phi2' : phi2 = get_phi2(Ar, m, tau) assert(np.abs(phi2-2.4e-26)/2.4e-26 < 1e-2) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 9eda04016d..6893cdb770 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,7 +2,7 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose=3 -amr.n_cell = 255 127 200 # 128 128 100 +amr.n_cell = 255 127 200 my_constants.kp_inv = 10.e-6 diff --git a/tests/laser_init_check_chirp.1Rank.sh b/tests/laser_init_check_chirp.1Rank.sh index 89b8ea3ef0..16a82636d7 100644 --- a/tests/laser_init_check_chirp.1Rank.sh +++ b/tests/laser_init_check_chirp.1Rank.sh @@ -54,4 +54,4 @@ mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ --chirp_type="beta" -rm -rf $TEST_NAME \ No newline at end of file +rm -rf $TEST_NAME From 7fdb7615143720366d619410262e7ce91ee08a05 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 10 Sep 2024 14:25:13 +0200 Subject: [PATCH 057/254] delete PFT_yz, add chirp_direction --- docs/source/run/parameters.rst | 5 ++--- src/laser/Laser.H | 3 +-- src/laser/Laser.cpp | 2 +- src/laser/MultiLaser.cpp | 16 ++++++++-------- tests/laser_init_check_chirp.1Rank.sh | 3 +++ 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index 7569f217f3..9faa96a114 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -879,9 +879,8 @@ Option: ``gaussian`` * ``.propagation_angle_yz`` (`float`) optinal (default `0`) Propagation angle of the pulse in the yz plane (0 is the along the z axis) -* ``.PFT_yz`` (`float`) optinal (default `pi/2`) - Pulse front tilt angle on yz plane - the angle between the pulse front (maximum intensity contour)and the propagation - direction defined by [Selcuk Akturk Opt. Express 12 (2004)](pi/2 is no PFT) +* ``.chirp_theta_xy`` (`float`) optinal (default `pi/2`) + Direction of the linear spatial and angular chirp on XoY plane. * ``.beta`` (`float`) optional (default `0.`) Angular dispersion (or angular chirp) at focus defined by `S. Akturk et al., Optics Express 12, 4399 (2004) `__. diff --git a/src/laser/Laser.H b/src/laser/Laser.H index 66736c029d..e507af926e 100644 --- a/src/laser/Laser.H +++ b/src/laser/Laser.H @@ -29,11 +29,10 @@ public: amrex::Real m_CEP {0.}; /**< Laser carrier-envelope phase (CEP) */ /** Propagation angle of the pulse in the yz plane (0 is the along the z axis) */ amrex::Real m_propagation_angle_yz {0.}; - /**Pulse front tilt angle of the pulse in yz plane (pi/2 is no PFT)*/ - amrex::Real m_PFT_yz {MathConst::pi/2.0}; amrex::Real m_L0 {0.}; /**< Laser length (HW 1/e in amplitude) */ amrex::Real m_tau {0.}; /**< Laser duration (HW 1/e in amplitude) */ /**Time stretching factors*/ + amrex::Real m_chirp_theta_xy {MathConst::pi/2.0}; amrex::Real m_zeta {0.}; amrex::Real m_beta {0.}; amrex::Real m_phi2 {0.}; diff --git a/src/laser/Laser.cpp b/src/laser/Laser.cpp index 4c3e13c80d..5c4fd3d8e5 100644 --- a/src/laser/Laser.cpp +++ b/src/laser/Laser.cpp @@ -25,7 +25,7 @@ Laser::Laser (std::string name) queryWithParser(pp, "w0", m_w0); queryWithParser(pp, "CEP", m_CEP); queryWithParser(pp, "propagation_angle_yz", m_propagation_angle_yz); - queryWithParser(pp, "PFT_yz", m_PFT_yz); + queryWithParser(pp, "chirp_theta_xy", m_chirp_theta_xy); bool length_is_specified = queryWithParser(pp, "L0", m_L0); bool duration_is_specified = queryWithParser(pp, "tau", m_tau); AMREX_ALWAYS_ASSERT_WITH_MESSAGE( length_is_specified + duration_is_specified == 1, diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 4e37add46b..f3284dbf40 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -1165,7 +1165,6 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) const amrex::Real w0_2 = laser.m_w0 * laser.m_w0; const amrex::Real cep = laser.m_CEP; const amrex::Real propagation_angle_yz = laser.m_propagation_angle_yz; - const amrex::Real PFT_yz = laser.m_PFT_yz - MathConst::pi/2.0; const amrex::Real x0 = laser.m_position_mean[0]; const amrex::Real y0 = laser.m_position_mean[1]; const amrex::Real z0 = laser.m_position_mean[2]; @@ -1176,6 +1175,7 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) const amrex::Real beta = laser.m_beta; const amrex::Real phi2 = laser.m_phi2; const amrex::Real clight = PhysConstSI::c; + const amrex::Real theta_xy = laser.m_chirp_theta_xy; amrex::ParallelFor( bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) @@ -1184,17 +1184,17 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) const amrex::Real y = j * dx_arr[1] + poff_y - y0; const amrex::Real z = islice * dx_arr[2] + poff_z - z0; // Coordinate rotation in yz plane for a laser propagating at an angle. - const amrex::Real yp = std::cos( propagation_angle_yz + PFT_yz ) * y \ - - std::sin( propagation_angle_yz + PFT_yz ) * z; - const amrex::Real zp = std::sin( propagation_angle_yz + PFT_yz ) * y \ - + std::cos( propagation_angle_yz + PFT_yz ) * z; + const amrex::Real yp = std::cos(propagation_angle_yz) * y \ + - std::sin(propagation_angle_yz) * z; + const amrex::Real zp = std::sin(propagation_angle_yz) * y \ + + std::cos(propagation_angle_yz) * z; // For first laser, setval to 0. if (ilaser == 0) { arr(i, j, k, comp ) = 0._rt; arr(i, j, k, comp + 1 ) = 0._rt; } // Compute envelope for time step 0 - Complex diffract_factor = 1._rt + I * ( zp - zfoc + z0 * std::cos( propagation_angle_yz ) ) \ + Complex diffract_factor = 1._rt + I * (zp - zfoc + z0 * std::cos(propagation_angle_yz)) \ * 2._rt/(k0 * w0_2); Complex inv_complex_waist_2 = 1._rt /(w0_2 * diffract_factor); // Time stretching due to STCs and phi2 complex envelope @@ -1204,8 +1204,8 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * inv_tau2; Complex prefactor = a0 / diffract_factor; Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * - amrex::pow(zp - beta * k0 * (x + yp) * clight - 2._rt * I * (x + yp)*(zeta - beta * zfoc) - * clight * inv_complex_waist_2, 2); + amrex::pow(zp - beta * k0 * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) * clight - 2._rt * I * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) + * (zeta - beta * zfoc) * clight * inv_complex_waist_2, 2); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; Complex envelope = stcfactor * amrex::exp( exp_argument ) * \ diff --git a/tests/laser_init_check_chirp.1Rank.sh b/tests/laser_init_check_chirp.1Rank.sh index 16a82636d7..0c11026722 100644 --- a/tests/laser_init_check_chirp.1Rank.sh +++ b/tests/laser_init_check_chirp.1Rank.sh @@ -28,6 +28,7 @@ TEST_NAME="${FILE_NAME%.*}" # Run the simulation with initial phi2 mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ laser.phi2 = 2.4e-26 \ + laser.chirp_theta_xy = 0 \ hipace.file_prefix = $TEST_NAME \ # Compare the result with theory $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ @@ -38,6 +39,7 @@ rm -rf $TEST_NAME # Run the simulation with initial zeta mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ laser.zeta = 2.4e-19 \ + laser.chirp_theta_xy = 0 \ hipace.file_prefix = $TEST_NAME \ # Compare the result with theory @@ -48,6 +50,7 @@ rm -rf $TEST_NAME mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ laser.beta= 2e-17 \ + laser.chirp_theta_xy = 0 \ hipace.file_prefix = $TEST_NAME \ # Compare the result with theory From 8d519b5cdcffa21cd32b15c825fdff5e6cd9d84f Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 30 Sep 2024 16:32:43 +0200 Subject: [PATCH 058/254] Update tests/laser_init_check_chirp.1Rank.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- tests/laser_init_check_chirp.1Rank.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/laser_init_check_chirp.1Rank.sh b/tests/laser_init_check_chirp.1Rank.sh index 0c11026722..0ddf6d5672 100644 --- a/tests/laser_init_check_chirp.1Rank.sh +++ b/tests/laser_init_check_chirp.1Rank.sh @@ -1,6 +1,6 @@ #! /usr/bin/env bash -# Copyright 2022 +# Copyright 2024 # # This file is part of HiPACE++. # From 397496b204e83538ca2fc1839e3c08a0b1850fc9 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 30 Sep 2024 16:32:52 +0200 Subject: [PATCH 059/254] Update examples/laser/inputs_chirp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- examples/laser/inputs_chirp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 6893cdb770..95e6980e44 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -18,8 +18,8 @@ lasers.lambda0 = .8e-6 laser.a0 = 1 laser.position_mean = 0. 0. 0 laser.focal_distance = 0.0 -laser.w0 = 30e-6 \ -laser.L0 = 5e-6 \ +laser.w0 = 30e-6 +laser.L0 = 5e-6 amr.max_level = 0 diagnostic.output_period = 1 From 27c90ada1f4447f208a8ef4327008489b2562a97 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 30 Sep 2024 16:32:59 +0200 Subject: [PATCH 060/254] Update docs/source/run/parameters.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- docs/source/run/parameters.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index 9faa96a114..713e0c483c 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -879,8 +879,8 @@ Option: ``gaussian`` * ``.propagation_angle_yz`` (`float`) optinal (default `0`) Propagation angle of the pulse in the yz plane (0 is the along the z axis) -* ``.chirp_theta_xy`` (`float`) optinal (default `pi/2`) - Direction of the linear spatial and angular chirp on XoY plane. +* ``.chirp_theta_xy`` (`float`) optional (default `pi/2`) + Direction of the linear spatial and angular chirp on x-y plane. * ``.beta`` (`float`) optional (default `0.`) Angular dispersion (or angular chirp) at focus defined by `S. Akturk et al., Optics Express 12, 4399 (2004) `__. From aecd9fe2c2af4043c6905a512f43c6462eba85e6 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 30 Sep 2024 16:33:23 +0200 Subject: [PATCH 061/254] Update examples/laser/analysis_laser_init_chirp.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 7bb68cb597..d3bb7bb421 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -1,6 +1,6 @@ #! /usr/bin/env python3 -# Copyright 2022 +# Copyright 2024 # # This file is part of HiPACE++. # From 8a0fbac05cee8985e77efb4bbe6c9d0f45b54373 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 30 Sep 2024 16:45:29 +0200 Subject: [PATCH 062/254] fix format --- docs/source/run/parameters.rst | 13 +- examples/laser/analysis_laser_init_chirp.py | 132 ++++++++++---------- 2 files changed, 72 insertions(+), 73 deletions(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index 713e0c483c..c3a2e0b5f4 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -889,19 +889,16 @@ Option: ``gaussian`` Spatial chirp at focus defined by `S. Akturk et al., Optics Express 12, 4399 (2004) `__. * ``.phi2`` (`float`) optional (default `pi/2`) - The amount of temporal chirp :math:`\phi^{(2)}` at focus (in the lab frame). Namely, a wave packet - centered on the frequency :math:`(\omega_0 + \delta \omega)` will reach its peak intensity - at :math:`z(\delta \omega) = z_0 - c \phi^{(2)} \, \delta \omega`. Thus, a positive - :math:`\phi^{(2)}` corresponds to positive chirp, i.e. red part of the spectrum in the - front of the pulse and blue part of the spectrum in the back. More specifically, the electric - field in the focal plane is of the form: + The amount of temporal chirp :math:`\phi^{(2)}` at focus (in the lab frame). + Namely, a wave packetcentered on the frequency :math:`(\omega_0 + \delta \omega)` will reach its peak intensity at :math:`z(\delta \omega) = z_0 - c \phi^{(2)} \, \delta \omega`. + Thus, a positive :math:`\phi^{(2)}` corresponds to positive chirp, i.e. red part of the spectrum in the front of the pulse and blue part of the spectrum in the back. + More specifically, the electric field in the focal plane is of the form: .. math:: E(\boldsymbol{x},t) \propto Re\left[ \exp\left( -\frac{(t-t_{peak})^2}{\tau^2 + 2i\phi^{(2)}} + i\omega_0 (t-t_{peak}) + i\phi_0 \right) \right] - where :math:`\tau` is given by ``.tau`` and represents the - Fourier-limited duration of the laser pulse. Thus, the actual duration of the chirped laser pulse is: + where :math:`\tau` is given by ``.tau`` and represents the Fourier-limited duration of the laser pulse. Thus, the actual duration of the chirped laser pulse is: .. math:: diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index d3bb7bb421..afe5ab69ff 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -1,76 +1,77 @@ -#! /usr/bin/env python3 +#!/usr/bin/env python3 -# Copyright 2024 -# -# This file is part of HiPACE++. -# -# Authors: Xingjian Hui -# License: BSD-3-Clause-LBNL - - -import matplotlib.pyplot as plt -import matplotlib -import argparse import numpy as np import scipy.constants as scc -import scipy from openpmd_viewer.addons import LpaDiagnostics +import argparse + +# Constants +C = scc.c # Speed of light (precomputing constant) + -def get_zeta(Ar,m, w0,L): - nu = 0 - sum=0 - laser_module=np.abs(Ar) - 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/ +def get_zeta(Ar, m, w0, L): + laser_module = np.abs(Ar) + phi_envelope = np.unwrap(np.angle(Ar), axis=1) + + # Vectorized operations to calculate pphi_pz and pphi_pzpy 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] - sum=sum+laser_module[i,j] - nu= nu / scc.c / sum + + pphi_pz = np.diff(phi_envelope, axis=0) / (z_diff[:, None] / C) + pphi_pzpy = np.diff(pphi_pz, axis=1) / x_diff + + # Vectorized summation + weighted_sum = np.sum(pphi_pzpy * laser_module[:-2, :-2]) + total_sum = np.sum(laser_module[:-2, :-2]) + + nu = weighted_sum / C / total_sum a = 4 * nu * w0**2 * L**4 - b = -4 * scc.c + b = -4 * C c = nu * w0**2 * L**2 + zeta_solutions = np.roots([a, b, c]) return np.min(zeta_solutions) -def get_phi2 (Ar,m,tau): - #get temporal chirp phi2 - temp_chirp = 0 - sum=0 - laser_module1=np.abs(Ar) - phi_envelop=np.unwrap(np.array(np.arctan2(Ar.imag, Ar.real)),axis=0) - #calculate pphi_pz + +def get_phi2(Ar, m, tau): + laser_module = np.abs(Ar) + phi_envelope = np.unwrap(np.angle(Ar), axis=0) + z_diff = np.diff(m.z) - pphi_pz = (np.diff(phi_envelop, axis=0)).T/ (z_diff/scc.c) - pphi_pz2 = ((np.diff(pphi_pz, axis=1))/(z_diff[:len(z_diff)-1])/scc.c).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] - sum=sum+laser_module1[i,j] - x=temp_chirp*scc.c**2/sum - a=4*x - b=-4 - c=tau**4*x + + # Vectorized operations to calculate pphi_pz and pphi_pz2 + pphi_pz = np.diff(phi_envelope, axis=0) / (z_diff[:, None] / C) + pphi_pz2 = np.diff(pphi_pz, axis=1) / (z_diff[:-1][:, None] / C) + + # Vectorized summation + temp_chirp = np.sum(pphi_pz2 * laser_module[:-2, :-2]) + total_sum = np.sum(laser_module[:-2, :-2]) + + x = temp_chirp * C**2 / total_sum + a = 4 * x + b = -4 + c = tau**4 * x + zeta_solutions = np.roots([a, b, c]) return np.max(zeta_solutions) -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) + +def get_centroids(F, x, z): + # Vectorized computation of centroids + index_array = np.arange(F.shape[1])[None, :] # Faster with broadcasting + 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 = 2 *scc.pi / 800e-9 + +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 + weight = np.mean(np.abs(F.T)**2, axis=np.ndim(F) - 1) + + # Vectorized derivative calculation + derivative = np.gradient(z_centroids) / (m.x[1] - m.x[0]) + + return np.sum(derivative * weight) / np.sum(weight) / k0 / C + parser = argparse.ArgumentParser(description='Verify the chirp initialization') parser.add_argument('--output-dir', @@ -80,22 +81,23 @@ def get_beta (F,m): parser.add_argument('--chirp_type', dest='chirp_type', default='phi2', - help='the type of the initialised chirp') + help='The type of the initialized chirp') args = parser.parse_args() ts = LpaDiagnostics(args.output_dir) Ar, m = ts.get_field(field='laserEnvelope', iteration=0) -lambda0=.8e-6 # Laser wavelength -w0 = 30.e-6 # Laser waist +lambda0 = 0.8e-6 # Laser wavelength +w0 = 30.e-6 # Laser waist L0 = 5e-6 -tau = L0 / scc.c # Laser duration -if args.chirp_type == 'phi2' : +tau = L0 / C # Laser duration +k0 = 2 * np.pi / 800e-9 +if args.chirp_type == 'phi2': phi2 = get_phi2(Ar, m, tau) - assert(np.abs(phi2-2.4e-26)/2.4e-26 < 1e-2) -elif args.chirp_type == 'zeta' : + assert np.abs(phi2 - 2.4e-26) / 2.4e-26 < 1e-2 +elif args.chirp_type == 'zeta': zeta = get_zeta(Ar, m, w0, L0) - assert(np.abs(zeta-2.4e-19)/2.4e-19 < 1e-2) -elif args.chirp_type == 'beta' : - beta = get_beta(Ar, m) - assert(np.abs(beta-2e-17)/2e-17 < 1e-2) + assert np.abs(zeta - 2.4e-19) / 2.4e-19 < 1e-2 +elif args.chirp_type == 'beta': + beta = get_beta(Ar, m, k0) + assert np.abs(beta - 2e-17) / 2e-17 < 1e-2 From 0016cb408455d30fbf3d9446c8997f2e9ceb709e Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 30 Sep 2024 16:53:24 +0200 Subject: [PATCH 063/254] fix format --- examples/laser/analysis_laser_init_chirp.py | 91 ++++++++++++--------- 1 file changed, 52 insertions(+), 39 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index afe5ab69ff..05fe4636e3 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -1,76 +1,89 @@ #!/usr/bin/env python3 +# Copyright 2024 +# +# This file is part of HiPACE++. +# +# Authors: Xingjian Hui +# License: BSD-3-Clause-LBNL + +import matplotlib.pyplot as plt +import matplotlib +import argparse import numpy as np import scipy.constants as scc +import scipy from openpmd_viewer.addons import LpaDiagnostics -import argparse - -# Constants -C = scc.c # Speed of light (precomputing constant) def get_zeta(Ar, m, w0, L): + nu = 0 + total_sum = 0 laser_module = np.abs(Ar) - phi_envelope = np.unwrap(np.angle(Ar), axis=1) + phi_envelope = np.arctan2(Ar.imag, Ar.real) + + # Unwrap phi_envelope + phi_envelope = np.unwrap(np.unwrap(phi_envelope, axis=0), axis=1) - # Vectorized operations to calculate pphi_pz and pphi_pzpy + # Calculate pphi_pz z_diff = np.diff(m.z) x_diff = np.diff(m.x) + pphi_pz = np.diff(phi_envelope, axis=0).T / (z_diff / scc.c) + pphi_pzpy = np.diff(pphi_pz, axis=0).T / x_diff - pphi_pz = np.diff(phi_envelope, axis=0) / (z_diff[:, None] / C) - pphi_pzpy = np.diff(pphi_pz, axis=1) / x_diff + for i in range(len(m.z) - 2): + for j in range(len(m.x) - 2): + nu += pphi_pzpy[i, j] * laser_module[i, j] + total_sum += laser_module[i, j] - # Vectorized summation - weighted_sum = np.sum(pphi_pzpy * laser_module[:-2, :-2]) - total_sum = np.sum(laser_module[:-2, :-2]) - - nu = weighted_sum / C / total_sum + nu = nu / scc.c / total_sum a = 4 * nu * w0**2 * L**4 - b = -4 * C + b = -4 * scc.c c = nu * w0**2 * L**2 - zeta_solutions = np.roots([a, b, c]) + return np.min(zeta_solutions) def get_phi2(Ar, m, tau): - laser_module = np.abs(Ar) - phi_envelope = np.unwrap(np.angle(Ar), axis=0) + # Get temporal chirp phi2 + temp_chirp = 0 + total_sum = 0 + laser_module1 = np.abs(Ar) + phi_envelope = np.unwrap(np.arctan2(Ar.imag, Ar.real), axis=0) + # Calculate pphi_pz z_diff = np.diff(m.z) + pphi_pz = np.diff(phi_envelope, axis=0).T / (z_diff / scc.c) + pphi_pz2 = np.diff(pphi_pz, axis=1) / (z_diff[:len(z_diff) - 1]) / scc.c - # Vectorized operations to calculate pphi_pz and pphi_pz2 - pphi_pz = np.diff(phi_envelope, axis=0) / (z_diff[:, None] / C) - pphi_pz2 = np.diff(pphi_pz, axis=1) / (z_diff[:-1][:, None] / C) - - # Vectorized summation - temp_chirp = np.sum(pphi_pz2 * laser_module[:-2, :-2]) - total_sum = np.sum(laser_module[:-2, :-2]) + for i in range(len(m.z) - 2): + for j in range(len(m.x) - 2): + temp_chirp += pphi_pz2[i, j] * laser_module1[i, j] + total_sum += laser_module1[i, j] - x = temp_chirp * C**2 / total_sum + x = temp_chirp * scc.c**2 / total_sum a = 4 * x b = -4 c = tau**4 * x - zeta_solutions = np.roots([a, b, c]) + return np.max(zeta_solutions) def get_centroids(F, x, z): - # Vectorized computation of centroids - index_array = np.arange(F.shape[1])[None, :] # Faster with broadcasting - centroids = np.sum(index_array * np.abs(F)**2, axis=1) / np.sum(np.abs(F)**2, axis=1) + 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): +def get_beta(F, m): + k0 = 2 * scc.pi / 800e-9 z_centroids = get_centroids(F.T, m.x, m.z) weight = np.mean(np.abs(F.T)**2, axis=np.ndim(F) - 1) - - # Vectorized derivative calculation derivative = np.gradient(z_centroids) / (m.x[1] - m.x[0]) - return np.sum(derivative * weight) / np.sum(weight) / k0 / C + return (np.sum(derivative * weight) / np.sum(weight)) / k0 / scc.c parser = argparse.ArgumentParser(description='Verify the chirp initialization') @@ -90,14 +103,14 @@ def get_beta(F, m, k0): lambda0 = 0.8e-6 # Laser wavelength w0 = 30.e-6 # Laser waist L0 = 5e-6 -tau = L0 / C # Laser duration -k0 = 2 * np.pi / 800e-9 +tau = L0 / scc.c # Laser duration + if args.chirp_type == 'phi2': phi2 = get_phi2(Ar, m, tau) - assert np.abs(phi2 - 2.4e-26) / 2.4e-26 < 1e-2 + assert(np.abs(phi2 - 2.4e-26) / 2.4e-26 < 1e-2) elif args.chirp_type == 'zeta': zeta = get_zeta(Ar, m, w0, L0) - assert np.abs(zeta - 2.4e-19) / 2.4e-19 < 1e-2 + assert(np.abs(zeta - 2.4e-19) / 2.4e-19 < 1e-2) elif args.chirp_type == 'beta': - beta = get_beta(Ar, m, k0) - assert np.abs(beta - 2e-17) / 2e-17 < 1e-2 + beta = get_beta(Ar, m) + assert(np.abs(beta - 2e-17) / 2e-17 < 1e-2) From d1afd49840bca7ace7655e80d95cf154615a3994 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 30 Sep 2024 17:05:08 +0200 Subject: [PATCH 064/254] change everything back --- examples/laser/analysis_laser_init_chirp.py | 115 +++++++++----------- 1 file changed, 50 insertions(+), 65 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 05fe4636e3..c847cf0a48 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#! /usr/bin/env python3 # Copyright 2024 # @@ -7,6 +7,7 @@ # Authors: Xingjian Hui # License: BSD-3-Clause-LBNL + import matplotlib.pyplot as plt import matplotlib import argparse @@ -15,76 +16,61 @@ import scipy from openpmd_viewer.addons import LpaDiagnostics - -def get_zeta(Ar, m, w0, L): +def get_zeta(Ar,m, w0,L): nu = 0 - total_sum = 0 - laser_module = np.abs(Ar) - phi_envelope = np.arctan2(Ar.imag, Ar.real) - - # Unwrap phi_envelope - phi_envelope = np.unwrap(np.unwrap(phi_envelope, axis=0), axis=1) - - # Calculate pphi_pz + sum=0 + laser_module=np.abs(Ar) + 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_envelope, 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 += pphi_pzpy[i, j] * laser_module[i, j] - total_sum += laser_module[i, j] - - nu = nu / scc.c / total_sum + 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] + sum=sum+laser_module[i,j] + nu= nu / scc.c / sum a = 4 * nu * w0**2 * L**4 b = -4 * scc.c c = nu * w0**2 * L**2 zeta_solutions = np.roots([a, b, c]) - return np.min(zeta_solutions) - -def get_phi2(Ar, m, tau): - # Get temporal chirp phi2 +def get_phi2 (Ar,m,tau): + #get temporal chirp phi2 temp_chirp = 0 - total_sum = 0 - laser_module1 = np.abs(Ar) - phi_envelope = np.unwrap(np.arctan2(Ar.imag, Ar.real), axis=0) - - # Calculate pphi_pz + sum=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_envelope, axis=0).T / (z_diff / scc.c) - pphi_pz2 = np.diff(pphi_pz, axis=1) / (z_diff[:len(z_diff) - 1]) / scc.c - - for i in range(len(m.z) - 2): - for j in range(len(m.x) - 2): - temp_chirp += pphi_pz2[i, j] * laser_module1[i, j] - total_sum += laser_module1[i, j] - - x = temp_chirp * scc.c**2 / total_sum - a = 4 * x - b = -4 - c = tau**4 * x + pphi_pz = (np.diff(phi_envelop, axis=0)).T/ (z_diff/scc.c) + pphi_pz2 = ((np.diff(pphi_pz, axis=1))/(z_diff[:len(z_diff)-1])/scc.c).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] + sum=sum+laser_module1[i,j] + x=temp_chirp*scc.c**2/sum + a=4*x + b=-4 + c=tau**4*x zeta_solutions = np.roots([a, b, c]) - return np.max(zeta_solutions) - -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) +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 = 2 * scc.pi / 800e-9 +def get_beta (F,m): + k0 = 2 *scc.pi / 800e-9 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 - + 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 parser = argparse.ArgumentParser(description='Verify the chirp initialization') parser.add_argument('--output-dir', @@ -94,23 +80,22 @@ def get_beta(F, m): parser.add_argument('--chirp_type', dest='chirp_type', default='phi2', - help='The type of the initialized chirp') + help='the type of the initialised chirp') args = parser.parse_args() ts = LpaDiagnostics(args.output_dir) Ar, m = ts.get_field(field='laserEnvelope', iteration=0) -lambda0 = 0.8e-6 # Laser wavelength -w0 = 30.e-6 # Laser waist +lambda0=.8e-6 # Laser wavelength +w0 = 30.e-6 # Laser waist L0 = 5e-6 -tau = L0 / scc.c # Laser duration - -if args.chirp_type == 'phi2': +tau = L0 / scc.c # Laser duration +if args.chirp_type == 'phi2' : phi2 = get_phi2(Ar, m, tau) - assert(np.abs(phi2 - 2.4e-26) / 2.4e-26 < 1e-2) -elif args.chirp_type == 'zeta': + assert(np.abs(phi2-2.4e-26)/2.4e-26 < 1e-2) +elif args.chirp_type == 'zeta' : zeta = get_zeta(Ar, m, w0, L0) - assert(np.abs(zeta - 2.4e-19) / 2.4e-19 < 1e-2) -elif args.chirp_type == 'beta': + assert(np.abs(zeta-2.4e-19)/2.4e-19 < 1e-2) +elif args.chirp_type == 'beta' : beta = get_beta(Ar, m) - assert(np.abs(beta - 2e-17) / 2e-17 < 1e-2) + assert(np.abs(beta-2e-17)/2e-17 < 1e-2) \ No newline at end of file From f16745744d247428325d1afcf7d97f6b42b86890 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 30 Sep 2024 17:26:24 +0200 Subject: [PATCH 065/254] formating chirp.py --- examples/laser/analysis_laser_init_chirp.py | 95 ++++++++++----------- 1 file changed, 47 insertions(+), 48 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index c847cf0a48..85b0dce8c0 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -7,7 +7,6 @@ # Authors: Xingjian Hui # License: BSD-3-Clause-LBNL - import matplotlib.pyplot as plt import matplotlib import argparse @@ -16,61 +15,60 @@ import scipy from openpmd_viewer.addons import LpaDiagnostics -def get_zeta(Ar,m, w0,L): +def get_zeta(Ar, m, w0, L): nu = 0 - sum=0 - laser_module=np.abs(Ar) - 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/ + sum = 0 + laser_module = np.abs(Ar) + 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] - sum=sum+laser_module[i,j] - nu= nu / scc.c / sum + 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] + sum = sum + laser_module[i, j] + nu = nu / scc.c / sum a = 4 * nu * w0**2 * L**4 b = -4 * scc.c c = nu * w0**2 * L**2 zeta_solutions = np.roots([a, b, c]) return np.min(zeta_solutions) -def get_phi2 (Ar,m,tau): - #get temporal chirp phi2 +def get_phi2(Ar, m, tau): + # get temporal chirp phi2 temp_chirp = 0 - sum=0 - laser_module1=np.abs(Ar) - phi_envelop=np.unwrap(np.array(np.arctan2(Ar.imag, Ar.real)),axis=0) - #calculate pphi_pz + sum = 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/ (z_diff/scc.c) - pphi_pz2 = ((np.diff(pphi_pz, axis=1))/(z_diff[:len(z_diff)-1])/scc.c).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] - sum=sum+laser_module1[i,j] - x=temp_chirp*scc.c**2/sum - a=4*x - b=-4 - c=tau**4*x + pphi_pz = (np.diff(phi_envelop, axis=0)).T / (z_diff / scc.c) + pphi_pz2 = (np.diff(pphi_pz, axis=1)) / (z_diff[:len(z_diff) - 1]) / scc.c + 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] + sum = sum + laser_module1[i, j] + x = temp_chirp * scc.c**2 / sum + a = 4 * x + b = -4 + c = tau**4 * x zeta_solutions = np.roots([a, b, c]) return np.max(zeta_solutions) -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) +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 = 2 *scc.pi / 800e-9 +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 + 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 parser = argparse.ArgumentParser(description='Verify the chirp initialization') parser.add_argument('--output-dir', @@ -80,22 +78,23 @@ def get_beta (F,m): parser.add_argument('--chirp_type', dest='chirp_type', default='phi2', - help='the type of the initialised chirp') + help='the type of the initialized chirp') args = parser.parse_args() ts = LpaDiagnostics(args.output_dir) Ar, m = ts.get_field(field='laserEnvelope', iteration=0) -lambda0=.8e-6 # Laser wavelength +lambda0 = .8e-6 # Laser wavelength w0 = 30.e-6 # Laser waist L0 = 5e-6 tau = L0 / scc.c # Laser duration -if args.chirp_type == 'phi2' : +k0 = 2 * scc.pi / lambda0 +if args.chirp_type == 'phi2': phi2 = get_phi2(Ar, m, tau) - assert(np.abs(phi2-2.4e-26)/2.4e-26 < 1e-2) -elif args.chirp_type == 'zeta' : + assert(np.abs(phi2 - 2.4e-26) / 2.4e-26 < 1e-2) +elif args.chirp_type == 'zeta': zeta = get_zeta(Ar, m, w0, L0) - assert(np.abs(zeta-2.4e-19)/2.4e-19 < 1e-2) -elif args.chirp_type == 'beta' : - beta = get_beta(Ar, m) - assert(np.abs(beta-2e-17)/2e-17 < 1e-2) \ No newline at end of file + assert(np.abs(zeta - 2.4e-19) / 2.4e-19 < 1e-2) +elif args.chirp_type == 'beta': + beta = get_beta(Ar, m, k0) + assert(np.abs(beta - 2e-17) / 2e-17 < 1e-2) From 0988ea2f69ebbe2a7fb6d71c56a49ce6bd63ddf7 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 30 Sep 2024 17:41:01 +0200 Subject: [PATCH 066/254] fix phi2 --- examples/laser/analysis_laser_init_chirp.py | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 85b0dce8c0..27c81eb041 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -38,24 +38,24 @@ def get_zeta(Ar, m, w0, L): zeta_solutions = np.roots([a, b, c]) return np.min(zeta_solutions) -def get_phi2(Ar, m, tau): - # get temporal chirp phi2 +def get_phi2 (Ar, m, tau): + #get temporal chirp phi2 temp_chirp = 0 sum = 0 laser_module1 = np.abs(Ar) phi_envelop = np.unwrap(np.array(np.arctan2(Ar.imag, Ar.real)), axis=0) - # calculate pphi_pz + #calculate pphi_pz z_diff = np.diff(m.z) - pphi_pz = (np.diff(phi_envelop, axis=0)).T / (z_diff / scc.c) - pphi_pz2 = (np.diff(pphi_pz, axis=1)) / (z_diff[:len(z_diff) - 1]) / scc.c - 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] - sum = sum + laser_module1[i, j] - x = temp_chirp * scc.c**2 / sum - a = 4 * x + pphi_pz = (np.diff(phi_envelop, axis=0)).T/ (z_diff/scc.c) + pphi_pz2 = ((np.diff(pphi_pz, axis=1)) / (z_diff[:len(z_diff)-1]) / scc.c).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] + sum = sum + laser_module1[i,j] + x = temp_chirp*scc.c**2/sum + a = 4*x b = -4 - c = tau**4 * x + c = tau**4*x zeta_solutions = np.roots([a, b, c]) return np.max(zeta_solutions) From d312ed9dff7d406532a19f95d3af29c9204dcf9c Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 30 Sep 2024 17:46:12 +0200 Subject: [PATCH 067/254] cancel spaces --- examples/laser/analysis_laser_init_chirp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 27c81eb041..026364a5e2 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -52,10 +52,10 @@ def get_phi2 (Ar, m, tau): for j in range(len(m.x)-2): temp_chirp = temp_chirp + pphi_pz2[i,j] * laser_module1[i,j] sum = sum + laser_module1[i,j] - x = temp_chirp*scc.c**2/sum - a = 4*x + x = temp_chirp * cc.c**2 / sum + a = 4 * x b = -4 - c = tau**4*x + c = tau**4 * x zeta_solutions = np.roots([a, b, c]) return np.max(zeta_solutions) From b218ca33106441e78b3e44231352ff58155927e2 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Mon, 30 Sep 2024 18:01:16 +0200 Subject: [PATCH 068/254] typo --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 026364a5e2..4b19540b82 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -52,7 +52,7 @@ def get_phi2 (Ar, m, tau): for j in range(len(m.x)-2): temp_chirp = temp_chirp + pphi_pz2[i,j] * laser_module1[i,j] sum = sum + laser_module1[i,j] - x = temp_chirp * cc.c**2 / sum + x = temp_chirp * scc.c**2 / sum a = 4 * x b = -4 c = tau**4 * x From 2fadc4bc1537014bfaef87b80a6dadb427464868 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Wed, 2 Oct 2024 17:02:39 +0200 Subject: [PATCH 069/254] change the definition of clight in gaussian init --- src/laser/MultiLaser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index f3284dbf40..cf11266dd1 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -1174,7 +1174,7 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) const amrex::Real zeta = laser.m_zeta; const amrex::Real beta = laser.m_beta; const amrex::Real phi2 = laser.m_phi2; - const amrex::Real clight = PhysConstSI::c; + const amrex::Real clight = get_phys_const().c; const amrex::Real theta_xy = laser.m_chirp_theta_xy; amrex::ParallelFor( bx, From fa87537031a4b7133c92c1f9cca2923245c1c9fd Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 10 Oct 2024 11:53:40 +0200 Subject: [PATCH 070/254] Update src/laser/Laser.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- src/laser/Laser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laser/Laser.cpp b/src/laser/Laser.cpp index 5c4fd3d8e5..2eb62d0365 100644 --- a/src/laser/Laser.cpp +++ b/src/laser/Laser.cpp @@ -31,7 +31,7 @@ Laser::Laser (std::string name) AMREX_ALWAYS_ASSERT_WITH_MESSAGE( length_is_specified + duration_is_specified == 1, "Please specify exlusively either the pulse length L0 or the duration tau of the laser"); if (duration_is_specified) m_L0 = m_tau * get_phys_const().c; - if (length_is_specified) m_tau = m_L0 / (get_phys_const().c); + if (length_is_specified) m_tau = m_L0 / get_phys_const().c; queryWithParser(pp, "focal_distance", m_focal_distance); queryWithParser(pp, "position_mean", m_position_mean); queryWithParser(pp, "zeta", m_zeta); From d26915cec6ecf44bc0aa88cada8b2cefba0f9f3f Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 10 Oct 2024 11:53:49 +0200 Subject: [PATCH 071/254] Update examples/laser/analysis_laser_init_chirp.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 4b19540b82..e0f75f5d40 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -44,7 +44,7 @@ def get_phi2 (Ar, m, tau): sum = 0 laser_module1 = np.abs(Ar) phi_envelop = np.unwrap(np.array(np.arctan2(Ar.imag, Ar.real)), axis=0) - #calculate pphi_pz + # calculate pphi_pz z_diff = np.diff(m.z) pphi_pz = (np.diff(phi_envelop, axis=0)).T/ (z_diff/scc.c) pphi_pz2 = ((np.diff(pphi_pz, axis=1)) / (z_diff[:len(z_diff)-1]) / scc.c).T From 6d3c8d9d47927ee0c33b387b17c6cd61cec06baa Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 10 Oct 2024 11:53:59 +0200 Subject: [PATCH 072/254] Update examples/laser/analysis_laser_init_chirp.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index e0f75f5d40..4ea27f8e49 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -39,7 +39,7 @@ def get_zeta(Ar, m, w0, L): return np.min(zeta_solutions) def get_phi2 (Ar, m, tau): - #get temporal chirp phi2 + # get temporal chirp phi2 temp_chirp = 0 sum = 0 laser_module1 = np.abs(Ar) From 4fb5d861dddf255a7103ee91a71c3e67098969c3 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 10 Oct 2024 11:54:16 +0200 Subject: [PATCH 073/254] Update docs/source/run/parameters.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- docs/source/run/parameters.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index c3a2e0b5f4..fb10d77066 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -890,8 +890,8 @@ Option: ``gaussian`` * ``.phi2`` (`float`) optional (default `pi/2`) The amount of temporal chirp :math:`\phi^{(2)}` at focus (in the lab frame). - Namely, a wave packetcentered on the frequency :math:`(\omega_0 + \delta \omega)` will reach its peak intensity at :math:`z(\delta \omega) = z_0 - c \phi^{(2)} \, \delta \omega`. - Thus, a positive :math:`\phi^{(2)}` corresponds to positive chirp, i.e. red part of the spectrum in the front of the pulse and blue part of the spectrum in the back. + Namely, a wave packet centered on the frequency :math:`(\omega_0 + \delta \omega)` will reach its peak intensity at :math:`z(\delta \omega) = z_0 - c \phi^{(2)} \, \delta \omega`. + Thus, a positive :math:`\phi^{(2)}` corresponds to positive chirp, i.e., red part of the spectrum in the front of the pulse and blue part of the spectrum in the back. More specifically, the electric field in the focal plane is of the form: .. math:: From 3cbf88ca9958b7f5559930049f685f9b9eb2a1a7 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Thu, 10 Oct 2024 11:58:06 +0200 Subject: [PATCH 074/254] change the CI test file --- CMakeLists.txt | 2 +- examples/laser/analysis_laser_init_chirp.py | 2 +- .../{laser_init_check_chirp.1Rank.sh => laser_STC.SI.1Rank.sh} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename tests/{laser_init_check_chirp.1Rank.sh => laser_STC.SI.1Rank.sh} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index b55a3b3a46..07967e8c1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -350,7 +350,7 @@ if(BUILD_TESTING) ) add_test(NAME laser_init_check_chirp.1Rank - COMMAND bash ${HiPACE_SOURCE_DIR}/tests/laser_init_check_chirp.1Rank.sh + COMMAND bash ${HiPACE_SOURCE_DIR}/tests/laser_STC.SI.1Rank.sh $ ${HiPACE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 4ea27f8e49..fa3b8f7677 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -22,7 +22,7 @@ def get_zeta(Ar, m, w0, L): 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/ + # 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) diff --git a/tests/laser_init_check_chirp.1Rank.sh b/tests/laser_STC.SI.1Rank.sh similarity index 100% rename from tests/laser_init_check_chirp.1Rank.sh rename to tests/laser_STC.SI.1Rank.sh From a192ad0756fbb180974d3ba9be709de9224032a6 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Thu, 10 Oct 2024 11:59:42 +0200 Subject: [PATCH 075/254] change the CI name --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 07967e8c1a..d92d6a0a12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -349,7 +349,7 @@ if(BUILD_TESTING) WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) - add_test(NAME laser_init_check_chirp.1Rank + add_test(NAME laser_STC.SI.1Rank COMMAND bash ${HiPACE_SOURCE_DIR}/tests/laser_STC.SI.1Rank.sh $ ${HiPACE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} From 7d9d65af1d31fca8c612d05c556319aef16eb85f Mon Sep 17 00:00:00 2001 From: huixingjian Date: Sat, 12 Oct 2024 12:12:27 +0200 Subject: [PATCH 076/254] change the explanation of the sh file --- tests/laser_STC.SI.1Rank.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/laser_STC.SI.1Rank.sh b/tests/laser_STC.SI.1Rank.sh index 0ddf6d5672..7b8f507a89 100644 --- a/tests/laser_STC.SI.1Rank.sh +++ b/tests/laser_STC.SI.1Rank.sh @@ -9,8 +9,8 @@ # This file is part of the HiPACE++ test suite. -# It runs a Hipace simulation of a laser propagating in vacuum -# and compares width and a0 with theory +# It initializes a Hipace simulation of a gaussian laser with initial STC parameters +# and test the correctness of the STC factors # abort on first encounted error set -eu -o pipefail From 936f4556d31dec25372a7cb9ac61683a0dea82d3 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Sat, 12 Oct 2024 12:15:59 +0200 Subject: [PATCH 077/254] change the name of the parameter from chirp_theta to STC_theta --- docs/source/run/parameters.rst | 2 +- src/laser/Laser.H | 2 +- src/laser/Laser.cpp | 2 +- src/laser/MultiLaser.cpp | 2 +- tests/laser_STC.SI.1Rank.sh | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index 4f787fca37..acacc847b9 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -914,7 +914,7 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start * ``.propagation_angle_yz`` (`float`) optinal (default `0`) Propagation angle of the pulse in the yz plane (0 is the along the z axis) - * ``.chirp_theta_xy`` (`float`) optional (default `pi/2`) + * ``.STC_theta_xy`` (`float`) optional (default `pi/2`) Direction of the linear spatial and angular chirp on x-y plane. * ``.beta`` (`float`) optional (default `0.`) diff --git a/src/laser/Laser.H b/src/laser/Laser.H index 728a962d89..3a9f8b9971 100644 --- a/src/laser/Laser.H +++ b/src/laser/Laser.H @@ -38,7 +38,7 @@ public: amrex::Real m_L0 {0.}; /**< Laser length (HW 1/e in amplitude) */ amrex::Real m_tau {0.}; /**< Laser duration (HW 1/e in amplitude) */ /**Time stretching factors*/ - amrex::Real m_chirp_theta_xy {MathConst::pi/2.0}; + amrex::Real m_STC_theta_xy {MathConst::pi/2.0}; amrex::Real m_zeta {0.}; amrex::Real m_beta {0.}; amrex::Real m_phi2 {0.}; diff --git a/src/laser/Laser.cpp b/src/laser/Laser.cpp index bca7f883b6..18c7adcb65 100644 --- a/src/laser/Laser.cpp +++ b/src/laser/Laser.cpp @@ -35,7 +35,7 @@ Laser::Laser (std::string name, amrex::Geometry laser_geom_3D) queryWithParser(pp, "w0", m_w0); queryWithParser(pp, "CEP", m_CEP); queryWithParser(pp, "propagation_angle_yz", m_propagation_angle_yz); - queryWithParser(pp, "chirp_theta_xy", m_chirp_theta_xy); + queryWithParser(pp, "STC_theta_xy", m_STC_theta_xy); bool length_is_specified = queryWithParser(pp, "L0", m_L0); bool duration_is_specified = queryWithParser(pp, "tau", m_tau); AMREX_ALWAYS_ASSERT_WITH_MESSAGE( length_is_specified + duration_is_specified == 1, diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index f063220fbe..cafd27168c 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -887,7 +887,7 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) const amrex::Real beta = laser.m_beta; const amrex::Real phi2 = laser.m_phi2; const amrex::Real clight = get_phys_const().c; - const amrex::Real theta_xy = laser.m_chirp_theta_xy; + const amrex::Real theta_xy = laser.m_STC_theta_xy; amrex::ParallelFor( bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) diff --git a/tests/laser_STC.SI.1Rank.sh b/tests/laser_STC.SI.1Rank.sh index 7b8f507a89..0ee5e2ff07 100644 --- a/tests/laser_STC.SI.1Rank.sh +++ b/tests/laser_STC.SI.1Rank.sh @@ -28,7 +28,7 @@ TEST_NAME="${FILE_NAME%.*}" # Run the simulation with initial phi2 mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ laser.phi2 = 2.4e-26 \ - laser.chirp_theta_xy = 0 \ + laser.STC_theta_xy = 0 \ hipace.file_prefix = $TEST_NAME \ # Compare the result with theory $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ @@ -39,7 +39,7 @@ rm -rf $TEST_NAME # Run the simulation with initial zeta mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ laser.zeta = 2.4e-19 \ - laser.chirp_theta_xy = 0 \ + laser.STC_theta_xy = 0 \ hipace.file_prefix = $TEST_NAME \ # Compare the result with theory @@ -50,7 +50,7 @@ rm -rf $TEST_NAME mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ laser.beta= 2e-17 \ - laser.chirp_theta_xy = 0 \ + laser.STC_theta_xy = 0 \ hipace.file_prefix = $TEST_NAME \ # Compare the result with theory From aa940371e93ea183a0680ece08048d7feeefc485 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:40:03 +0200 Subject: [PATCH 078/254] Update parameters.rst --- docs/source/run/parameters.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index acacc847b9..bb1964ff01 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -909,7 +909,7 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start Use either the pulse length or the pulse duration. * ``.focal_distance`` (`float`) - Distance at which the laser pulse if focused (in the z direction, counted from laser initial position). + Distance at which the laser pulse is focused (in the z direction, counted from laser initial position). * ``.propagation_angle_yz`` (`float`) optinal (default `0`) Propagation angle of the pulse in the yz plane (0 is the along the z axis) From 45773670b5a8c002c6f2f9acabd9b640de73f5d8 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:42:38 +0200 Subject: [PATCH 079/254] Update parameters.rst --- docs/source/run/parameters.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index bb1964ff01..2a793b7391 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -903,7 +903,6 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start * ``.propagation_angle_yz`` (`float`) optional (default `0`) Propagation angle of the pulse in the yz plane (0 is along the z axis) - * ``.tau`` (`float`) optional (default `0`) The laser pulse duration. The pulse length is set to `laser.tau`:math:`*c_0`. Use either the pulse length or the pulse duration. From 38c3eacf835e85269949edae15bb0a9ebcbfd31c Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:43:37 +0200 Subject: [PATCH 080/254] Update inputs_chirp --- examples/laser/inputs_chirp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 95e6980e44..ee261d350d 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -1,6 +1,6 @@ max_step = 1 hipace.dt = 70.e-6/clight -hipace.verbose=3 +hipace.verbose = 3 amr.n_cell = 255 127 200 @@ -9,8 +9,8 @@ my_constants.kp_inv = 10.e-6 hipace.file_prefix = new hipace.do_tiling = 0 -geometry.prob_lo = -15.*kp_inv -15.*kp_inv -2.*kp_inv -geometry.prob_hi = 15.*kp_inv 15.*kp_inv 2.*kp_inv +geometry.prob_lo = -15.*kp_inv -15.*kp_inv -2.*kp_inv +geometry.prob_hi = 15.*kp_inv 15.*kp_inv 2.*kp_inv lasers.names = laser lasers.lambda0 = .8e-6 From b6715128a298e73ad0235fc2137eb3c5de3a4496 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:54:52 +0200 Subject: [PATCH 081/254] Update parameters.rst --- docs/source/run/parameters.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index 2a793b7391..130abdb06c 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -901,7 +901,7 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start Distance at which the laser pulse is focused (in the z direction, counted from laser initial position). * ``.propagation_angle_yz`` (`float`) optional (default `0`) - Propagation angle of the pulse in the yz plane (0 is along the z axis) + Propagation angle of the pulse in the yz plane (0 is along z axis) * ``.tau`` (`float`) optional (default `0`) The laser pulse duration. The pulse length is set to `laser.tau`:math:`*c_0`. @@ -910,7 +910,7 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start * ``.focal_distance`` (`float`) Distance at which the laser pulse is focused (in the z direction, counted from laser initial position). - * ``.propagation_angle_yz`` (`float`) optinal (default `0`) + * ``.propagation_angle_yz`` (`float`) optional (default `0`) Propagation angle of the pulse in the yz plane (0 is the along the z axis) * ``.STC_theta_xy`` (`float`) optional (default `pi/2`) From c037958dee6aefe73a94bf280b46d107c5626d47 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 15 Oct 2024 11:04:43 +0200 Subject: [PATCH 082/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 27 +++++++++------------ 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index fa3b8f7677..bd828bc8ef 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -7,17 +7,14 @@ # Authors: Xingjian Hui # License: BSD-3-Clause-LBNL -import matplotlib.pyplot as plt -import matplotlib import argparse import numpy as np import scipy.constants as scc -import scipy from openpmd_viewer.addons import LpaDiagnostics def get_zeta(Ar, m, w0, L): nu = 0 - sum = 0 + summ = 0 laser_module = np.abs(Ar) phi_envelop = np.array(np.arctan2(Ar.imag, Ar.real)) # unwrap phi_envelop @@ -30,18 +27,18 @@ def get_zeta(Ar, m, w0, L): 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] - sum = sum + laser_module[i, j] - nu = nu / scc.c / sum + 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_solutions = np.roots([a, b, c]) - return np.min(zeta_solutions) + zeta_roots = np.roots([a, b, c]) + return np.min(zeta_roots) def get_phi2 (Ar, m, tau): # get temporal chirp phi2 temp_chirp = 0 - sum = 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 @@ -51,13 +48,13 @@ def get_phi2 (Ar, m, tau): 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] - sum = sum + laser_module1[i,j] - x = temp_chirp * scc.c**2 / sum + summ = summ + laser_module1[i,j] + x = temp_chirp * scc.c**2 / summ a = 4 * x b = -4 c = tau**4 * x - zeta_solutions = np.roots([a, b, c]) - return np.max(zeta_solutions) + zeta_roots = np.roots([a, b, c]) + return np.max(zeta_roots) def get_centroids(F, x, z): index_array = np.mgrid[0:F.shape[0], 0:F.shape[1]][1] @@ -66,11 +63,11 @@ def get_centroids(F, x, z): 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) + 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 -parser = argparse.ArgumentParser(description='Verify the chirp initialization') +parser = argparse.ArgumentParser(description = 'Verify the chirp initialization') parser.add_argument('--output-dir', dest='output_dir', default='diags/hdf5', From 599fae18715d8c2c5a321ffdd4397e48ec1a476a Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 15 Oct 2024 11:14:12 +0200 Subject: [PATCH 083/254] Update Laser.H --- src/laser/Laser.H | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/laser/Laser.H b/src/laser/Laser.H index 3a9f8b9971..cd5c6c2c88 100644 --- a/src/laser/Laser.H +++ b/src/laser/Laser.H @@ -2,8 +2,8 @@ * * This file is part of HiPACE++. * - * Authors: MaxThevenet, AlexanderSinn - * Severin Diederichs, atmyers, Angel Ferran Pousa + * Authors: MaxThevenet, AlexanderSinn, Severin Diederichs, + * atmyers, Angel Ferran Pousa, Xingjian Hui * License: BSD-3-Clause-LBNL */ @@ -23,6 +23,7 @@ public: *\param[in] laser_geom_3D 3D laser geometry for level 0 */ void GetEnvelopeFromFileHelper (amrex::Geometry laser_geom_3D); + template void GetEnvelopeFromFile (amrex::Geometry laser_geom_3D); Laser (std::string name, amrex::Geometry laser_geom_3D); @@ -33,11 +34,11 @@ public: amrex::Real m_a0 {0.}; /**< Laser peak normalized amplitude */ amrex::Real m_w0 {0.}; /**< Laser waist */ amrex::Real m_CEP {0.}; /**< Laser carrier-envelope phase (CEP) */ - /** Propagation angle of the pulse in the yz plane (0 is the along the z axis) */ + /** Propagation angle of the pulse in the yz plane (0 is along z axis) */ amrex::Real m_propagation_angle_yz {0.}; amrex::Real m_L0 {0.}; /**< Laser length (HW 1/e in amplitude) */ amrex::Real m_tau {0.}; /**< Laser duration (HW 1/e in amplitude) */ - /**Time stretching factors*/ + /** Time stretching factors */ amrex::Real m_STC_theta_xy {MathConst::pi/2.0}; amrex::Real m_zeta {0.}; amrex::Real m_beta {0.}; From 0fc420515027a56a6f7ec8f74fee3c24e6213453 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 15 Oct 2024 11:22:10 +0200 Subject: [PATCH 084/254] Update laser_STC.SI.1Rank.sh --- tests/laser_STC.SI.1Rank.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/laser_STC.SI.1Rank.sh b/tests/laser_STC.SI.1Rank.sh index 0ee5e2ff07..9f274487f7 100644 --- a/tests/laser_STC.SI.1Rank.sh +++ b/tests/laser_STC.SI.1Rank.sh @@ -12,7 +12,7 @@ # It initializes a Hipace simulation of a gaussian laser with initial STC parameters # and test the correctness of the STC factors -# abort on first encounted error +# Abort on first encountered error set -eu -o pipefail # Read input parameters @@ -29,7 +29,7 @@ TEST_NAME="${FILE_NAME%.*}" mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ laser.phi2 = 2.4e-26 \ laser.STC_theta_xy = 0 \ - hipace.file_prefix = $TEST_NAME \ + hipace.file_prefix = $TEST_NAME # Compare the result with theory $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ --chirp_type="phi2" @@ -40,7 +40,7 @@ rm -rf $TEST_NAME mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ laser.zeta = 2.4e-19 \ laser.STC_theta_xy = 0 \ - hipace.file_prefix = $TEST_NAME \ + hipace.file_prefix = $TEST_NAME # Compare the result with theory $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ @@ -49,9 +49,9 @@ $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ rm -rf $TEST_NAME mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ - laser.beta= 2e-17 \ + laser.beta = 2e-17 \ laser.STC_theta_xy = 0 \ - hipace.file_prefix = $TEST_NAME \ + hipace.file_prefix = $TEST_NAME # Compare the result with theory $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ From f4ee9369052c3d6b41315ef3a6b3e1771bdee51c Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 15 Oct 2024 12:44:22 +0200 Subject: [PATCH 085/254] Update parameters.rst --- docs/source/run/parameters.rst | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index 130abdb06c..85fb811929 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -903,16 +903,6 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start * ``.propagation_angle_yz`` (`float`) optional (default `0`) Propagation angle of the pulse in the yz plane (0 is along z axis) - * ``.tau`` (`float`) optional (default `0`) - The laser pulse duration. The pulse length is set to `laser.tau`:math:`*c_0`. - Use either the pulse length or the pulse duration. - - * ``.focal_distance`` (`float`) - Distance at which the laser pulse is focused (in the z direction, counted from laser initial position). - - * ``.propagation_angle_yz`` (`float`) optional (default `0`) - Propagation angle of the pulse in the yz plane (0 is the along the z axis) - * ``.STC_theta_xy`` (`float`) optional (default `pi/2`) Direction of the linear spatial and angular chirp on x-y plane. From 233fd3612f438d97d0c51f4a2efa565c1f236763 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 16 Oct 2024 15:46:51 +0200 Subject: [PATCH 086/254] Update parameters.rst --- docs/source/run/parameters.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index 85fb811929..cbb4d7edc8 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -904,7 +904,7 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start Propagation angle of the pulse in the yz plane (0 is along z axis) * ``.STC_theta_xy`` (`float`) optional (default `pi/2`) - Direction of the linear spatial and angular chirp on x-y plane. + Direction of the linear spatial and angular chirp on xoy plane. * ``.beta`` (`float`) optional (default `0.`) Angular dispersion (or angular chirp) at focus defined by `S. Akturk et al., Optics Express 12, 4399 (2004) `__. From 2203095ec55a3e044b79440452ffa0b76b30340f Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 17 Oct 2024 13:46:58 +0200 Subject: [PATCH 087/254] Update parameters.rst --- docs/source/run/parameters.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index cbb4d7edc8..4032f930fa 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -904,7 +904,7 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start Propagation angle of the pulse in the yz plane (0 is along z axis) * ``.STC_theta_xy`` (`float`) optional (default `pi/2`) - Direction of the linear spatial and angular chirp on xoy plane. + Direction of the linear spatial and angular chirp on xoy plane (0 is along x axis). * ``.beta`` (`float`) optional (default `0.`) Angular dispersion (or angular chirp) at focus defined by `S. Akturk et al., Optics Express 12, 4399 (2004) `__. From ccb07cec8e9525811a5d646a6179fd8c3aeb8588 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:27:42 +0100 Subject: [PATCH 088/254] Update tests/laser_STC.SI.1Rank.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- tests/laser_STC.SI.1Rank.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/laser_STC.SI.1Rank.sh b/tests/laser_STC.SI.1Rank.sh index 9f274487f7..49485291ce 100644 --- a/tests/laser_STC.SI.1Rank.sh +++ b/tests/laser_STC.SI.1Rank.sh @@ -9,7 +9,7 @@ # This file is part of the HiPACE++ test suite. -# It initializes a Hipace simulation of a gaussian laser with initial STC parameters +# It initializes a Hipace simulation of a gaussian laser with initial spatiotemporal couplings (STCs) # and test the correctness of the STC factors # Abort on first encountered error From 79c7f3a09a68ce67b14501d83b00195d551bc21c Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:27:51 +0100 Subject: [PATCH 089/254] Update docs/source/run/parameters.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- docs/source/run/parameters.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index 4032f930fa..d216ad3689 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -901,7 +901,7 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start Distance at which the laser pulse is focused (in the z direction, counted from laser initial position). * ``.propagation_angle_yz`` (`float`) optional (default `0`) - Propagation angle of the pulse in the yz plane (0 is along z axis) + Propagation angle of the pulse in the yz plane (0 is along the z axis) * ``.STC_theta_xy`` (`float`) optional (default `pi/2`) Direction of the linear spatial and angular chirp on xoy plane (0 is along x axis). From 3eedf097271f46df49d32e582c14cdb4b3cbc2d4 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:28:06 +0100 Subject: [PATCH 090/254] Update docs/source/run/parameters.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- docs/source/run/parameters.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index d216ad3689..eed3bb4219 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -903,8 +903,9 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start * ``.propagation_angle_yz`` (`float`) optional (default `0`) Propagation angle of the pulse in the yz plane (0 is along the z axis) - * ``.STC_theta_xy`` (`float`) optional (default `pi/2`) - Direction of the linear spatial and angular chirp on xoy plane (0 is along x axis). + * ``.STC_theta_xy`` (`float`) optional (default `0`) + Direction of the linear spatial and angular chirps in the xy plane (`0` is along x, `pi/2` along y). + In what follows, all chirps are given as defined in `S. Akturk et al., Optics Express 12, 4399 (2004) `__. * ``.beta`` (`float`) optional (default `0.`) Angular dispersion (or angular chirp) at focus defined by `S. Akturk et al., Optics Express 12, 4399 (2004) `__. From 720a077e02692390aa930110c9b3c065106f869d Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:28:21 +0100 Subject: [PATCH 091/254] Update docs/source/run/parameters.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- docs/source/run/parameters.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index eed3bb4219..ee8853144d 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -908,10 +908,10 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start In what follows, all chirps are given as defined in `S. Akturk et al., Optics Express 12, 4399 (2004) `__. * ``.beta`` (`float`) optional (default `0.`) - Angular dispersion (or angular chirp) at focus defined by `S. Akturk et al., Optics Express 12, 4399 (2004) `__. + Angular dispersion (or angular chirp) at focus. * ``.zeta`` (`float`) optional (default `0.`) - Spatial chirp at focus defined by `S. Akturk et al., Optics Express 12, 4399 (2004) `__. + Spatial chirp at focus. * ``.phi2`` (`float`) optional (default `pi/2`) The amount of temporal chirp :math:`\phi^{(2)}` at focus (in the lab frame). From fb540f3b65c66ca4e95be2cd7be14162a56ecf33 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:29:11 +0100 Subject: [PATCH 092/254] Update docs/source/run/parameters.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- docs/source/run/parameters.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index ee8853144d..9ffd73c129 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -929,8 +929,6 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start \tau' = \sqrt{ \tau^2 + 4 (\phi^{(2)})^2/\tau^2 } - See also the definition in `S. Akturk et al., Optics Express 12, 4399 (2004) `__. - Option: ``from_file`` the laser is loaded from an openPMD file * ``.input_file`` (`string`) optional (default `""`) From 97795e0a9f506d39a9fd0a3e560a931b17fd2e99 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:29:34 +0100 Subject: [PATCH 093/254] Update src/laser/Laser.H MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- src/laser/Laser.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laser/Laser.H b/src/laser/Laser.H index cd5c6c2c88..d30b005577 100644 --- a/src/laser/Laser.H +++ b/src/laser/Laser.H @@ -34,7 +34,7 @@ public: amrex::Real m_a0 {0.}; /**< Laser peak normalized amplitude */ amrex::Real m_w0 {0.}; /**< Laser waist */ amrex::Real m_CEP {0.}; /**< Laser carrier-envelope phase (CEP) */ - /** Propagation angle of the pulse in the yz plane (0 is along z axis) */ + /** Propagation angle of the pulse in the yz plane (0 is along the z axis) */ amrex::Real m_propagation_angle_yz {0.}; amrex::Real m_L0 {0.}; /**< Laser length (HW 1/e in amplitude) */ amrex::Real m_tau {0.}; /**< Laser duration (HW 1/e in amplitude) */ From 961f4e1b2b5e0950848f1dff48b3e3643f1f085c Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:30:15 +0100 Subject: [PATCH 094/254] Update examples/laser/analysis_laser_init_chirp.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index bd828bc8ef..57ab1f1ca7 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -75,7 +75,7 @@ def get_beta(F, m, k0): parser.add_argument('--chirp_type', dest='chirp_type', default='phi2', - help='the type of the initialized chirp') + help='Type of the initialized chirp') args = parser.parse_args() ts = LpaDiagnostics(args.output_dir) From 324f9a0f2a4176deeaadfb0e056c19be975e447f Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:21:46 +0100 Subject: [PATCH 095/254] Update docs/source/run/parameters.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- docs/source/run/parameters.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index 9ffd73c129..0e5e3d0981 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -914,7 +914,7 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start Spatial chirp at focus. * ``.phi2`` (`float`) optional (default `pi/2`) - The amount of temporal chirp :math:`\phi^{(2)}` at focus (in the lab frame). + Temporal chirp :math:`\phi^{(2)}` at focus. Namely, a wave packet centered on the frequency :math:`(\omega_0 + \delta \omega)` will reach its peak intensity at :math:`z(\delta \omega) = z_0 - c \phi^{(2)} \, \delta \omega`. Thus, a positive :math:`\phi^{(2)}` corresponds to positive chirp, i.e., red part of the spectrum in the front of the pulse and blue part of the spectrum in the back. More specifically, the electric field in the focal plane is of the form: From 8eac5fd9db23d8e5d07499ed175e7cc89cc70266 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 30 Oct 2024 00:57:22 +0100 Subject: [PATCH 096/254] Update parameters.rst --- docs/source/run/parameters.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index 0e5e3d0981..8a1d6eb576 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -908,13 +908,13 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start In what follows, all chirps are given as defined in `S. Akturk et al., Optics Express 12, 4399 (2004) `__. * ``.beta`` (`float`) optional (default `0.`) - Angular dispersion (or angular chirp) at focus. + Angular dispersion (or angular chirp) at focus in second. * ``.zeta`` (`float`) optional (default `0.`) - Spatial chirp at focus. + Spatial chirp at focus in second*meter. * ``.phi2`` (`float`) optional (default `pi/2`) - Temporal chirp :math:`\phi^{(2)}` at focus. + Temporal chirp :math:`\phi^{(2)}` at focus in second^2. Namely, a wave packet centered on the frequency :math:`(\omega_0 + \delta \omega)` will reach its peak intensity at :math:`z(\delta \omega) = z_0 - c \phi^{(2)} \, \delta \omega`. Thus, a positive :math:`\phi^{(2)}` corresponds to positive chirp, i.e., red part of the spectrum in the front of the pulse and blue part of the spectrum in the back. More specifically, the electric field in the focal plane is of the form: From 78f27bc3910240e0b37538116b256e7e4cd6b5e9 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 30 Oct 2024 00:57:40 +0100 Subject: [PATCH 097/254] Update src/laser/Laser.H MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- src/laser/Laser.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laser/Laser.H b/src/laser/Laser.H index d30b005577..03b4fb073a 100644 --- a/src/laser/Laser.H +++ b/src/laser/Laser.H @@ -39,7 +39,7 @@ public: amrex::Real m_L0 {0.}; /**< Laser length (HW 1/e in amplitude) */ amrex::Real m_tau {0.}; /**< Laser duration (HW 1/e in amplitude) */ /** Time stretching factors */ - amrex::Real m_STC_theta_xy {MathConst::pi/2.0}; + amrex::Real m_STC_theta_xy {0.}; amrex::Real m_zeta {0.}; amrex::Real m_beta {0.}; amrex::Real m_phi2 {0.}; From 6bf42dba1a4ca8a32d601a155a5782e4627d4c67 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 30 Oct 2024 01:00:27 +0100 Subject: [PATCH 098/254] Update parameters.rst --- docs/source/run/parameters.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index 8a1d6eb576..2964ccd688 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -908,13 +908,13 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start In what follows, all chirps are given as defined in `S. Akturk et al., Optics Express 12, 4399 (2004) `__. * ``.beta`` (`float`) optional (default `0.`) - Angular dispersion (or angular chirp) at focus in second. + Angular dispersion (or angular chirp) at focus in :math:`second`. * ``.zeta`` (`float`) optional (default `0.`) - Spatial chirp at focus in second*meter. + Spatial chirp at focus in :math:`second \cdot meter`. * ``.phi2`` (`float`) optional (default `pi/2`) - Temporal chirp :math:`\phi^{(2)}` at focus in second^2. + Temporal chirp :math:`\phi^{(2)}` at focus in :math:`second^2`. Namely, a wave packet centered on the frequency :math:`(\omega_0 + \delta \omega)` will reach its peak intensity at :math:`z(\delta \omega) = z_0 - c \phi^{(2)} \, \delta \omega`. Thus, a positive :math:`\phi^{(2)}` corresponds to positive chirp, i.e., red part of the spectrum in the front of the pulse and blue part of the spectrum in the back. More specifically, the electric field in the focal plane is of the form: From 8470e921b7fb46de416dd4797da19558d9388cea Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 30 Oct 2024 01:02:12 +0100 Subject: [PATCH 099/254] Update parameters.rst --- docs/source/run/parameters.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index 2964ccd688..6ba152f5c4 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -911,7 +911,7 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start Angular dispersion (or angular chirp) at focus in :math:`second`. * ``.zeta`` (`float`) optional (default `0.`) - Spatial chirp at focus in :math:`second \cdot meter`. + Spatial chirp at focus in :math:`second \cdot meter`. * ``.phi2`` (`float`) optional (default `pi/2`) Temporal chirp :math:`\phi^{(2)}` at focus in :math:`second^2`. From 58810455dc8c225f03ffb610c0a75c4393b74d84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxence=20Th=C3=A9venet?= Date: Mon, 18 Nov 2024 17:03:23 +0100 Subject: [PATCH 100/254] Update docs/source/run/parameters.rst --- docs/source/run/parameters.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index 6ba152f5c4..1edadddff4 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -915,8 +915,8 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start * ``.phi2`` (`float`) optional (default `pi/2`) Temporal chirp :math:`\phi^{(2)}` at focus in :math:`second^2`. - Namely, a wave packet centered on the frequency :math:`(\omega_0 + \delta \omega)` will reach its peak intensity at :math:`z(\delta \omega) = z_0 - c \phi^{(2)} \, \delta \omega`. - Thus, a positive :math:`\phi^{(2)}` corresponds to positive chirp, i.e., red part of the spectrum in the front of the pulse and blue part of the spectrum in the back. + Namely, a wave packet centered on frequency :math:`(\omega_0 + \delta \omega)` reaches its peak intensity at :math:`z(\delta \omega) = z_0 - c \phi^{(2)} \, \delta \omega`. + Thus, a positive :math:`\phi^{(2)}` corresponds to positive chirp, i.e., red part of the spectrum in the front of the pulse and blue part in the back. More specifically, the electric field in the focal plane is of the form: .. math:: From db379014e96369d5bb9a4dc916ac74550511b8b2 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 27 Nov 2024 16:36:51 +0100 Subject: [PATCH 101/254] Update examples/laser/analysis_laser_init_chirp.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- examples/laser/analysis_laser_init_chirp.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 57ab1f1ca7..6cdda9af32 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -20,10 +20,8 @@ def get_zeta(Ar, m, w0, L): # 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 + pphi_pz = (np.diff(phi_envelop, axis=0)).T / (np.diff(m.z) / scc.c) + pphi_pzpy = (np.diff(pphi_pz, axis=0)).T / np.diff(m.x) 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] From 248e903e37c94b6c3eda1277543f42a71426d313 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 27 Nov 2024 16:37:10 +0100 Subject: [PATCH 102/254] Update examples/laser/analysis_laser_init_chirp.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- examples/laser/analysis_laser_init_chirp.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 6cdda9af32..b8197cd88c 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -22,11 +22,7 @@ def get_zeta(Ar, m, w0, L): # calculate pphi_pz pphi_pz = (np.diff(phi_envelop, axis=0)).T / (np.diff(m.z) / scc.c) pphi_pzpy = (np.diff(pphi_pz, axis=0)).T / np.diff(m.x) - 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 + nu = np.sum(pphi_pzpy * laser_module) / scc.c / np.sum(laser_module) a = 4 * nu * w0**2 * L**4 b = -4 * scc.c c = nu * w0**2 * L**2 From 25630be4a404069b2c68340aa5d5d61306e630e2 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 27 Nov 2024 16:37:24 +0100 Subject: [PATCH 103/254] Update examples/laser/analysis_laser_init_chirp.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- examples/laser/analysis_laser_init_chirp.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index b8197cd88c..e43fed1f48 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -13,8 +13,6 @@ from openpmd_viewer.addons import LpaDiagnostics def get_zeta(Ar, m, w0, L): - nu = 0 - summ = 0 laser_module = np.abs(Ar) phi_envelop = np.array(np.arctan2(Ar.imag, Ar.real)) # unwrap phi_envelop From 16a9e31447670f2a27b857e85734ad0fd361daf1 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 27 Nov 2024 17:08:45 +0100 Subject: [PATCH 104/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index e43fed1f48..4286a4be0a 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -18,8 +18,8 @@ def get_zeta(Ar, m, w0, L): # unwrap phi_envelop phi_envelop = np.unwrap(np.unwrap(phi_envelop, axis=0), axis=1) # calculate pphi_pz - pphi_pz = (np.diff(phi_envelop, axis=0)).T / (np.diff(m.z) / scc.c) - pphi_pzpy = (np.diff(pphi_pz, axis=0)).T / np.diff(m.x) + pphi_pz = (np.gradient(phi_envelop,np.diff(m.z) / scc.c, axis=0)).T + pphi_pzpy = (np.gradient(pphi_pz,m.x axis=0)).T nu = np.sum(pphi_pzpy * laser_module) / scc.c / np.sum(laser_module) a = 4 * nu * w0**2 * L**4 b = -4 * scc.c From d78d093173f1f0efc3954af21babf6eb0d29ebd7 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 4 Dec 2024 12:09:10 +0100 Subject: [PATCH 105/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 4286a4be0a..8d276914d1 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -18,7 +18,7 @@ def get_zeta(Ar, m, w0, L): # unwrap phi_envelop phi_envelop = np.unwrap(np.unwrap(phi_envelop, axis=0), axis=1) # calculate pphi_pz - pphi_pz = (np.gradient(phi_envelop,np.diff(m.z) / scc.c, axis=0)).T + pphi_pz = (np.gradient(phi_envelop,m.z / scc.c, axis=0)).T pphi_pzpy = (np.gradient(pphi_pz,m.x axis=0)).T nu = np.sum(pphi_pzpy * laser_module) / scc.c / np.sum(laser_module) a = 4 * nu * w0**2 * L**4 From 3bb3ba7be53aa8eb87780121cd3ae312d336cab5 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 4 Dec 2024 12:18:06 +0100 Subject: [PATCH 106/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 8d276914d1..fb8dcdaec3 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -19,7 +19,7 @@ def get_zeta(Ar, m, w0, L): phi_envelop = np.unwrap(np.unwrap(phi_envelop, axis=0), axis=1) # calculate pphi_pz pphi_pz = (np.gradient(phi_envelop,m.z / scc.c, axis=0)).T - pphi_pzpy = (np.gradient(pphi_pz,m.x axis=0)).T + pphi_pzpy = (np.gradient(pphi_pz,m.x, axis=0)).T nu = np.sum(pphi_pzpy * laser_module) / scc.c / np.sum(laser_module) a = 4 * nu * w0**2 * L**4 b = -4 * scc.c From 3b9b19ef5662d7f7b1b31978595fcfd0a5ef9231 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 4 Dec 2024 17:01:42 +0100 Subject: [PATCH 107/254] Update MultiLaser.cpp --- src/laser/MultiLaser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index cafd27168c..7bacc3ed3c 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -912,7 +912,7 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) // Time stretching due to STCs and phi2 complex envelope // (1 if zeta=0, beta=0, phi2=0) Complex stretch_factor = 1._rt \ - + 4._rt * (zeta + beta * zfoc * inv_tau2) * (zeta + beta * zfoc * inv_complex_waist_2) \ + + 4._rt * (zeta + beta * zfoc) * inv_tau2 * (zeta + beta * zfoc) * inv_complex_waist_2 \ + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * inv_tau2; Complex prefactor = a0 / diffract_factor; Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * From 62d0ee3e650a9d4b19e2e4bd5683195e9fe6b8d6 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 4 Dec 2024 17:47:20 +0100 Subject: [PATCH 108/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index fb8dcdaec3..f7582feb21 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -78,6 +78,7 @@ def get_beta(F, m, k0): L0 = 5e-6 tau = L0 / scc.c # Laser duration k0 = 2 * scc.pi / lambda0 +print(zeta) if args.chirp_type == 'phi2': phi2 = get_phi2(Ar, m, tau) assert(np.abs(phi2 - 2.4e-26) / 2.4e-26 < 1e-2) From ab9a5e19a01c97cb12c6e28a591758ce478d10f6 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 4 Dec 2024 18:52:12 +0100 Subject: [PATCH 109/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index f7582feb21..e8db5a89a4 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -78,7 +78,7 @@ def get_beta(F, m, k0): L0 = 5e-6 tau = L0 / scc.c # Laser duration k0 = 2 * scc.pi / lambda0 -print(zeta) +print(get_zeta(Ar, m, w0, L0)) if args.chirp_type == 'phi2': phi2 = get_phi2(Ar, m, tau) assert(np.abs(phi2 - 2.4e-26) / 2.4e-26 < 1e-2) From 7b37e55d962d4dd7c9a3cadd355b75345c7d4737 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:13:04 +0100 Subject: [PATCH 110/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index e8db5a89a4..b69488568a 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -20,10 +20,10 @@ def get_zeta(Ar, m, w0, L): # calculate pphi_pz pphi_pz = (np.gradient(phi_envelop,m.z / scc.c, axis=0)).T pphi_pzpy = (np.gradient(pphi_pz,m.x, axis=0)).T - nu = np.sum(pphi_pzpy * laser_module) / scc.c / np.sum(laser_module) - a = 4 * nu * w0**2 * L**4 - b = -4 * scc.c - c = nu * w0**2 * L**2 + nu = np.sum(pphi_pzpy * laser_module) / np.sum(laser_module) + a = nu * scc.c**2 + b = -scc.c**2 + c = w0**2 * L**2 / 4 zeta_roots = np.roots([a, b, c]) return np.min(zeta_roots) From f11c2bb2672e62a39da1f2d0df9719bbbac5835e Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:17:00 +0100 Subject: [PATCH 111/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index b69488568a..d3081b11ba 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -21,11 +21,11 @@ def get_zeta(Ar, m, w0, L): pphi_pz = (np.gradient(phi_envelop,m.z / scc.c, axis=0)).T pphi_pzpy = (np.gradient(pphi_pz,m.x, axis=0)).T nu = np.sum(pphi_pzpy * laser_module) / np.sum(laser_module) - a = nu * scc.c**2 + a = nu * scc.c**2 b = -scc.c**2 c = w0**2 * L**2 / 4 zeta_roots = np.roots([a, b, c]) - return np.min(zeta_roots) + return np.max(zeta_roots) def get_phi2 (Ar, m, tau): # get temporal chirp phi2 From c01f483ec70ba58743ba623464d66fd20a2bc166 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 12:03:06 +0100 Subject: [PATCH 112/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index d3081b11ba..e74ee777fe 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -23,7 +23,7 @@ def get_zeta(Ar, m, w0, L): nu = np.sum(pphi_pzpy * laser_module) / np.sum(laser_module) a = nu * scc.c**2 b = -scc.c**2 - c = w0**2 * L**2 / 4 + c = w0**2 * L**2 * nu / 4 zeta_roots = np.roots([a, b, c]) return np.max(zeta_roots) From d7fd8ff983d3e76c4769361dbb4f32448b453655 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 12:13:33 +0100 Subject: [PATCH 113/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index ee261d350d..0c5145f5e4 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,7 +2,7 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose = 3 -amr.n_cell = 255 127 200 +amr.n_cell = 255 511 200 my_constants.kp_inv = 10.e-6 From 74831401ee5d301c3e08cee74db6c46a4e1275af Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 12:52:10 +0100 Subject: [PATCH 114/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index e74ee777fe..972543f091 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -18,7 +18,7 @@ def get_zeta(Ar, m, w0, L): # unwrap phi_envelop phi_envelop = np.unwrap(np.unwrap(phi_envelop, axis=0), axis=1) # calculate pphi_pz - pphi_pz = (np.gradient(phi_envelop,m.z / scc.c, axis=0)).T + pphi_pz = (np.gradient(phi_envelop,m.z, axis=0)).T * scc.c pphi_pzpy = (np.gradient(pphi_pz,m.x, axis=0)).T nu = np.sum(pphi_pzpy * laser_module) / np.sum(laser_module) a = nu * scc.c**2 From 8e86f7726dac8b81198631ac19c305116a6200b0 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:15:46 +0100 Subject: [PATCH 115/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 972543f091..7b5ffa20e3 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -13,7 +13,7 @@ from openpmd_viewer.addons import LpaDiagnostics def get_zeta(Ar, m, w0, L): - laser_module = np.abs(Ar) + laser_module = np.abs(Ar**2) 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) @@ -31,7 +31,7 @@ def get_phi2 (Ar, m, tau): # get temporal chirp phi2 temp_chirp = 0 summ = 0 - laser_module1 = np.abs(Ar) + laser_module1 = np.abs(Ar**2) phi_envelop = np.unwrap(np.array(np.arctan2(Ar.imag, Ar.real)), axis=0) # calculate pphi_pz z_diff = np.diff(m.z) From 7c0b78ac22d395a8e59eead864380a0255026f81 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:28:15 +0100 Subject: [PATCH 116/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 7b5ffa20e3..076edde875 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -25,7 +25,7 @@ def get_zeta(Ar, m, w0, L): b = -scc.c**2 c = w0**2 * L**2 * nu / 4 zeta_roots = np.roots([a, b, c]) - return np.max(zeta_roots) + return np.max(np.abs(zeta_roots)) def get_phi2 (Ar, m, tau): # get temporal chirp phi2 From 53ebf239bc8c64745c10908fbeef4e10d763cf1e Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:42:12 +0100 Subject: [PATCH 117/254] Update laser_STC.SI.1Rank.sh --- tests/laser_STC.SI.1Rank.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/laser_STC.SI.1Rank.sh b/tests/laser_STC.SI.1Rank.sh index 49485291ce..642b8d9524 100644 --- a/tests/laser_STC.SI.1Rank.sh +++ b/tests/laser_STC.SI.1Rank.sh @@ -38,7 +38,7 @@ rm -rf $TEST_NAME # Run the simulation with initial zeta mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ - laser.zeta = 2.4e-19 \ + laser.zeta = 2.4e-23 \ laser.STC_theta_xy = 0 \ hipace.file_prefix = $TEST_NAME From 34eabc7eed47412afbb002d1135a537a0dbe0f89 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:09:11 +0100 Subject: [PATCH 118/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 51 +++++++++++++-------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 076edde875..ddd7c02338 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -12,21 +12,6 @@ import scipy.constants as scc from openpmd_viewer.addons import LpaDiagnostics -def get_zeta(Ar, m, w0, L): - laser_module = np.abs(Ar**2) - 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 - pphi_pz = (np.gradient(phi_envelop,m.z, axis=0)).T * scc.c - pphi_pzpy = (np.gradient(pphi_pz,m.x, axis=0)).T - nu = np.sum(pphi_pzpy * laser_module) / np.sum(laser_module) - a = nu * scc.c**2 - b = -scc.c**2 - c = w0**2 * L**2 * nu / 4 - zeta_roots = np.roots([a, b, c]) - return np.max(np.abs(zeta_roots)) - def get_phi2 (Ar, m, tau): # get temporal chirp phi2 temp_chirp = 0 @@ -53,11 +38,37 @@ def get_centroids(F, x, z): 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 +def temporal2spectral_fft(Ar,m): + spect=np.fft.ifft( + Ar, axis=1, norm="backward" + ) + Nt = len(m.z) + dt= (m.z[1]-m.z[0])/scc.c + omega = 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0 *scc.c + return omega,spect + +def get_zeta(Ar,m): + omega,env_spec=temporal2spectral_fft(Ar,m) + env_spec_abs = np.abs(env_spec**2) + + yda = np.sum(m.x * env_spec_abs, axis=1) / np.sum(env_spec_abs, axis=1) + derivative_y_zeta = np.gradient(yda, omega) + weight_y_2d = np.mean(env_spec_abs, axis=1) + print(derivative_y_zeta.shape) + print(weight_y_2d.shape) + zeta_y = np.average(derivative_y_zeta.T, weights=weight_y_2d) + return zeta_y + +def get_beta(Ar,m,k0): + omega,env_spec=temporal2spectral_fft(Ar,m) + env_spec_abs = np.abs(env_spec**2) + phi_envelop_abs = np.unwrap( + np.arctan2(env_spec.imag, env_spec.real), axis=0 + ) + angle_y = np.gradient(phi_envelop_abs, m.x[1]-m.x[0], axis=0) / k0 + derivative_y_beta = np.gradient(angle_y, omega, axis=0) + beta_y = np.average(derivative_y_beta, weights=env_spec_abs) + return beta_y parser = argparse.ArgumentParser(description = 'Verify the chirp initialization') parser.add_argument('--output-dir', From 9a1aac3704ce966e9e6b6ed62e62f264a62e3250 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:09:46 +0100 Subject: [PATCH 119/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index ddd7c02338..c837d12e9d 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -54,8 +54,6 @@ def get_zeta(Ar,m): yda = np.sum(m.x * env_spec_abs, axis=1) / np.sum(env_spec_abs, axis=1) derivative_y_zeta = np.gradient(yda, omega) weight_y_2d = np.mean(env_spec_abs, axis=1) - print(derivative_y_zeta.shape) - print(weight_y_2d.shape) zeta_y = np.average(derivative_y_zeta.T, weights=weight_y_2d) return zeta_y From 538b79aeb0a98ca43c705fc93906bfc3a36af534 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:14:42 +0100 Subject: [PATCH 120/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index c837d12e9d..ec8b447359 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -50,7 +50,6 @@ def temporal2spectral_fft(Ar,m): def get_zeta(Ar,m): omega,env_spec=temporal2spectral_fft(Ar,m) env_spec_abs = np.abs(env_spec**2) - yda = np.sum(m.x * env_spec_abs, axis=1) / np.sum(env_spec_abs, axis=1) derivative_y_zeta = np.gradient(yda, omega) weight_y_2d = np.mean(env_spec_abs, axis=1) @@ -66,7 +65,7 @@ def get_beta(Ar,m,k0): angle_y = np.gradient(phi_envelop_abs, m.x[1]-m.x[0], axis=0) / k0 derivative_y_beta = np.gradient(angle_y, omega, axis=0) beta_y = np.average(derivative_y_beta, weights=env_spec_abs) - return beta_y + return beta_y parser = argparse.ArgumentParser(description = 'Verify the chirp initialization') parser.add_argument('--output-dir', @@ -92,7 +91,7 @@ def get_beta(Ar,m,k0): phi2 = get_phi2(Ar, m, tau) assert(np.abs(phi2 - 2.4e-26) / 2.4e-26 < 1e-2) elif args.chirp_type == 'zeta': - zeta = get_zeta(Ar, m, w0, L0) + zeta = get_zeta(Ar, m) assert(np.abs(zeta - 2.4e-19) / 2.4e-19 < 1e-2) elif args.chirp_type == 'beta': beta = get_beta(Ar, m, k0) From d5f1b9a151077d008c19b8de6c8cec993631e927 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:21:05 +0100 Subject: [PATCH 121/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index ec8b447359..6154533bba 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -86,7 +86,7 @@ def get_beta(Ar,m,k0): L0 = 5e-6 tau = L0 / scc.c # Laser duration k0 = 2 * scc.pi / lambda0 -print(get_zeta(Ar, m, w0, L0)) +print(get_zeta(Ar, m)) if args.chirp_type == 'phi2': phi2 = get_phi2(Ar, m, tau) assert(np.abs(phi2 - 2.4e-26) / 2.4e-26 < 1e-2) From 64cae759c556e40d9f3e46d79fdb0250f9084b42 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:28:11 +0100 Subject: [PATCH 122/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 6154533bba..6c7c2e68b7 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -90,9 +90,9 @@ def get_beta(Ar,m,k0): if args.chirp_type == 'phi2': phi2 = get_phi2(Ar, m, tau) assert(np.abs(phi2 - 2.4e-26) / 2.4e-26 < 1e-2) -elif args.chirp_type == 'zeta': - zeta = get_zeta(Ar, m) - assert(np.abs(zeta - 2.4e-19) / 2.4e-19 < 1e-2) elif args.chirp_type == 'beta': beta = get_beta(Ar, m, k0) assert(np.abs(beta - 2e-17) / 2e-17 < 1e-2) +elif args.chirp_type == 'zeta': + zeta = get_zeta(Ar, m) + assert(np.abs(zeta - 2.4e-19) / 2.4e-19 < 1e-2) From e43990274b24b7fc52ddf0a438f212896550c59a Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:36:34 +0100 Subject: [PATCH 123/254] Update laser_STC.SI.1Rank.sh --- tests/laser_STC.SI.1Rank.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/laser_STC.SI.1Rank.sh b/tests/laser_STC.SI.1Rank.sh index 642b8d9524..49485291ce 100644 --- a/tests/laser_STC.SI.1Rank.sh +++ b/tests/laser_STC.SI.1Rank.sh @@ -38,7 +38,7 @@ rm -rf $TEST_NAME # Run the simulation with initial zeta mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ - laser.zeta = 2.4e-23 \ + laser.zeta = 2.4e-19 \ laser.STC_theta_xy = 0 \ hipace.file_prefix = $TEST_NAME From c8616123d7d9b7db43ef8d7710a5ad4e40c6338e Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:41:10 +0100 Subject: [PATCH 124/254] Update analysis_laser_init_chirp.py From 7e772997c00619ac3f2c636ba7e1aa30e97f42b8 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:57:29 +0100 Subject: [PATCH 125/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 6c7c2e68b7..4ab6b8b62b 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -95,4 +95,4 @@ def get_beta(Ar,m,k0): assert(np.abs(beta - 2e-17) / 2e-17 < 1e-2) elif args.chirp_type == 'zeta': zeta = get_zeta(Ar, m) - assert(np.abs(zeta - 2.4e-19) / 2.4e-19 < 1e-2) + assert(np.abs(zeta - 2.4e-22) / 2.4e-22 < 1e-2) From f94d0f35d92629d9791a88ca146b62227ffee308 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:58:01 +0100 Subject: [PATCH 126/254] Update laser_STC.SI.1Rank.sh --- tests/laser_STC.SI.1Rank.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/laser_STC.SI.1Rank.sh b/tests/laser_STC.SI.1Rank.sh index 49485291ce..a0e8c6a530 100644 --- a/tests/laser_STC.SI.1Rank.sh +++ b/tests/laser_STC.SI.1Rank.sh @@ -38,7 +38,7 @@ rm -rf $TEST_NAME # Run the simulation with initial zeta mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ - laser.zeta = 2.4e-19 \ + laser.zeta = 2.4e-22 \ laser.STC_theta_xy = 0 \ hipace.file_prefix = $TEST_NAME From 49ffe35b9c0b19bbfbb5ea59bf078ce1b6cf33ae Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:38:44 +0100 Subject: [PATCH 127/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 25 +++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 4ab6b8b62b..464ff1cd55 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -12,21 +12,22 @@ import scipy.constants as scc from openpmd_viewer.addons import LpaDiagnostics -def get_phi2 (Ar, m, tau): +def get_duration(Ar,m): + weights=np.abs(Ar**2) + mean_val = np.average(m.z, weights=np.sum(weights,axis=1)) + std = np.sqrt(np.average((m.z - mean_val) ** 2, weights=np.sum(weights,axis=1))) + return 2*std/scc.c + +def get_phi2 (Ar, m): # get temporal chirp phi2 - temp_chirp = 0 - summ = 0 + tau = get_duration(Ar,m) laser_module1 = np.abs(Ar**2) - phi_envelop = np.unwrap(np.array(np.arctan2(Ar.imag, Ar.real)), axis=0) + phi_envelop = np.unwrap( np.unwrap(np.array(np.arctan2(Ar.imag, Ar.real)), axis=0), axis=1) # calculate pphi_pz - z_diff = np.diff(m.z) - pphi_pz = (np.diff(phi_envelop, axis=0)).T/ (z_diff/scc.c) - pphi_pz2 = ((np.diff(pphi_pz, axis=1)) / (z_diff[:len(z_diff)-1]) / scc.c).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 + pphi_pz = np.gradient(phi_envelop, (m.z[1]-m.z[0]), axis=1) + pphi_pz2 = np.gradient(pphi_pz, (m.z[1]-m.z[0]), axis=1) + temp_chirp = np.average(pphi_pz2, weights=laser_module1) + x = temp_chirp a = 4 * x b = -4 c = tau**4 * x From e7fdc3085b0f8d9b029145be3b43f39bddcfdf0a Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:44:48 +0100 Subject: [PATCH 128/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 464ff1cd55..a2a7c44da5 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -89,7 +89,7 @@ def get_beta(Ar,m,k0): k0 = 2 * scc.pi / lambda0 print(get_zeta(Ar, m)) if args.chirp_type == 'phi2': - phi2 = get_phi2(Ar, m, tau) + phi2 = get_phi2(Ar, m) assert(np.abs(phi2 - 2.4e-26) / 2.4e-26 < 1e-2) elif args.chirp_type == 'beta': beta = get_beta(Ar, m, k0) From 1cf5942faabc087ade73ac699ea9600e8b0b6966 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:53:15 +0100 Subject: [PATCH 129/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index a2a7c44da5..58cc4f4c5c 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -24,8 +24,8 @@ def get_phi2 (Ar, m): laser_module1 = np.abs(Ar**2) phi_envelop = np.unwrap( np.unwrap(np.array(np.arctan2(Ar.imag, Ar.real)), axis=0), axis=1) # calculate pphi_pz - pphi_pz = np.gradient(phi_envelop, (m.z[1]-m.z[0]), axis=1) - pphi_pz2 = np.gradient(pphi_pz, (m.z[1]-m.z[0]), axis=1) + pphi_pz = np.gradient(phi_envelop, (m.z[1]-m.z[0])/scc.c, axis=0) + pphi_pz2 = np.gradient(pphi_pz, (m.z[1]-m.z[0])/scc.c, axis=0) temp_chirp = np.average(pphi_pz2, weights=laser_module1) x = temp_chirp a = 4 * x From 4b137a89db665f1e3f714995c114fc5a93d935d5 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:04:39 +0100 Subject: [PATCH 130/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 58cc4f4c5c..09cb623ae9 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -31,15 +31,14 @@ def get_phi2 (Ar, m): a = 4 * x b = -4 c = tau**4 * x - zeta_roots = np.roots([a, b, c]) - return np.max(zeta_roots) + return np.max(np.roots([a, b, c])) 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 temporal2spectral_fft(Ar,m): +def temporal2spectral_fft(Ar,m,k0): spect=np.fft.ifft( Ar, axis=1, norm="backward" ) @@ -48,8 +47,8 @@ def temporal2spectral_fft(Ar,m): omega = 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0 *scc.c return omega,spect -def get_zeta(Ar,m): - omega,env_spec=temporal2spectral_fft(Ar,m) +def get_zeta(Ar,m,k0): + omega,env_spec=temporal2spectral_fft(Ar,m,k0) env_spec_abs = np.abs(env_spec**2) yda = np.sum(m.x * env_spec_abs, axis=1) / np.sum(env_spec_abs, axis=1) derivative_y_zeta = np.gradient(yda, omega) @@ -58,7 +57,7 @@ def get_zeta(Ar,m): return zeta_y def get_beta(Ar,m,k0): - omega,env_spec=temporal2spectral_fft(Ar,m) + omega,env_spec=temporal2spectral_fft(Ar,m,k0) env_spec_abs = np.abs(env_spec**2) phi_envelop_abs = np.unwrap( np.arctan2(env_spec.imag, env_spec.real), axis=0 @@ -95,5 +94,5 @@ def get_beta(Ar,m,k0): beta = get_beta(Ar, m, k0) assert(np.abs(beta - 2e-17) / 2e-17 < 1e-2) elif args.chirp_type == 'zeta': - zeta = get_zeta(Ar, m) + zeta = get_zeta(Ar, m,k0) assert(np.abs(zeta - 2.4e-22) / 2.4e-22 < 1e-2) From 3f5e205e7059935ea093b06296077826ab39ba20 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:08:28 +0100 Subject: [PATCH 131/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 09cb623ae9..cf59ef08a8 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -86,7 +86,7 @@ def get_beta(Ar,m,k0): L0 = 5e-6 tau = L0 / scc.c # Laser duration k0 = 2 * scc.pi / lambda0 -print(get_zeta(Ar, m)) +print(get_zeta(Ar, m,k0)) if args.chirp_type == 'phi2': phi2 = get_phi2(Ar, m) assert(np.abs(phi2 - 2.4e-26) / 2.4e-26 < 1e-2) From a6598f507a06b4d048c310b630b9b70025c34017 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:15:29 +0100 Subject: [PATCH 132/254] Update inputs_SI --- examples/laser/inputs_SI | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_SI b/examples/laser/inputs_SI index f14b4ec22b..55098767ad 100644 --- a/examples/laser/inputs_SI +++ b/examples/laser/inputs_SI @@ -2,7 +2,7 @@ max_step = 30 hipace.dt = 70.e-6/clight hipace.verbose=3 -amr.n_cell = 128 128 50 +amr.n_cell = 128 128 50 # 128 128 100 my_constants.kp_inv = 10.e-6 From 294c63881d60aa148d90c7790afa093eb72f1d75 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:18:12 +0100 Subject: [PATCH 133/254] Update laser_STC.SI.1Rank.sh --- tests/laser_STC.SI.1Rank.sh | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/tests/laser_STC.SI.1Rank.sh b/tests/laser_STC.SI.1Rank.sh index a0e8c6a530..baffabf8f8 100644 --- a/tests/laser_STC.SI.1Rank.sh +++ b/tests/laser_STC.SI.1Rank.sh @@ -28,33 +28,11 @@ TEST_NAME="${FILE_NAME%.*}" # Run the simulation with initial phi2 mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ laser.phi2 = 2.4e-26 \ - laser.STC_theta_xy = 0 \ - hipace.file_prefix = $TEST_NAME -# Compare the result with theory -$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ - --chirp_type="phi2" - -rm -rf $TEST_NAME - -# Run the simulation with initial zeta -mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ laser.zeta = 2.4e-22 \ - laser.STC_theta_xy = 0 \ - hipace.file_prefix = $TEST_NAME - -# Compare the result with theory -$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ - --chirp_type="zeta" - -rm -rf $TEST_NAME - -mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ laser.beta = 2e-17 \ laser.STC_theta_xy = 0 \ hipace.file_prefix = $TEST_NAME - # Compare the result with theory -$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \ - --chirp_type="beta" +$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME rm -rf $TEST_NAME From 06b3ea5487ebfee73ea7521b49956553ff67df53 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:19:09 +0100 Subject: [PATCH 134/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index cf59ef08a8..bffc07ae48 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -87,12 +87,6 @@ def get_beta(Ar,m,k0): tau = L0 / scc.c # Laser duration k0 = 2 * scc.pi / lambda0 print(get_zeta(Ar, m,k0)) -if args.chirp_type == 'phi2': - phi2 = get_phi2(Ar, m) - assert(np.abs(phi2 - 2.4e-26) / 2.4e-26 < 1e-2) -elif args.chirp_type == 'beta': - beta = get_beta(Ar, m, k0) - assert(np.abs(beta - 2e-17) / 2e-17 < 1e-2) -elif args.chirp_type == 'zeta': - zeta = get_zeta(Ar, m,k0) - assert(np.abs(zeta - 2.4e-22) / 2.4e-22 < 1e-2) +assert(np.abs(get_phi2(Ar, m) - 2.4e-26) / 2.4e-26 < 1e-2) +assert(np.abs(get_beta(Ar, m, k0) - 2e-17) / 2e-17 < 1e-2) +assert(np.abs( get_zeta(Ar, m,k0) - 2.4e-22) / 2.4e-22 < 1e-2) From 30e59c03b87b6e20277d3b5b0002495c24684291 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:25:02 +0100 Subject: [PATCH 135/254] Update laser_STC.SI.1Rank.sh --- tests/laser_STC.SI.1Rank.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/laser_STC.SI.1Rank.sh b/tests/laser_STC.SI.1Rank.sh index baffabf8f8..dba74718ad 100644 --- a/tests/laser_STC.SI.1Rank.sh +++ b/tests/laser_STC.SI.1Rank.sh @@ -28,8 +28,8 @@ TEST_NAME="${FILE_NAME%.*}" # Run the simulation with initial phi2 mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ laser.phi2 = 2.4e-26 \ - laser.zeta = 2.4e-22 \ - laser.beta = 2e-17 \ + laser.zeta = 2.4e-21 \ + laser.beta = 2e-16 \ laser.STC_theta_xy = 0 \ hipace.file_prefix = $TEST_NAME # Compare the result with theory From 7a4c1050db4c67d0958a4eb016668bb42090dfe8 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:26:18 +0100 Subject: [PATCH 136/254] Update MultiLaser.cpp --- src/laser/MultiLaser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 7bacc3ed3c..98b49c3eb5 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -912,12 +912,12 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) // Time stretching due to STCs and phi2 complex envelope // (1 if zeta=0, beta=0, phi2=0) Complex stretch_factor = 1._rt \ - + 4._rt * (zeta + beta * zfoc) * inv_tau2 * (zeta + beta * zfoc) * inv_complex_waist_2 \ + + 4._rt * (-zeta + beta * zfoc) * inv_tau2 * (-zeta + beta * zfoc) * inv_complex_waist_2 \ + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * inv_tau2; Complex prefactor = a0 / diffract_factor; Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * amrex::pow(zp - beta * k0 * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) * clight - 2._rt * I * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) - * (zeta - beta * zfoc) * clight * inv_complex_waist_2, 2); + * (-zeta - beta * zfoc) * clight * inv_complex_waist_2, 2); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; Complex envelope = stcfactor * amrex::exp( exp_argument ) * \ From 0c17d24048103208081ccdccfca8eda53246cf89 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:27:13 +0100 Subject: [PATCH 137/254] Update laser_STC.SI.1Rank.sh --- tests/laser_STC.SI.1Rank.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/laser_STC.SI.1Rank.sh b/tests/laser_STC.SI.1Rank.sh index dba74718ad..a5cc360380 100644 --- a/tests/laser_STC.SI.1Rank.sh +++ b/tests/laser_STC.SI.1Rank.sh @@ -27,10 +27,6 @@ TEST_NAME="${FILE_NAME%.*}" # Run the simulation with initial phi2 mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ - laser.phi2 = 2.4e-26 \ - laser.zeta = 2.4e-21 \ - laser.beta = 2e-16 \ - laser.STC_theta_xy = 0 \ hipace.file_prefix = $TEST_NAME # Compare the result with theory $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME From 03420a572a4a86ec2c9662721744dccac8cd6910 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:27:47 +0100 Subject: [PATCH 138/254] Update inputs_chirp --- examples/laser/inputs_chirp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 0c5145f5e4..a7ee6ed80f 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -20,6 +20,10 @@ laser.position_mean = 0. 0. 0 laser.focal_distance = 0.0 laser.w0 = 30e-6 laser.L0 = 5e-6 +laser.phi2 = 2.4e-26 +laser.zeta = 2.4e-21 +laser.beta = 2e-16 +laser.STC_theta_xy = 0 amr.max_level = 0 diagnostic.output_period = 1 From 0afc89db107f3296655cbcb9ebbd28b5b30816e0 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:28:14 +0100 Subject: [PATCH 139/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index bffc07ae48..e9acb451ed 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -88,5 +88,5 @@ def get_beta(Ar,m,k0): k0 = 2 * scc.pi / lambda0 print(get_zeta(Ar, m,k0)) assert(np.abs(get_phi2(Ar, m) - 2.4e-26) / 2.4e-26 < 1e-2) -assert(np.abs(get_beta(Ar, m, k0) - 2e-17) / 2e-17 < 1e-2) -assert(np.abs( get_zeta(Ar, m,k0) - 2.4e-22) / 2.4e-22 < 1e-2) +assert(np.abs(get_beta(Ar, m, k0) - 2e-16) / 2e-16 < 1e-2) +assert(np.abs( get_zeta(Ar, m,k0) - 2.4e-21) / 2.4e-21 < 1e-2) From 7cd81f466d2302e02edbb49f318a849b8827a98f Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:35:02 +0100 Subject: [PATCH 140/254] Update MultiLaser.cpp --- src/laser/MultiLaser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 98b49c3eb5..7bacc3ed3c 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -912,12 +912,12 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) // Time stretching due to STCs and phi2 complex envelope // (1 if zeta=0, beta=0, phi2=0) Complex stretch_factor = 1._rt \ - + 4._rt * (-zeta + beta * zfoc) * inv_tau2 * (-zeta + beta * zfoc) * inv_complex_waist_2 \ + + 4._rt * (zeta + beta * zfoc) * inv_tau2 * (zeta + beta * zfoc) * inv_complex_waist_2 \ + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * inv_tau2; Complex prefactor = a0 / diffract_factor; Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * amrex::pow(zp - beta * k0 * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) * clight - 2._rt * I * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) - * (-zeta - beta * zfoc) * clight * inv_complex_waist_2, 2); + * (zeta - beta * zfoc) * clight * inv_complex_waist_2, 2); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; Complex envelope = stcfactor * amrex::exp( exp_argument ) * \ From 5fa7db370fa3001e82a23781c14cf2348e8d1aa8 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:38:59 +0100 Subject: [PATCH 141/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index e9acb451ed..f8d15d6551 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -81,12 +81,11 @@ def get_beta(Ar,m,k0): ts = LpaDiagnostics(args.output_dir) Ar, m = ts.get_field(field='laserEnvelope', iteration=0) -lambda0 = .8e-6 # Laser wavelength -w0 = 30.e-6 # Laser waist -L0 = 5e-6 -tau = L0 / scc.c # Laser duration +lambda0 = .6e-6 # Laser wavelength +w0 = 5e-6 # Laser waist +tau = 5e-14 # Laser duration k0 = 2 * scc.pi / lambda0 print(get_zeta(Ar, m,k0)) -assert(np.abs(get_phi2(Ar, m) - 2.4e-26) / 2.4e-26 < 1e-2) -assert(np.abs(get_beta(Ar, m, k0) - 2e-16) / 2e-16 < 1e-2) -assert(np.abs( get_zeta(Ar, m,k0) - 2.4e-21) / 2.4e-21 < 1e-2) +assert(np.abs(get_phi2(Ar, m) - 2.4e-19) / 2.4e-19 < 1e-2) +assert(np.abs(get_beta(Ar, m, k0) - 3e-18) / 3e-18 < 1e-2) +assert(np.abs( get_zeta(Ar, m,k0) - 2.4e-24) / 2.4e-24 < 1e-2) From 9b421f0377640aec1c2a2c151d1432ed634785ac Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:41:19 +0100 Subject: [PATCH 142/254] Update inputs_chirp --- examples/laser/inputs_chirp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index a7ee6ed80f..dfeb7bf876 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -9,20 +9,20 @@ my_constants.kp_inv = 10.e-6 hipace.file_prefix = new hipace.do_tiling = 0 -geometry.prob_lo = -15.*kp_inv -15.*kp_inv -2.*kp_inv -geometry.prob_hi = 15.*kp_inv 15.*kp_inv 2.*kp_inv +geometry.prob_lo = -15e-6 -15e-6 -8e-6 +geometry.prob_hi = 15e-6 15e-6 8e-6 lasers.names = laser -lasers.lambda0 = .8e-6 +lasers.lambda0 = .6e-6 laser.a0 = 1 laser.position_mean = 0. 0. 0 laser.focal_distance = 0.0 -laser.w0 = 30e-6 -laser.L0 = 5e-6 -laser.phi2 = 2.4e-26 -laser.zeta = 2.4e-21 -laser.beta = 2e-16 +laser.w0 = 5e-6 +laser.tau = 5e-14 +laser.phi2 = 2.4e-19 +laser.zeta = 2.4e-24 +laser.beta = 3e-18 laser.STC_theta_xy = 0 amr.max_level = 0 From eab515e8d14260ef8c70b15bf3a0a64898fb26b2 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:46:34 +0100 Subject: [PATCH 143/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index f8d15d6551..eba3378ab0 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -85,7 +85,10 @@ def get_beta(Ar,m,k0): w0 = 5e-6 # Laser waist tau = 5e-14 # Laser duration k0 = 2 * scc.pi / lambda0 -print(get_zeta(Ar, m,k0)) +print('zeta is ') +print(get_zeta(Ar, m, k0)) +print('beta is ') +print(get_beta(Ar, m, k0)) assert(np.abs(get_phi2(Ar, m) - 2.4e-19) / 2.4e-19 < 1e-2) assert(np.abs(get_beta(Ar, m, k0) - 3e-18) / 3e-18 < 1e-2) assert(np.abs( get_zeta(Ar, m,k0) - 2.4e-24) / 2.4e-24 < 1e-2) From 6e45dc55486a759c43fd12955e96d82c3da9c425 Mon Sep 17 00:00:00 2001 From: huixingjian Date: Tue, 10 Dec 2024 16:02:18 +0100 Subject: [PATCH 144/254] use lasy to diag --- .github/workflows/setup/ubuntu_ompi.sh | 2 + examples/laser/analysis_laser_init_chirp.py | 82 +++++---------------- 2 files changed, 19 insertions(+), 65 deletions(-) diff --git a/.github/workflows/setup/ubuntu_ompi.sh b/.github/workflows/setup/ubuntu_ompi.sh index 136e72c305..4b566ef846 100755 --- a/.github/workflows/setup/ubuntu_ompi.sh +++ b/.github/workflows/setup/ubuntu_ompi.sh @@ -34,3 +34,5 @@ sudo update-alternatives --set python /usr/bin/python3 python -m pip install --upgrade pip python -m pip install --upgrade matplotlib==3.2.2 numpy scipy openpmd-viewer openpmd-api +python -m pip install pip install git+https://github.com/huixingjian/lasy-.git@add_diag_util + diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index eba3378ab0..0096f63a3c 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -11,61 +11,17 @@ import numpy as np import scipy.constants as scc from openpmd_viewer.addons import LpaDiagnostics - -def get_duration(Ar,m): - weights=np.abs(Ar**2) - mean_val = np.average(m.z, weights=np.sum(weights,axis=1)) - std = np.sqrt(np.average((m.z - mean_val) ** 2, weights=np.sum(weights,axis=1))) - return 2*std/scc.c - -def get_phi2 (Ar, m): - # get temporal chirp phi2 - tau = get_duration(Ar,m) - laser_module1 = np.abs(Ar**2) - phi_envelop = np.unwrap( np.unwrap(np.array(np.arctan2(Ar.imag, Ar.real)), axis=0), axis=1) - # calculate pphi_pz - pphi_pz = np.gradient(phi_envelop, (m.z[1]-m.z[0])/scc.c, axis=0) - pphi_pz2 = np.gradient(pphi_pz, (m.z[1]-m.z[0])/scc.c, axis=0) - temp_chirp = np.average(pphi_pz2, weights=laser_module1) - x = temp_chirp - a = 4 * x - b = -4 - c = tau**4 * x - return np.max(np.roots([a, b, c])) - -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 temporal2spectral_fft(Ar,m,k0): - spect=np.fft.ifft( - Ar, axis=1, norm="backward" - ) - Nt = len(m.z) - dt= (m.z[1]-m.z[0])/scc.c - omega = 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0 *scc.c - return omega,spect - -def get_zeta(Ar,m,k0): - omega,env_spec=temporal2spectral_fft(Ar,m,k0) - env_spec_abs = np.abs(env_spec**2) - yda = np.sum(m.x * env_spec_abs, axis=1) / np.sum(env_spec_abs, axis=1) - derivative_y_zeta = np.gradient(yda, omega) - weight_y_2d = np.mean(env_spec_abs, axis=1) - zeta_y = np.average(derivative_y_zeta.T, weights=weight_y_2d) - return zeta_y - -def get_beta(Ar,m,k0): - omega,env_spec=temporal2spectral_fft(Ar,m,k0) - env_spec_abs = np.abs(env_spec**2) - phi_envelop_abs = np.unwrap( - np.arctan2(env_spec.imag, env_spec.real), axis=0 - ) - angle_y = np.gradient(phi_envelop_abs, m.x[1]-m.x[0], axis=0) / k0 - derivative_y_beta = np.gradient(angle_y, omega, axis=0) - beta_y = np.average(derivative_y_beta, weights=env_spec_abs) - return beta_y +from lasy.utils.laser_utils import get_STC +from lasy.profiles import FromOpenPMDProfile + +profile = FromOpenPMDProfile(path=args.output_dir,iteration=0,pol=[1,0],field='laserEnvelope',coord=, is_envelope=True) +laser = Laser( + dim="xyt", + lo=(-15e-6, -15e-6, -30e-15), + hi=(15e-6,15e-6, +30e-15), + npoints=(50, 400), + profile=profile, + ) parser = argparse.ArgumentParser(description = 'Verify the chirp initialization') parser.add_argument('--output-dir', @@ -78,17 +34,13 @@ def get_beta(Ar,m,k0): help='Type of the initialized chirp') args = parser.parse_args() -ts = LpaDiagnostics(args.output_dir) -Ar, m = ts.get_field(field='laserEnvelope', iteration=0) -lambda0 = .6e-6 # Laser wavelength -w0 = 5e-6 # Laser waist -tau = 5e-14 # Laser duration k0 = 2 * scc.pi / lambda0 +stc=get_STC(laser.grid,laser.dim,k0) print('zeta is ') -print(get_zeta(Ar, m, k0)) +print(stc['zeta_x']) print('beta is ') -print(get_beta(Ar, m, k0)) -assert(np.abs(get_phi2(Ar, m) - 2.4e-19) / 2.4e-19 < 1e-2) -assert(np.abs(get_beta(Ar, m, k0) - 3e-18) / 3e-18 < 1e-2) -assert(np.abs( get_zeta(Ar, m,k0) - 2.4e-24) / 2.4e-24 < 1e-2) +print(stc['beta_x']) +assert(np.abs(stc['phi2'] - 2.4e-19) / 2.4e-19 < 1e-2) +assert(np.abs(stc['beta_x'] - 3e-18) / 3e-18 < 1e-2) +assert(np.abs(stc['zeta_x'] - 2.4e-24) / 2.4e-24 < 1e-2) From 0df4f48b035ec368cb70429184562af41ad1db23 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:03:38 +0100 Subject: [PATCH 145/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 0096f63a3c..df282df1ba 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -14,15 +14,6 @@ from lasy.utils.laser_utils import get_STC from lasy.profiles import FromOpenPMDProfile -profile = FromOpenPMDProfile(path=args.output_dir,iteration=0,pol=[1,0],field='laserEnvelope',coord=, is_envelope=True) -laser = Laser( - dim="xyt", - lo=(-15e-6, -15e-6, -30e-15), - hi=(15e-6,15e-6, +30e-15), - npoints=(50, 400), - profile=profile, - ) - parser = argparse.ArgumentParser(description = 'Verify the chirp initialization') parser.add_argument('--output-dir', dest='output_dir', @@ -34,6 +25,14 @@ help='Type of the initialized chirp') args = parser.parse_args() +profile = FromOpenPMDProfile(path=args.output_dir,iteration=0,pol=[1,0],field='laserEnvelope',coord=, is_envelope=True) +laser = Laser( + dim="xyt", + lo=(-15e-6, -15e-6, -30e-15), + hi=(15e-6,15e-6, +30e-15), + npoints=(50, 400), + profile=profile, + ) k0 = 2 * scc.pi / lambda0 stc=get_STC(laser.grid,laser.dim,k0) From 76d402ba92cd5dc493ddb302cb9c8b74f8d161fb Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:37:33 +0100 Subject: [PATCH 146/254] Update ubuntu_ompi.sh --- .github/workflows/setup/ubuntu_ompi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/setup/ubuntu_ompi.sh b/.github/workflows/setup/ubuntu_ompi.sh index 4b566ef846..2a3b90400b 100755 --- a/.github/workflows/setup/ubuntu_ompi.sh +++ b/.github/workflows/setup/ubuntu_ompi.sh @@ -34,5 +34,5 @@ sudo update-alternatives --set python /usr/bin/python3 python -m pip install --upgrade pip python -m pip install --upgrade matplotlib==3.2.2 numpy scipy openpmd-viewer openpmd-api -python -m pip install pip install git+https://github.com/huixingjian/lasy-.git@add_diag_util +python -m pip install --no-deps git+https://github.com/huixingjian/lasy-.git@add_diag_util From 29890bd45800306b199e829c8e7939fd40d68fc0 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:43:04 +0100 Subject: [PATCH 147/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index df282df1ba..ff5c34d0f5 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -25,7 +25,7 @@ help='Type of the initialized chirp') args = parser.parse_args() -profile = FromOpenPMDProfile(path=args.output_dir,iteration=0,pol=[1,0],field='laserEnvelope',coord=, is_envelope=True) +profile = FromOpenPMDProfile(path=args.output_dir,iteration=0,pol=[1,0],field='laserEnvelope', is_envelope=True) laser = Laser( dim="xyt", lo=(-15e-6, -15e-6, -30e-15), From ac584661075e1a324cea9c29c138c8e8999a0016 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:50:20 +0100 Subject: [PATCH 148/254] Update inputs_chirp --- examples/laser/inputs_chirp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index dfeb7bf876..a806ea5284 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,7 +2,7 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose = 3 -amr.n_cell = 255 511 200 +amr.n_cell = 255 255 50 my_constants.kp_inv = 10.e-6 @@ -33,4 +33,4 @@ hipace.depos_order_xy = 0 boundary.field = Dirichlet boundary.particle = Absorbing -diagnostic.diag_type = xz +diagnostic.diag_type = xyz From 38dbc5b5b05b35112f0cadb0e4e8a050273e81d7 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:50:54 +0100 Subject: [PATCH 149/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index ff5c34d0f5..e6f3d0742f 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -30,7 +30,7 @@ dim="xyt", lo=(-15e-6, -15e-6, -30e-15), hi=(15e-6,15e-6, +30e-15), - npoints=(50, 400), + npoints=(255, 255, 50), profile=profile, ) From a880f70bd19fb17cb825ed1c2f41ac0a8ff0d3f9 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:52:03 +0100 Subject: [PATCH 150/254] Update inputs_chirp --- examples/laser/inputs_chirp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index a806ea5284..e34e07cc59 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -33,4 +33,5 @@ hipace.depos_order_xy = 0 boundary.field = Dirichlet boundary.particle = Absorbing +diagnostic.field_data = laserEnvelope diagnostic.diag_type = xyz From b5015e1e9d3e2e7ebe2f7f43c57b23fa198aa17e Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 10 Dec 2024 17:06:27 +0100 Subject: [PATCH 151/254] Update ubuntu_ompi.sh --- .github/workflows/setup/ubuntu_ompi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/setup/ubuntu_ompi.sh b/.github/workflows/setup/ubuntu_ompi.sh index 2a3b90400b..3b748f2b99 100755 --- a/.github/workflows/setup/ubuntu_ompi.sh +++ b/.github/workflows/setup/ubuntu_ompi.sh @@ -33,6 +33,6 @@ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2 sudo update-alternatives --set python /usr/bin/python3 python -m pip install --upgrade pip -python -m pip install --upgrade matplotlib==3.2.2 numpy scipy openpmd-viewer openpmd-api +python -m pip install --upgrade matplotlib==3.2.2 numpy scipy openpmd-viewer openpmd-api axiprop python -m pip install --no-deps git+https://github.com/huixingjian/lasy-.git@add_diag_util From ac709e06e77909eaa7fb98ab9fc126173fcccaeb Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 10 Dec 2024 17:27:27 +0100 Subject: [PATCH 152/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index e6f3d0742f..fcd4a0fbe2 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -25,7 +25,7 @@ help='Type of the initialized chirp') args = parser.parse_args() -profile = FromOpenPMDProfile(path=args.output_dir,iteration=0,pol=[1,0],field='laserEnvelope', is_envelope=True) +profile = FromOpenPMDProfile(path=args.output_dir,iteration=0,pol=[1,0],field='laserEnvelope', is_envelope=True,prefix='') laser = Laser( dim="xyt", lo=(-15e-6, -15e-6, -30e-15), From 815e663ae6aeaf0a65e76951f12cbf7bf1f65384 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 10 Dec 2024 17:32:14 +0100 Subject: [PATCH 153/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index fcd4a0fbe2..25f139b2e7 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -25,7 +25,7 @@ help='Type of the initialized chirp') args = parser.parse_args() -profile = FromOpenPMDProfile(path=args.output_dir,iteration=0,pol=[1,0],field='laserEnvelope', is_envelope=True,prefix='') +profile = FromOpenPMDProfile(path=args.output_dir,iteration=0,pol=[1,0],field='laserEnvelope', is_envelope=True, prefix='') laser = Laser( dim="xyt", lo=(-15e-6, -15e-6, -30e-15), From b70fe7bf84cb0e98e46da6eeb904673fdfee1a7d Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 10 Dec 2024 18:02:34 +0100 Subject: [PATCH 154/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 25f139b2e7..0035088ec8 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -24,7 +24,7 @@ default='phi2', help='Type of the initialized chirp') args = parser.parse_args() - +print(args.output_dir) profile = FromOpenPMDProfile(path=args.output_dir,iteration=0,pol=[1,0],field='laserEnvelope', is_envelope=True, prefix='') laser = Laser( dim="xyt", From aa68948e95bf07f6e2f2d2cc851dcd8808abc6b0 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 10 Dec 2024 18:03:04 +0100 Subject: [PATCH 155/254] Update laser_STC.SI.1Rank.sh --- tests/laser_STC.SI.1Rank.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/laser_STC.SI.1Rank.sh b/tests/laser_STC.SI.1Rank.sh index a5cc360380..e325cba214 100644 --- a/tests/laser_STC.SI.1Rank.sh +++ b/tests/laser_STC.SI.1Rank.sh @@ -30,5 +30,5 @@ mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ hipace.file_prefix = $TEST_NAME # Compare the result with theory $HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME - +ls . rm -rf $TEST_NAME From bf1dae6aca288ba7dbd9699d4205bc87b6dfce5c Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 10 Dec 2024 18:19:19 +0100 Subject: [PATCH 156/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 0035088ec8..8cdad11d1c 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -25,7 +25,7 @@ help='Type of the initialized chirp') args = parser.parse_args() print(args.output_dir) -profile = FromOpenPMDProfile(path=args.output_dir,iteration=0,pol=[1,0],field='laserEnvelope', is_envelope=True, prefix='') +profile = FromOpenPMDProfile(path='./',iteration=0,pol=[1,0],field='laserEnvelope', is_envelope=True, prefix=args.output_dir) laser = Laser( dim="xyt", lo=(-15e-6, -15e-6, -30e-15), From 90f5506641e29d235611a532f053b94952453606 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 10 Dec 2024 18:23:08 +0100 Subject: [PATCH 157/254] Update laser_STC.SI.1Rank.sh --- tests/laser_STC.SI.1Rank.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/laser_STC.SI.1Rank.sh b/tests/laser_STC.SI.1Rank.sh index e325cba214..347e30c372 100644 --- a/tests/laser_STC.SI.1Rank.sh +++ b/tests/laser_STC.SI.1Rank.sh @@ -23,7 +23,7 @@ HIPACE_EXAMPLE_DIR=${HIPACE_SOURCE_DIR}/examples/laser HIPACE_TEST_DIR=${HIPACE_SOURCE_DIR}/tests FILE_NAME=`basename "$0"` -TEST_NAME="${FILE_NAME%.*}" +TEST_NAME="${FILE_NAME%.*}_0" # Run the simulation with initial phi2 mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ From bd28df606659944a066ebac9189a0e034eb40222 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 10 Dec 2024 19:34:26 +0100 Subject: [PATCH 158/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 8cdad11d1c..de879ef3ba 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -25,11 +25,11 @@ help='Type of the initialized chirp') args = parser.parse_args() print(args.output_dir) -profile = FromOpenPMDProfile(path='./',iteration=0,pol=[1,0],field='laserEnvelope', is_envelope=True, prefix=args.output_dir) +profile = FromOpenPMDProfile(path=' ',iteration=0,pol=[1,0],field='laserEnvelope', is_envelope=True, prefix=args.output_dir) laser = Laser( dim="xyt", lo=(-15e-6, -15e-6, -30e-15), - hi=(15e-6,15e-6, +30e-15), + hi=(15e-6, 15e-6, +30e-15), npoints=(255, 255, 50), profile=profile, ) From eee6fbad901edca5c77c331fae63a525d25f28e8 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 11 Dec 2024 15:22:02 +0100 Subject: [PATCH 159/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index de879ef3ba..89fe539cd7 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -25,7 +25,7 @@ help='Type of the initialized chirp') args = parser.parse_args() print(args.output_dir) -profile = FromOpenPMDProfile(path=' ',iteration=0,pol=[1,0],field='laserEnvelope', is_envelope=True, prefix=args.output_dir) +profile = FromOpenPMDProfile(path=args.output_dir,iteration=0,pol=[1,0],field='laserEnvelope', is_envelope=True, prefix='openpmd') laser = Laser( dim="xyt", lo=(-15e-6, -15e-6, -30e-15), From 7032c2471b829acf0dd18864160f4b3734a75b45 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 11 Dec 2024 15:32:40 +0100 Subject: [PATCH 160/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 89fe539cd7..53eb9afa6b 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -13,6 +13,7 @@ from openpmd_viewer.addons import LpaDiagnostics from lasy.utils.laser_utils import get_STC from lasy.profiles import FromOpenPMDProfile +from lasy.laser import Laser parser = argparse.ArgumentParser(description = 'Verify the chirp initialization') parser.add_argument('--output-dir', From dfca07c995f1fee83c499b03f65b624e1507ae78 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 11 Dec 2024 15:41:08 +0100 Subject: [PATCH 161/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 53eb9afa6b..2bd7379488 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -35,7 +35,7 @@ profile=profile, ) -k0 = 2 * scc.pi / lambda0 +k0 = 2 * scc.pi / 0.6e-6 stc=get_STC(laser.grid,laser.dim,k0) print('zeta is ') print(stc['zeta_x']) From b125be0a814bd035bdefbe9d62c13efd16d7f6a7 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 11 Dec 2024 15:51:31 +0100 Subject: [PATCH 162/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 2bd7379488..ea9c9a8fd1 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -36,7 +36,7 @@ ) k0 = 2 * scc.pi / 0.6e-6 -stc=get_STC(laser.grid,laser.dim,k0) +stc=get_STC(xlaser.dim,.6e-6,k0) print('zeta is ') print(stc['zeta_x']) print('beta is ') From b9ac2c830d5036c82a6f4cbf13c543dbf7cf3be9 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 11 Dec 2024 16:00:09 +0100 Subject: [PATCH 163/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index ea9c9a8fd1..01a36506fb 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -36,7 +36,7 @@ ) k0 = 2 * scc.pi / 0.6e-6 -stc=get_STC(xlaser.dim,.6e-6,k0) +stc=get_STC(laser.dim,laser.grid,k0) print('zeta is ') print(stc['zeta_x']) print('beta is ') From 925fdaf995f46c56138343f3aa2fbd57e9f35461 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:55:30 +0100 Subject: [PATCH 164/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 01a36506fb..76f8a10c2d 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -29,9 +29,9 @@ profile = FromOpenPMDProfile(path=args.output_dir,iteration=0,pol=[1,0],field='laserEnvelope', is_envelope=True, prefix='openpmd') laser = Laser( dim="xyt", - lo=(-15e-6, -15e-6, -30e-15), - hi=(15e-6, 15e-6, +30e-15), - npoints=(255, 255, 50), + lo=(np.min(profile.axes['x']), np.min(profile.axes['y']), np.min(profile.axes['t'])), + hi=(np.max(profile.axes['x']), np.max(profile.axes['y']), np.max(profile.axes['t'])), + npoints=(255, 255, 200), profile=profile, ) From 8395f5b1e1c8a429be3bba63e7505ae9540cc6d4 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:07:05 +0100 Subject: [PATCH 165/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 76f8a10c2d..abf7f7286d 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -37,6 +37,8 @@ k0 = 2 * scc.pi / 0.6e-6 stc=get_STC(laser.dim,laser.grid,k0) +print('phi2 is ') +print('stc['phi2'] ') print('zeta is ') print(stc['zeta_x']) print('beta is ') From e9df9031d8c19545eefc9dff35e819a0f5d8f747 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:07:23 +0100 Subject: [PATCH 166/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index e34e07cc59..dc16b73490 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,7 +2,7 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose = 3 -amr.n_cell = 255 255 50 +amr.n_cell = 255 255 200 my_constants.kp_inv = 10.e-6 From 10649f74ec0ecc5e3d504daa0c185896fdb61331 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:15:59 +0100 Subject: [PATCH 167/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index abf7f7286d..34cf8776da 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -38,7 +38,7 @@ k0 = 2 * scc.pi / 0.6e-6 stc=get_STC(laser.dim,laser.grid,k0) print('phi2 is ') -print('stc['phi2'] ') +print(stc['phi2']) print('zeta is ') print(stc['zeta_x']) print('beta is ') From d1cb2dc3a9cc04d63a6f95b2923418f1c11c7691 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:25:26 +0100 Subject: [PATCH 168/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index dc16b73490..5b2d8c85bb 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,7 +2,7 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose = 3 -amr.n_cell = 255 255 200 +amr.n_cell = 511 511 500 my_constants.kp_inv = 10.e-6 From 25da5b696a45e67c87b5d8df5374ac655a706c1e Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:26:00 +0100 Subject: [PATCH 169/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 34cf8776da..ca6b70c3b8 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -41,8 +41,10 @@ print(stc['phi2']) print('zeta is ') print(stc['zeta_x']) +print(stc['zeta_y']) print('beta is ') print(stc['beta_x']) +print(stc['beta_y']) assert(np.abs(stc['phi2'] - 2.4e-19) / 2.4e-19 < 1e-2) assert(np.abs(stc['beta_x'] - 3e-18) / 3e-18 < 1e-2) assert(np.abs(stc['zeta_x'] - 2.4e-24) / 2.4e-24 < 1e-2) From a3000831a6d1978fac74fa7200d40118b252b972 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:35:45 +0100 Subject: [PATCH 170/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 5b2d8c85bb..9db147c313 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -21,7 +21,7 @@ laser.focal_distance = 0.0 laser.w0 = 5e-6 laser.tau = 5e-14 laser.phi2 = 2.4e-19 -laser.zeta = 2.4e-24 +laser.zeta = 0 laser.beta = 3e-18 laser.STC_theta_xy = 0 amr.max_level = 0 From 332126b37d89dacc0a7804fbc7d62a0be0657ca9 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:47:17 +0100 Subject: [PATCH 171/254] Update inputs_chirp --- examples/laser/inputs_chirp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 9db147c313..33a651660b 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -21,8 +21,8 @@ laser.focal_distance = 0.0 laser.w0 = 5e-6 laser.tau = 5e-14 laser.phi2 = 2.4e-19 -laser.zeta = 0 -laser.beta = 3e-18 +laser.zeta = 2.4e-24 +laser.beta = 0 laser.STC_theta_xy = 0 amr.max_level = 0 From c8c1ded3bf07fcdbb2bd73ea8001a65b60faac05 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 11 Dec 2024 19:16:12 +0100 Subject: [PATCH 172/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index ca6b70c3b8..78e56f116b 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -36,7 +36,7 @@ ) k0 = 2 * scc.pi / 0.6e-6 -stc=get_STC(laser.dim,laser.grid,k0) +stc=get_STC(laser.dim,laser.grid,k0=k0) print('phi2 is ') print(stc['phi2']) print('zeta is ') From 06a3149d3c828da78ba6e9bb97ee61c0236d2e17 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 11 Dec 2024 19:16:41 +0100 Subject: [PATCH 173/254] Update inputs_chirp --- examples/laser/inputs_chirp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 33a651660b..380249ed38 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,11 +2,7 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose = 3 -amr.n_cell = 511 511 500 - -my_constants.kp_inv = 10.e-6 - -hipace.file_prefix = new +amr.n_cell = 255 255 200 hipace.do_tiling = 0 geometry.prob_lo = -15e-6 -15e-6 -8e-6 From 5868db71c495c09ca4a8ff77333e04b1f2b448c7 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Wed, 11 Dec 2024 19:31:23 +0100 Subject: [PATCH 174/254] Update inputs_chirp --- examples/laser/inputs_chirp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 380249ed38..858f1e9260 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -5,8 +5,8 @@ hipace.verbose = 3 amr.n_cell = 255 255 200 hipace.do_tiling = 0 -geometry.prob_lo = -15e-6 -15e-6 -8e-6 -geometry.prob_hi = 15e-6 15e-6 8e-6 +geometry.prob_lo = -30e-6 -30e-6 -8e-6 +geometry.prob_hi = 30e-6 30e-6 8e-6 lasers.names = laser lasers.lambda0 = .6e-6 From d5094998f6bad7dfca72c3e4331167b2049e8a48 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 12 Dec 2024 13:52:59 +0100 Subject: [PATCH 175/254] Update inputs_chirp --- examples/laser/inputs_chirp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 858f1e9260..30df3af99f 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -5,8 +5,8 @@ hipace.verbose = 3 amr.n_cell = 255 255 200 hipace.do_tiling = 0 -geometry.prob_lo = -30e-6 -30e-6 -8e-6 -geometry.prob_hi = 30e-6 30e-6 8e-6 +geometry.prob_lo = -20e-6 -20e-6 -8e-6 +geometry.prob_hi = 20e-6 20e-6 8e-6 lasers.names = laser lasers.lambda0 = .6e-6 @@ -15,7 +15,7 @@ laser.a0 = 1 laser.position_mean = 0. 0. 0 laser.focal_distance = 0.0 laser.w0 = 5e-6 -laser.tau = 5e-14 +laser.tau = 2e-14 laser.phi2 = 2.4e-19 laser.zeta = 2.4e-24 laser.beta = 0 From cbc143cd8052f8a10bb76b2387b68e969ce9a440 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:21:33 +0100 Subject: [PATCH 176/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 30df3af99f..483b581cbe 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -17,7 +17,7 @@ laser.focal_distance = 0.0 laser.w0 = 5e-6 laser.tau = 2e-14 laser.phi2 = 2.4e-19 -laser.zeta = 2.4e-24 +laser.zeta = 2.4e-20 laser.beta = 0 laser.STC_theta_xy = 0 amr.max_level = 0 From cb02a6f5c6376f2044e5b22b84379c19b8f2f247 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:24:46 +0100 Subject: [PATCH 177/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 483b581cbe..30ba2aeeff 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -16,7 +16,7 @@ laser.position_mean = 0. 0. 0 laser.focal_distance = 0.0 laser.w0 = 5e-6 laser.tau = 2e-14 -laser.phi2 = 2.4e-19 +laser.phi2 = 0 laser.zeta = 2.4e-20 laser.beta = 0 laser.STC_theta_xy = 0 From 33e1be534ddcd4c8b1537c29559ea3ad69912c5e Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:14:47 +0100 Subject: [PATCH 178/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 30ba2aeeff..6c2ab5121c 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,7 +2,7 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose = 3 -amr.n_cell = 255 255 200 +amr.n_cell = 511 511 500 hipace.do_tiling = 0 geometry.prob_lo = -20e-6 -20e-6 -8e-6 From 440e2eb83bf7e6fc604f88b9597ae594e6fa8847 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:38:22 +0100 Subject: [PATCH 179/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 78e56f116b..05314f2933 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -11,7 +11,7 @@ import numpy as np import scipy.constants as scc from openpmd_viewer.addons import LpaDiagnostics -from lasy.utils.laser_utils import get_STC +from lasy.utils.laser_utils import get_Beta, get_Phi2, get_Zeta from lasy.profiles import FromOpenPMDProfile from lasy.laser import Laser @@ -36,15 +36,14 @@ ) k0 = 2 * scc.pi / 0.6e-6 -stc=get_STC(laser.dim,laser.grid,k0=k0) +Phi2, phi2 = get_Phi2(Laser.dim, Laser.grid) +[zeta_x, zeta_y] = get_Zeta(Laser.dim, Laser.grid, k0) +[beta_x, beta_y] = get_Beta( Laser.dim, Laser.grid, k0) + print('phi2 is ') -print(stc['phi2']) +print(phi2) print('zeta is ') -print(stc['zeta_x']) -print(stc['zeta_y']) +print([zeta_x, zeta_y]) print('beta is ') -print(stc['beta_x']) -print(stc['beta_y']) -assert(np.abs(stc['phi2'] - 2.4e-19) / 2.4e-19 < 1e-2) -assert(np.abs(stc['beta_x'] - 3e-18) / 3e-18 < 1e-2) -assert(np.abs(stc['zeta_x'] - 2.4e-24) / 2.4e-24 < 1e-2) +print([beta_x, beta_y]) + From 898ff88df136896fbf6651e6e75c7913864cded4 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:47:43 +0100 Subject: [PATCH 180/254] Update inputs_chirp --- examples/laser/inputs_chirp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 6c2ab5121c..ed159e2d45 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -16,9 +16,9 @@ laser.position_mean = 0. 0. 0 laser.focal_distance = 0.0 laser.w0 = 5e-6 laser.tau = 2e-14 -laser.phi2 = 0 -laser.zeta = 2.4e-20 -laser.beta = 0 +laser.phi2 = 2.4e-24 +laser.zeta = 2.4e-22 +laser.beta = 3e-18 laser.STC_theta_xy = 0 amr.max_level = 0 From 9499527477ac94e7d2e873f1405ea1cc0a536d99 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:50:44 +0100 Subject: [PATCH 181/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 05314f2933..6b5d35f78f 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -36,9 +36,9 @@ ) k0 = 2 * scc.pi / 0.6e-6 -Phi2, phi2 = get_Phi2(Laser.dim, Laser.grid) -[zeta_x, zeta_y] = get_Zeta(Laser.dim, Laser.grid, k0) -[beta_x, beta_y] = get_Beta( Laser.dim, Laser.grid, k0) +Phi2, phi2 = get_Phi2(Laser.grid.dim, Laser.grid) +[zeta_x, zeta_y] = get_Zeta(Laser.grid.dim, Laser.grid, k0) +[beta_x, beta_y] = get_Beta( Laser.grid.dim, Laser.grid, k0) print('phi2 is ') print(phi2) @@ -46,4 +46,6 @@ print([zeta_x, zeta_y]) print('beta is ') print([beta_x, beta_y]) - +np.testing.assert_approx_equal(phi2, 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 3b5e418d72b2c0b19d6e0661a068f63068cb3523 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:02:10 +0100 Subject: [PATCH 182/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 6b5d35f78f..54c2f2c491 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -36,9 +36,9 @@ ) k0 = 2 * scc.pi / 0.6e-6 -Phi2, phi2 = get_Phi2(Laser.grid.dim, Laser.grid) -[zeta_x, zeta_y] = get_Zeta(Laser.grid.dim, Laser.grid, k0) -[beta_x, beta_y] = get_Beta( Laser.grid.dim, Laser.grid, k0) +Phi2, phi2 = get_Phi2(laser.grid.dim, laser.grid) +[zeta_x, zeta_y] = get_Zeta(laser.grid.dim, laser.grid, k0) +[beta_x, beta_y] = get_Beta(laser.grid.dim, laser.grid, k0) print('phi2 is ') print(phi2) From bce883691efd638d54132440bb1a873bd53ea05e Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:12:45 +0100 Subject: [PATCH 183/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 54c2f2c491..19093e9203 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -36,9 +36,9 @@ ) k0 = 2 * scc.pi / 0.6e-6 -Phi2, phi2 = get_Phi2(laser.grid.dim, laser.grid) -[zeta_x, zeta_y] = get_Zeta(laser.grid.dim, laser.grid, k0) -[beta_x, beta_y] = get_Beta(laser.grid.dim, laser.grid, k0) +Phi2, phi2 = get_Phi2(laser.dim, laser.grid) +[zeta_x, zeta_y] = get_Zeta(laser.dim, laser.grid, k0) +[beta_x, beta_y] = get_Beta(laser.dim, laser.grid, k0) print('phi2 is ') print(phi2) From cc302563e08118cb1e0ec9bf098d448b91d3f7a1 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:13:45 +0100 Subject: [PATCH 184/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index ed159e2d45..816a2e9127 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,7 +2,7 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose = 3 -amr.n_cell = 511 511 500 +amr.n_cell = 127 127 200 hipace.do_tiling = 0 geometry.prob_lo = -20e-6 -20e-6 -8e-6 From 06eadd69e7d5f2e7f1cbe83e80c06c520e6ca51a Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:27:01 +0100 Subject: [PATCH 185/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 816a2e9127..c6d7c9177d 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -18,7 +18,7 @@ laser.w0 = 5e-6 laser.tau = 2e-14 laser.phi2 = 2.4e-24 laser.zeta = 2.4e-22 -laser.beta = 3e-18 +laser.beta = 0 laser.STC_theta_xy = 0 amr.max_level = 0 From ca25ee134093133f4aa9f6555a5852cf4e41e5e5 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:38:01 +0100 Subject: [PATCH 186/254] Update MultiLaser.cpp --- src/laser/MultiLaser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 7bacc3ed3c..98b49c3eb5 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -912,12 +912,12 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) // Time stretching due to STCs and phi2 complex envelope // (1 if zeta=0, beta=0, phi2=0) Complex stretch_factor = 1._rt \ - + 4._rt * (zeta + beta * zfoc) * inv_tau2 * (zeta + beta * zfoc) * inv_complex_waist_2 \ + + 4._rt * (-zeta + beta * zfoc) * inv_tau2 * (-zeta + beta * zfoc) * inv_complex_waist_2 \ + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * inv_tau2; Complex prefactor = a0 / diffract_factor; Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * amrex::pow(zp - beta * k0 * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) * clight - 2._rt * I * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) - * (zeta - beta * zfoc) * clight * inv_complex_waist_2, 2); + * (-zeta - beta * zfoc) * clight * inv_complex_waist_2, 2); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; Complex envelope = stcfactor * amrex::exp( exp_argument ) * \ From 8b6276477640e72ef1b46e98dc718cd0daec83c8 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 18:01:49 +0100 Subject: [PATCH 187/254] Update MultiLaser.cpp --- src/laser/MultiLaser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 98b49c3eb5..7bacc3ed3c 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -912,12 +912,12 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) // Time stretching due to STCs and phi2 complex envelope // (1 if zeta=0, beta=0, phi2=0) Complex stretch_factor = 1._rt \ - + 4._rt * (-zeta + beta * zfoc) * inv_tau2 * (-zeta + beta * zfoc) * inv_complex_waist_2 \ + + 4._rt * (zeta + beta * zfoc) * inv_tau2 * (zeta + beta * zfoc) * inv_complex_waist_2 \ + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * inv_tau2; Complex prefactor = a0 / diffract_factor; Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * amrex::pow(zp - beta * k0 * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) * clight - 2._rt * I * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) - * (-zeta - beta * zfoc) * clight * inv_complex_waist_2, 2); + * (zeta - beta * zfoc) * clight * inv_complex_waist_2, 2); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; Complex envelope = stcfactor * amrex::exp( exp_argument ) * \ From 473e3ba5b88fee9f6baabad8bcb3d53c262846ad Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 18:02:09 +0100 Subject: [PATCH 188/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 19093e9203..14255e9771 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -46,6 +46,6 @@ print([zeta_x, zeta_y]) print('beta is ') print([beta_x, beta_y]) -np.testing.assert_approx_equal(phi2, 2.4e-24, significant=2) +#np.testing.assert_approx_equal(phi2, 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 f842f5ce2ac22b0e8c90d362aae94303ce4fe276 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 18:02:35 +0100 Subject: [PATCH 189/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index c6d7c9177d..2f11653ed1 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -16,7 +16,7 @@ laser.position_mean = 0. 0. 0 laser.focal_distance = 0.0 laser.w0 = 5e-6 laser.tau = 2e-14 -laser.phi2 = 2.4e-24 +laser.phi2 = 0 laser.zeta = 2.4e-22 laser.beta = 0 laser.STC_theta_xy = 0 From e9a863ced9f6c32237a26a8795645b70afa91b49 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 18:17:56 +0100 Subject: [PATCH 190/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 2f11653ed1..577c84fbac 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -18,7 +18,7 @@ laser.w0 = 5e-6 laser.tau = 2e-14 laser.phi2 = 0 laser.zeta = 2.4e-22 -laser.beta = 0 +laser.beta = 3e-18 laser.STC_theta_xy = 0 amr.max_level = 0 From eda52e90974f2c403fea7d97389a035d27a484aa Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 18:38:18 +0100 Subject: [PATCH 191/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 577c84fbac..e69b0ccbae 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -17,7 +17,7 @@ laser.focal_distance = 0.0 laser.w0 = 5e-6 laser.tau = 2e-14 laser.phi2 = 0 -laser.zeta = 2.4e-22 +laser.zeta = 0 laser.beta = 3e-18 laser.STC_theta_xy = 0 amr.max_level = 0 From 959426002ef09a8c295a22227cf873794d2d0837 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 19:06:58 +0100 Subject: [PATCH 192/254] Update MultiLaser.cpp --- src/laser/MultiLaser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 7bacc3ed3c..47f8aade9c 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -916,7 +916,7 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * inv_tau2; Complex prefactor = a0 / diffract_factor; Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * - amrex::pow(zp - beta * k0 * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) * clight - 2._rt * I * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) + amrex::pow(zp + beta * k0 * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) * clight - 2._rt * I * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) * (zeta - beta * zfoc) * clight * inv_complex_waist_2, 2); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; From 29388303e810ecbf36965d2222388bc1e32aa400 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 19:21:43 +0100 Subject: [PATCH 193/254] Update MultiLaser.cpp --- src/laser/MultiLaser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 47f8aade9c..442007c2ee 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -916,7 +916,7 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * inv_tau2; Complex prefactor = a0 / diffract_factor; Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * - amrex::pow(zp + beta * k0 * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) * clight - 2._rt * I * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) + amrex::pow(zp - beta * k0 * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) * clight - 2._rt * I * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) * (zeta - beta * zfoc) * clight * inv_complex_waist_2, 2); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; From 47c31ec219d47fddfd7a90d98ab3906013f8ab27 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 19:23:42 +0100 Subject: [PATCH 194/254] Update inputs_chirp --- examples/laser/inputs_chirp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index e69b0ccbae..dc3183621e 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,7 +2,7 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose = 3 -amr.n_cell = 127 127 200 +amr.n_cell = 255 255 200 hipace.do_tiling = 0 geometry.prob_lo = -20e-6 -20e-6 -8e-6 @@ -18,7 +18,7 @@ laser.w0 = 5e-6 laser.tau = 2e-14 laser.phi2 = 0 laser.zeta = 0 -laser.beta = 3e-18 +laser.beta = 3e-17 laser.STC_theta_xy = 0 amr.max_level = 0 From 264431d091a055e1c1b0e3ee7c052a39b2632bc4 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 19:32:29 +0100 Subject: [PATCH 195/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index dc3183621e..dd60e21b44 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,7 +2,7 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose = 3 -amr.n_cell = 255 255 200 +amr.n_cell = 511 255 200 hipace.do_tiling = 0 geometry.prob_lo = -20e-6 -20e-6 -8e-6 From c54bad4e855c8781d00de54da7081dd376c340c3 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 16 Dec 2024 19:32:53 +0100 Subject: [PATCH 196/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 14255e9771..c1c2c17fb5 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -31,7 +31,7 @@ dim="xyt", lo=(np.min(profile.axes['x']), np.min(profile.axes['y']), np.min(profile.axes['t'])), hi=(np.max(profile.axes['x']), np.max(profile.axes['y']), np.max(profile.axes['t'])), - npoints=(255, 255, 200), + npoints=(511, 255, 200), profile=profile, ) From 4651541d7051643bd713ac9e8befae39f27b19f1 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:27:37 +0100 Subject: [PATCH 197/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index dd60e21b44..bc2510d2d4 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,7 +2,7 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose = 3 -amr.n_cell = 511 255 200 +amr.n_cell = 511 255 500 hipace.do_tiling = 0 geometry.prob_lo = -20e-6 -20e-6 -8e-6 From e5eb5f1d8d3e3daf1e5dcedded172f5fec4c3b7f Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:27:51 +0100 Subject: [PATCH 198/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index c1c2c17fb5..49f99820ec 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -31,7 +31,7 @@ dim="xyt", lo=(np.min(profile.axes['x']), np.min(profile.axes['y']), np.min(profile.axes['t'])), hi=(np.max(profile.axes['x']), np.max(profile.axes['y']), np.max(profile.axes['t'])), - npoints=(511, 255, 200), + npoints=(511, 255, 500), profile=profile, ) From 44526ae365d9a13a5078f20439dafab08c0e305b Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:42:36 +0100 Subject: [PATCH 199/254] Update inputs_chirp --- examples/laser/inputs_chirp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index bc2510d2d4..bfbb840cc6 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -5,8 +5,8 @@ hipace.verbose = 3 amr.n_cell = 511 255 500 hipace.do_tiling = 0 -geometry.prob_lo = -20e-6 -20e-6 -8e-6 -geometry.prob_hi = 20e-6 20e-6 8e-6 +geometry.prob_lo = -20e-6 -20e-6 -12e-6 +geometry.prob_hi = 20e-6 20e-6 12e-6 lasers.names = laser lasers.lambda0 = .6e-6 From 1b986249566afe7e1457127064353a424c8a1376 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:44:59 +0100 Subject: [PATCH 200/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index bfbb840cc6..5e2754d7d1 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -18,7 +18,7 @@ laser.w0 = 5e-6 laser.tau = 2e-14 laser.phi2 = 0 laser.zeta = 0 -laser.beta = 3e-17 +laser.beta = 3e-14 laser.STC_theta_xy = 0 amr.max_level = 0 From a7ba153065c4ea5a941f31535e57e1418ae85f56 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:26:39 +0100 Subject: [PATCH 201/254] Update inputs_chirp --- examples/laser/inputs_chirp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 5e2754d7d1..a3224f2bef 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,11 +2,11 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose = 3 -amr.n_cell = 511 255 500 +amr.n_cell = 511 255 1000 hipace.do_tiling = 0 -geometry.prob_lo = -20e-6 -20e-6 -12e-6 -geometry.prob_hi = 20e-6 20e-6 12e-6 +geometry.prob_lo = -10e-6 -10e-6 -10e-6 +geometry.prob_hi = 10e-6 10e-6 10e-6 lasers.names = laser lasers.lambda0 = .6e-6 @@ -14,7 +14,7 @@ lasers.lambda0 = .6e-6 laser.a0 = 1 laser.position_mean = 0. 0. 0 laser.focal_distance = 0.0 -laser.w0 = 5e-6 +laser.w0 = 2e-6 laser.tau = 2e-14 laser.phi2 = 0 laser.zeta = 0 From 629001d1e8a837e9fec90ef816fdd6391b854e5c Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:38:42 +0100 Subject: [PATCH 202/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 49f99820ec..e72c0aecbe 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -11,7 +11,7 @@ import numpy as np import scipy.constants as scc from openpmd_viewer.addons import LpaDiagnostics -from lasy.utils.laser_utils import get_Beta, get_Phi2, get_Zeta +from lasy.utils.laser_utils import get_beta, get_phi2, get_zeta from lasy.profiles import FromOpenPMDProfile from lasy.laser import Laser @@ -36,9 +36,9 @@ ) k0 = 2 * scc.pi / 0.6e-6 -Phi2, phi2 = get_Phi2(laser.dim, laser.grid) -[zeta_x, zeta_y] = get_Zeta(laser.dim, laser.grid, k0) -[beta_x, beta_y] = get_Beta(laser.dim, laser.grid, k0) +Phi2, phi2 = get_phi2(laser.dim, laser.grid) +[zeta_x, zeta_y] = get_zeta(laser.dim, laser.grid, k0) +[beta_x, beta_y] = get_beta(laser.dim, laser.grid, k0) print('phi2 is ') print(phi2) From 1f5241e0f919952f82ced9ffff849c56d7270c0c Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:52:18 +0100 Subject: [PATCH 203/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index e72c0aecbe..b8f7d275b4 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -31,7 +31,7 @@ dim="xyt", lo=(np.min(profile.axes['x']), np.min(profile.axes['y']), np.min(profile.axes['t'])), hi=(np.max(profile.axes['x']), np.max(profile.axes['y']), np.max(profile.axes['t'])), - npoints=(511, 255, 500), + npoints=(511, 255, 1000), profile=profile, ) From b43e6e122e47287022a1d24576d4c522dc8f9ded Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:53:12 +0100 Subject: [PATCH 204/254] Update inputs_chirp --- examples/laser/inputs_chirp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index a3224f2bef..c9bc2f63da 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -5,8 +5,8 @@ hipace.verbose = 3 amr.n_cell = 511 255 1000 hipace.do_tiling = 0 -geometry.prob_lo = -10e-6 -10e-6 -10e-6 -geometry.prob_hi = 10e-6 10e-6 10e-6 +geometry.prob_lo = -4e-6 -4e-6 -6e-6 +geometry.prob_hi = 4e-6 4e-6 6e-6 lasers.names = laser lasers.lambda0 = .6e-6 @@ -15,7 +15,7 @@ laser.a0 = 1 laser.position_mean = 0. 0. 0 laser.focal_distance = 0.0 laser.w0 = 2e-6 -laser.tau = 2e-14 +laser.tau = 1e-14 laser.phi2 = 0 laser.zeta = 0 laser.beta = 3e-14 From 2851f9a09516cfdca1ce8a62ca61f1650bf9ae52 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:10:24 +0100 Subject: [PATCH 205/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index c9bc2f63da..77f9d53486 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,7 +2,7 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose = 3 -amr.n_cell = 511 255 1000 +amr.n_cell = 511 255 500 hipace.do_tiling = 0 geometry.prob_lo = -4e-6 -4e-6 -6e-6 From 9a65bb1173f4085f075965fcd5e116f8cbfc757c Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:21:03 +0100 Subject: [PATCH 206/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index b8f7d275b4..e72c0aecbe 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -31,7 +31,7 @@ dim="xyt", lo=(np.min(profile.axes['x']), np.min(profile.axes['y']), np.min(profile.axes['t'])), hi=(np.max(profile.axes['x']), np.max(profile.axes['y']), np.max(profile.axes['t'])), - npoints=(511, 255, 1000), + npoints=(511, 255, 500), profile=profile, ) From c6f584d26e68b21487a58d9bed0c548140da9d42 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:31:19 +0100 Subject: [PATCH 207/254] Update inputs_chirp --- examples/laser/inputs_chirp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 77f9d53486..fa65c6f3ad 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -5,8 +5,8 @@ hipace.verbose = 3 amr.n_cell = 511 255 500 hipace.do_tiling = 0 -geometry.prob_lo = -4e-6 -4e-6 -6e-6 -geometry.prob_hi = 4e-6 4e-6 6e-6 +geometry.prob_lo = -4e-6 -4e-6 -4e-6 +geometry.prob_hi = 4e-6 4e-6 4e-6 lasers.names = laser lasers.lambda0 = .6e-6 @@ -18,7 +18,7 @@ laser.w0 = 2e-6 laser.tau = 1e-14 laser.phi2 = 0 laser.zeta = 0 -laser.beta = 3e-14 +laser.beta = 3e-15 laser.STC_theta_xy = 0 amr.max_level = 0 From 503b8f74d0ca364e6af88530b4495d9dadcb70e4 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:07:02 +0100 Subject: [PATCH 208/254] Update inputs_chirp --- examples/laser/inputs_chirp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index fa65c6f3ad..419c753b31 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -5,8 +5,8 @@ hipace.verbose = 3 amr.n_cell = 511 255 500 hipace.do_tiling = 0 -geometry.prob_lo = -4e-6 -4e-6 -4e-6 -geometry.prob_hi = 4e-6 4e-6 4e-6 +geometry.prob_lo = -3e-6 -3e-6 -2e-6 +geometry.prob_hi = 3e-6 3e-6 2e-6 lasers.names = laser lasers.lambda0 = .6e-6 @@ -18,7 +18,7 @@ laser.w0 = 2e-6 laser.tau = 1e-14 laser.phi2 = 0 laser.zeta = 0 -laser.beta = 3e-15 +laser.beta = 2e-15 laser.STC_theta_xy = 0 amr.max_level = 0 From 05c82e72bbfa48de19999775348d24be208fa2f4 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:19:11 +0100 Subject: [PATCH 209/254] Update inputs_chirp --- examples/laser/inputs_chirp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 419c753b31..4145d8c1dd 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,11 +2,11 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose = 3 -amr.n_cell = 511 255 500 +amr.n_cell = 1023 255 1000 hipace.do_tiling = 0 -geometry.prob_lo = -3e-6 -3e-6 -2e-6 -geometry.prob_hi = 3e-6 3e-6 2e-6 +geometry.prob_lo = -5e-6 -5e-6 -2e-6 +geometry.prob_hi = 5e-6 5e-6 2e-6 lasers.names = laser lasers.lambda0 = .6e-6 @@ -18,7 +18,7 @@ laser.w0 = 2e-6 laser.tau = 1e-14 laser.phi2 = 0 laser.zeta = 0 -laser.beta = 2e-15 +laser.beta = 1e-14 laser.STC_theta_xy = 0 amr.max_level = 0 From 3b6695d4afabeb5d15bc99dc9723ffd551108a7c Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:36:08 +0100 Subject: [PATCH 210/254] Update inputs_chirp --- examples/laser/inputs_chirp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 4145d8c1dd..1c9f0b6e98 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -16,9 +16,9 @@ laser.position_mean = 0. 0. 0 laser.focal_distance = 0.0 laser.w0 = 2e-6 laser.tau = 1e-14 -laser.phi2 = 0 -laser.zeta = 0 -laser.beta = 1e-14 +laser.phi2 = 3e-24 +laser.zeta = 3e-22 +laser.beta = 0 laser.STC_theta_xy = 0 amr.max_level = 0 From 56327e9b99bd8cc1a0e1f25b2a189ae32e5e344e Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:37:00 +0100 Subject: [PATCH 211/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index e72c0aecbe..4ac12f6e80 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -46,6 +46,6 @@ print([zeta_x, zeta_y]) print('beta is ') print([beta_x, beta_y]) -#np.testing.assert_approx_equal(phi2, 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, 3e-24, significant=2) +np.testing.assert_approx_equal(zeta_y,3e-22, significant=2) +#np.testing.assert_approx_equal(beta_y, 3e-18, significant=2) From cb070e9d27261d79c2dbe28c27d11e2e1c48e251 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:50:16 +0100 Subject: [PATCH 212/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 1c9f0b6e98..50840c85ab 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,7 +2,7 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose = 3 -amr.n_cell = 1023 255 1000 +amr.n_cell = 255 255 200 hipace.do_tiling = 0 geometry.prob_lo = -5e-6 -5e-6 -2e-6 From 4f53a72f004d9ac92a42c374dd50a9eb57d878f2 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 9 Jan 2025 11:27:27 +0100 Subject: [PATCH 213/254] Update ubuntu_ompi.sh --- .github/workflows/setup/ubuntu_ompi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/setup/ubuntu_ompi.sh b/.github/workflows/setup/ubuntu_ompi.sh index 3b748f2b99..f99695ee2b 100755 --- a/.github/workflows/setup/ubuntu_ompi.sh +++ b/.github/workflows/setup/ubuntu_ompi.sh @@ -34,5 +34,5 @@ sudo update-alternatives --set python /usr/bin/python3 python -m pip install --upgrade pip python -m pip install --upgrade matplotlib==3.2.2 numpy scipy openpmd-viewer openpmd-api axiprop -python -m pip install --no-deps git+https://github.com/huixingjian/lasy-.git@add_diag_util +python -m pip install --no-deps lasy From e06306cb028b72f5204b56b5be8cc162ed12d651 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 9 Jan 2025 11:28:00 +0100 Subject: [PATCH 214/254] Update ubuntu_ompi.sh --- .github/workflows/setup/ubuntu_ompi.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/setup/ubuntu_ompi.sh b/.github/workflows/setup/ubuntu_ompi.sh index f99695ee2b..685770e331 100755 --- a/.github/workflows/setup/ubuntu_ompi.sh +++ b/.github/workflows/setup/ubuntu_ompi.sh @@ -33,6 +33,4 @@ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2 sudo update-alternatives --set python /usr/bin/python3 python -m pip install --upgrade pip -python -m pip install --upgrade matplotlib==3.2.2 numpy scipy openpmd-viewer openpmd-api axiprop -python -m pip install --no-deps lasy - +python -m pip install --upgrade matplotlib==3.2.2 numpy scipy openpmd-viewer openpmd-api axiprop lasy From a1214cea3898ebbeab702d007bc1d93b811ba223 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 9 Jan 2025 16:54:06 +0100 Subject: [PATCH 215/254] Update ubuntu_ompi.sh --- .github/workflows/setup/ubuntu_ompi.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/setup/ubuntu_ompi.sh b/.github/workflows/setup/ubuntu_ompi.sh index 016f9d6377..f9dc15d0ec 100755 --- a/.github/workflows/setup/ubuntu_ompi.sh +++ b/.github/workflows/setup/ubuntu_ompi.sh @@ -33,5 +33,7 @@ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2 sudo update-alternatives --set python /usr/bin/python3 python -m pip install --upgrade pip -python -m pip install --upgrade matplotlib==3.2.2 numpy scipy openpmd-viewer openpmd-api axiprop lasy +python -m pip install --upgrade matplotlib==3.2.2 numpy scipy openpmd-viewer openpmd-api axiprop +python -m pip install git+https://github.com/LASY-org/lasy.git + From e345bcf83ab72edddf1f00c09af21793572fc27d Mon Sep 17 00:00:00 2001 From: huixingjian Date: Thu, 9 Jan 2025 17:09:39 +0100 Subject: [PATCH 216/254] pip install lasy --- .github/workflows/setup/ubuntu.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/setup/ubuntu.sh b/.github/workflows/setup/ubuntu.sh index 5ba05ab5f6..79ac58c4a3 100755 --- a/.github/workflows/setup/ubuntu.sh +++ b/.github/workflows/setup/ubuntu.sh @@ -32,3 +32,4 @@ sudo update-alternatives --set python /usr/bin/python3 python -m pip install --upgrade pip python -m pip install --upgrade matplotlib numpy scipy openpmd-viewer openpmd-api +python -m pip install git+https://github.com/LASY-org/lasy.git From 09b73acf5ac3525e618e5e867bfd2f21266d0bfb Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:55:35 +0100 Subject: [PATCH 217/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 80 ++++++++++++++++----- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 4ac12f6e80..b35b41ce0c 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -11,10 +11,56 @@ import numpy as np import scipy.constants as scc from openpmd_viewer.addons import LpaDiagnostics -from lasy.utils.laser_utils import get_beta, get_phi2, get_zeta -from lasy.profiles import FromOpenPMDProfile -from lasy.laser import Laser +from openpmd_viewer import OpenPMDTimeSeries +#from lasy.utils.laser_utils import get_beta, get_phi2, get_zeta +#from lasy.profiles import FromOpenPMDProfile +#from lasy.laser import Laser +def get_phi2 (Ar, m): + # get temporal chirp phi2 + tau = get_duration(Ar,m) + laser_module1 = np.abs(Ar**2) + phi_envelop = np.unwrap( np.unwrap(np.arctan(Ar.imag/Ar.real), axis=0), axis=1) + # calculate pphi_pz + pphi_pz = np.gradient(phi_envelop, (m.z[1]-m.z[0])/scc.c, axis=0) + pphi_pz2 = np.gradient(pphi_pz, (m.z[1]-m.z[0])/scc.c, axis=0) + temp_chirp = np.average(pphi_pz2, weights=laser_module1) + x = temp_chirp + a = 4 * x + b = -4 + c = tau**4 * x + zeta_roots = np.roots([a, b, c]) + return np.max(zeta_roots) +def temporal2spectral_fft(Ar, m, k0): + spect=np.fft.ifft( + Ar, axis=1, norm="backward" + ) + Nt = len(m.z) + dt= (m.z[1]-m.z[0])/scc.c + omega = 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0 *scc.c + return omega,spect + + +def get_zeta(Ar,m,k0): + omega,env_spec=temporal2spectral_fft(Ar,m,k0) + env_spec_abs = np.abs(env_spec**2) + yda = np.sum(m.y * env_spec_abs, axis=1) / np.sum(env_spec_abs, axis=1) + derivative_y_zeta = np.gradient(yda, omega) + weight_y_2d = np.mean(env_spec_abs, axis=1) + #print(len(derivative_y_zeta)) + zeta_y = np.average(derivative_y_zeta.T, weights=weight_y_2d) + return zeta_y + +def get_beta(F, m, k0): + omega,env_spec=temporal2spectral_fft(F,m,k0) + phi_envelop_abs = np.unwrap( + np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=1 + ) + angle_y = np.gradient(phi_envelop_abs, m.y, axis=1) / k0 + dtdb= np.gradient(angle_y, omega, axis=0) + weight = np.abs(env_spec)**2 + return (np.sum(dtdb * weight) / np.sum(weight)) + parser = argparse.ArgumentParser(description = 'Verify the chirp initialization') parser.add_argument('--output-dir', dest='output_dir', @@ -25,20 +71,22 @@ default='phi2', help='Type of the initialized chirp') args = parser.parse_args() -print(args.output_dir) -profile = FromOpenPMDProfile(path=args.output_dir,iteration=0,pol=[1,0],field='laserEnvelope', is_envelope=True, prefix='openpmd') -laser = Laser( - dim="xyt", - lo=(np.min(profile.axes['x']), np.min(profile.axes['y']), np.min(profile.axes['t'])), - hi=(np.max(profile.axes['x']), np.max(profile.axes['y']), np.max(profile.axes['t'])), - npoints=(511, 255, 500), - profile=profile, - ) - +Ar,m +#print(args.output_dir) +#profile = FromOpenPMDProfile(path=args.output_dir,iteration=0,pol=[1,0],field='laserEnvelope', is_envelope=True, prefix='openpmd') +#laser = Laser( +# dim="xyt", +# lo=(np.min(profile.axes['x']), np.min(profile.axes['y']), np.min(profile.axes['t'])), +# hi=(np.max(profile.axes['x']), np.max(profile.axes['y']), np.max(profile.axes['t'])), +# npoints=(511, 255, 500), +# profile=profile, +# ) +ts=OpenPMDTimeSeries(args.output_dir) +Ar, m = ts.get_field(field='laserEnvelope', iteration=0) k0 = 2 * scc.pi / 0.6e-6 -Phi2, phi2 = get_phi2(laser.dim, laser.grid) -[zeta_x, zeta_y] = get_zeta(laser.dim, laser.grid, k0) -[beta_x, beta_y] = get_beta(laser.dim, laser.grid, k0) +phi2 = get_phi2(Ar, m) +zeta= get_zeta(Ar, m, k0) +beta = get_beta(Ar, m, k0) print('phi2 is ') print(phi2) From 76b93392dc6a909449a0f73536b4edab735dd880 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:56:03 +0100 Subject: [PATCH 218/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index b35b41ce0c..94ec9305d7 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -71,7 +71,7 @@ def get_beta(F, m, k0): default='phi2', help='Type of the initialized chirp') args = parser.parse_args() -Ar,m + #print(args.output_dir) #profile = FromOpenPMDProfile(path=args.output_dir,iteration=0,pol=[1,0],field='laserEnvelope', is_envelope=True, prefix='openpmd') #laser = Laser( From 535bb4db4f1ec4fe8f886546b2bcb13928b9f83d Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:58:52 +0100 Subject: [PATCH 219/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 94ec9305d7..49456655fc 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -24,13 +24,14 @@ def get_phi2 (Ar, m): # calculate pphi_pz pphi_pz = np.gradient(phi_envelop, (m.z[1]-m.z[0])/scc.c, axis=0) pphi_pz2 = np.gradient(pphi_pz, (m.z[1]-m.z[0])/scc.c, axis=0) - temp_chirp = np.average(pphi_pz2, weights=laser_module1) + temp_chirp = np.average(pphi_pz2, weights=laser_module1) x = temp_chirp a = 4 * x b = -4 c = tau**4 * x zeta_roots = np.roots([a, b, c]) return np.max(zeta_roots) + def temporal2spectral_fft(Ar, m, k0): spect=np.fft.ifft( Ar, axis=1, norm="backward" @@ -40,7 +41,6 @@ def temporal2spectral_fft(Ar, m, k0): omega = 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0 *scc.c return omega,spect - def get_zeta(Ar,m,k0): omega,env_spec=temporal2spectral_fft(Ar,m,k0) env_spec_abs = np.abs(env_spec**2) @@ -59,7 +59,7 @@ def get_beta(F, m, k0): angle_y = np.gradient(phi_envelop_abs, m.y, axis=1) / k0 dtdb= np.gradient(angle_y, omega, axis=0) weight = np.abs(env_spec)**2 - return (np.sum(dtdb * weight) / np.sum(weight)) + return (np.sum(dtdb * weight) / np.sum(weight)) parser = argparse.ArgumentParser(description = 'Verify the chirp initialization') parser.add_argument('--output-dir', From b27d3c15cad8d7437eff1c086eaa760649521ed6 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 9 Jan 2025 18:00:35 +0100 Subject: [PATCH 220/254] Update analysis_laser_init_chirp.py From f6c2299b9c01088e6b3b3c26eac1eb6c076eb6e6 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 9 Jan 2025 18:05:57 +0100 Subject: [PATCH 221/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 49456655fc..61ffc76642 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -16,6 +16,12 @@ #from lasy.profiles import FromOpenPMDProfile #from lasy.laser import Laser +def get_duration(Ar,m): + weights=np.abs(Ar**2) + mean_val = np.average(m.z, weights=np.sum(weights,axis=1)) + std = np.sqrt(np.average((m.z - mean_val) ** 2, weights=np.sum(weights,axis=1))) + return 2*std/scc.c + def get_phi2 (Ar, m): # get temporal chirp phi2 tau = get_duration(Ar,m) From d8734be4d43acb5f412384fc20e622f1742691f0 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 9 Jan 2025 18:06:18 +0100 Subject: [PATCH 222/254] Update ubuntu.sh --- .github/workflows/setup/ubuntu.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/setup/ubuntu.sh b/.github/workflows/setup/ubuntu.sh index 79ac58c4a3..5ba05ab5f6 100755 --- a/.github/workflows/setup/ubuntu.sh +++ b/.github/workflows/setup/ubuntu.sh @@ -32,4 +32,3 @@ sudo update-alternatives --set python /usr/bin/python3 python -m pip install --upgrade pip python -m pip install --upgrade matplotlib numpy scipy openpmd-viewer openpmd-api -python -m pip install git+https://github.com/LASY-org/lasy.git From 4f92ec5e7d79f5ff6c229b0fc0a73d75d73708f1 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 9 Jan 2025 18:19:45 +0100 Subject: [PATCH 223/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 50840c85ab..ebb4f2ecf6 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -30,4 +30,4 @@ boundary.field = Dirichlet boundary.particle = Absorbing diagnostic.field_data = laserEnvelope -diagnostic.diag_type = xyz +diagnostic.diag_type = yz From c61bb36da4a11c703ff4e56515eb638e8bff470e Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Thu, 9 Jan 2025 18:46:11 +0100 Subject: [PATCH 224/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 61ffc76642..acac0a9c5a 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -97,9 +97,9 @@ def get_beta(F, m, k0): print('phi2 is ') print(phi2) print('zeta is ') -print([zeta_x, zeta_y]) +print(zeta) print('beta is ') -print([beta_x, beta_y]) +print(beta) np.testing.assert_approx_equal(phi2, 3e-24, significant=2) np.testing.assert_approx_equal(zeta_y,3e-22, significant=2) #np.testing.assert_approx_equal(beta_y, 3e-18, significant=2) From 834aa59c3c4337a5e4fc1b86cf9ee4fc95d11436 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:01:30 +0100 Subject: [PATCH 225/254] Update ubuntu_ompi.sh --- .github/workflows/setup/ubuntu_ompi.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/setup/ubuntu_ompi.sh b/.github/workflows/setup/ubuntu_ompi.sh index f9dc15d0ec..22316bbff7 100755 --- a/.github/workflows/setup/ubuntu_ompi.sh +++ b/.github/workflows/setup/ubuntu_ompi.sh @@ -34,6 +34,5 @@ sudo update-alternatives --set python /usr/bin/python3 python -m pip install --upgrade pip python -m pip install --upgrade matplotlib==3.2.2 numpy scipy openpmd-viewer openpmd-api axiprop -python -m pip install git+https://github.com/LASY-org/lasy.git From 3edda944b731cf473be63a8c584018d742576946 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:01:55 +0100 Subject: [PATCH 226/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index acac0a9c5a..be28b63c88 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -60,7 +60,7 @@ def get_zeta(Ar,m,k0): def get_beta(F, m, k0): omega,env_spec=temporal2spectral_fft(F,m,k0) phi_envelop_abs = np.unwrap( - np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=1 + np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=0 ) angle_y = np.gradient(phi_envelop_abs, m.y, axis=1) / k0 dtdb= np.gradient(angle_y, omega, axis=0) From 138600ab4036c317db1c6e16db216e7a56828c6c Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:15:39 +0100 Subject: [PATCH 227/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index ebb4f2ecf6..51eeeb1849 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -19,7 +19,7 @@ laser.tau = 1e-14 laser.phi2 = 3e-24 laser.zeta = 3e-22 laser.beta = 0 -laser.STC_theta_xy = 0 +laser.STC_theta_xy = 3.14159265358/2 amr.max_level = 0 diagnostic.output_period = 1 From 461df6a48dea22ef679f878c24531fc8e8a5f754 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:29:21 +0100 Subject: [PATCH 228/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index be28b63c88..20602f1a4b 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -40,7 +40,7 @@ def get_phi2 (Ar, m): def temporal2spectral_fft(Ar, m, k0): spect=np.fft.ifft( - Ar, axis=1, norm="backward" + Ar, axis=0, norm="backward" ) Nt = len(m.z) dt= (m.z[1]-m.z[0])/scc.c From 92426f775330b66e65e30c5d002c4f5d2561cf67 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 10 Jan 2025 17:00:19 +0100 Subject: [PATCH 229/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 51eeeb1849..980d2852f2 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -16,7 +16,7 @@ laser.position_mean = 0. 0. 0 laser.focal_distance = 0.0 laser.w0 = 2e-6 laser.tau = 1e-14 -laser.phi2 = 3e-24 +laser.phi2 = 0 laser.zeta = 3e-22 laser.beta = 0 laser.STC_theta_xy = 3.14159265358/2 From 40a461b4d09f71de77cd78b8df0a83c996e5732a Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 10 Jan 2025 20:57:28 +0100 Subject: [PATCH 230/254] Update inputs_chirp --- examples/laser/inputs_chirp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 980d2852f2..0dacbd0372 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -19,7 +19,7 @@ laser.tau = 1e-14 laser.phi2 = 0 laser.zeta = 3e-22 laser.beta = 0 -laser.STC_theta_xy = 3.14159265358/2 +laser.STC_theta_xy = 0 amr.max_level = 0 diagnostic.output_period = 1 @@ -30,4 +30,4 @@ boundary.field = Dirichlet boundary.particle = Absorbing diagnostic.field_data = laserEnvelope -diagnostic.diag_type = yz +diagnostic.diag_type = xz From 55ccc11053605286453fbaeb27404ba1bc9f267c Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Fri, 10 Jan 2025 20:58:45 +0100 Subject: [PATCH 231/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 20602f1a4b..1e8ee7066f 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -50,7 +50,7 @@ def temporal2spectral_fft(Ar, m, k0): def get_zeta(Ar,m,k0): omega,env_spec=temporal2spectral_fft(Ar,m,k0) env_spec_abs = np.abs(env_spec**2) - yda = np.sum(m.y * env_spec_abs, axis=1) / np.sum(env_spec_abs, axis=1) + yda = np.sum(m.x * env_spec_abs, axis=1) / np.sum(env_spec_abs, axis=1) derivative_y_zeta = np.gradient(yda, omega) weight_y_2d = np.mean(env_spec_abs, axis=1) #print(len(derivative_y_zeta)) @@ -62,7 +62,7 @@ def get_beta(F, m, k0): phi_envelop_abs = np.unwrap( np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=0 ) - angle_y = np.gradient(phi_envelop_abs, m.y, axis=1) / k0 + angle_y = np.gradient(phi_envelop_abs, m.x, axis=1) / k0 dtdb= np.gradient(angle_y, omega, axis=0) weight = np.abs(env_spec)**2 return (np.sum(dtdb * weight) / np.sum(weight)) From 6f95e87a1991aed404126327f04e63bfec73a2f1 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:01:48 +0100 Subject: [PATCH 232/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 0dacbd0372..3562989eb1 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -17,7 +17,7 @@ laser.focal_distance = 0.0 laser.w0 = 2e-6 laser.tau = 1e-14 laser.phi2 = 0 -laser.zeta = 3e-22 +laser.zeta = 3e-24 laser.beta = 0 laser.STC_theta_xy = 0 amr.max_level = 0 From 95c83e3cf3acce60d75eccfd432b1ef41dcce58e Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:02:50 +0100 Subject: [PATCH 233/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 3562989eb1..3c4cc31c4a 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -19,7 +19,7 @@ laser.tau = 1e-14 laser.phi2 = 0 laser.zeta = 3e-24 laser.beta = 0 -laser.STC_theta_xy = 0 +laser.STC_theta_xy = 3.14159265358/2 amr.max_level = 0 diagnostic.output_period = 1 From 81bc82ceb068e430bf5127f23edb296e1eae1af5 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:03:03 +0100 Subject: [PATCH 234/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 3c4cc31c4a..5f467fd955 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -30,4 +30,4 @@ boundary.field = Dirichlet boundary.particle = Absorbing diagnostic.field_data = laserEnvelope -diagnostic.diag_type = xz +diagnostic.diag_type = yz From d038315b2f823803740c4aa6d375b3f3c7fd4433 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:03:47 +0100 Subject: [PATCH 235/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 1e8ee7066f..20602f1a4b 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -50,7 +50,7 @@ def temporal2spectral_fft(Ar, m, k0): def get_zeta(Ar,m,k0): omega,env_spec=temporal2spectral_fft(Ar,m,k0) env_spec_abs = np.abs(env_spec**2) - yda = np.sum(m.x * env_spec_abs, axis=1) / np.sum(env_spec_abs, axis=1) + yda = np.sum(m.y * env_spec_abs, axis=1) / np.sum(env_spec_abs, axis=1) derivative_y_zeta = np.gradient(yda, omega) weight_y_2d = np.mean(env_spec_abs, axis=1) #print(len(derivative_y_zeta)) @@ -62,7 +62,7 @@ def get_beta(F, m, k0): phi_envelop_abs = np.unwrap( np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=0 ) - angle_y = np.gradient(phi_envelop_abs, m.x, axis=1) / k0 + angle_y = np.gradient(phi_envelop_abs, m.y, axis=1) / k0 dtdb= np.gradient(angle_y, omega, axis=0) weight = np.abs(env_spec)**2 return (np.sum(dtdb * weight) / np.sum(weight)) From a7b0676a2b2d277cfae84e471fd40522a2420b6d Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:09:39 +0100 Subject: [PATCH 236/254] Update inputs_chirp --- examples/laser/inputs_chirp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 5f467fd955..2e82e046e5 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -2,7 +2,7 @@ max_step = 1 hipace.dt = 70.e-6/clight hipace.verbose = 3 -amr.n_cell = 255 255 200 +amr.n_cell = 255 255 1000 hipace.do_tiling = 0 geometry.prob_lo = -5e-6 -5e-6 -2e-6 @@ -15,7 +15,7 @@ laser.a0 = 1 laser.position_mean = 0. 0. 0 laser.focal_distance = 0.0 laser.w0 = 2e-6 -laser.tau = 1e-14 +laser.tau = 1.3e-14 laser.phi2 = 0 laser.zeta = 3e-24 laser.beta = 0 From 6f0cbb9975b20b3ab9d6ce187337dc6e08e54002 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:13:29 +0100 Subject: [PATCH 237/254] Update inputs_chirp --- examples/laser/inputs_chirp | 53 +++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 2e82e046e5..a483f19098 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -1,33 +1,40 @@ max_step = 1 -hipace.dt = 70.e-6/clight -hipace.verbose = 3 +amr.n_cell = 256 256 1024 -amr.n_cell = 255 255 1000 -hipace.do_tiling = 0 +my_constants.kp_inv = clight/wp +my_constants.kp = wp/clight +my_constants.wp = sqrt( ne * q_e^2/(m_e *epsilon0) ) +my_constants.ne = 1.0505e23 +my_constants.Rm = 3*kp_inv +my_constants.Lramp = 6.e-3 -geometry.prob_lo = -5e-6 -5e-6 -2e-6 -geometry.prob_hi = 5e-6 5e-6 2e-6 +hipace.verbose = 1 +hipace.dt = 10.*kp_inv/clight +diagnostic.output_period = 10 -lasers.names = laser -lasers.lambda0 = .6e-6 - -laser.a0 = 1 -laser.position_mean = 0. 0. 0 -laser.focal_distance = 0.0 -laser.w0 = 2e-6 -laser.tau = 1.3e-14 -laser.phi2 = 0 -laser.zeta = 3e-24 -laser.beta = 0 -laser.STC_theta_xy = 3.14159265358/2 amr.max_level = 0 - -diagnostic.output_period = 1 - -hipace.depos_order_xy = 0 - boundary.field = Dirichlet boundary.particle = Absorbing +geometry.prob_lo = -18*kp_inv -18*kp_inv -7.5*kp_inv +geometry.prob_hi = 18*kp_inv 18*kp_inv 1.5*kp_inv +lasers.names = laser +lasers.lambda0 = 800e-9 +lasers.solver_type = multigrid +lasers.MG_tolerance_rel = 1e-5 +laser.a0 = 1.9 +laser.position_mean = 0. 0. 0 +laser.w0 = 3*kp_inv +laser.L0 = 5e-6 +laser.zeta = 2.4e-24 +laser.STC_theta_xy = 3.14159265358 / 2 +plasmas.names = plasma +plasma.density(x,y,z) = "ne*(1+4*(x^2+y^2)/(kp^2 * Rm^4 ) ) * + if (z > Lramp, 1, .5*(1-cos(pi*z/Lramp))) * + if (z>0,1,0)" +plasma.ppc = 1 1 +plasma.element = electron +plasma.radius = 23.*kp_inv diagnostic.field_data = laserEnvelope diagnostic.diag_type = yz + From 70f37ac3f2670169d6b7b50d1b8b4e62e224132a Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:14:43 +0100 Subject: [PATCH 238/254] Update inputs_chirp --- examples/laser/inputs_chirp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index a483f19098..52ba8a2e57 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -1,4 +1,4 @@ -max_step = 1 +max_step = 2 amr.n_cell = 256 256 1024 my_constants.kp_inv = clight/wp @@ -37,4 +37,3 @@ plasma.element = electron plasma.radius = 23.*kp_inv diagnostic.field_data = laserEnvelope diagnostic.diag_type = yz - From 9073784267e4cae833e71f93a50d844eed6b62b2 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:19:37 +0100 Subject: [PATCH 239/254] Update MultiLaser.cpp --- src/laser/MultiLaser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 3de5511905..8c3ef19264 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -920,12 +920,12 @@ MultiLaser::InitLaserSlice (const int islice, const int comp) // Time stretching due to STCs and phi2 complex envelope // (1 if zeta=0, beta=0, phi2=0) Complex stretch_factor = 1._rt \ - + 4._rt * (zeta + beta * zfoc) * inv_tau2 * (zeta + beta * zfoc) * inv_complex_waist_2 \ + + 4._rt * (-zeta + beta * zfoc) * inv_tau2 * (-zeta + beta * zfoc) * inv_complex_waist_2 \ + 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * inv_tau2; Complex prefactor = a0 / diffract_factor; Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) * amrex::pow(zp - beta * k0 * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) * clight - 2._rt * I * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) - * (zeta - beta * zfoc) * clight * inv_complex_waist_2, 2); + * (-zeta - beta * zfoc) * clight * inv_complex_waist_2, 2); Complex stcfactor = prefactor * amrex::exp( - time_exponent ); Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2; Complex envelope = stcfactor * amrex::exp( exp_argument ) * \ From cfaa84b5366e5a06ef79941c58020b3e6658709b Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:21:25 +0100 Subject: [PATCH 240/254] Update inputs_chirp --- examples/laser/inputs_chirp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 52ba8a2e57..6827af6b38 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -26,6 +26,7 @@ laser.a0 = 1.9 laser.position_mean = 0. 0. 0 laser.w0 = 3*kp_inv laser.L0 = 5e-6 +laser.phi2 = 2.4e-20 laser.zeta = 2.4e-24 laser.STC_theta_xy = 3.14159265358 / 2 plasmas.names = plasma From 93a9778ec9b4b52f95025966e43910595467ddc8 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:22:36 +0100 Subject: [PATCH 241/254] Update analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py index 20602f1a4b..b9c65e7d9d 100755 --- a/examples/laser/analysis_laser_init_chirp.py +++ b/examples/laser/analysis_laser_init_chirp.py @@ -100,6 +100,6 @@ def get_beta(F, m, k0): print(zeta) print('beta is ') print(beta) -np.testing.assert_approx_equal(phi2, 3e-24, significant=2) -np.testing.assert_approx_equal(zeta_y,3e-22, significant=2) +np.testing.assert_approx_equal(phi2, 2.4e-20, significant=2) +np.testing.assert_approx_equal(zeta_y,2.4e-24, significant=2) #np.testing.assert_approx_equal(beta_y, 3e-18, significant=2) From c98df19a6d9e279c743556dadfa2b1a1c313e2ff Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:26:48 +0100 Subject: [PATCH 242/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 6827af6b38..502e59868e 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -27,7 +27,7 @@ laser.position_mean = 0. 0. 0 laser.w0 = 3*kp_inv laser.L0 = 5e-6 laser.phi2 = 2.4e-20 -laser.zeta = 2.4e-24 +laser.zeta = 2.4e-26 laser.STC_theta_xy = 3.14159265358 / 2 plasmas.names = plasma plasma.density(x,y,z) = "ne*(1+4*(x^2+y^2)/(kp^2 * Rm^4 ) ) * From a6492f40775a474e4c5393b2eac2ee1a8a59d070 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:31:13 +0100 Subject: [PATCH 243/254] Update inputs_chirp --- examples/laser/inputs_chirp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 502e59868e..f9bf04800f 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -15,8 +15,8 @@ diagnostic.output_period = 10 amr.max_level = 0 boundary.field = Dirichlet boundary.particle = Absorbing -geometry.prob_lo = -18*kp_inv -18*kp_inv -7.5*kp_inv -geometry.prob_hi = 18*kp_inv 18*kp_inv 1.5*kp_inv +geometry.prob_lo = -9*kp_inv -9*kp_inv -1.5*kp_inv +geometry.prob_hi = 9*kp_inv 9*kp_inv 1.5*kp_inv lasers.names = laser lasers.lambda0 = 800e-9 @@ -27,7 +27,7 @@ laser.position_mean = 0. 0. 0 laser.w0 = 3*kp_inv laser.L0 = 5e-6 laser.phi2 = 2.4e-20 -laser.zeta = 2.4e-26 +laser.zeta = 2.4e-25 laser.STC_theta_xy = 3.14159265358 / 2 plasmas.names = plasma plasma.density(x,y,z) = "ne*(1+4*(x^2+y^2)/(kp^2 * Rm^4 ) ) * From 2c579f1d90a9016fc8ad7f9b5882f068c681fa6a Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:34:52 +0100 Subject: [PATCH 244/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index f9bf04800f..ce02350e75 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -27,7 +27,7 @@ laser.position_mean = 0. 0. 0 laser.w0 = 3*kp_inv laser.L0 = 5e-6 laser.phi2 = 2.4e-20 -laser.zeta = 2.4e-25 +laser.zeta = 2.4e-24 laser.STC_theta_xy = 3.14159265358 / 2 plasmas.names = plasma plasma.density(x,y,z) = "ne*(1+4*(x^2+y^2)/(kp^2 * Rm^4 ) ) * From 9ec8616a3f93a026ef57e59818b13b43d35a4a2c Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:38:37 +0100 Subject: [PATCH 245/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index ce02350e75..b3701776fe 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -27,7 +27,7 @@ laser.position_mean = 0. 0. 0 laser.w0 = 3*kp_inv laser.L0 = 5e-6 laser.phi2 = 2.4e-20 -laser.zeta = 2.4e-24 +laser.zeta = 2.4e-23 laser.STC_theta_xy = 3.14159265358 / 2 plasmas.names = plasma plasma.density(x,y,z) = "ne*(1+4*(x^2+y^2)/(kp^2 * Rm^4 ) ) * From 4a38d56fa0448ea5dc0a7385986dba10ad6916bc Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:42:23 +0100 Subject: [PATCH 246/254] Update inputs_chirp --- examples/laser/inputs_chirp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index b3701776fe..de466a5901 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -15,8 +15,8 @@ diagnostic.output_period = 10 amr.max_level = 0 boundary.field = Dirichlet boundary.particle = Absorbing -geometry.prob_lo = -9*kp_inv -9*kp_inv -1.5*kp_inv -geometry.prob_hi = 9*kp_inv 9*kp_inv 1.5*kp_inv +geometry.prob_lo = -9*kp_inv -9*kp_inv -3*kp_inv +geometry.prob_hi = 9*kp_inv 9*kp_inv 3*kp_inv lasers.names = laser lasers.lambda0 = 800e-9 @@ -27,7 +27,7 @@ laser.position_mean = 0. 0. 0 laser.w0 = 3*kp_inv laser.L0 = 5e-6 laser.phi2 = 2.4e-20 -laser.zeta = 2.4e-23 +laser.beta = 3e-18 laser.STC_theta_xy = 3.14159265358 / 2 plasmas.names = plasma plasma.density(x,y,z) = "ne*(1+4*(x^2+y^2)/(kp^2 * Rm^4 ) ) * From 111c34d0b11434bdc9b95c6c2f33d79d2414eec7 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 13 Jan 2025 12:35:15 +0100 Subject: [PATCH 247/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index de466a5901..3000698639 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -27,7 +27,7 @@ laser.position_mean = 0. 0. 0 laser.w0 = 3*kp_inv laser.L0 = 5e-6 laser.phi2 = 2.4e-20 -laser.beta = 3e-18 +laser.beta = 3e-16 laser.STC_theta_xy = 3.14159265358 / 2 plasmas.names = plasma plasma.density(x,y,z) = "ne*(1+4*(x^2+y^2)/(kp^2 * Rm^4 ) ) * From 4b826f06e54dc26ea9a9740d79e9c154ac635a6c Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Mon, 13 Jan 2025 12:50:36 +0100 Subject: [PATCH 248/254] Update inputs_chirp --- examples/laser/inputs_chirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp index 3000698639..4af2aea252 100644 --- a/examples/laser/inputs_chirp +++ b/examples/laser/inputs_chirp @@ -27,7 +27,7 @@ laser.position_mean = 0. 0. 0 laser.w0 = 3*kp_inv laser.L0 = 5e-6 laser.phi2 = 2.4e-20 -laser.beta = 3e-16 +laser.beta = 3e-15 laser.STC_theta_xy = 3.14159265358 / 2 plasmas.names = plasma plasma.density(x,y,z) = "ne*(1+4*(x^2+y^2)/(kp^2 * Rm^4 ) ) * From 3667fa1cf699f746a4d18f1a8b80d666c2ce9fa3 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 18 Jan 2025 21:59:07 +0100 Subject: [PATCH 249/254] Update ubuntu_ompi.sh --- .github/workflows/setup/ubuntu_ompi.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/setup/ubuntu_ompi.sh b/.github/workflows/setup/ubuntu_ompi.sh index 22316bbff7..136e72c305 100755 --- a/.github/workflows/setup/ubuntu_ompi.sh +++ b/.github/workflows/setup/ubuntu_ompi.sh @@ -33,6 +33,4 @@ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2 sudo update-alternatives --set python /usr/bin/python3 python -m pip install --upgrade pip -python -m pip install --upgrade matplotlib==3.2.2 numpy scipy openpmd-viewer openpmd-api axiprop - - +python -m pip install --upgrade matplotlib==3.2.2 numpy scipy openpmd-viewer openpmd-api From 509c8d9fdbd0a8a95ef54de7d409869c4d3adaab Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 18 Jan 2025 22:00:29 +0100 Subject: [PATCH 250/254] Update CMakeLists.txt --- CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8af2d856d7..dc4604f2f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,12 +342,6 @@ if(BUILD_TESTING) WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) - add_test(NAME laser_STC.SI.1Rank - COMMAND bash ${HiPACE_SOURCE_DIR}/tests/laser_STC.SI.1Rank.sh - $ ${HiPACE_SOURCE_DIR} - WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - ) - if (NOT HiPACE_COMPUTE STREQUAL CUDA) # These tests only run on CPU From bfe5ee23506a0557d4a10000de97a3699fc35ca6 Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 18 Jan 2025 22:01:13 +0100 Subject: [PATCH 251/254] Delete examples/laser/analysis_laser_init_chirp.py --- examples/laser/analysis_laser_init_chirp.py | 105 -------------------- 1 file changed, 105 deletions(-) delete mode 100755 examples/laser/analysis_laser_init_chirp.py diff --git a/examples/laser/analysis_laser_init_chirp.py b/examples/laser/analysis_laser_init_chirp.py deleted file mode 100755 index b9c65e7d9d..0000000000 --- a/examples/laser/analysis_laser_init_chirp.py +++ /dev/null @@ -1,105 +0,0 @@ -#! /usr/bin/env python3 - -# Copyright 2024 -# -# This file is part of HiPACE++. -# -# Authors: Xingjian Hui -# License: BSD-3-Clause-LBNL - -import argparse -import numpy as np -import scipy.constants as scc -from openpmd_viewer.addons import LpaDiagnostics -from openpmd_viewer import OpenPMDTimeSeries -#from lasy.utils.laser_utils import get_beta, get_phi2, get_zeta -#from lasy.profiles import FromOpenPMDProfile -#from lasy.laser import Laser - -def get_duration(Ar,m): - weights=np.abs(Ar**2) - mean_val = np.average(m.z, weights=np.sum(weights,axis=1)) - std = np.sqrt(np.average((m.z - mean_val) ** 2, weights=np.sum(weights,axis=1))) - return 2*std/scc.c - -def get_phi2 (Ar, m): - # get temporal chirp phi2 - tau = get_duration(Ar,m) - laser_module1 = np.abs(Ar**2) - phi_envelop = np.unwrap( np.unwrap(np.arctan(Ar.imag/Ar.real), axis=0), axis=1) - # calculate pphi_pz - pphi_pz = np.gradient(phi_envelop, (m.z[1]-m.z[0])/scc.c, axis=0) - pphi_pz2 = np.gradient(pphi_pz, (m.z[1]-m.z[0])/scc.c, axis=0) - temp_chirp = np.average(pphi_pz2, weights=laser_module1) - x = temp_chirp - a = 4 * x - b = -4 - c = tau**4 * x - zeta_roots = np.roots([a, b, c]) - return np.max(zeta_roots) - -def temporal2spectral_fft(Ar, m, k0): - spect=np.fft.ifft( - Ar, axis=0, norm="backward" - ) - Nt = len(m.z) - dt= (m.z[1]-m.z[0])/scc.c - omega = 2 * np.pi * np.fft.fftfreq(Nt, dt) + k0 *scc.c - return omega,spect - -def get_zeta(Ar,m,k0): - omega,env_spec=temporal2spectral_fft(Ar,m,k0) - env_spec_abs = np.abs(env_spec**2) - yda = np.sum(m.y * env_spec_abs, axis=1) / np.sum(env_spec_abs, axis=1) - derivative_y_zeta = np.gradient(yda, omega) - weight_y_2d = np.mean(env_spec_abs, axis=1) - #print(len(derivative_y_zeta)) - zeta_y = np.average(derivative_y_zeta.T, weights=weight_y_2d) - return zeta_y - -def get_beta(F, m, k0): - omega,env_spec=temporal2spectral_fft(F,m,k0) - phi_envelop_abs = np.unwrap( - np.array(np.arctan2(env_spec.imag, env_spec.real)), axis=0 - ) - angle_y = np.gradient(phi_envelop_abs, m.y, axis=1) / k0 - dtdb= np.gradient(angle_y, omega, axis=0) - weight = np.abs(env_spec)**2 - return (np.sum(dtdb * weight) / np.sum(weight)) - -parser = argparse.ArgumentParser(description = 'Verify the chirp initialization') -parser.add_argument('--output-dir', - dest='output_dir', - default='diags/hdf5', - help='Path to the directory containing output files') -parser.add_argument('--chirp_type', - dest='chirp_type', - default='phi2', - help='Type of the initialized chirp') -args = parser.parse_args() - -#print(args.output_dir) -#profile = FromOpenPMDProfile(path=args.output_dir,iteration=0,pol=[1,0],field='laserEnvelope', is_envelope=True, prefix='openpmd') -#laser = Laser( -# dim="xyt", -# lo=(np.min(profile.axes['x']), np.min(profile.axes['y']), np.min(profile.axes['t'])), -# hi=(np.max(profile.axes['x']), np.max(profile.axes['y']), np.max(profile.axes['t'])), -# npoints=(511, 255, 500), -# profile=profile, -# ) -ts=OpenPMDTimeSeries(args.output_dir) -Ar, m = ts.get_field(field='laserEnvelope', iteration=0) -k0 = 2 * scc.pi / 0.6e-6 -phi2 = get_phi2(Ar, m) -zeta= get_zeta(Ar, m, k0) -beta = get_beta(Ar, m, k0) - -print('phi2 is ') -print(phi2) -print('zeta is ') -print(zeta) -print('beta is ') -print(beta) -np.testing.assert_approx_equal(phi2, 2.4e-20, significant=2) -np.testing.assert_approx_equal(zeta_y,2.4e-24, significant=2) -#np.testing.assert_approx_equal(beta_y, 3e-18, significant=2) From 1fa19586cbce76f345da4f84ead608658c83b10a Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 18 Jan 2025 22:01:31 +0100 Subject: [PATCH 252/254] Delete examples/laser/inputs_chirp --- examples/laser/inputs_chirp | 40 ------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 examples/laser/inputs_chirp diff --git a/examples/laser/inputs_chirp b/examples/laser/inputs_chirp deleted file mode 100644 index 4af2aea252..0000000000 --- a/examples/laser/inputs_chirp +++ /dev/null @@ -1,40 +0,0 @@ -max_step = 2 -amr.n_cell = 256 256 1024 - -my_constants.kp_inv = clight/wp -my_constants.kp = wp/clight -my_constants.wp = sqrt( ne * q_e^2/(m_e *epsilon0) ) -my_constants.ne = 1.0505e23 -my_constants.Rm = 3*kp_inv -my_constants.Lramp = 6.e-3 - -hipace.verbose = 1 -hipace.dt = 10.*kp_inv/clight -diagnostic.output_period = 10 - -amr.max_level = 0 -boundary.field = Dirichlet -boundary.particle = Absorbing -geometry.prob_lo = -9*kp_inv -9*kp_inv -3*kp_inv -geometry.prob_hi = 9*kp_inv 9*kp_inv 3*kp_inv - -lasers.names = laser -lasers.lambda0 = 800e-9 -lasers.solver_type = multigrid -lasers.MG_tolerance_rel = 1e-5 -laser.a0 = 1.9 -laser.position_mean = 0. 0. 0 -laser.w0 = 3*kp_inv -laser.L0 = 5e-6 -laser.phi2 = 2.4e-20 -laser.beta = 3e-15 -laser.STC_theta_xy = 3.14159265358 / 2 -plasmas.names = plasma -plasma.density(x,y,z) = "ne*(1+4*(x^2+y^2)/(kp^2 * Rm^4 ) ) * - if (z > Lramp, 1, .5*(1-cos(pi*z/Lramp))) * - if (z>0,1,0)" -plasma.ppc = 1 1 -plasma.element = electron -plasma.radius = 23.*kp_inv -diagnostic.field_data = laserEnvelope -diagnostic.diag_type = yz From 59d5f43daede1a96f1ce6c27f0590654ac6a1aae Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 18 Jan 2025 22:01:47 +0100 Subject: [PATCH 253/254] Delete tests/laser_STC.SI.1Rank.sh --- tests/laser_STC.SI.1Rank.sh | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 tests/laser_STC.SI.1Rank.sh diff --git a/tests/laser_STC.SI.1Rank.sh b/tests/laser_STC.SI.1Rank.sh deleted file mode 100644 index 347e30c372..0000000000 --- a/tests/laser_STC.SI.1Rank.sh +++ /dev/null @@ -1,34 +0,0 @@ -#! /usr/bin/env bash - -# Copyright 2024 -# -# This file is part of HiPACE++. -# -# Authors: Xingjian Hui -# License: BSD-3-Clause-LBNL - - -# This file is part of the HiPACE++ test suite. -# It initializes a Hipace simulation of a gaussian laser with initial spatiotemporal couplings (STCs) -# and test the correctness of the STC factors - -# Abort on first encountered error -set -eu -o pipefail - -# Read input parameters -HIPACE_EXECUTABLE=$1 -HIPACE_SOURCE_DIR=$2 - -HIPACE_EXAMPLE_DIR=${HIPACE_SOURCE_DIR}/examples/laser -HIPACE_TEST_DIR=${HIPACE_SOURCE_DIR}/tests - -FILE_NAME=`basename "$0"` -TEST_NAME="${FILE_NAME%.*}_0" - -# Run the simulation with initial phi2 -mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \ - hipace.file_prefix = $TEST_NAME -# Compare the result with theory -$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME -ls . -rm -rf $TEST_NAME From b8a15f50344242f03eee2da3f51efefe1102f79a Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Sat, 18 Jan 2025 22:01:58 +0100 Subject: [PATCH 254/254] Delete tests/laser_evolution.SI.2Rank.sh --- tests/laser_evolution.SI.2Rank.sh | 54 ------------------------------- 1 file changed, 54 deletions(-) delete mode 100755 tests/laser_evolution.SI.2Rank.sh diff --git a/tests/laser_evolution.SI.2Rank.sh b/tests/laser_evolution.SI.2Rank.sh deleted file mode 100755 index f91fa558a5..0000000000 --- a/tests/laser_evolution.SI.2Rank.sh +++ /dev/null @@ -1,54 +0,0 @@ -#! /usr/bin/env bash - -# Copyright 2022 -# -# This file is part of HiPACE++. -# -# Authors: MaxThevenet -# License: BSD-3-Clause-LBNL - - -# This file is part of the HiPACE++ test suite. -# It runs a Hipace simulation of a laser propagating in vacuum -# and compares width and a0 with theory - -# abort on first encounted error -set -eu -o pipefail - -# Read input parameters -HIPACE_EXECUTABLE=$1 -HIPACE_SOURCE_DIR=$2 - -HIPACE_EXAMPLE_DIR=${HIPACE_SOURCE_DIR}/examples/laser -HIPACE_TEST_DIR=${HIPACE_SOURCE_DIR}/tests - -FILE_NAME=`basename "$0"` -TEST_NAME="${FILE_NAME%.*}" - -# Relative tolerance for checksum tests depends on the platform -RTOL=1e-12 && [[ "$HIPACE_EXECUTABLE" == *"hipace"*".CUDA."* ]] && RTOL=1e-7 - -# Run the simulation with multigrid Poisson solver -mpiexec -n 2 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ - lasers.solver_type = multigrid \ - hipace.file_prefix = $TEST_NAME -# Compare the result with theory -$HIPACE_EXAMPLE_DIR/analysis_laser_vacuum.py --output-dir=$TEST_NAME - -rm -rf $TEST_NAME - -# Run the simulation with FFT Poisson solver -mpiexec -n 2 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_SI \ - lasers.solver_type = fft \ - hipace.file_prefix = $TEST_NAME -# Compare the result with theory -$HIPACE_EXAMPLE_DIR/analysis_laser_vacuum.py --output-dir=$TEST_NAME -# Compare the results with checksum benchmark -$HIPACE_TEST_DIR/checksum/checksumAPI.py \ - --skip-particles \ - --evaluate \ - --rtol $RTOL \ - --file_name $TEST_NAME \ - --test-name $TEST_NAME - -rm -rf $TEST_NAME