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 1, 2024
1 parent 512b968 commit 28d59bf
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 30 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],
)

0 comments on commit 28d59bf

Please sign in to comment.