From 41b17de0e4554397737b42c60d9f1037225234e4 Mon Sep 17 00:00:00 2001 From: Spencer Jolly <35569785+spencerjolly@users.noreply.github.com> Date: Mon, 15 Jan 2024 11:28:26 +0100 Subject: [PATCH] Update test_laser_profiles.py --- tests/test_laser_profiles.py | 103 +++++++++++++++++------------------ 1 file changed, 50 insertions(+), 53 deletions(-) diff --git a/tests/test_laser_profiles.py b/tests/test_laser_profiles.py index 9e44673e..d62f664a 100644 --- a/tests/test_laser_profiles.py +++ b/tests/test_laser_profiles.py @@ -47,32 +47,39 @@ def gaussian(): return profile +@pytest.fixture(scope="function") +def spatial_chirp(): + # Cases with Gaussian laser having non-zero spatial chirp (b) + wavelength = 0.8e-6 + pol = (1, 0) + laser_energy = 1.0 # J + t_peak = 0.0e-15 # s + tau = 30.0e-15 # s + w0 = 5.0e-6 # m + a = 0.0 + b = w0 * tau / 2 # m.s + profile = GaussianProfile( + wavelength, pol, laser_energy, w0, tau, t_peak, a, b, gdd=0.0 + ) -def test_profile_gaussian_spatial_chirp(spatial_chirp): - # - 3D Cartesian case - dim = "xyt" - lo = (-10e-6, -10e-6, -60e-15) - hi = (+10e-6, +10e-6, +60e-15) - npoints = (100, 100, 100) - - laser = Laser(dim, lo, hi, npoints, spatial_chirp) - laser.write_to_file("gaussianlaserSC") - laser.propagate(1e-6) - laser.write_to_file("gaussianlaserSC") - - -def test_profile_gaussian_angular_dispersion(angular_dispersion): - # - 3D Cartesian case - dim = "xyt" - lo = (-10e-6, -10e-6, -60e-15) - hi = (+10e-6, +10e-6, +60e-15) - npoints = (100, 100, 100) + return profile - laser = Laser(dim, lo, hi, npoints, angular_dispersion) - laser.write_to_file("gaussianlaserAD") - laser.propagate(1e-6) - laser.write_to_file("gaussianlaserAD") +@pytest.fixture(scope="function") +def angular_dispersion(): + # Cases with Gaussian laser having non-zero angular dispersion (a) + wavelength = 0.8e-6 + pol = (1, 0) + laser_energy = 1.0 # J + t_peak = 0.0e-15 # s + tau = 30.0e-15 # s + w0 = 5.0e-6 # m + a = tau / w0 # s/m + b = 0.0 + profile = GaussianProfile( + wavelength, pol, laser_energy, w0, tau, t_peak, a, b, gdd=0.0 + ) + return profile def test_transverse_profiles_rt(): npoints = 4000 @@ -185,40 +192,30 @@ def test_profile_gaussian_cylindrical(gaussian): laser.propagate(1e-6) laser.write_to_file("gaussianlaserRZ") +def test_profile_gaussian_spatial_chirp(spatial_chirp): + # - 3D Cartesian case + dim = "xyt" + lo = (-10e-6, -10e-6, -60e-15) + hi = (+10e-6, +10e-6, +60e-15) + npoints = (100, 100, 100) -def spatial_chirp(): - # Cases with Gaussian laser having non-zero spatial chirp (b) - wavelength = 0.8e-6 - pol = (1, 0) - laser_energy = 1.0 # J - t_peak = 0.0e-15 # s - tau = 30.0e-15 # s - w0 = 5.0e-6 # m - a = 0.0 - b = w0 * tau / 2 # m.s - profile = GaussianProfile( - wavelength, pol, laser_energy, w0, tau, t_peak, a, b, gdd=0.0 - ) - - return profile - + laser = Laser(dim, lo, hi, npoints, spatial_chirp) + laser.write_to_file("gaussianlaserSC") + laser.propagate(1e-6) + laser.write_to_file("gaussianlaserSC") -def angular_dispersion(): - # Cases with Gaussian laser having non-zero angular dispersion (a) - wavelength = 0.8e-6 - pol = (1, 0) - laser_energy = 1.0 # J - t_peak = 0.0e-15 # s - tau = 30.0e-15 # s - w0 = 5.0e-6 # m - a = tau / w0 # s/m - b = 0.0 - profile = GaussianProfile( - wavelength, pol, laser_energy, w0, tau, t_peak, a, b, gdd=0.0 - ) - return profile +def test_profile_gaussian_angular_dispersion(angular_dispersion): + # - 3D Cartesian case + dim = "xyt" + lo = (-10e-6, -10e-6, -60e-15) + hi = (+10e-6, +10e-6, +60e-15) + npoints = (100, 100, 100) + laser = Laser(dim, lo, hi, npoints, angular_dispersion) + laser.write_to_file("gaussianlaserAD") + laser.propagate(1e-6) + laser.write_to_file("gaussianlaserAD") def test_from_array_profile(): # Create a 3D numpy array, use it to create a LASY profile,