diff options
author | 2019-10-10 13:58:31 +0200 | |
---|---|---|
committer | 2019-10-10 13:58:31 +0200 | |
commit | 0c11a538def7e66cd6e09c09e206da5a5460f8cc (patch) | |
tree | b2a07af0bf5d86ec3d1bc05a72afa4d88e9e2489 /Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py | |
parent | 431818ad7bb72bc5396c7a870024f310de6f055c (diff) | |
parent | 96ea487480fc7ce60eb20895ca4cc20cbba5888d (diff) | |
download | WarpX-0c11a538def7e66cd6e09c09e206da5a5460f8cc.tar.gz WarpX-0c11a538def7e66cd6e09c09e206da5a5460f8cc.tar.zst WarpX-0c11a538def7e66cd6e09c09e206da5a5460f8cc.zip |
merging with qed_phys_part_with_lambda
Diffstat (limited to 'Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py')
-rwxr-xr-x | Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py b/Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py new file mode 100755 index 000000000..90420ba22 --- /dev/null +++ b/Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py @@ -0,0 +1,35 @@ +#! /usr/bin/env python3 +import yt +import numpy as np +import scipy.stats as st +import sys + +# This script checks if electrons and positrons initialized with +# Quantum Synchrotron 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_ele_tau = all_data["electrons", 'particle_tau'] + res_pos_tau = all_data["positrons", 'particle_tau'] + + loc_ele, scale_ele = st.expon.fit(res_ele_tau) + loc_pos, scale_pos = st.expon.fit(res_pos_tau) + + # loc should be very close to 0, scale should be very close to 1 + assert(np.abs(loc_ele - 0) < tol) + assert(np.abs(loc_pos - 0) < tol) + assert(np.abs(scale_ele - 1) < tol) + assert(np.abs(scale_pos - 1) < tol) + +def main(): + check() + +if __name__ == "__main__": + main()
\ No newline at end of file |