From 5817971d808a76cbfd79c95ff964af0186615472 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Wed, 9 Oct 2019 18:08:19 +0200 Subject: Added tests for the initialization of the optical depth (disabled since they would need PICSAR on the QED branch) --- .../qed/quantum_synchrotron/check_2d_tau_init.py | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py (limited to 'Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py') 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..65b441719 --- /dev/null +++ b/Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py @@ -0,0 +1,38 @@ +#! /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) + + print(loc_ele, scale_ele) + print(loc_pos, scale_pos) + + # 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 -- cgit v1.2.3 From f256ff9792c366b2b880294c1019a2d005d15cc3 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Thu, 10 Oct 2019 11:25:47 +0200 Subject: Correct test script --- Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py') diff --git a/Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py b/Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py index 65b441719..9d16cce5a 100755 --- a/Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py +++ b/Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py @@ -22,9 +22,6 @@ def check(): loc_ele, scale_ele = st.expon.fit(res_ele_tau) loc_pos, scale_pos = st.expon.fit(res_pos_tau) - print(loc_ele, scale_ele) - print(loc_pos, scale_pos) - # 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) -- cgit v1.2.3 From aac707a7f03c2c7e06047931e975f92ddfebc400 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Thu, 10 Oct 2019 11:31:20 +0200 Subject: Style changes --- Examples/Modules/qed/breit_wheeler/check_2d_tau_init.py | 2 +- Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py | 2 +- Regression/WarpX-tests.ini | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py') diff --git a/Examples/Modules/qed/breit_wheeler/check_2d_tau_init.py b/Examples/Modules/qed/breit_wheeler/check_2d_tau_init.py index 98f37e5e3..ddfe2dd3e 100755 --- a/Examples/Modules/qed/breit_wheeler/check_2d_tau_init.py +++ b/Examples/Modules/qed/breit_wheeler/check_2d_tau_init.py @@ -4,7 +4,7 @@ import numpy as np import scipy.stats as st import sys -# This script checks if photons initialized with Breit Wheeler process enabled +# This script checks if photons initialized with Breit Wheeler process enabled # do actually have an exponentially distributed optical depth # Tolerance diff --git a/Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py b/Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py index 9d16cce5a..62b7da2ad 100755 --- a/Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py +++ b/Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py @@ -4,7 +4,7 @@ import numpy as np import scipy.stats as st import sys -# This script checks if electrons and positrons initialized with +# This script checks if electrons and positrons initialized with # Quantum Synchrotron process enabled # do actually have an exponentially distributed optical depth diff --git a/Regression/WarpX-tests.ini b/Regression/WarpX-tests.ini index a5805f566..c31e04d69 100644 --- a/Regression/WarpX-tests.ini +++ b/Regression/WarpX-tests.ini @@ -633,7 +633,7 @@ doVis = 0 compareParticles = 0 analysisRoutine = Examples/Tests/photon_pusher/check.py -# NEEDS PICSAR on the QED branch +# NEEDS PICSAR on the QED branch #[breit_wheeler_tau_init] #buildDir = . #inputFile = Examples/Modules/qed/breit_wheeler/inputs.2d_test_tau_init @@ -649,7 +649,7 @@ analysisRoutine = Examples/Tests/photon_pusher/check.py #compareParticles = 0 #analysisRoutine = Examples/Modules/qed/breit_wheeler/check.py -# NEEDS PICSAR on the QED branch +# NEEDS PICSAR on the QED branch #[quantum_sync_tau_init] #buildDir = . #inputFile = Examples/Modules/qed/quantum_synchrotron/inputs.2d_test_tau_init -- cgit v1.2.3 From 03d13d76c546860607dd72394af938a607fca41c Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Thu, 10 Oct 2019 11:36:21 +0200 Subject: Style changes --- Examples/Modules/qed/breit_wheeler/check_2d_tau_init.py | 2 +- Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py') diff --git a/Examples/Modules/qed/breit_wheeler/check_2d_tau_init.py b/Examples/Modules/qed/breit_wheeler/check_2d_tau_init.py index ddfe2dd3e..5677990f8 100755 --- a/Examples/Modules/qed/breit_wheeler/check_2d_tau_init.py +++ b/Examples/Modules/qed/breit_wheeler/check_2d_tau_init.py @@ -1,7 +1,7 @@ #! /usr/bin/env python3 import yt import numpy as np -import scipy.stats as st +import scipy.stats as st import sys # This script checks if photons initialized with Breit Wheeler process enabled diff --git a/Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py b/Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py index 62b7da2ad..90420ba22 100755 --- a/Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py +++ b/Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py @@ -1,11 +1,11 @@ #! /usr/bin/env python3 import yt import numpy as np -import scipy.stats as st +import scipy.stats as st import sys # This script checks if electrons and positrons initialized with -# Quantum Synchrotron process enabled +# Quantum Synchrotron process enabled # do actually have an exponentially distributed optical depth # Tolerance -- cgit v1.2.3