Skip to content

Commit

Permalink
Update test_STC.py
Browse files Browse the repository at this point in the history
  • Loading branch information
huixingjian authored Dec 17, 2024
1 parent 6f650f2 commit 5e8ce8b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions tests/test_STC.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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()

Expand All @@ -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)

Check notice

Code scanning / CodeQL

Unused global variable Note test

The global variable 'beta_x' is not used.

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)
Expand Down

0 comments on commit 5e8ce8b

Please sign in to comment.