From 5e8ce8bde80b4f75d5b256047e8ac646f53ab46e Mon Sep 17 00:00:00 2001 From: Xingjian Hui <151739545+huixingjian@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:33:56 +0100 Subject: [PATCH] Update test_STC.py --- tests/test_STC.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/test_STC.py b/tests/test_STC.py index 7d8f9a8c..c18c3768 100644 --- a/tests/test_STC.py +++ b/tests/test_STC.py @@ -2,7 +2,7 @@ Test checks the implementation of the initialization and diagnostics to spatio-temporal coupling gaussian lasers by creating a gaussian pulse on focus and calculate the STC factors by the implemented functions in laser.utils. -The correctness is also checked through comparing the gaussian profile and a combined gaussian profile off-focus. +The correctness is also checked through comparing the gaussian profile and a combined gaussian profile out of focus. """ import numpy as np @@ -27,8 +27,9 @@ stc_theta = scc.pi / 2 # rad z_r = (np.pi * w0**2) / wavelength z_foc = 3 * z_r + # Create STC profile. -profile = GaussianProfile( +STCprofile = GaussianProfile( wavelength=wavelength, pol=pol, laser_energy=laser_energy, @@ -47,17 +48,18 @@ lo=(-10e-6, -10e-6, -10e-14), hi=(10e-6, 10e-6, +10e-14), npoints=(100, 100, 200), - profile=profile, + profile=STCprofile, ) -# Create laser with given profile in `rt` geometry. +# Create laser out of focus with given profile in `rt` geometry by combined and gaussian profile. long_profile = GaussianLongitudinalProfile(wavelength, tau, t_peak) trans_profile = GaussianTransverseProfile(w0, wavelength, z_foc) + combined_profile = CombinedLongitudinalTransverseProfile( wavelength, pol, laser_energy, long_profile, trans_profile ) -profile_gaussian = GaussianProfile( +gaussian_profile = GaussianProfile( wavelength=wavelength, pol=pol, laser_energy=laser_energy, @@ -80,9 +82,10 @@ lo=(0e-6, -10e-14), hi=(50e-6, +10e-14), npoints=(60, 200), - profile=profile_gaussian, + profile=gaussian_profile, ) +# calculate the error of gaussian profile env_combined = laser_2d_combined.grid.get_temporal_field() env_gaussian = laser_2d_gaussian.grid.get_temporal_field() @@ -96,11 +99,11 @@ ) Phi2_3d, phi2_3d = get_phi2(laser_3d.dim, laser_3d.grid) - [zeta_x, zeta_y], [nu_x, nu_y] = get_zeta( laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6 ) [beta_x, beta_y] = get_beta(laser_3d.dim, laser_3d.grid, 2.0 * np.pi / 0.6e-6) + assert (err_real + err_imag) < 1e-6 np.testing.assert_approx_equal(phi2_3d, 2.4e-24, significant=2) np.testing.assert_approx_equal(zeta_y, 2.4e-22, significant=2)