aboutsummaryrefslogtreecommitdiff
path: root/Examples/Modules/boosted_diags/analysis_3Dbacktransformed_diag.py
diff options
context:
space:
mode:
authorGravatar Luca Fedeli <luca.fedeli@cea.fr> 2019-10-22 02:41:37 -0500
committerGravatar GitHub <noreply@github.com> 2019-10-22 02:41:37 -0500
commit4b816d568b298c83bcc272c78a95aa9b790c9e5c (patch)
tree04b237145fa21db8b4797cafa139bdd588c0f117 /Examples/Modules/boosted_diags/analysis_3Dbacktransformed_diag.py
parent9ee0c52e47748619baa44abd04653a9b8bd15c54 (diff)
parent366f46aa9a4b9ea56f0846795aa3900b99791923 (diff)
downloadWarpX-4b816d568b298c83bcc272c78a95aa9b790c9e5c.tar.gz
WarpX-4b816d568b298c83bcc272c78a95aa9b790c9e5c.tar.zst
WarpX-4b816d568b298c83bcc272c78a95aa9b790c9e5c.zip
Merge branch 'dev' into classical_radiation_reaction
Diffstat (limited to 'Examples/Modules/boosted_diags/analysis_3Dbacktransformed_diag.py')
-rwxr-xr-xExamples/Modules/boosted_diags/analysis_3Dbacktransformed_diag.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/Examples/Modules/boosted_diags/analysis_3Dbacktransformed_diag.py b/Examples/Modules/boosted_diags/analysis_3Dbacktransformed_diag.py
new file mode 100755
index 000000000..3b8e7aa76
--- /dev/null
+++ b/Examples/Modules/boosted_diags/analysis_3Dbacktransformed_diag.py
@@ -0,0 +1,36 @@
+#! /usr/bin/env python
+
+'''
+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 numpy as np
+import read_raw_data
+
+# Read data from back-transformed diagnostics of entire domain
+snapshot = './lab_frame_data/snapshots/snapshot00002'
+header = './lab_frame_data/snapshots/Header'
+allrd, info = read_raw_data.read_lab_snapshot(snapshot, header)
+F = allrd['Ez']
+print("F.shape ", F.shape)
+F_1D = np.squeeze(F[F.shape[0]//2,F.shape[1]//2,:])
+
+
+# Read data from reduced back-transformed diagnostics (i.e. slice)
+snapshot_slice = './lab_frame_data/slices/slice00002'
+header_slice = './lab_frame_data/slices/Header'
+allrd, info = read_raw_data.read_lab_snapshot(snapshot_slice, header_slice)
+Fs = allrd['Ez']
+print("Fs.shape", Fs.shape)
+Fs_1D = np.squeeze(Fs[Fs.shape[0]//2,1,:])
+
+error = np.max(np.abs(Fs_1D - F_1D)) / np.max(np.abs(F_1D))
+
+# Print error and assert small error
+print("relative error: " + str(error))
+assert( error < 1E-15 )