aboutsummaryrefslogtreecommitdiff
path: root/Examples/Modules/RigidInjection/analysis_rigid_injection_BF.py
diff options
context:
space:
mode:
authorGravatar MaxThevenet <mthevenet@lbl.gov> 2019-08-15 10:45:07 -0700
committerGravatar MaxThevenet <mthevenet@lbl.gov> 2019-08-15 10:45:07 -0700
commit6689e4933e7f7a2ede1739799b70a7e5045bdfef (patch)
tree30aa3c151a3b20ab4143031010530ca7b484c300 /Examples/Modules/RigidInjection/analysis_rigid_injection_BF.py
parent459e23a19b3746fc43b4c6421f9d0dde8a46c8ec (diff)
downloadWarpX-6689e4933e7f7a2ede1739799b70a7e5045bdfef.tar.gz
WarpX-6689e4933e7f7a2ede1739799b70a7e5045bdfef.tar.zst
WarpX-6689e4933e7f7a2ede1739799b70a7e5045bdfef.zip
RigidInjection test in boosted frame using back-transformed diags
Diffstat (limited to 'Examples/Modules/RigidInjection/analysis_rigid_injection_BF.py')
-rwxr-xr-xExamples/Modules/RigidInjection/analysis_rigid_injection_BF.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/Examples/Modules/RigidInjection/analysis_rigid_injection_BF.py b/Examples/Modules/RigidInjection/analysis_rigid_injection_BF.py
new file mode 100755
index 000000000..7522d1ab1
--- /dev/null
+++ b/Examples/Modules/RigidInjection/analysis_rigid_injection_BF.py
@@ -0,0 +1,39 @@
+#! /usr/bin/env python
+
+import sys, os, yt, glob
+import numpy as np
+import scipy.constants as scc
+import read_raw_data
+yt.funcs.mylog.setLevel(0)
+
+# filename = sys.argv[1]
+
+def get_particle_field(snapshot, species, field):
+ fn = snapshot + '/' + species
+ files = glob.glob(os.path.join(fn, field + '_*'))
+ files.sort()
+ all_data = np.array([])
+ for f in files:
+ data = np.fromfile(f)
+ all_data = np.concatenate((all_data, data))
+ return all_data
+
+# Read data from back-transformed diagnostics
+snapshot = './lab_frame_data/snapshot00001'
+header = './lab_frame_data/Header'
+allrd, info = read_raw_data.read_lab_snapshot(snapshot, header)
+z = np.mean( get_particle_field(snapshot, 'beam', 'z') )
+w = np.std ( get_particle_field(snapshot, 'beam', 'x') )
+
+# initial parameters
+z0 = 20.e-6
+w0 = 1.e-6
+theta0 = np.arcsin(0.1)
+
+# Theoretical beam width after propagation if rigid ON
+wth = np.sqrt( w0**2 + (z-z0)**2*theta0**2 )
+error = np.abs((w-wth)/wth)
+
+# Print error and assert small error
+print("error: " + str(error))
+assert( error < 0.03 )