diff --git a/Examples/Physics_applications/capacitive_discharge/analysis_1d.py b/Examples/Physics_applications/capacitive_discharge/analysis_1d.py index 82d98c38210..e9043e5dc01 100755 --- a/Examples/Physics_applications/capacitive_discharge/analysis_1d.py +++ b/Examples/Physics_applications/capacitive_discharge/analysis_1d.py @@ -2,8 +2,14 @@ # Copyright 2022 Modern Electron, David Grote +import os +import sys + import numpy as np +sys.path.insert(1, "../../../../warpx/Regression/Checksum/") +from checksumAPI import evaluate_checksum + # fmt: off ref_density = np.array([ 1.27989677e+14, 2.23601330e+14, 2.55400265e+14, 2.55664972e+14, @@ -45,3 +51,9 @@ density_data = np.load("ion_density_case_1.npy") print(repr(density_data)) assert np.allclose(density_data, ref_density) + +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Physics_applications/capacitive_discharge/analysis_2d.py b/Examples/Physics_applications/capacitive_discharge/analysis_2d.py index f52f69f4bf4..d4845ffb718 100755 --- a/Examples/Physics_applications/capacitive_discharge/analysis_2d.py +++ b/Examples/Physics_applications/capacitive_discharge/analysis_2d.py @@ -7,12 +7,15 @@ # solver that directly solves the Poisson equation using matrix inversion # rather than the iterative approach from the MLMG solver. +import os import sys -sys.path.append("../../../../warpx/Regression/Checksum/") +sys.path.insert(1, "../../../../warpx/Regression/Checksum/") +from checksumAPI import evaluate_checksum -import checksumAPI - -my_check = checksumAPI.evaluate_checksum( - "test_2d_background_mcc", "diags/diag1000050", do_particles=True, rtol=5e-3 +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + rtol=5e-3, ) diff --git a/Examples/Physics_applications/capacitive_discharge/analysis_dsmc.py b/Examples/Physics_applications/capacitive_discharge/analysis_dsmc.py index 505521fc1ca..1458924b35c 100755 --- a/Examples/Physics_applications/capacitive_discharge/analysis_dsmc.py +++ b/Examples/Physics_applications/capacitive_discharge/analysis_dsmc.py @@ -7,15 +7,8 @@ import numpy as np -sys.path.append("../../../../warpx/Regression/Checksum/") - -import checksumAPI - -# this will be the name of the plot file -fn = sys.argv[1] -test_name = os.path.split(os.getcwd())[1] - -my_check = checksumAPI.evaluate_checksum(test_name, fn, do_particles=True) +sys.path.insert(1, "../../../../warpx/Regression/Checksum/") +from checksumAPI import evaluate_checksum # fmt: off ref_density = np.array([ @@ -58,3 +51,9 @@ density_data = np.load("ion_density_case_1.npy") print(repr(density_data)) assert np.allclose(density_data, ref_density) + +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Physics_applications/laser_acceleration/analysis_1d_fluid_boosted.py b/Examples/Physics_applications/laser_acceleration/analysis_1d_fluid_boosted.py index 934d298c6b7..03369d48adf 100755 --- a/Examples/Physics_applications/laser_acceleration/analysis_1d_fluid_boosted.py +++ b/Examples/Physics_applications/laser_acceleration/analysis_1d_fluid_boosted.py @@ -25,7 +25,7 @@ from scipy.constants import c, e, epsilon_0, m_e sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # this will be the name of the plot file fn = sys.argv[1] @@ -188,5 +188,8 @@ def odefcn(phi, xi, kp, a0, c, tau, xi_0, lambda_laser): assert error_rel < tolerance_rel -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Physics_applications/laser_acceleration/analysis_openpmd_rz.py b/Examples/Physics_applications/laser_acceleration/analysis_openpmd_rz.py index f136ffeb1d4..0e07ddf914c 100755 --- a/Examples/Physics_applications/laser_acceleration/analysis_openpmd_rz.py +++ b/Examples/Physics_applications/laser_acceleration/analysis_openpmd_rz.py @@ -1,10 +1,14 @@ #!/usr/bin/env python3 +import os import sys import numpy as np import openpmd_api as io +sys.path.insert(1, "../../../../warpx/Regression/Checksum/") +from checksumAPI import evaluate_checksum + filename = sys.argv[1] series = io.Series(f"{filename}/openpmd_%T.h5", io.Access.read_only) @@ -63,3 +67,10 @@ assert ( (electron_meanz > 0) and (beam_meanz < 0) ), "problem with openPMD+RZ. Maybe openPMD+RZ mixed up the order of rho_ diagnostics?" + +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + output_format="openpmd", +) diff --git a/Examples/Physics_applications/laser_acceleration/analysis_refined_injection.py b/Examples/Physics_applications/laser_acceleration/analysis_refined_injection.py index bc7fac15247..d481075c112 100755 --- a/Examples/Physics_applications/laser_acceleration/analysis_refined_injection.py +++ b/Examples/Physics_applications/laser_acceleration/analysis_refined_injection.py @@ -17,7 +17,7 @@ yt.funcs.mylog.setLevel(50) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # this will be the name of the plot file fn = sys.argv[1] @@ -59,5 +59,8 @@ # Test uniformity up to 0.5% relative variation assert rho_slice.std() < 0.005 * abs(rho_slice.mean()) -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Physics_applications/spacecraft_charging/analysis.py b/Examples/Physics_applications/spacecraft_charging/analysis.py index 8819c435fb7..1795f5dfb6e 100755 --- a/Examples/Physics_applications/spacecraft_charging/analysis.py +++ b/Examples/Physics_applications/spacecraft_charging/analysis.py @@ -23,13 +23,9 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum -# Open plotfile specified in command line filename = sys.argv[1] -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename, output_format="openpmd") - ts = OpenPMDTimeSeries(filename) dt = 1.27e-8 t = [] @@ -78,3 +74,10 @@ def func(x, v0, tau): assert (diff_v0 < tolerance_v0) and ( diff_tau < tolerance_tau ), "Test spacecraft_charging did not pass" + +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + output_format="openpmd", +) diff --git a/Examples/Tests/accelerator_lattice/analysis.py b/Examples/Tests/accelerator_lattice/analysis.py index 6f76fd86855..b208d086d8c 100755 --- a/Examples/Tests/accelerator_lattice/analysis.py +++ b/Examples/Tests/accelerator_lattice/analysis.py @@ -24,7 +24,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum filename = sys.argv[1] ds = yt.load(filename) @@ -131,5 +131,8 @@ def applylens(x0, vx0, vz0, gamma, lens_length, lens_strength): "error in x particle velocity" ) -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/boosted_diags/analysis.py b/Examples/Tests/boosted_diags/analysis.py index 62956133af6..0d4794a8894 100755 --- a/Examples/Tests/boosted_diags/analysis.py +++ b/Examples/Tests/boosted_diags/analysis.py @@ -27,7 +27,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum filename = sys.argv[1] @@ -56,5 +56,8 @@ (w,) = ts.get_particle(["w"], species="beam", iteration=3) assert (400 < len(w)) & (len(w) < 600) -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/boundaries/analysis.py b/Examples/Tests/boundaries/analysis.py index be76a728a1f..ce3251ea406 100755 --- a/Examples/Tests/boundaries/analysis.py +++ b/Examples/Tests/boundaries/analysis.py @@ -23,7 +23,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # The min and max size of the box along the three axis. dmin = -1.0 @@ -111,5 +111,8 @@ def do_periodic(x): np.abs((zz - zza) / zz) < 1.0e-15 ), "Periodic particle position not correct" -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/btd_rz/analysis.py b/Examples/Tests/btd_rz/analysis.py index 5002b4c80b3..87f74599105 100755 --- a/Examples/Tests/btd_rz/analysis.py +++ b/Examples/Tests/btd_rz/analysis.py @@ -17,7 +17,7 @@ from scipy.optimize import curve_fit sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum def gaussian_laser(z, a0, z0_phase, z0_prop, ctau, lambda0): @@ -58,6 +58,8 @@ def fit_function(z, z0_phase): ## Check that the a0 agrees within 5% of the predicted value assert np.allclose(Ex, Ex_fit, atol=0.18 * Ex.max()) -# Checksum regression analysis -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, plotfile) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/collider_relevant_diags/analysis.py b/Examples/Tests/collider_relevant_diags/analysis.py index f6eb9de124f..232bc47af21 100755 --- a/Examples/Tests/collider_relevant_diags/analysis.py +++ b/Examples/Tests/collider_relevant_diags/analysis.py @@ -8,8 +8,8 @@ import pandas as pd from scipy.constants import c, e, hbar, m_e -sys.path.append("../../../../warpx/Regression/Checksum/") -import checksumAPI +sys.path.insert(1, "../../../../warpx/Regression/Checksum/") +from checksumAPI import evaluate_checksum sys.path.append("../../../../warpx/Tools/Parser/") from input_file_parser import parse_input_file @@ -180,7 +180,8 @@ def dL_dt(): dL_dt_cr = df[[col for col in df.columns if "dL_dt" in col]].to_numpy() assert np.allclose(dL_dt_cr, dL_dt(), rtol=1e-8) -# Checksum analysis -plotfile = sys.argv[1] -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, plotfile) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/collision/analysis_collision_1d.py b/Examples/Tests/collision/analysis_collision_1d.py index 1888696953e..97ddee0591d 100755 --- a/Examples/Tests/collision/analysis_collision_1d.py +++ b/Examples/Tests/collision/analysis_collision_1d.py @@ -23,7 +23,7 @@ from scipy.constants import e sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # this will be the name of the plot file last_fn = sys.argv[1] @@ -124,5 +124,8 @@ print("tolerance = ", tolerance) assert error < tolerance -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, last_fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/collision/analysis_collision_2d.py b/Examples/Tests/collision/analysis_collision_2d.py index 7e1d74001a3..7ce3e4cdf2e 100755 --- a/Examples/Tests/collision/analysis_collision_2d.py +++ b/Examples/Tests/collision/analysis_collision_2d.py @@ -33,7 +33,7 @@ import yt sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum test_name = os.path.split(os.getcwd())[1] @@ -121,4 +121,8 @@ last_fn, random_filter_fn, random_fraction, dim, species_name ) -checksumAPI.evaluate_checksum(test_name, last_fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/collision/analysis_collision_3d.py b/Examples/Tests/collision/analysis_collision_3d.py index 0a1b016a227..59c625d3cb8 100755 --- a/Examples/Tests/collision/analysis_collision_3d.py +++ b/Examples/Tests/collision/analysis_collision_3d.py @@ -33,7 +33,7 @@ import yt sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum tolerance = 0.001 @@ -111,5 +111,8 @@ last_fn, random_filter_fn, random_fraction, dim, species_name ) -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, last_fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/collision/analysis_collision_3d_isotropization.py b/Examples/Tests/collision/analysis_collision_3d_isotropization.py index 6386ce74812..2cfe7f9fffd 100755 --- a/Examples/Tests/collision/analysis_collision_3d_isotropization.py +++ b/Examples/Tests/collision/analysis_collision_3d_isotropization.py @@ -19,7 +19,7 @@ import yt sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum e = sc.e pi = sc.pi @@ -64,5 +64,8 @@ print(f"tolerance = {tolerance}") assert error < tolerance -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/collision/analysis_collision_rz.py b/Examples/Tests/collision/analysis_collision_rz.py index 168d8a8a7cf..2df2f6500d2 100755 --- a/Examples/Tests/collision/analysis_collision_rz.py +++ b/Examples/Tests/collision/analysis_collision_rz.py @@ -24,7 +24,7 @@ import yt sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum tolerance = 1.0e-15 @@ -55,5 +55,9 @@ print("tolerance = ", tolerance) assert error < tolerance -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, last_fn, do_particles=False) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + do_particles=False, +) diff --git a/Examples/Tests/diff_lumi_diag/analysis.py b/Examples/Tests/diff_lumi_diag/analysis.py index ef573fc4863..8f2061ff1dc 100755 --- a/Examples/Tests/diff_lumi_diag/analysis.py +++ b/Examples/Tests/diff_lumi_diag/analysis.py @@ -11,7 +11,7 @@ from read_raw_data import read_reduced_diags_histogram sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Extract the differential luminosity from the file _, _, E_bin, bin_data = read_reduced_diags_histogram( @@ -44,9 +44,9 @@ print("Tolerance: ", tol) assert error < tol -# Get name of the test -fn = sys.argv[1] -test_name = os.path.split(os.getcwd())[1] - -# Run checksum regression test -checksumAPI.evaluate_checksum(test_name, fn, rtol=1e-2) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + rtol=1e-2, +) diff --git a/Examples/Tests/divb_cleaning/analysis.py b/Examples/Tests/divb_cleaning/analysis.py index e534e5b0d59..d72226a01cc 100755 --- a/Examples/Tests/divb_cleaning/analysis.py +++ b/Examples/Tests/divb_cleaning/analysis.py @@ -15,9 +15,8 @@ import yt yt.funcs.mylog.setLevel(50) -import re -import checksumAPI +from checksumAPI import evaluate_checksum from scipy.constants import c # Name of the last plotfile @@ -53,9 +52,8 @@ assert rel_error < tolerance -test_name = os.path.split(os.getcwd())[1] - -if re.search("single_precision", fn): - checksumAPI.evaluate_checksum(test_name, fn, rtol=1.0e-3) -else: - checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/electrostatic_dirichlet_bc/analysis.py b/Examples/Tests/electrostatic_dirichlet_bc/analysis.py index 82fe061c3a8..1b8f6923c1c 100755 --- a/Examples/Tests/electrostatic_dirichlet_bc/analysis.py +++ b/Examples/Tests/electrostatic_dirichlet_bc/analysis.py @@ -14,10 +14,16 @@ # Possible running time: ~ 19 s import glob +import os +import re +import sys import numpy as np import yt +sys.path.insert(1, "../../../../warpx/Regression/Checksum/") +from checksumAPI import evaluate_checksum + files = sorted(glob.glob("diags/diag1*"))[1:] assert len(files) > 0 @@ -39,3 +45,11 @@ assert np.allclose(potentials_lo, expected_potentials_lo, rtol=0.1) assert np.allclose(potentials_hi, expected_potentials_hi, rtol=0.1) + +# compare checksums +test_name = os.path.split(os.getcwd())[1] +test_name = re.sub("_picmi", "", test_name) # same checksums for PICMI test +evaluate_checksum( + test_name=test_name, + output_file=sys.argv[1], +) diff --git a/Examples/Tests/electrostatic_sphere/analysis_electrostatic_sphere.py b/Examples/Tests/electrostatic_sphere/analysis_electrostatic_sphere.py index 33842058b0b..dd15a6492f1 100755 --- a/Examples/Tests/electrostatic_sphere/analysis_electrostatic_sphere.py +++ b/Examples/Tests/electrostatic_sphere/analysis_electrostatic_sphere.py @@ -29,7 +29,7 @@ from scipy.optimize import fsolve sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum yt.funcs.mylog.setLevel(0) @@ -193,5 +193,8 @@ def return_energies(iteration): Ek_i + Ep_i ) # Check conservation of energy -# Checksum regression analysis -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/electrostatic_sphere_eb/analysis.py b/Examples/Tests/electrostatic_sphere_eb/analysis.py index 71b3bfa3aa5..e12070119ac 100755 --- a/Examples/Tests/electrostatic_sphere_eb/analysis.py +++ b/Examples/Tests/electrostatic_sphere_eb/analysis.py @@ -8,10 +8,9 @@ import sys sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI - # Check reduced diagnostics for charge on EB import numpy as np +from checksumAPI import evaluate_checksum from scipy.constants import epsilon_0 # Theoretical charge on the embedded boundary, for sphere at potential phi_0 @@ -29,6 +28,8 @@ q_sim_eighth = data_eighth[1, 2] assert abs((q_sim_eighth - q_th / 8) / (q_th / 8)) < 0.06 -filename = sys.argv[1] -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/electrostatic_sphere_eb/analysis_rz.py b/Examples/Tests/electrostatic_sphere_eb/analysis_rz.py index b33f19488d0..e3976c95e68 100755 --- a/Examples/Tests/electrostatic_sphere_eb/analysis_rz.py +++ b/Examples/Tests/electrostatic_sphere_eb/analysis_rz.py @@ -24,7 +24,7 @@ from unyt import m sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum tolerance = 0.0041 @@ -67,5 +67,9 @@ print("tolerance = ", tolerance) assert errmax_phi < tolerance and errmax_Er < tolerance -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, fn, do_particles=False) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + do_particles=False, +) diff --git a/Examples/Tests/electrostatic_sphere_eb/analysis_rz_mr.py b/Examples/Tests/electrostatic_sphere_eb/analysis_rz_mr.py index 77710ca5f72..586b35fc7a4 100755 --- a/Examples/Tests/electrostatic_sphere_eb/analysis_rz_mr.py +++ b/Examples/Tests/electrostatic_sphere_eb/analysis_rz_mr.py @@ -19,7 +19,7 @@ from openpmd_viewer import OpenPMDTimeSeries sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum tolerance = 0.004 print(f"tolerance = {tolerance}") @@ -110,5 +110,9 @@ def get_error_per_lev(ts, level): for level in range(nlevels + 1): get_error_per_lev(ts, level) -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, fn, output_format="openpmd") +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + output_format="openpmd", +) diff --git a/Examples/Tests/embedded_boundary_cube/analysis_fields.py b/Examples/Tests/embedded_boundary_cube/analysis_fields.py index 49da1a76edd..3202ccfaca2 100755 --- a/Examples/Tests/embedded_boundary_cube/analysis_fields.py +++ b/Examples/Tests/embedded_boundary_cube/analysis_fields.py @@ -9,7 +9,7 @@ from scipy.constants import c, mu_0, pi sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # This is a script that analyses the simulation results from # the script `inputs_3d`. This simulates a TMmnp mode in a PEC cubic resonator. @@ -110,4 +110,8 @@ rel_err_z = np.sqrt(np.sum(np.square(Bz_sim - Bz_th)) / np.sum(np.square(Bz_th))) assert rel_err_z < rel_tol_err -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/embedded_boundary_cube/analysis_fields_2d.py b/Examples/Tests/embedded_boundary_cube/analysis_fields_2d.py index 70a5b7d46c5..454d78169b7 100755 --- a/Examples/Tests/embedded_boundary_cube/analysis_fields_2d.py +++ b/Examples/Tests/embedded_boundary_cube/analysis_fields_2d.py @@ -8,7 +8,7 @@ from scipy.constants import c, mu_0, pi sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # This is a script that analyses the simulation results from # the script `inputs_3d`. This simulates a TMmnp mode in a PEC cubic resonator. @@ -63,6 +63,8 @@ Ey_sim = data["Ey"].to_ndarray() rel_err_y = np.sqrt(np.sum(np.square(Ey_sim / c - By_th)) / np.sum(np.square(By_th))) -test_name = os.path.split(os.getcwd())[1] - -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/embedded_boundary_diffraction/analysis_fields.py b/Examples/Tests/embedded_boundary_diffraction/analysis_fields.py index 84dfacbb505..8f0b7818516 100755 --- a/Examples/Tests/embedded_boundary_diffraction/analysis_fields.py +++ b/Examples/Tests/embedded_boundary_diffraction/analysis_fields.py @@ -15,7 +15,7 @@ from scipy.ndimage import gaussian_filter1d sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum filename = sys.argv[1] ts = OpenPMDTimeSeries(filename) @@ -42,6 +42,9 @@ def r_first_minimum(iz): theta_diffraction = np.arcsin(1.22 * 0.1 / 0.4) / 2 assert np.all(abs(r[50:] - theta_diffraction * info.z[50:]) < 0.03) -# Open the right plot file -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename, output_format="openpmd") +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + output_format="openpmd", +) diff --git a/Examples/Tests/embedded_boundary_python_api/analysis.py b/Examples/Tests/embedded_boundary_python_api/analysis.py index 09cc2accfea..7fda682f618 100755 --- a/Examples/Tests/embedded_boundary_python_api/analysis.py +++ b/Examples/Tests/embedded_boundary_python_api/analysis.py @@ -3,8 +3,17 @@ # This script just checks that the PICMI file executed successfully. # If it did there will be a plotfile for the final step. +import os import sys -step = int(sys.argv[1][-5:]) +sys.path.insert(1, "../../../../warpx/Regression/Checksum/") +from checksumAPI import evaluate_checksum +step = int(sys.argv[1][-5:]) assert step == 2 + +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/embedded_boundary_rotated_cube/analysis_fields_2d.py b/Examples/Tests/embedded_boundary_rotated_cube/analysis_fields_2d.py index 6f3904e8764..451913fd54d 100755 --- a/Examples/Tests/embedded_boundary_rotated_cube/analysis_fields_2d.py +++ b/Examples/Tests/embedded_boundary_rotated_cube/analysis_fields_2d.py @@ -8,7 +8,7 @@ from scipy.constants import c, mu_0, pi sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # This is a script that analyses the simulation results from # the script `inputs_3d`. This simulates a TMmnp mode in a PEC cubic resonator. @@ -68,6 +68,8 @@ rel_err_y = np.sqrt(np.sum(np.square(By_sim - By_th)) / np.sum(np.square(By_th))) assert rel_err_y < rel_tol_err -test_name = os.path.split(os.getcwd())[1] - -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/embedded_boundary_rotated_cube/analysis_fields_3d.py b/Examples/Tests/embedded_boundary_rotated_cube/analysis_fields_3d.py index 968ebe395a5..838c9c82479 100755 --- a/Examples/Tests/embedded_boundary_rotated_cube/analysis_fields_3d.py +++ b/Examples/Tests/embedded_boundary_rotated_cube/analysis_fields_3d.py @@ -15,7 +15,7 @@ from scipy.constants import c, mu_0, pi sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # This is a script that analyses the simulation results from # the script `inputs_3d`. This simulates a TMmnp mode in a PEC cubic resonator rotated by pi/8. @@ -144,6 +144,8 @@ ) assert rel_err_z < rel_tol_err -test_name = os.path.split(os.getcwd())[1] - -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/embedded_circle/analysis.py b/Examples/Tests/embedded_circle/analysis.py index 569ca40dce4..d1bb04fedb6 100755 --- a/Examples/Tests/embedded_circle/analysis.py +++ b/Examples/Tests/embedded_circle/analysis.py @@ -4,13 +4,11 @@ import sys sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI - -# this will be the name of the plot file -fn = sys.argv[1] - -# Get name of the test -test_name = os.path.split(os.getcwd())[1] - -# Run checksum regression test -checksumAPI.evaluate_checksum(test_name, fn, rtol=1e-2) +from checksumAPI import evaluate_checksum + +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + rtol=1e-2, +) diff --git a/Examples/Tests/energy_conserving_thermal_plasma/analysis.py b/Examples/Tests/energy_conserving_thermal_plasma/analysis.py index 4cf7b4ff4e6..0d29f85e7eb 100755 --- a/Examples/Tests/energy_conserving_thermal_plasma/analysis.py +++ b/Examples/Tests/energy_conserving_thermal_plasma/analysis.py @@ -18,10 +18,7 @@ import numpy as np sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI - -# this will be the name of the plot file -fn = sys.argv[1] +from checksumAPI import evaluate_checksum # Get energy as a function of time, from reduced diagnostics EFdata = np.genfromtxt("./diags/reducedfiles/EF.txt") # Field energy @@ -33,6 +30,8 @@ # Check that the energy is conserved to 0.3% assert np.all(abs(E - E[0]) / E[0] < 0.003) -# Checksum test -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/field_ionization/analysis.py b/Examples/Tests/field_ionization/analysis.py index 62d3f839941..a02c293601b 100755 --- a/Examples/Tests/field_ionization/analysis.py +++ b/Examples/Tests/field_ionization/analysis.py @@ -26,7 +26,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Open plotfile specified in command line, and get ion's ionization level. filename = sys.argv[1] @@ -107,5 +107,8 @@ except yt.utilities.exceptions.YTFieldNotFound: pass # The backtransformed diagnostic version of the test does not have orig_z -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/field_probe/analysis.py b/Examples/Tests/field_probe/analysis.py index 57085fb7cdc..e974e284b65 100755 --- a/Examples/Tests/field_probe/analysis.py +++ b/Examples/Tests/field_probe/analysis.py @@ -18,9 +18,15 @@ which can be solved analytically. """ +import os +import sys + import numpy as np import pandas as pd +sys.path.insert(1, "../../../../warpx/Regression/Checksum/") +from checksumAPI import evaluate_checksum + filename = "diags/reducedfiles/FP_line.txt" # Open data file @@ -59,3 +65,9 @@ def I_envelope(x, lam=0.2e-6, a=0.3e-6, D=1.7e-6): print("Average error greater than 2.5%") assert averror < 2.5 + +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/flux_injection/analysis_flux_injection_3d.py b/Examples/Tests/flux_injection/analysis_flux_injection_3d.py index 3840bb72e74..dc89780703d 100755 --- a/Examples/Tests/flux_injection/analysis_flux_injection_3d.py +++ b/Examples/Tests/flux_injection/analysis_flux_injection_3d.py @@ -22,7 +22,6 @@ """ import os -import re import sys import matplotlib.pyplot as plt @@ -32,7 +31,7 @@ from scipy.special import erf sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum yt.funcs.mylog.setLevel(0) @@ -148,9 +147,8 @@ def compare_gaussian_flux(u, w, u_th, u_m, label=""): plt.tight_layout() plt.savefig("Distribution.png") -# Verify checksum -test_name = os.path.split(os.getcwd())[1] -if re.search("single_precision", fn): - checksumAPI.evaluate_checksum(test_name, fn, rtol=1.0e-3) -else: - checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/flux_injection/analysis_flux_injection_rz.py b/Examples/Tests/flux_injection/analysis_flux_injection_rz.py index ad73fdb47af..33b487cc36b 100755 --- a/Examples/Tests/flux_injection/analysis_flux_injection_rz.py +++ b/Examples/Tests/flux_injection/analysis_flux_injection_rz.py @@ -26,14 +26,13 @@ """ import os -import re import sys import numpy as np import yt sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum yt.funcs.mylog.setLevel(0) @@ -58,9 +57,8 @@ # Check that the particles are at the right radius assert np.all((r >= 1.48) & (r <= 1.92)) -test_name = os.path.split(os.getcwd())[1] - -if re.search("single_precision", fn): - checksumAPI.evaluate_checksum(test_name, fn, rtol=1.0e-3) -else: - checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/gaussian_beam/analysis.py b/Examples/Tests/gaussian_beam/analysis.py index c2318d0cb7d..a2278b2cf7a 100755 --- a/Examples/Tests/gaussian_beam/analysis.py +++ b/Examples/Tests/gaussian_beam/analysis.py @@ -14,8 +14,7 @@ from scipy.constants import c, eV, m_e, micro, nano sys.path.insert(1, "../../../../warpx/Regression/Checksum/") - -import checksumAPI +from checksumAPI import evaluate_checksum from openpmd_viewer import OpenPMDTimeSeries GeV = 1e9 * eV @@ -39,8 +38,6 @@ def s(z, sigma0, emit): return np.sqrt(sigma0**2 + emit**2 * (z - focal_distance) ** 2 / sigma0**2) -filename = sys.argv[1] - ts = OpenPMDTimeSeries("./diags/openpmd/") ( @@ -71,5 +68,8 @@ def s(z, sigma0, emit): assert np.allclose(sx, sx_theory, rtol=0.051, atol=0) assert np.allclose(sy, sy_theory, rtol=0.038, atol=0) -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/implicit/analysis_1d.py b/Examples/Tests/implicit/analysis_1d.py index bbbbb8db9b2..665fcaac951 100755 --- a/Examples/Tests/implicit/analysis_1d.py +++ b/Examples/Tests/implicit/analysis_1d.py @@ -16,10 +16,7 @@ import numpy as np sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI - -# this will be the name of the plot file -fn = sys.argv[1] +from checksumAPI import evaluate_checksum field_energy = np.loadtxt("diags/reducedfiles/field_energy.txt", skiprows=1) particle_energy = np.loadtxt("diags/reducedfiles/particle_energy.txt", skiprows=1) @@ -41,5 +38,8 @@ assert max_delta_E < tolerance_rel -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/implicit/analysis_vandb_jfnk_2d.py b/Examples/Tests/implicit/analysis_vandb_jfnk_2d.py index 3c962eb91ea..29a2c870574 100755 --- a/Examples/Tests/implicit/analysis_vandb_jfnk_2d.py +++ b/Examples/Tests/implicit/analysis_vandb_jfnk_2d.py @@ -18,7 +18,7 @@ from scipy.constants import e, epsilon_0 sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # this will be the name of the plot file fn = sys.argv[1] @@ -66,5 +66,8 @@ assert drho_rms < tolerance_rel_charge -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/initial_distribution/analysis.py b/Examples/Tests/initial_distribution/analysis.py index 6d23c5da1e4..834934df255 100755 --- a/Examples/Tests/initial_distribution/analysis.py +++ b/Examples/Tests/initial_distribution/analysis.py @@ -27,9 +27,7 @@ from read_raw_data import read_reduced_diags, read_reduced_diags_histogram sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI - -filename = sys.argv[1] +from checksumAPI import evaluate_checksum # print tolerance tolerance = 0.02 @@ -451,6 +449,8 @@ def Gaussian(mean, sigma, u): assert f9_error < tolerance - -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/initial_plasma_profile/analysis.py b/Examples/Tests/initial_plasma_profile/analysis.py index f5fc75ee578..d372bd30a93 100755 --- a/Examples/Tests/initial_plasma_profile/analysis.py +++ b/Examples/Tests/initial_plasma_profile/analysis.py @@ -9,16 +9,13 @@ import os import sys -import yt - -yt.funcs.mylog.setLevel(50) - sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI - -# Name of the plotfile -fn = sys.argv[1] - -test_name = os.path.split(os.getcwd())[1] - -checksumAPI.evaluate_checksum(test_name, fn, rtol=1e-4, do_particles=False) +from checksumAPI import evaluate_checksum + +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + rtol=1e-4, + do_particles=False, +) diff --git a/Examples/Tests/ion_stopping/analysis.py b/Examples/Tests/ion_stopping/analysis.py index e343bd23fdd..45983538025 100755 --- a/Examples/Tests/ion_stopping/analysis.py +++ b/Examples/Tests/ion_stopping/analysis.py @@ -19,7 +19,7 @@ from scipy.constants import e, epsilon_0, k, m_e, m_p sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Define constants using the WarpX names for the evals below q_e = e @@ -194,5 +194,8 @@ def stopping_from_ions(dt, ni, Ti, mi, Zi, Zb, ion_mass, ion_energy): assert np.all(error3 < tolerance) assert np.all(error4 < tolerance) -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, last_filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/langmuir/analysis_1d.py b/Examples/Tests/langmuir/analysis_1d.py index d041ca03b36..8eefd95b4f7 100755 --- a/Examples/Tests/langmuir/analysis_1d.py +++ b/Examples/Tests/langmuir/analysis_1d.py @@ -27,7 +27,7 @@ from scipy.constants import c, e, epsilon_0, m_e sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # test name test_name = os.path.split(os.getcwd())[1] @@ -126,4 +126,8 @@ def get_theoretical_field(field, t): print("tolerance = {}".format(tolerance)) assert error_rel < tolerance -checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/langmuir/analysis_2d.py b/Examples/Tests/langmuir/analysis_2d.py index ac98354c73b..31995e896a5 100755 --- a/Examples/Tests/langmuir/analysis_2d.py +++ b/Examples/Tests/langmuir/analysis_2d.py @@ -27,7 +27,7 @@ from scipy.constants import c, e, epsilon_0, m_e sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # test name test_name = os.path.split(os.getcwd())[1] @@ -163,4 +163,8 @@ def get_theoretical_field(field, t): print("tolerance = {}".format(tolerance)) assert error_rel < tolerance -checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/langmuir/analysis_3d.py b/Examples/Tests/langmuir/analysis_3d.py index 9f4b2cc1f93..05f1c585ec0 100755 --- a/Examples/Tests/langmuir/analysis_3d.py +++ b/Examples/Tests/langmuir/analysis_3d.py @@ -27,7 +27,7 @@ from scipy.constants import c, e, epsilon_0, m_e sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # test name test_name = os.path.split(os.getcwd())[1] @@ -212,7 +212,8 @@ def get_theoretical_field(field, t): print("tolerance = {}".format(tolerance)) assert error_rel < tolerance -if re.search("single_precision", test_name): - checksumAPI.evaluate_checksum(test_name, fn, rtol=1.0e-3) -else: - checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/langmuir/analysis_rz.py b/Examples/Tests/langmuir/analysis_rz.py index dd26fd29db7..64f8cfb6313 100755 --- a/Examples/Tests/langmuir/analysis_rz.py +++ b/Examples/Tests/langmuir/analysis_rz.py @@ -30,7 +30,7 @@ from scipy.constants import c, e, epsilon_0, m_e sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # this will be the name of the plot file fn = sys.argv[1] @@ -183,4 +183,8 @@ def Ez(z, r, epsilon, k0, w0, wp, t): fn, random_filter_fn, random_fraction, dim, species_name ) -checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/langmuir_fluids/analysis_1d.py b/Examples/Tests/langmuir_fluids/analysis_1d.py index fa4566b6173..c448303783f 100755 --- a/Examples/Tests/langmuir_fluids/analysis_1d.py +++ b/Examples/Tests/langmuir_fluids/analysis_1d.py @@ -26,7 +26,7 @@ from scipy.constants import c, e, epsilon_0, m_e sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # this will be the name of the plot file fn = sys.argv[1] @@ -148,5 +148,8 @@ def get_theoretical_rho_field(field, t): assert error_rel < tolerance_rel -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/langmuir_fluids/analysis_2d.py b/Examples/Tests/langmuir_fluids/analysis_2d.py index d7ecca986e4..d8ba50a9df1 100755 --- a/Examples/Tests/langmuir_fluids/analysis_2d.py +++ b/Examples/Tests/langmuir_fluids/analysis_2d.py @@ -26,7 +26,7 @@ from scipy.constants import c, e, epsilon_0, m_e sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # this will be the name of the plot file fn = sys.argv[1] @@ -178,5 +178,8 @@ def get_theoretical_rho_field(field, t): assert error_rel < tolerance_rel -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/langmuir_fluids/analysis_3d.py b/Examples/Tests/langmuir_fluids/analysis_3d.py index 321b528b6cb..899dc72424b 100755 --- a/Examples/Tests/langmuir_fluids/analysis_3d.py +++ b/Examples/Tests/langmuir_fluids/analysis_3d.py @@ -14,7 +14,6 @@ # $$ E_y = \epsilon \,\frac{m_e c^2 k_y}{q_e}\cos(k_x x)\sin(k_y y)\cos(k_z z)\sin( \omega_p t)$$ # $$ E_z = \epsilon \,\frac{m_e c^2 k_z}{q_e}\cos(k_x x)\cos(k_y y)\sin(k_z z)\sin( \omega_p t)$$ import os -import re import sys import matplotlib.pyplot as plt @@ -27,7 +26,7 @@ from scipy.constants import c, e, epsilon_0, m_e sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # this will be the name of the plot file fn = sys.argv[1] @@ -213,9 +212,8 @@ def get_theoretical_rho_field(field, t): assert error_rel < tolerance_rel -test_name = os.path.split(os.getcwd())[1] - -if re.search("single_precision", fn): - checksumAPI.evaluate_checksum(test_name, fn, rtol=1.0e-3) -else: - checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/langmuir_fluids/analysis_rz.py b/Examples/Tests/langmuir_fluids/analysis_rz.py index f629ddc6626..0e918a6ab31 100755 --- a/Examples/Tests/langmuir_fluids/analysis_rz.py +++ b/Examples/Tests/langmuir_fluids/analysis_rz.py @@ -29,7 +29,7 @@ from scipy.constants import c, e, epsilon_0, m_e sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # this will be the name of the plot file fn = sys.argv[1] @@ -226,4 +226,8 @@ def rho(z, r, epsilon, k0, w0, wp, t): assert error_rel < tolerance_rel -checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/laser_injection/analysis_1d.py b/Examples/Tests/laser_injection/analysis_1d.py index 9215125427d..5ce7065c967 100755 --- a/Examples/Tests/laser_injection/analysis_1d.py +++ b/Examples/Tests/laser_injection/analysis_1d.py @@ -24,7 +24,7 @@ from scipy.signal import hilbert sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Maximum acceptable error for this test relative_error_threshold = 0.05 @@ -192,8 +192,11 @@ def main(): check_laser(filename_end) - test_name = os.path.split(os.getcwd())[1] - checksumAPI.evaluate_checksum(test_name, filename_end) + # compare checksums + evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + ) if __name__ == "__main__": diff --git a/Examples/Tests/laser_injection/analysis_2d.py b/Examples/Tests/laser_injection/analysis_2d.py index c6548e8be1d..5e2d9ebf280 100755 --- a/Examples/Tests/laser_injection/analysis_2d.py +++ b/Examples/Tests/laser_injection/analysis_2d.py @@ -30,7 +30,7 @@ from scipy.signal import hilbert sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Maximum acceptable error for this test relative_error_threshold = 0.05 @@ -225,8 +225,11 @@ def main(): check_laser(filename_end) - test_name = os.path.split(os.getcwd())[1] - checksumAPI.evaluate_checksum(test_name, filename_end) + # compare checksums + evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + ) if __name__ == "__main__": diff --git a/Examples/Tests/laser_injection/analysis_3d.py b/Examples/Tests/laser_injection/analysis_3d.py index bf2a03e342c..153b721b526 100755 --- a/Examples/Tests/laser_injection/analysis_3d.py +++ b/Examples/Tests/laser_injection/analysis_3d.py @@ -18,10 +18,7 @@ import numpy as np sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI - -# this will be the name of the plot file -fn = sys.argv[1] +from checksumAPI import evaluate_checksum # you can save an image to be displayed on the website t = np.arange(0.0, 2.0, 0.01) @@ -29,5 +26,8 @@ plt.plot(t, s) plt.savefig("laser_analysis.png") -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/laser_injection_from_file/analysis_1d.py b/Examples/Tests/laser_injection_from_file/analysis_1d.py index 1b5f209cb91..c6542ed1ac8 100755 --- a/Examples/Tests/laser_injection_from_file/analysis_1d.py +++ b/Examples/Tests/laser_injection_from_file/analysis_1d.py @@ -28,7 +28,7 @@ yt.funcs.mylog.setLevel(50) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Maximum acceptable error for this test relative_error_threshold = 0.065 @@ -113,5 +113,8 @@ def gauss_env(T, Z): print("Relative error frequency: ", relative_error_freq) assert relative_error_freq < relative_error_threshold -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/laser_injection_from_file/analysis_1d_boost.py b/Examples/Tests/laser_injection_from_file/analysis_1d_boost.py index 89c0ea3c57c..e410369cb45 100755 --- a/Examples/Tests/laser_injection_from_file/analysis_1d_boost.py +++ b/Examples/Tests/laser_injection_from_file/analysis_1d_boost.py @@ -28,7 +28,7 @@ yt.funcs.mylog.setLevel(50) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Maximum acceptable error for this test relative_error_threshold = 0.065 @@ -113,6 +113,8 @@ def gauss_env(T, Z): print("Relative error frequency: ", relative_error_freq) assert relative_error_freq < relative_error_threshold -# Do the checksum test -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/laser_injection_from_file/analysis_2d.py b/Examples/Tests/laser_injection_from_file/analysis_2d.py index ab5649e968f..1e6704f55a5 100755 --- a/Examples/Tests/laser_injection_from_file/analysis_2d.py +++ b/Examples/Tests/laser_injection_from_file/analysis_2d.py @@ -28,7 +28,7 @@ yt.funcs.mylog.setLevel(50) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Maximum acceptable error for this test relative_error_threshold = 0.065 @@ -139,5 +139,8 @@ def gauss_env(T, X, Y, Z): print("Relative error frequency: ", relative_error_freq) assert relative_error_freq < relative_error_threshold -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/laser_injection_from_file/analysis_2d_binary.py b/Examples/Tests/laser_injection_from_file/analysis_2d_binary.py index bcb13bba410..7fc14824471 100755 --- a/Examples/Tests/laser_injection_from_file/analysis_2d_binary.py +++ b/Examples/Tests/laser_injection_from_file/analysis_2d_binary.py @@ -27,7 +27,7 @@ yt.funcs.mylog.setLevel(50) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Maximum acceptable error for this test relative_error_threshold = 0.065 @@ -146,5 +146,8 @@ def gauss_env(T, XX, ZZ): print("Relative error frequency: ", relative_error_freq) assert relative_error_freq < relative_error_threshold -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/laser_injection_from_file/analysis_3d.py b/Examples/Tests/laser_injection_from_file/analysis_3d.py index 7d30af28639..3921e3d5930 100755 --- a/Examples/Tests/laser_injection_from_file/analysis_3d.py +++ b/Examples/Tests/laser_injection_from_file/analysis_3d.py @@ -28,7 +28,7 @@ yt.funcs.mylog.setLevel(50) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Maximum acceptable error for this test relative_error_threshold = 0.065 @@ -145,5 +145,8 @@ def gauss_env(T, X, Y, Z): print("Relative error frequency: ", relative_error_freq) assert relative_error_freq < relative_error_threshold -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/laser_injection_from_file/analysis_from_RZ_file.py b/Examples/Tests/laser_injection_from_file/analysis_from_RZ_file.py index 72575da96b4..f797ddb5d90 100755 --- a/Examples/Tests/laser_injection_from_file/analysis_from_RZ_file.py +++ b/Examples/Tests/laser_injection_from_file/analysis_from_RZ_file.py @@ -29,7 +29,7 @@ yt.funcs.mylog.setLevel(50) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Maximum acceptable error for this test relative_error_threshold = 0.065 @@ -147,5 +147,8 @@ def laguerre_env(T, X, Y, Z, p, m): print("Relative error frequency: ", relative_error_freq) assert relative_error_freq < relative_error_threshold -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/laser_injection_from_file/analysis_rz.py b/Examples/Tests/laser_injection_from_file/analysis_rz.py index 90e392bcf25..c37c6d8b3c2 100755 --- a/Examples/Tests/laser_injection_from_file/analysis_rz.py +++ b/Examples/Tests/laser_injection_from_file/analysis_rz.py @@ -28,7 +28,7 @@ yt.funcs.mylog.setLevel(50) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Maximum acceptable error for this test relative_error_threshold = 0.065 @@ -140,5 +140,8 @@ def gauss_env(T, X, Y, Z): print("Relative error frequency: ", relative_error_freq) assert relative_error_freq < relative_error_threshold -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/load_external_field/analysis_3d.py b/Examples/Tests/load_external_field/analysis_3d.py index 0865584d683..05cba3ea7bd 100755 --- a/Examples/Tests/load_external_field/analysis_3d.py +++ b/Examples/Tests/load_external_field/analysis_3d.py @@ -23,7 +23,7 @@ import yt sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum tolerance = 1.0e-8 x0 = 0.12238072 @@ -44,5 +44,8 @@ print("tolerance = ", tolerance) assert error < tolerance -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/load_external_field/analysis_rz.py b/Examples/Tests/load_external_field/analysis_rz.py index 75d9c084718..7de160cdd50 100755 --- a/Examples/Tests/load_external_field/analysis_rz.py +++ b/Examples/Tests/load_external_field/analysis_rz.py @@ -23,7 +23,7 @@ import yt sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum tolerance = 1.0e-8 r0 = 0.12402005 @@ -41,5 +41,8 @@ print("tolerance = ", tolerance) assert error < tolerance -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/magnetostatic_eb/analysis_rz.py b/Examples/Tests/magnetostatic_eb/analysis_rz.py index 05aa4a3fe47..f31069ad230 100755 --- a/Examples/Tests/magnetostatic_eb/analysis_rz.py +++ b/Examples/Tests/magnetostatic_eb/analysis_rz.py @@ -1,20 +1,14 @@ #!/usr/bin/env python3 import os -import re import sys sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI - -# this will be the name of the plot file -fn = sys.argv[1] - -# Get name of the test -test_name = os.path.split(os.getcwd())[1] - -# Run checksum regression test -if re.search("single_precision", fn): - checksumAPI.evaluate_checksum(test_name, fn, rtol=2.0e-6, do_particles=False) -else: - checksumAPI.evaluate_checksum(test_name, fn, do_particles=False) +from checksumAPI import evaluate_checksum + +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + do_particles=False, +) diff --git a/Examples/Tests/nci_fdtd_stability/analysis_ncicorr.py b/Examples/Tests/nci_fdtd_stability/analysis_ncicorr.py index 7bfa47f3164..ad635bf0fbe 100755 --- a/Examples/Tests/nci_fdtd_stability/analysis_ncicorr.py +++ b/Examples/Tests/nci_fdtd_stability/analysis_ncicorr.py @@ -19,7 +19,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum fn = sys.argv[1] use_MR = re.search("nci_correctorMR", fn) is not None @@ -50,5 +50,8 @@ assert energy < energy_threshold -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/nci_psatd_stability/analysis_galilean.py b/Examples/Tests/nci_psatd_stability/analysis_galilean.py index 40c74ecc5bf..99f14d91371 100755 --- a/Examples/Tests/nci_psatd_stability/analysis_galilean.py +++ b/Examples/Tests/nci_psatd_stability/analysis_galilean.py @@ -23,7 +23,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum filename = sys.argv[1] @@ -118,5 +118,9 @@ print(f"tol_charge = {tol_charge}") assert err_charge < tol_charge -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename, rtol=1.0e-8) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + rtol=1e-8, +) diff --git a/Examples/Tests/nci_psatd_stability/analysis_multiJ.py b/Examples/Tests/nci_psatd_stability/analysis_multiJ.py index 2a438d5d22e..6dcfb6565fe 100755 --- a/Examples/Tests/nci_psatd_stability/analysis_multiJ.py +++ b/Examples/Tests/nci_psatd_stability/analysis_multiJ.py @@ -19,7 +19,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum filename = sys.argv[1] @@ -50,5 +50,8 @@ print(f"tol_energy = {tol_energy}") assert err_energy < tol_energy -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/nodal_electrostatic/analysis.py b/Examples/Tests/nodal_electrostatic/analysis.py index c8725ce5d95..f015d525280 100755 --- a/Examples/Tests/nodal_electrostatic/analysis.py +++ b/Examples/Tests/nodal_electrostatic/analysis.py @@ -6,10 +6,7 @@ import numpy as np sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI - -# this will be the name of the plot file -fn = sys.argv[1] +from checksumAPI import evaluate_checksum # check that the maximum chi value is small fname = "diags/reducedfiles/ParticleExtrema_beam_p.txt" @@ -21,6 +18,8 @@ pho_num = np.loadtxt(fname)[:, 7] assert pho_num.all() == 0.0 -# Checksum regression analysis -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/nuclear_fusion/analysis_deuterium_deuterium_3d_intraspecies.py b/Examples/Tests/nuclear_fusion/analysis_deuterium_deuterium_3d_intraspecies.py index 22de371090c..8ae0e768815 100755 --- a/Examples/Tests/nuclear_fusion/analysis_deuterium_deuterium_3d_intraspecies.py +++ b/Examples/Tests/nuclear_fusion/analysis_deuterium_deuterium_3d_intraspecies.py @@ -29,10 +29,7 @@ import numpy as np sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI - -# Name of the plotfile -fn = sys.argv[1] +from checksumAPI import evaluate_checksum # Load data from reduced diagnostics (physical time and neutron weights) time = np.loadtxt("./reduced_diags/particle_number.txt", usecols=1) @@ -52,6 +49,8 @@ print("tolerance = ", tolerance) assert error < tolerance -# Compare checksums with benchmark -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/nuclear_fusion/analysis_proton_boron_fusion.py b/Examples/Tests/nuclear_fusion/analysis_proton_boron_fusion.py index 25e898c05be..c69080ac726 100755 --- a/Examples/Tests/nuclear_fusion/analysis_proton_boron_fusion.py +++ b/Examples/Tests/nuclear_fusion/analysis_proton_boron_fusion.py @@ -12,9 +12,9 @@ import yt sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI import numpy as np import scipy.constants as scc +from checksumAPI import evaluate_checksum ## This script performs various checks for the proton boron nuclear fusion module. The simulation ## that we check is made of 5 different tests, each with different proton, boron and alpha species. @@ -880,8 +880,11 @@ def main(): rho_end = field_data_end["rho"].to_ndarray() check_charge_conservation(rho_start, rho_end) - test_name = os.path.split(os.getcwd())[1] - checksumAPI.evaluate_checksum(test_name, filename_end) + # compare checksums + evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + ) if __name__ == "__main__": diff --git a/Examples/Tests/nuclear_fusion/analysis_two_product_fusion.py b/Examples/Tests/nuclear_fusion/analysis_two_product_fusion.py index be1fbb0702a..1a458a25e4a 100755 --- a/Examples/Tests/nuclear_fusion/analysis_two_product_fusion.py +++ b/Examples/Tests/nuclear_fusion/analysis_two_product_fusion.py @@ -12,9 +12,9 @@ import yt sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI import numpy as np import scipy.constants as scc +from checksumAPI import evaluate_checksum ## This script performs various checks for the fusion module. The simulation ## that we check is made of 2 different tests, each with different reactant and product species. @@ -555,8 +555,11 @@ def main(): rho_end = field_data_end["rho"].to_ndarray() check_charge_conservation(rho_start, rho_end) - test_name = os.path.split(os.getcwd())[1] - checksumAPI.evaluate_checksum(test_name, filename_end) + # compare checksums + evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + ) if __name__ == "__main__": diff --git a/Examples/Tests/ohm_solver_em_modes/analysis.py b/Examples/Tests/ohm_solver_em_modes/analysis.py index 36869623ac4..bee634415d9 100755 --- a/Examples/Tests/ohm_solver_em_modes/analysis.py +++ b/Examples/Tests/ohm_solver_em_modes/analysis.py @@ -353,9 +353,10 @@ def get_analytic_L_mode(w): import sys sys.path.insert(1, "../../../../warpx/Regression/Checksum/") - import checksumAPI + from checksumAPI import evaluate_checksum - # this will be the name of the plot file - fn = sys.argv[1] - test_name = os.path.split(os.getcwd())[1] - checksumAPI.evaluate_checksum(test_name, fn) + # compare checksums + evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + ) diff --git a/Examples/Tests/ohm_solver_em_modes/analysis_rz.py b/Examples/Tests/ohm_solver_em_modes/analysis_rz.py index 4d5bc2aa016..a1eb185bbf6 100755 --- a/Examples/Tests/ohm_solver_em_modes/analysis_rz.py +++ b/Examples/Tests/ohm_solver_em_modes/analysis_rz.py @@ -187,9 +187,11 @@ def process(it): import sys sys.path.insert(1, "../../../../warpx/Regression/Checksum/") - import checksumAPI + from checksumAPI import evaluate_checksum - # this will be the name of the plot file - fn = sys.argv[1] - test_name = os.path.split(os.getcwd())[1] - checksumAPI.evaluate_checksum(test_name, fn, rtol=1e-6) + # compare checksums + evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + rtol=1e-6, + ) diff --git a/Examples/Tests/ohm_solver_ion_Landau_damping/analysis.py b/Examples/Tests/ohm_solver_ion_Landau_damping/analysis.py index 700ad68fe87..620331cf13f 100755 --- a/Examples/Tests/ohm_solver_ion_Landau_damping/analysis.py +++ b/Examples/Tests/ohm_solver_ion_Landau_damping/analysis.py @@ -117,9 +117,10 @@ import sys sys.path.insert(1, "../../../../warpx/Regression/Checksum/") - import checksumAPI + from checksumAPI import evaluate_checksum - # this will be the name of the plot file - fn = sys.argv[1] - test_name = os.path.split(os.getcwd())[1] - checksumAPI.evaluate_checksum(test_name, fn) + # compare checksums + evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + ) diff --git a/Examples/Tests/ohm_solver_ion_beam_instability/analysis.py b/Examples/Tests/ohm_solver_ion_beam_instability/analysis.py index 5bd9db3d91d..3b0a18f29d5 100755 --- a/Examples/Tests/ohm_solver_ion_beam_instability/analysis.py +++ b/Examples/Tests/ohm_solver_ion_beam_instability/analysis.py @@ -236,9 +236,10 @@ import sys sys.path.insert(1, "../../../../warpx/Regression/Checksum/") - import checksumAPI + from checksumAPI import evaluate_checksum - # this will be the name of the plot file - fn = sys.argv[1] - test_name = os.path.split(os.getcwd())[1] - checksumAPI.evaluate_checksum(test_name, fn) + # compare checksums + evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + ) diff --git a/Examples/Tests/ohm_solver_magnetic_reconnection/analysis.py b/Examples/Tests/ohm_solver_magnetic_reconnection/analysis.py index 93d574e5294..e7b41d4fbb4 100755 --- a/Examples/Tests/ohm_solver_magnetic_reconnection/analysis.py +++ b/Examples/Tests/ohm_solver_magnetic_reconnection/analysis.py @@ -190,9 +190,10 @@ def animate(i): import sys sys.path.insert(1, "../../../../warpx/Regression/Checksum/") - import checksumAPI + from checksumAPI import evaluate_checksum - # this will be the name of the plot file - fn = sys.argv[1] - test_name = os.path.split(os.getcwd())[1] - checksumAPI.evaluate_checksum(test_name, fn) + # compare checksums + evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + ) diff --git a/Examples/Tests/open_bc_poisson_solver/analysis.py b/Examples/Tests/open_bc_poisson_solver/analysis.py index 8d5be875c7a..8ffd9ef52e2 100755 --- a/Examples/Tests/open_bc_poisson_solver/analysis.py +++ b/Examples/Tests/open_bc_poisson_solver/analysis.py @@ -9,7 +9,7 @@ from scipy.special import erf sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum sigmaz = 300e-6 sigmax = 516e-9 @@ -37,8 +37,6 @@ def evaluate_E(x, y, z): return E_complex.imag, E_complex.real -fn = sys.argv[1] - path = os.path.join("diags", "diag2") ts = OpenPMDTimeSeries(path) @@ -64,8 +62,9 @@ def evaluate_E(x, y, z): assert np.allclose(Ey_warpx, Ey_theory, rtol=0.029, atol=0) -# Get name of the test -test_name = os.path.split(os.getcwd())[1] - -# Run checksum regression test -checksumAPI.evaluate_checksum(test_name, fn, rtol=1e-2) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + rtol=1e-2, +) diff --git a/Examples/Tests/particle_boundary_interaction/analysis.py b/Examples/Tests/particle_boundary_interaction/analysis.py index 3b9d2f12b84..d06200157d2 100755 --- a/Examples/Tests/particle_boundary_interaction/analysis.py +++ b/Examples/Tests/particle_boundary_interaction/analysis.py @@ -17,13 +17,10 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Open plotfile specified in command line filename = sys.argv[1] -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename, output_format="openpmd") - ts = OpenPMDTimeSeries(filename) it = ts.iterations @@ -52,3 +49,10 @@ assert ( (diff_x < tolerance) and (y[0] < 1e-8) and (diff_z < tolerance) ), "Test particle_boundary_interaction did not pass" + +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + output_format="openpmd", +) diff --git a/Examples/Tests/particle_boundary_process/CMakeLists.txt b/Examples/Tests/particle_boundary_process/CMakeLists.txt index a7081fe9090..499cf445da5 100644 --- a/Examples/Tests/particle_boundary_process/CMakeLists.txt +++ b/Examples/Tests/particle_boundary_process/CMakeLists.txt @@ -6,7 +6,7 @@ add_warpx_test( 2 # dims 1 # nprocs inputs_test_2d_particle_reflection_picmi.py # inputs - analysis_reflection.py # analysis + analysis_default_regression.py # analysis diags/diag1000010 # output OFF # dependency ) diff --git a/Examples/Tests/particle_boundary_process/analysis_absorption.py b/Examples/Tests/particle_boundary_process/analysis_absorption.py index fdde2622684..79e8d0e4bc6 100755 --- a/Examples/Tests/particle_boundary_process/analysis_absorption.py +++ b/Examples/Tests/particle_boundary_process/analysis_absorption.py @@ -1,15 +1,19 @@ #!/usr/bin/env python3 -import sys - -import yt - # This test shoots a beam of electrons at cubic embedded boundary geometry # At time step 40, none of the particles have hit the boundary yet. At time # step 60, all of them should have been absorbed by the boundary. In the # absence of the cube, none of the particles would have had time to exit # the problem domain yet. +import os +import sys + +import yt + +sys.path.insert(1, "../../../../warpx/Regression/Checksum/") +from checksumAPI import evaluate_checksum + # all particles are still there ds40 = yt.load("diags/diag1000040") np40 = ds40.index.particle_headers["electrons"].num_particles @@ -20,3 +24,9 @@ ds60 = yt.load(filename) np60 = ds60.index.particle_headers["electrons"].num_particles assert np60 == 0 + +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/particle_boundary_process/analysis_default_regression.py b/Examples/Tests/particle_boundary_process/analysis_default_regression.py new file mode 120000 index 00000000000..d8ce3fca419 --- /dev/null +++ b/Examples/Tests/particle_boundary_process/analysis_default_regression.py @@ -0,0 +1 @@ +../../analysis_default_regression.py \ No newline at end of file diff --git a/Examples/Tests/particle_boundary_process/analysis_reflection.py b/Examples/Tests/particle_boundary_process/analysis_reflection.py deleted file mode 100755 index 1187a58e75d..00000000000 --- a/Examples/Tests/particle_boundary_process/analysis_reflection.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright 2021 Modern Electron -# -# License: BSD-3-Clause-LBNL - -# This script just checks that the PICMI file executed successfully. -# If it did there will be a plotfile for the final step. - -import yt - -plotfile = "Python_particle_reflection_plt000010" -ds = yt.load(plotfile) # noqa - -assert True diff --git a/Examples/Tests/particle_boundary_process/inputs_test_2d_particle_reflection_picmi.py b/Examples/Tests/particle_boundary_process/inputs_test_2d_particle_reflection_picmi.py index 0803bc05d59..ef1b7d45e1a 100755 --- a/Examples/Tests/particle_boundary_process/inputs_test_2d_particle_reflection_picmi.py +++ b/Examples/Tests/particle_boundary_process/inputs_test_2d_particle_reflection_picmi.py @@ -80,16 +80,12 @@ particle_diag = picmi.ParticleDiagnostic( name="diag1", period=10, - write_dir=".", - warpx_file_prefix="Python_particle_reflection_plt", ) field_diag = picmi.FieldDiagnostic( grid=grid, name="diag1", data_list=["E"], period=10, - write_dir=".", - warpx_file_prefix="Python_particle_reflection_plt", ) ########################## diff --git a/Examples/Tests/particle_fields_diags/analysis_particle_diags_impl.py b/Examples/Tests/particle_fields_diags/analysis_particle_diags_impl.py index a7c84b05459..01a7436a787 100755 --- a/Examples/Tests/particle_fields_diags/analysis_particle_diags_impl.py +++ b/Examples/Tests/particle_fields_diags/analysis_particle_diags_impl.py @@ -20,7 +20,7 @@ from scipy.constants import c, e, m_e, m_p sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum def do_analysis(single_precision=False): @@ -248,5 +248,9 @@ def do_analysis(single_precision=False): assert error_opmd[k] < tolerance print(k, "relative error openPMD = ", error_opmd[k]) - test_name = os.path.split(os.getcwd())[1] - checksumAPI.evaluate_checksum(test_name, fn, rtol=check_tolerance) + # compare checksums + evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + rtol=check_tolerance, + ) diff --git a/Examples/Tests/particle_pusher/analysis.py b/Examples/Tests/particle_pusher/analysis.py index acef0e819d3..9ed92507d4d 100755 --- a/Examples/Tests/particle_pusher/analysis.py +++ b/Examples/Tests/particle_pusher/analysis.py @@ -28,7 +28,7 @@ import yt sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum tolerance = 0.001 @@ -41,5 +41,8 @@ print("tolerance = ", tolerance) assert abs(x) < tolerance -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/particle_thermal_boundary/analysis.py b/Examples/Tests/particle_thermal_boundary/analysis.py index 49f33b5b805..621bf2032be 100755 --- a/Examples/Tests/particle_thermal_boundary/analysis.py +++ b/Examples/Tests/particle_thermal_boundary/analysis.py @@ -20,7 +20,7 @@ import numpy as np sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum FE_rdiag = "./diags/reducedfiles/EF.txt" init_Fenergy = np.loadtxt(FE_rdiag)[1, 2] @@ -32,6 +32,9 @@ init_Penergy = np.loadtxt(PE_rdiag)[0, 2] final_Penergy = np.loadtxt(PE_rdiag)[-1, 2] assert abs(final_Penergy - init_Penergy) / init_Penergy < 0.02 -filename = sys.argv[1] -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) + +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/particles_in_pml/analysis_particles_in_pml.py b/Examples/Tests/particles_in_pml/analysis_particles_in_pml.py index df106976e78..8e7d95eda08 100755 --- a/Examples/Tests/particles_in_pml/analysis_particles_in_pml.py +++ b/Examples/Tests/particles_in_pml/analysis_particles_in_pml.py @@ -25,7 +25,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Open plotfile specified in command line filename = sys.argv[1] @@ -67,5 +67,8 @@ print("tolerance_abs: " + str(tolerance_abs)) assert max_Efield < tolerance_abs -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/pec/analysis_pec.py b/Examples/Tests/pec/analysis_pec.py index 12907bb7846..29d9a4e26f4 100755 --- a/Examples/Tests/pec/analysis_pec.py +++ b/Examples/Tests/pec/analysis_pec.py @@ -12,7 +12,6 @@ # and as a result, the minimum and maximum value after reflection would be two times the value at initialization due to constructive interference. # Additionally, the value of Ey at the boundary must be equal to zero. import os -import re import sys import matplotlib @@ -26,7 +25,7 @@ import numpy as np sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # this will be the name of the plot file fn = sys.argv[1] @@ -91,9 +90,8 @@ assert max_Ey_error_rel < tolerance_rel assert min_Ey_error_rel < tolerance_rel -test_name = os.path.split(os.getcwd())[1] - -if re.search("single_precision", fn): - checksumAPI.evaluate_checksum(test_name, fn, rtol=1.0e-3) -else: - checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/pec/analysis_pec_mr.py b/Examples/Tests/pec/analysis_pec_mr.py index 8361246b8dd..069a1d01afa 100755 --- a/Examples/Tests/pec/analysis_pec_mr.py +++ b/Examples/Tests/pec/analysis_pec_mr.py @@ -12,7 +12,6 @@ # and as a result, the minimum and maximum value after reflection would be two times the value at initialization due to constructive interference. # Additionally, the value of Ey at the boundary must be equal to zero. import os -import re import sys import matplotlib @@ -26,7 +25,7 @@ import numpy as np sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # this will be the name of the plot file fn = sys.argv[1] @@ -91,9 +90,8 @@ assert max_Ey_error_rel < tolerance_rel assert min_Ey_error_rel < tolerance_rel -test_name = os.path.split(os.getcwd())[1] - -if re.search("single_precision", fn): - checksumAPI.evaluate_checksum(test_name, fn, rtol=1.0e-3) -else: - checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/photon_pusher/analysis.py b/Examples/Tests/photon_pusher/analysis.py index 9135ad981ba..2a77e325bc5 100755 --- a/Examples/Tests/photon_pusher/analysis.py +++ b/Examples/Tests/photon_pusher/analysis.py @@ -14,7 +14,7 @@ import yt sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # This script checks if photons initialized with different momenta and # different initial directions propagate along straight lines at the speed of @@ -153,8 +153,11 @@ def check(): assert (max(disc_pos) <= tol_pos) and (max(disc_mom) <= tol_mom) - test_name = os.path.split(os.getcwd())[1] - checksumAPI.evaluate_checksum(test_name, filename) + # compare checksums + evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + ) # This function generates the input file to test the photon pusher. diff --git a/Examples/Tests/plasma_lens/analysis.py b/Examples/Tests/plasma_lens/analysis.py index 11e2a084ac5..46036573940 100755 --- a/Examples/Tests/plasma_lens/analysis.py +++ b/Examples/Tests/plasma_lens/analysis.py @@ -25,7 +25,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum filename = sys.argv[1] ds = yt.load(filename) @@ -195,8 +195,10 @@ def applylens(x0, vx0, vz0, gamma, lens_length, lens_strength): "error in y particle velocity" ) -# The PICMI and native input versions run the same test, so -# their results are compared to the same benchmark file +# compare checksums test_name = os.path.split(os.getcwd())[1] -test_name = re.sub("_picmi", "", test_name) -checksumAPI.evaluate_checksum(test_name, filename) +test_name = re.sub("_picmi", "", test_name) # same checksums for PICMI test +evaluate_checksum( + test_name=test_name, + output_file=sys.argv[1], +) diff --git a/Examples/Tests/pml/analysis_pml_ckc.py b/Examples/Tests/pml/analysis_pml_ckc.py index 4e6bff076c7..f6637e2d47b 100755 --- a/Examples/Tests/pml/analysis_pml_ckc.py +++ b/Examples/Tests/pml/analysis_pml_ckc.py @@ -17,7 +17,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum filename = sys.argv[1] @@ -57,5 +57,8 @@ assert error_rel < tolerance_rel -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/pml/analysis_pml_psatd.py b/Examples/Tests/pml/analysis_pml_psatd.py index 00b867857f9..4f44c0f3432 100755 --- a/Examples/Tests/pml/analysis_pml_psatd.py +++ b/Examples/Tests/pml/analysis_pml_psatd.py @@ -17,7 +17,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum filename = sys.argv[1] @@ -75,5 +75,8 @@ assert reflectivity < reflectivity_max -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/pml/analysis_pml_psatd_rz.py b/Examples/Tests/pml/analysis_pml_psatd_rz.py index 2d9d58734a1..fb662e36d40 100755 --- a/Examples/Tests/pml/analysis_pml_psatd_rz.py +++ b/Examples/Tests/pml/analysis_pml_psatd_rz.py @@ -24,7 +24,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Open plotfile specified in command line filename = sys.argv[1] @@ -55,5 +55,8 @@ print("tolerance_abs: " + str(tolerance_abs)) assert max_Efield < tolerance_abs -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/pml/analysis_pml_yee.py b/Examples/Tests/pml/analysis_pml_yee.py index a24854af095..5f6d21e579c 100755 --- a/Examples/Tests/pml/analysis_pml_yee.py +++ b/Examples/Tests/pml/analysis_pml_yee.py @@ -17,7 +17,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum filename = sys.argv[1] @@ -57,5 +57,8 @@ assert error_rel < tolerance_rel -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/point_of_contact_eb/analysis.py b/Examples/Tests/point_of_contact_eb/analysis.py index 3f42aa6eeca..1c9dbc85f4c 100755 --- a/Examples/Tests/point_of_contact_eb/analysis.py +++ b/Examples/Tests/point_of_contact_eb/analysis.py @@ -17,12 +17,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI - -# Open plotfile specified in command line -filename = sys.argv[1] -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename, output_format="openpmd") +from checksumAPI import evaluate_checksum ts_scraping = OpenPMDTimeSeries("./diags/diag2/particles_at_eb/") @@ -97,3 +92,10 @@ and (diff_ny < tolerance_n) and (np.abs(nz) < 1e-8) ), "Test point_of_contact did not pass" + +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + output_format="openpmd", +) diff --git a/Examples/Tests/projection_divb_cleaner/analysis.py b/Examples/Tests/projection_divb_cleaner/analysis.py index 256d1929d06..2324c370032 100755 --- a/Examples/Tests/projection_divb_cleaner/analysis.py +++ b/Examples/Tests/projection_divb_cleaner/analysis.py @@ -23,7 +23,7 @@ import yt sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum tolerance = 4e-3 @@ -73,5 +73,8 @@ print("tolerance = ", tolerance) assert error < tolerance -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/qed/analysis_breit_wheeler_opmd.py b/Examples/Tests/qed/analysis_breit_wheeler_opmd.py index 25547eda438..b88f00a85dc 100755 --- a/Examples/Tests/qed/analysis_breit_wheeler_opmd.py +++ b/Examples/Tests/qed/analysis_breit_wheeler_opmd.py @@ -13,7 +13,7 @@ import openpmd_api as io # sys.path.insert(1, '../../../../warpx/Regression/Checksum/') -# import checksumAPI +# from checksumAPI import evaluate_checksum # This script is a frontend for the analysis routines @@ -72,8 +72,12 @@ def main(): ac.check(dt, particle_data) - # test_name = os.path.split(os.getcwd())[1] - # checksumAPI.evaluate_checksum(test_name, filename_end) + # compare checksums + # evaluate_checksum( + # test_name=os.path.split(os.getcwd())[1], + # output_file=sys.argv[1], + # output_format="openpmd", + # ) if __name__ == "__main__": diff --git a/Examples/Tests/qed/analysis_breit_wheeler_yt.py b/Examples/Tests/qed/analysis_breit_wheeler_yt.py index 9836e3e8894..48c45c990b0 100755 --- a/Examples/Tests/qed/analysis_breit_wheeler_yt.py +++ b/Examples/Tests/qed/analysis_breit_wheeler_yt.py @@ -14,7 +14,7 @@ sys.path.insert(1, "../../../../warpx/Regression/Checksum/") import analysis_breit_wheeler_core as ac -import checksumAPI +from checksumAPI import evaluate_checksum # This script is a frontend for the analysis routines # in analysis_breit_wheeler_core.py (please refer to this file for @@ -58,8 +58,11 @@ def main(): ac.check(dt, particle_data) - test_name = os.path.split(os.getcwd())[1] - checksumAPI.evaluate_checksum(test_name, filename_end) + # compare checksums + evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + ) if __name__ == "__main__": diff --git a/Examples/Tests/qed/analysis_quantum_sync.py b/Examples/Tests/qed/analysis_quantum_sync.py index cf60d2ee647..531a0eac195 100755 --- a/Examples/Tests/qed/analysis_quantum_sync.py +++ b/Examples/Tests/qed/analysis_quantum_sync.py @@ -18,8 +18,8 @@ import yt sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI import matplotlib.pyplot as plt +from checksumAPI import evaluate_checksum # This script performs detailed checks of the Quantum Synchrotron photon emission process. # Two electron populations and two positron populations are initialized with different momenta in different @@ -348,8 +348,11 @@ def check(): print("*************\n") - test_name = os.path.split(os.getcwd())[1] - checksumAPI.evaluate_checksum(test_name, filename_end) + # compare checksums + evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + ) def main(): diff --git a/Examples/Tests/qed/analysis_schwinger.py b/Examples/Tests/qed/analysis_schwinger.py index 30a25e6a956..4ad21e3d518 100755 --- a/Examples/Tests/qed/analysis_schwinger.py +++ b/Examples/Tests/qed/analysis_schwinger.py @@ -19,7 +19,7 @@ import yt sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # define some parameters @@ -161,5 +161,8 @@ def do_analysis(Ex, Ey, Ez, Bx, By, Bz): do_analysis(Ex_test, Ey_test, Ez_test, Bx_test, By_test, Bz_test) -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/radiation_reaction/analysis.py b/Examples/Tests/radiation_reaction/analysis.py index e24129d3e38..74155a89cb3 100755 --- a/Examples/Tests/radiation_reaction/analysis.py +++ b/Examples/Tests/radiation_reaction/analysis.py @@ -37,7 +37,7 @@ import yt sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Input filename inputname = "inputs" @@ -163,8 +163,11 @@ def check(): assert error_rel < tolerance_rel - test_name = os.path.split(os.getcwd())[1] - checksumAPI.evaluate_checksum(test_name, filename) + # compare checksums + evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + ) def generate(): diff --git a/Examples/Tests/reduced_diags/analysis_reduced_diags_impl.py b/Examples/Tests/reduced_diags/analysis_reduced_diags_impl.py index 64b726e5954..42916d34568 100755 --- a/Examples/Tests/reduced_diags/analysis_reduced_diags_impl.py +++ b/Examples/Tests/reduced_diags/analysis_reduced_diags_impl.py @@ -21,7 +21,7 @@ from scipy.constants import mu_0 as mu0 sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # gamma threshold to switch between the relativistic expression of # the kinetic energy and its Taylor expansion. @@ -376,7 +376,9 @@ def do_analysis(single_precision=False): assert error[k] < tol print() - test_name = os.path.split(os.getcwd())[1] - - checksum_rtol = 2e-9 if single_precision else 1e-9 - checksumAPI.evaluate_checksum(test_name, fn, rtol=checksum_rtol) + # compare checksums + evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + rtol=1e-9, + ) diff --git a/Examples/Tests/reduced_diags/analysis_reduced_diags_load_balance_costs.py b/Examples/Tests/reduced_diags/analysis_reduced_diags_load_balance_costs.py index 05f696e2fe6..49a0018baa5 100755 --- a/Examples/Tests/reduced_diags/analysis_reduced_diags_load_balance_costs.py +++ b/Examples/Tests/reduced_diags/analysis_reduced_diags_load_balance_costs.py @@ -24,7 +24,7 @@ import numpy as np sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Command line argument fn = sys.argv[1] @@ -77,8 +77,10 @@ def get_efficiency(i): # than non-load balanced case assert efficiency_before < efficiency_after -# The PICMI and native input versions run the same test, so -# their results are compared to the same benchmark file +# compare checksums test_name = os.path.split(os.getcwd())[1] -test_name = re.sub("_picmi", "", test_name) -checksumAPI.evaluate_checksum(test_name, fn) +test_name = re.sub("_picmi", "", test_name) # same checksums for PICMI test +evaluate_checksum( + test_name=test_name, + output_file=sys.argv[1], +) diff --git a/Examples/Tests/relativistic_space_charge_initialization/analysis.py b/Examples/Tests/relativistic_space_charge_initialization/analysis.py index 4828e3ddce5..ef0a87dce92 100755 --- a/Examples/Tests/relativistic_space_charge_initialization/analysis.py +++ b/Examples/Tests/relativistic_space_charge_initialization/analysis.py @@ -25,7 +25,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Parameters from the Simulation Qtot = -1.0e-20 @@ -95,5 +95,9 @@ def check(E, E_th, label): check(Ex_array, Ex_th, "Ex") -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename, do_particles=False) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + do_particles=False, +) diff --git a/Examples/Tests/repelling_particles/analysis.py b/Examples/Tests/repelling_particles/analysis.py index 401ba7ba5d0..74bde7b68ca 100755 --- a/Examples/Tests/repelling_particles/analysis.py +++ b/Examples/Tests/repelling_particles/analysis.py @@ -35,6 +35,9 @@ yt.funcs.mylog.setLevel(0) +sys.path.insert(1, "../../../../warpx/Regression/Checksum/") +from checksumAPI import evaluate_checksum + # Check plotfile name specified in command line last_filename = sys.argv[1] filename_radical = re.findall(r"(.*?)\d+/*$", last_filename)[0] @@ -76,9 +79,8 @@ assert np.allclose(beta1[1:], beta_th[1:], atol=0.01) assert np.allclose(-beta2[1:], beta_th[1:], atol=0.01) -# Run checksum regression test -sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI - -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, last_filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/resampling/analysis.py b/Examples/Tests/resampling/analysis.py index f55f3b996c5..40bad24d65e 100755 --- a/Examples/Tests/resampling/analysis.py +++ b/Examples/Tests/resampling/analysis.py @@ -17,7 +17,7 @@ from scipy.special import erf sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum fn_final = sys.argv[1] fn0 = fn_final[:-4] + "0000" @@ -171,5 +171,8 @@ # Check that particles with weight higher than level weight are unaffected by resampling. assert np.all(w[-numparts_unaffected:] == w0[-numparts_unaffected:]) -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, fn_final) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/restart/CMakeLists.txt b/Examples/Tests/restart/CMakeLists.txt index bb3e90059c9..df5b1239a01 100644 --- a/Examples/Tests/restart/CMakeLists.txt +++ b/Examples/Tests/restart/CMakeLists.txt @@ -11,29 +11,24 @@ add_warpx_test( OFF # dependency ) -# TODO -# - Add checksums file -# - Enable analysis add_warpx_test( test_2d_runtime_components_picmi # name 2 # dims 1 # nprocs inputs_test_2d_runtime_components_picmi.py # inputs - OFF #analysis_default_regression.py # analysis - OFF #diags/diag1000010 # output + analysis_default_regression.py # analysis + diags/diag1000010 # output OFF # dependency ) -# TODO -# - Add checksums file -# - Enable analysis +# FIXME add_warpx_test( test_2d_runtime_components_picmi_restart # name 2 # dims 1 # nprocs "inputs_test_2d_runtime_components_picmi.py amr.restart='../test_2d_runtime_components_picmi/diags/chk000005'" # inputs - OFF #analysis_default_restart.py # analysis - OFF #diags/diag1000010 # output + OFF #analysis_default_restart.py # analysis + OFF #diags/diag1000010 # output test_2d_runtime_components_picmi # dependency ) diff --git a/Examples/Tests/restart/analysis_restart.py b/Examples/Tests/restart/analysis_restart.py index 4a4d198f63f..26a05da90f2 100755 --- a/Examples/Tests/restart/analysis_restart.py +++ b/Examples/Tests/restart/analysis_restart.py @@ -4,7 +4,7 @@ import sys sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum filename = sys.argv[1] @@ -14,7 +14,8 @@ check_restart(filename) -# Check-sum analysis -filename = sys.argv[1] -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/rigid_injection/analysis_rigid_injection_btd.py b/Examples/Tests/rigid_injection/analysis_rigid_injection_btd.py index 9b9054a4d42..759c211b42d 100755 --- a/Examples/Tests/rigid_injection/analysis_rigid_injection_btd.py +++ b/Examples/Tests/rigid_injection/analysis_rigid_injection_btd.py @@ -30,7 +30,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum filename = sys.argv[1] @@ -81,5 +81,8 @@ print(f"tolerance = {tol}") assert err < tol -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/rigid_injection/analysis_rigid_injection_lab.py b/Examples/Tests/rigid_injection/analysis_rigid_injection_lab.py index 94b2a1ac07e..91e2bed1ed0 100755 --- a/Examples/Tests/rigid_injection/analysis_rigid_injection_lab.py +++ b/Examples/Tests/rigid_injection/analysis_rigid_injection_lab.py @@ -31,7 +31,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum filename = sys.argv[1] @@ -102,5 +102,8 @@ def remove_rigid_lines(plotfile, nlines_if_rigid): assert np.array_equal(z, orig_z) assert np.array_equal(1 * (np.abs(x) < 5.0e-7), center) -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/scraping/analysis_rz.py b/Examples/Tests/scraping/analysis_rz.py index 8bf86e320f3..aa0038dbcf5 100755 --- a/Examples/Tests/scraping/analysis_rz.py +++ b/Examples/Tests/scraping/analysis_rz.py @@ -28,7 +28,7 @@ from openpmd_viewer import OpenPMDTimeSeries sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum tolerance = 0 @@ -83,6 +83,9 @@ def n_scraped_particles(iteration): np.sort(id_initial) == np.sort(id_final) ) # Sort because particles may not be in the same order -# Checksum test -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, fn, do_particles=False) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + do_particles=False, +) diff --git a/Examples/Tests/silver_mueller/analysis.py b/Examples/Tests/silver_mueller/analysis.py index e1de7199aa0..aee27131bc9 100755 --- a/Examples/Tests/silver_mueller/analysis.py +++ b/Examples/Tests/silver_mueller/analysis.py @@ -20,7 +20,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum filename = sys.argv[1] @@ -51,5 +51,8 @@ assert np.all(abs(Ey) < max_reflection_amplitude) assert np.all(abs(Ez) < max_reflection_amplitude) -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/single_particle/analysis.py b/Examples/Tests/single_particle/analysis.py index 198d84c6bfd..4127663e14d 100755 --- a/Examples/Tests/single_particle/analysis.py +++ b/Examples/Tests/single_particle/analysis.py @@ -16,7 +16,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Build Jx without filter. This can be obtained by running this test without # a filter, e.g., execute @@ -66,5 +66,8 @@ assert error_rel < tolerance_rel -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/Tests/space_charge_initialization/analysis.py b/Examples/Tests/space_charge_initialization/analysis.py index 1d5c8b9cb78..d63ba8f7334 100755 --- a/Examples/Tests/space_charge_initialization/analysis.py +++ b/Examples/Tests/space_charge_initialization/analysis.py @@ -26,7 +26,7 @@ yt.funcs.mylog.setLevel(0) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Parameters from the Simulation Qtot = -1.0e-20 @@ -124,5 +124,9 @@ def check(E, E_th, label): if ds.dimensionality == 3: check(Ez_array, Ez_th, "Ez") -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, filename, do_particles=0) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], + do_particles=False, +) diff --git a/Examples/Tests/vay_deposition/analysis.py b/Examples/Tests/vay_deposition/analysis.py index 82776c34c42..ba428520660 100755 --- a/Examples/Tests/vay_deposition/analysis.py +++ b/Examples/Tests/vay_deposition/analysis.py @@ -16,7 +16,7 @@ yt.funcs.mylog.setLevel(50) sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum # Plotfile data set fn = sys.argv[1] @@ -35,6 +35,8 @@ print("tolerance = {}".format(tolerance)) assert error_rel < tolerance -# Checksum analysis -test_name = os.path.split(os.getcwd())[1] -checksumAPI.evaluate_checksum(test_name, fn) +# compare checksums +evaluate_checksum( + test_name=os.path.split(os.getcwd())[1], + output_file=sys.argv[1], +) diff --git a/Examples/analysis_default_openpmd_regression.py b/Examples/analysis_default_openpmd_regression.py index 03a0f1ede1f..6f38693f820 100755 --- a/Examples/analysis_default_openpmd_regression.py +++ b/Examples/analysis_default_openpmd_regression.py @@ -5,16 +5,22 @@ import sys sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum -# this will be the name of the plot file -fn = sys.argv[1] - -# Get name of the test test_name = os.path.split(os.getcwd())[1] +output_file = sys.argv[1] # Run checksum regression test -if re.search("single_precision", fn): - checksumAPI.evaluate_checksum(test_name, fn, output_format="openpmd", rtol=2.0e-6) +if re.search("single_precision", output_file): + evaluate_checksum( + test_name=test_name, + output_file=output_file, + output_format="openpmd", + rtol=2e-6, + ) else: - checksumAPI.evaluate_checksum(test_name, fn, output_format="openpmd") + evaluate_checksum( + test_name=test_name, + output_file=output_file, + output_format="openpmd", + ) diff --git a/Examples/analysis_default_regression.py b/Examples/analysis_default_regression.py index 519bbeeea64..7c02f6904b2 100755 --- a/Examples/analysis_default_regression.py +++ b/Examples/analysis_default_regression.py @@ -5,17 +5,21 @@ import sys sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum -# this will be the name of the plot file -fn = sys.argv[1] - -# Get name of the test test_name = os.path.split(os.getcwd())[1] +output_file = sys.argv[1] # Run checksum regression test -if re.search("single_precision", fn): - checksumAPI.evaluate_checksum(test_name, fn, rtol=2.0e-6) +if re.search("single_precision", output_file): + evaluate_checksum( + test_name=test_name, + output_file=output_file, + rtol=2e-6, + ) else: # using default relative tolerance - checksumAPI.evaluate_checksum(test_name, fn) + evaluate_checksum( + test_name=test_name, + output_file=output_file, + ) diff --git a/Examples/analysis_default_restart.py b/Examples/analysis_default_restart.py index 55bab253dbc..c019a0b5945 100755 --- a/Examples/analysis_default_restart.py +++ b/Examples/analysis_default_restart.py @@ -7,7 +7,7 @@ import yt sys.path.insert(1, "../../../../warpx/Regression/Checksum/") -import checksumAPI +from checksumAPI import evaluate_checksum def check_restart(filename, tolerance=1e-12): @@ -67,12 +67,17 @@ def check_restart(filename, tolerance=1e-12): print() -filename = sys.argv[1] +# test name (for checksums, remove "_restart") and output file name +test_name = os.path.split(os.getcwd())[1] +test_name = test_name.replace("_restart", "") +output_file = sys.argv[1] # compare restart results against original results -check_restart(filename) +check_restart(output_file) # compare restart checksums against original checksums -testname = os.path.split(os.getcwd())[1] -testname = testname.replace("_restart", "") -checksumAPI.evaluate_checksum(testname, filename, rtol=1e-12) +evaluate_checksum( + test_name=test_name, + output_file=output_file, + rtol=1e-12, +) diff --git a/Regression/Checksum/benchmarks_json/test_1d_background_mcc_picmi.json b/Regression/Checksum/benchmarks_json/test_1d_background_mcc_picmi.json new file mode 100644 index 00000000000..029294deb66 --- /dev/null +++ b/Regression/Checksum/benchmarks_json/test_1d_background_mcc_picmi.json @@ -0,0 +1,20 @@ +{ + "lev=0": { + "rho_electrons": 0.0044328572492614605, + "rho_he_ions": 0.005198609403474849 + }, + "electrons": { + "particle_momentum_x": 3.5020450942268976e-20, + "particle_momentum_y": 3.5342700024993965e-20, + "particle_momentum_z": 1.2596017960675146e-19, + "particle_position_x": 2139.5967568101983, + "particle_weight": 14577210937500.002 + }, + "he_ions": { + "particle_momentum_x": 2.770046913680294e-19, + "particle_momentum_y": 2.755651798947783e-19, + "particle_momentum_z": 3.619494241595636e-19, + "particle_position_x": 2200.218124999781, + "particle_weight": 17184714843750.002 + } +} diff --git a/Regression/Checksum/benchmarks_json/test_2d_background_mcc_picmi.json b/Regression/Checksum/benchmarks_json/test_2d_background_mcc_picmi.json new file mode 100644 index 00000000000..579f46d33ab --- /dev/null +++ b/Regression/Checksum/benchmarks_json/test_2d_background_mcc_picmi.json @@ -0,0 +1,22 @@ +{ + "electrons": { + "particle_momentum_x": 1.011638818664759e-18, + "particle_momentum_y": 2.81974298744432e-19, + "particle_momentum_z": 2.809194032519318e-19, + "particle_position_x": 17136.01865460215, + "particle_position_y": 936.3651769897449, + "particle_weight": 61113170379.63868 + }, + "he_ions": { + "particle_momentum_x": 2.883076633513297e-18, + "particle_momentum_y": 2.195704870583595e-18, + "particle_momentum_z": 2.198216553980008e-18, + "particle_position_x": 17607.42545752183, + "particle_position_y": 1100.024786059151, + "particle_weight": 71976747650.1465 + }, + "lev=0": { + "rho_electrons": 0.03558889419586454, + "rho_he_ions": 0.04176234095111594 + } +} \ No newline at end of file diff --git a/Regression/Checksum/benchmarks_json/test_2d_dirichlet_bc.json b/Regression/Checksum/benchmarks_json/test_2d_dirichlet_bc.json new file mode 100644 index 00000000000..41567dc3bf2 --- /dev/null +++ b/Regression/Checksum/benchmarks_json/test_2d_dirichlet_bc.json @@ -0,0 +1,5 @@ +{ + "lev=0": { + "phi": 10817.97280547637 + } +} diff --git a/Regression/Checksum/benchmarks_json/test_2d_field_probe.json b/Regression/Checksum/benchmarks_json/test_2d_field_probe.json new file mode 100644 index 00000000000..cb82acfc067 --- /dev/null +++ b/Regression/Checksum/benchmarks_json/test_2d_field_probe.json @@ -0,0 +1,10 @@ +{ + "lev=0": { + "Bx": 0.0, + "By": 126826.78487921853, + "Bz": 0.0, + "Ex": 32517064310550.266, + "Ey": 0.0, + "Ez": 17321323003697.61 + } +} diff --git a/Regression/Checksum/benchmarks_json/test_2d_particle_reflection_picmi.json b/Regression/Checksum/benchmarks_json/test_2d_particle_reflection_picmi.json new file mode 100644 index 00000000000..97d0c1f5e58 --- /dev/null +++ b/Regression/Checksum/benchmarks_json/test_2d_particle_reflection_picmi.json @@ -0,0 +1,7 @@ +{ + "lev=0": { + "Ex": 4.865922376234882e-11, + "Ey": 0.0, + "Ez": 2.3293326580399806e-10 + } +} diff --git a/Regression/Checksum/benchmarks_json/test_2d_runtime_components_picmi.json b/Regression/Checksum/benchmarks_json/test_2d_runtime_components_picmi.json new file mode 100644 index 00000000000..f1eb0047d49 --- /dev/null +++ b/Regression/Checksum/benchmarks_json/test_2d_runtime_components_picmi.json @@ -0,0 +1,14 @@ +{ + "lev=0": { + "phi": 0.001516261626005395 + }, + "electrons": { + "particle_momentum_x": 7.75165529536844e-26, + "particle_momentum_y": 6.938526597814195e-26, + "particle_momentum_z": 6.572519525636007e-26, + "particle_newPid": 500.0, + "particle_position_x": 1.4999588764814886, + "particle_position_y": 1.4999551809410656, + "particle_weight": 200.0 + } +} diff --git a/Regression/Checksum/benchmarks_json/test_3d_embedded_boundary_picmi.json b/Regression/Checksum/benchmarks_json/test_3d_embedded_boundary_picmi.json new file mode 100644 index 00000000000..f3483a544b5 --- /dev/null +++ b/Regression/Checksum/benchmarks_json/test_3d_embedded_boundary_picmi.json @@ -0,0 +1,5 @@ +{ + "lev=0": { + "Ex": 0.0 + } +} diff --git a/Regression/Checksum/benchmarks_json/test_3d_particle_absorption.json b/Regression/Checksum/benchmarks_json/test_3d_particle_absorption.json new file mode 100644 index 00000000000..ce6e2fcf79b --- /dev/null +++ b/Regression/Checksum/benchmarks_json/test_3d_particle_absorption.json @@ -0,0 +1,10 @@ +{ + "lev=0": { + "Bx": 202106.71291347666, + "By": 202106.71291347663, + "Bz": 3371.897999274175, + "Ex": 38304043178806.11, + "Ey": 38304043178806.11, + "Ez": 83057027925874.84 + } +} diff --git a/Regression/Checksum/benchmarks_json/test_rz_laser_acceleration_opmd.json b/Regression/Checksum/benchmarks_json/test_rz_laser_acceleration_opmd.json new file mode 100644 index 00000000000..de631f4767a --- /dev/null +++ b/Regression/Checksum/benchmarks_json/test_rz_laser_acceleration_opmd.json @@ -0,0 +1,35 @@ +{ + "lev=0": { + "Bt": 4299.677335258863, + "Bz": 34749.512290662635, + "Er": 1343319090029.9607, + "jr": 5229952989213.152, + "jt": 9.287962600874053e+17, + "jz": 3712414162446391.5, + "part_per_cell": 6288.0, + "part_per_grid": 25755648.0, + "rho": 102920475.65331206, + "rho_beam": 12377109.352622943, + "rho_electrons": 90543366.3006891 + }, + "beam": { + "particle_position_x": 3.651481908823126e-05, + "particle_position_y": 4.275668879776449e-05, + "particle_position_z": 0.0025531549045483943, + "particle_momentum_x": 3.879691286254116e-20, + "particle_momentum_y": 5.0782566944104114e-20, + "particle_momentum_z": 1.3503182565048374e-17, + "particle_weight": 6241509.074460764 + }, + "electrons": { + "particle_origX": 0.03652440297475791, + "particle_origZ": 0.06924276562500002, + "particle_position_x": 0.036524412900510936, + "particle_position_y": 0.03652445428108603, + "particle_position_z": 0.06924303765442104, + "particle_momentum_x": 5.508781425380743e-23, + "particle_momentum_y": 7.236141259605716e-21, + "particle_momentum_z": 4.4528442530356535e-22, + "particle_weight": 1118799420.1067173 + } +} diff --git a/Regression/Checksum/checksum.py b/Regression/Checksum/checksum.py index 4133d882a41..b2f327e36e3 100644 --- a/Regression/Checksum/checksum.py +++ b/Regression/Checksum/checksum.py @@ -243,9 +243,8 @@ def evaluate(self, rtol=1.0e-9, atol=1.0e-40): ) print("Benchmark: %s" % ref_benchmark.data.keys()) print("Test file: %s" % self.data.keys()) - print("\n----------------\nNew file for " + self.test_name + ":") + print(f"\nNew checksums file {self.test_name}.json:") print(json.dumps(self.data, indent=2)) - print("----------------") sys.exit(1) # Dictionaries have same inner keys (field and particle quantities)? @@ -261,9 +260,8 @@ def evaluate(self, rtol=1.0e-9, atol=1.0e-40): % (key1, ref_benchmark.data[key1].keys()) ) print("Test file inner keys in %s: %s" % (key1, self.data[key1].keys())) - print("\n----------------\nNew file for " + self.test_name + ":") + print(f"\nNew checksums file {self.test_name}.json:") print(json.dumps(self.data, indent=2)) - print("----------------") sys.exit(1) # Dictionaries have same values? @@ -298,7 +296,6 @@ def evaluate(self, rtol=1.0e-9, atol=1.0e-40): rel_err = abs_err / np.abs(x) print("Relative error: {:.2e}".format(rel_err)) if checksums_differ: - print("\n----------------\nNew file for " + self.test_name + ":") + print(f"\nNew checksums file {self.test_name}.json:") print(json.dumps(self.data, indent=2)) - print("----------------") sys.exit(1)