Skip to content

Commit

Permalink
Merge branch 'ECP-WarpX:development' into implicit_solvers_pc
Browse files Browse the repository at this point in the history
  • Loading branch information
debog authored Oct 4, 2024
2 parents a698210 + a7d3935 commit ac479fc
Show file tree
Hide file tree
Showing 128 changed files with 909 additions and 510 deletions.
12 changes: 12 additions & 0 deletions Examples/Physics_applications/capacitive_discharge/analysis_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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],
)
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down Expand Up @@ -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],
)
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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],
)
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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_<species> diagnostics?"

# compare checksums
evaluate_checksum(
test_name=os.path.split(os.getcwd())[1],
output_file=sys.argv[1],
output_format="openpmd",
)
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/collision/analysis_collision_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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],
)
8 changes: 6 additions & 2 deletions Examples/Tests/collision/analysis_collision_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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],
)
9 changes: 6 additions & 3 deletions Examples/Tests/collision/analysis_collision_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import yt

sys.path.insert(1, "../../../../warpx/Regression/Checksum/")
import checksumAPI
from checksumAPI import evaluate_checksum

tolerance = 0.001

Expand Down Expand Up @@ -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],
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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],
)
10 changes: 7 additions & 3 deletions Examples/Tests/collision/analysis_collision_rz.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import yt

sys.path.insert(1, "../../../../warpx/Regression/Checksum/")
import checksumAPI
from checksumAPI import evaluate_checksum

tolerance = 1.0e-15

Expand Down Expand Up @@ -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,
)
14 changes: 7 additions & 7 deletions Examples/Tests/diff_lumi_diag/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
)
Loading

0 comments on commit ac479fc

Please sign in to comment.