Skip to content

Commit 22bc9a9

Browse files
committed
Unify CI test for regression and TimeAvgDiag
For PICMI, the TimeAveragedDiag test is automatically disabled because we cannot simply define the necessary output intervals. We need to be able to define period=[100,69:100] like for the app input.
1 parent 13cd6e4 commit 22bc9a9

File tree

3 files changed

+43
-29
lines changed

3 files changed

+43
-29
lines changed

Examples/Physics_applications/laser_ion/CMakeLists.txt

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,17 @@ add_warpx_test(
66
2 # dims
77
2 # nprocs
88
inputs_test_2d_laser_ion_acc # inputs
9-
analysis_default_openpmd_regression.py # analysis
9+
analysis_test_laser_ion.py # analysis
1010
diags/diagInst/ # output
1111
OFF # dependency
1212
)
1313

14-
add_warpx_test(
15-
test_2d_laser_ion_acc_time_avg # name
16-
2 # dims
17-
2 # nprocs
18-
inputs_test_2d_laser_ion_acc # inputs; will not be used b/c dependent test
19-
analysis_time_avg_diags.py # analysis
20-
diags/diagTimeAvg/ # output
21-
test_2d_laser_ion_acc # dependency
22-
)
23-
2414
add_warpx_test(
2515
test_2d_laser_ion_acc_picmi # name
2616
2 # dims
2717
2 # nprocs
2818
inputs_test_2d_laser_ion_acc_picmi.py # inputs
29-
analysis_default_openpmd_regression.py # analysis
19+
analysis_test_laser_ion.py # analysis
3020
diags/diagInst/ # output
3121
OFF # dependency
3222
)
33-
34-
# We do not have an intervals parser for PICMI yet which would accept more than a single integer for the output period
35-
#add_warpx_test(
36-
# test_2d_laser_ion_acc_time_avg_picmi # name
37-
# 2 # dims
38-
# 2 # nprocs
39-
# inputs_test_2d_laser_ion_acc_picmi.py # inputs
40-
# analysis_time_avg_diags.py # analysis
41-
# diags/diagTimeAvg/ # output
42-
# test_2d_laser_ion_acc_picmi # dependency
43-
#)

Examples/Physics_applications/laser_ion/analysis_default_openpmd_regression.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

Examples/Physics_applications/laser_ion/analysis_time_avg_diags.py renamed to Examples/Physics_applications/laser_ion/analysis_test_laser_ion.py

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
11
#!/usr/bin/env python3
22

3+
import os
4+
import re
35
import sys
46

57
import numpy as np
68
import openpmd_api as io
79

10+
sys.path.insert(1, "../../../../warpx/Regression/Checksum/")
11+
from checksumAPI import evaluate_checksum
12+
13+
14+
def analyze_openpmd_regression(output_file):
15+
# Run checksum regression test
16+
if re.search("single_precision", output_file):
17+
evaluate_checksum(
18+
test_name=test_name,
19+
output_file=output_file,
20+
output_format="openpmd",
21+
rtol=2e-6,
22+
)
23+
else:
24+
evaluate_checksum(
25+
test_name=test_name,
26+
output_file=output_file,
27+
output_format="openpmd",
28+
)
29+
830

931
def load_field_from_iteration(
1032
series, iteration: int, field: str, coord: str = None
@@ -27,15 +49,15 @@ def load_field_from_iteration(
2749
return field_data
2850

2951

30-
def main():
52+
def compare_time_avg_with_instantaneous_diags(dir_inst: str, dir_avg: str):
53+
"""Compare instantaneous data (multiple iterations averaged in post-processing) with in-situ averaged data."""
54+
3155
field = "E"
3256
coord = "z"
3357
avg_period_steps = 5
3458
avg_output_step = 100
3559

36-
path_tpl_inst = "diags/diagInst/openpmd_%T.h5"
37-
38-
dir_avg = sys.argv[1]
60+
path_tpl_inst = f"{dir_inst}/openpmd_%T.h5"
3961
path_tpl_avg = f"{dir_avg}/openpmd_%T.h5"
4062

4163
si = io.Series(path_tpl_inst, io.Access.read_only)
@@ -63,4 +85,18 @@ def main():
6385

6486

6587
if __name__ == "__main__":
66-
main()
88+
89+
test_name = os.path.split(os.getcwd())[1]
90+
inst_output_file = sys.argv[1]
91+
92+
# Regression checksum test
93+
# NOTE: works only in the example directory due to relative path import
94+
analyze_openpmd_regression(inst_output_file)
95+
96+
# TODO: implement intervals parser for PICMI that allows more complex output periods
97+
if "picmi" not in test_name:
98+
# Functionality test for TimeAveragedDiagnostics
99+
compare_time_avg_with_instantaneous_diags(
100+
dir_inst=sys.argv[1],
101+
dir_avg="diags/diagTimeAvg/",
102+
)

0 commit comments

Comments
 (0)