Skip to content

Commit

Permalink
Unify CI test for regression and TimeAvgDiag
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
n01r committed Oct 18, 2024
1 parent 13cd6e4 commit 22bc9a9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 29 deletions.
25 changes: 2 additions & 23 deletions Examples/Physics_applications/laser_ion/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,17 @@ add_warpx_test(
2 # dims
2 # nprocs
inputs_test_2d_laser_ion_acc # inputs
analysis_default_openpmd_regression.py # analysis
analysis_test_laser_ion.py # analysis
diags/diagInst/ # output
OFF # dependency
)

add_warpx_test(
test_2d_laser_ion_acc_time_avg # name
2 # dims
2 # nprocs
inputs_test_2d_laser_ion_acc # inputs; will not be used b/c dependent test
analysis_time_avg_diags.py # analysis
diags/diagTimeAvg/ # output
test_2d_laser_ion_acc # dependency
)

add_warpx_test(
test_2d_laser_ion_acc_picmi # name
2 # dims
2 # nprocs
inputs_test_2d_laser_ion_acc_picmi.py # inputs
analysis_default_openpmd_regression.py # analysis
analysis_test_laser_ion.py # analysis
diags/diagInst/ # output
OFF # dependency
)

# We do not have an intervals parser for PICMI yet which would accept more than a single integer for the output period
#add_warpx_test(
# test_2d_laser_ion_acc_time_avg_picmi # name
# 2 # dims
# 2 # nprocs
# inputs_test_2d_laser_ion_acc_picmi.py # inputs
# analysis_time_avg_diags.py # analysis
# diags/diagTimeAvg/ # output
# test_2d_laser_ion_acc_picmi # dependency
#)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
#!/usr/bin/env python3

import os
import re
import sys

import numpy as np
import openpmd_api as io

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


def analyze_openpmd_regression(output_file):
# Run checksum regression test
if re.search("single_precision", output_file):
evaluate_checksum(
test_name=test_name,
output_file=output_file,
output_format="openpmd",
rtol=2e-6,
)
else:
evaluate_checksum(
test_name=test_name,
output_file=output_file,
output_format="openpmd",
)


def load_field_from_iteration(
series, iteration: int, field: str, coord: str = None
Expand All @@ -27,15 +49,15 @@ def load_field_from_iteration(
return field_data


def main():
def compare_time_avg_with_instantaneous_diags(dir_inst: str, dir_avg: str):
"""Compare instantaneous data (multiple iterations averaged in post-processing) with in-situ averaged data."""

field = "E"
coord = "z"
avg_period_steps = 5
avg_output_step = 100

path_tpl_inst = "diags/diagInst/openpmd_%T.h5"

dir_avg = sys.argv[1]
path_tpl_inst = f"{dir_inst}/openpmd_%T.h5"
path_tpl_avg = f"{dir_avg}/openpmd_%T.h5"

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


if __name__ == "__main__":
main()

test_name = os.path.split(os.getcwd())[1]
inst_output_file = sys.argv[1]

# Regression checksum test
# NOTE: works only in the example directory due to relative path import
analyze_openpmd_regression(inst_output_file)

# TODO: implement intervals parser for PICMI that allows more complex output periods
if "picmi" not in test_name:
# Functionality test for TimeAveragedDiagnostics
compare_time_avg_with_instantaneous_diags(
dir_inst=sys.argv[1],
dir_avg="diags/diagTimeAvg/",
)

0 comments on commit 22bc9a9

Please sign in to comment.