Skip to content

Commit

Permalink
More checksums updates
Browse files Browse the repository at this point in the history
  • Loading branch information
EZoni committed Oct 2, 2024
1 parent 512b968 commit ca00dda
Show file tree
Hide file tree
Showing 24 changed files with 150 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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],
)
13 changes: 8 additions & 5 deletions Examples/Physics_applications/spacecraft_charging/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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",
)
9 changes: 6 additions & 3 deletions Examples/Tests/accelerator_lattice/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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],
)
9 changes: 6 additions & 3 deletions Examples/Tests/boosted_diags/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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],
)
9 changes: 6 additions & 3 deletions Examples/Tests/boundaries/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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],
)
10 changes: 6 additions & 4 deletions Examples/Tests/btd_rz/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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],
)
13 changes: 7 additions & 6 deletions Examples/Tests/collider_relevant_diags/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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],
)
9 changes: 6 additions & 3 deletions Examples/Tests/implicit/analysis_vandb_jfnk_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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],
)
12 changes: 6 additions & 6 deletions Examples/Tests/initial_distribution/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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],
)
21 changes: 9 additions & 12 deletions Examples/Tests/initial_plasma_profile/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
9 changes: 6 additions & 3 deletions Examples/Tests/ion_stopping/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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],
)
8 changes: 6 additions & 2 deletions Examples/Tests/langmuir/analysis_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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],
)
8 changes: 6 additions & 2 deletions Examples/Tests/langmuir/analysis_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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],
)
11 changes: 6 additions & 5 deletions Examples/Tests/langmuir/analysis_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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],
)
8 changes: 6 additions & 2 deletions Examples/Tests/langmuir/analysis_rz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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],
)
9 changes: 6 additions & 3 deletions Examples/Tests/langmuir_fluids/analysis_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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],
)
9 changes: 6 additions & 3 deletions Examples/Tests/langmuir_fluids/analysis_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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],
)
14 changes: 6 additions & 8 deletions Examples/Tests/langmuir_fluids/analysis_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -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],
)
Loading

0 comments on commit ca00dda

Please sign in to comment.