aboutsummaryrefslogtreecommitdiff
path: root/Examples/Modules/boosted_diags/analysis.py
diff options
context:
space:
mode:
authorGravatar Remi Lehe <remi.lehe@normalesup.org> 2022-11-09 11:29:57 -0800
committerGravatar GitHub <noreply@github.com> 2022-11-09 19:29:57 +0000
commit3e98c31a491fb438cb98692c7a62dbcdd717c39b (patch)
treef9da28c9351338b5253bf86b80561fc92ad9f09a /Examples/Modules/boosted_diags/analysis.py
parent6beaa9fc0f5a68694d8dfbb70d6eae01446e4490 (diff)
downloadWarpX-3e98c31a491fb438cb98692c7a62dbcdd717c39b.tar.gz
WarpX-3e98c31a491fb438cb98692c7a62dbcdd717c39b.tar.zst
WarpX-3e98c31a491fb438cb98692c7a62dbcdd717c39b.zip
BTD: remove old/legacy back-transformed diagnostics (#3485)
* Start removing old BTD * Remove GetCellCenteredData * Remove do_backtransform_fields and do_backtransform_particles * Remove more functions * Remove more variables * Update documentation * Fix CI test `RigidInjection_BTD` * Remove slicing from `BTD_ReducedSliceDiag` * Rename `BTD_ReducedSliceDiag` as `LaserAcceleration_BTD` * Query deprecated input and abort Co-authored-by: Edoardo Zoni <ezoni@lbl.gov>
Diffstat (limited to 'Examples/Modules/boosted_diags/analysis.py')
-rwxr-xr-xExamples/Modules/boosted_diags/analysis.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/Examples/Modules/boosted_diags/analysis.py b/Examples/Modules/boosted_diags/analysis.py
new file mode 100755
index 000000000..c6c089f98
--- /dev/null
+++ b/Examples/Modules/boosted_diags/analysis.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python3
+
+# Copyright 2019 Maxence Thevenet, Revathi Jambunathan
+#
+# This file is part of WarpX.
+#
+# License: BSD-3-Clause-LBNL
+
+
+'''
+Analysis script of a WarpX simulation in a boosted frame.
+
+The simulation runs in a boosted frame, and the analysis is done in the lab
+frame, i.e., on the back-transformed diagnostics for the full 3D simulation and
+an x-z slice at y=y_center. The field-data, Ez, along z, at (x_center,y_center,:) is compared
+between the full back-transformed diagnostic and the reduced diagnostic (i.e., x-z slice) .
+'''
+
+import os
+import sys
+
+import numpy as np
+import openpmd_api as io
+import yt
+
+yt.funcs.mylog.setLevel(0)
+
+sys.path.insert(1, '../../../../warpx/Regression/Checksum/')
+import checksumAPI
+
+filename = sys.argv[1]
+
+# Tolerances to check consistency between legacy BTD and new BTD
+rtol = 1e-16
+atol = 1e-16
+
+# Read data from new back-transformed diagnostics (plotfile)
+ds_plotfile = yt.load(filename)
+data = ds_plotfile.covering_grid(
+ level=0,
+ left_edge=ds_plotfile.domain_left_edge,
+ dims=ds_plotfile.domain_dimensions)
+Ez_plotfile = data[('mesh', 'Ez')].to_ndarray()
+
+# Read data from new back-transformed diagnostics (openPMD)
+series = io.Series("./diags/diag2/openpmd_%T.h5", io.Access.read_only)
+ds_openpmd = series.iterations[3]
+Ez_openpmd = ds_openpmd.meshes['E']['z'].load_chunk()
+Ez_openpmd = Ez_openpmd.transpose()
+series.flush()
+
+# Compare arrays to check consistency between new BTD formats (plotfile and openPMD)
+assert(np.allclose(Ez_plotfile, Ez_openpmd, rtol=rtol, atol=atol))
+
+test_name = os.path.split(os.getcwd())[1]
+checksumAPI.evaluate_checksum(test_name, filename)