aboutsummaryrefslogtreecommitdiff
path: root/Examples/Modules/qed/breit_wheeler/check_2d_tau_init.py
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/Modules/qed/breit_wheeler/check_2d_tau_init.py')
-rwxr-xr-xExamples/Modules/qed/breit_wheeler/check_2d_tau_init.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/Examples/Modules/qed/breit_wheeler/check_2d_tau_init.py b/Examples/Modules/qed/breit_wheeler/check_2d_tau_init.py
new file mode 100755
index 000000000..5677990f8
--- /dev/null
+++ b/Examples/Modules/qed/breit_wheeler/check_2d_tau_init.py
@@ -0,0 +1,30 @@
+#! /usr/bin/env python3
+import yt
+import numpy as np
+import scipy.stats as st
+import sys
+
+# This script checks if photons initialized with Breit Wheeler process enabled
+# do actually have an exponentially distributed optical depth
+
+# Tolerance
+tol = 1e-2
+
+def check():
+ filename = sys.argv[1]
+ data_set = yt.load(filename)
+
+ all_data = data_set.all_data()
+ res_tau = all_data["photons", 'particle_tau']
+
+ loc, scale = st.expon.fit(res_tau)
+
+ # loc should be very close to 0, scale should be very close to 1
+ assert(np.abs(loc - 0) < tol)
+ assert(np.abs(scale - 1) < tol)
+
+def main():
+ check()
+
+if __name__ == "__main__":
+ main() \ No newline at end of file