From 442071f0f29679f96ba5fbc21fa1ec75567233a6 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni Date: Tue, 1 Oct 2024 10:21:33 -0700 Subject: [PATCH] More checksums updates --- .../analysis_refined_injection.py | 9 +++++--- .../spacecraft_charging/analysis.py | 13 ++++++----- .../Tests/accelerator_lattice/analysis.py | 9 +++++--- Examples/Tests/boosted_diags/analysis.py | 9 +++++--- Examples/Tests/boundaries/analysis.py | 9 +++++--- Examples/Tests/btd_rz/analysis.py | 10 +++++---- .../Tests/collider_relevant_diags/analysis.py | 13 ++++++----- .../Tests/implicit/analysis_vandb_jfnk_2d.py | 9 +++++--- .../Tests/initial_distribution/analysis.py | 12 +++++----- .../Tests/initial_plasma_profile/analysis.py | 21 ++++++++---------- Examples/Tests/ion_stopping/analysis.py | 9 +++++--- Examples/Tests/langmuir/analysis_1d.py | 8 +++++-- Examples/Tests/langmuir/analysis_2d.py | 8 +++++-- Examples/Tests/langmuir/analysis_3d.py | 11 +++++----- Examples/Tests/langmuir/analysis_rz.py | 8 +++++-- Examples/Tests/langmuir_fluids/analysis_1d.py | 9 +++++--- Examples/Tests/langmuir_fluids/analysis_2d.py | 9 +++++--- Examples/Tests/langmuir_fluids/analysis_3d.py | 14 +++++------- Examples/Tests/langmuir_fluids/analysis_rz.py | 8 +++++-- Examples/Tests/laser_injection/analysis_1d.py | 9 +++++--- Examples/Tests/laser_injection/analysis_2d.py | 9 +++++--- Examples/Tests/laser_injection/analysis_3d.py | 12 +++++----- .../laser_injection_from_file/analysis_1d.py | 9 +++++--- .../analysis_1d_boost.py | 10 +++++---- .../laser_injection_from_file/analysis_2d.py | 9 +++++--- .../analysis_2d_binary.py | 9 +++++--- .../laser_injection_from_file/analysis_3d.py | 9 +++++--- .../analysis_from_RZ_file.py | 9 +++++--- .../laser_injection_from_file/analysis_rz.py | 9 +++++--- .../Tests/load_external_field/analysis_3d.py | 9 +++++--- .../Tests/load_external_field/analysis_rz.py | 9 +++++--- .../Tests/magnetostatic_eb/analysis_rz.py | 22 +++++++------------ .../nci_fdtd_stability/analysis_ncicorr.py | 9 +++++--- .../nci_psatd_stability/analysis_galilean.py | 10 ++++++--- .../nci_psatd_stability/analysis_multiJ.py | 9 +++++--- .../Tests/nodal_electrostatic/analysis.py | 13 +++++------ 36 files changed, 225 insertions(+), 148 deletions(-) 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/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..ccf1d87f9e9 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], + filename=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], +)