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) --- .../Modules/qed/breit_wheeler/check_2d_tau_init.py | 30 +++++++ .../qed/breit_wheeler/inputs.2d_test_tau_init | 68 ++++++++++++++++ .../qed/quantum_synchrotron/check_2d_tau_init.py | 38 +++++++++ .../quantum_synchrotron/inputs.2d_test_tau_init | 92 ++++++++++++++++++++++ 4 files changed, 228 insertions(+) create mode 100755 Examples/Modules/qed/breit_wheeler/check_2d_tau_init.py create mode 100644 Examples/Modules/qed/breit_wheeler/inputs.2d_test_tau_init create mode 100755 Examples/Modules/qed/quantum_synchrotron/check_2d_tau_init.py create mode 100644 Examples/Modules/qed/quantum_synchrotron/inputs.2d_test_tau_init (limited to 'Examples/Modules') 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..98f37e5e3 --- /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 diff --git a/Examples/Modules/qed/breit_wheeler/inputs.2d_test_tau_init b/Examples/Modules/qed/breit_wheeler/inputs.2d_test_tau_init new file mode 100644 index 000000000..9eb29ad1b --- /dev/null +++ b/Examples/Modules/qed/breit_wheeler/inputs.2d_test_tau_init @@ -0,0 +1,68 @@ +################################# +####### GENERAL PARAMETERS ###### +################################# +max_step = 0 +amr.n_cell = 128 128 +amr.max_grid_size = 128 # maximum size of each AMReX box, used to decompose the domain +amr.blocking_factor = 32 # minimum size of each AMReX box, used to decompose the domain +amr.plot_int = 10 +geometry.coord_sys = 0 # 0: Cartesian +geometry.is_periodic = 0 0 # Is periodic? +geometry.prob_lo = -32.e-6 -32.e-6 # physical domain +geometry.prob_hi = 32.e-6 32.e-6 +amr.max_level = 0 # Maximum level in hierarchy (1 might be unstable, >1 is not supported) +warpx.fine_tag_lo = -5.e-6 -35.e-6 +warpx.fine_tag_hi = 5.e-6 -25.e-6 + +################################# +############ NUMERICS ########### +################################# +algo.current_deposition = esirkepov +algo.charge_deposition = standard +algo.field_gathering = standard +algo.particle_pusher = boris +interpolation.nox = 3 # Particle interpolation order. Must be the same in x, y, and z +interpolation.noy = 3 +interpolation.noz = 3 +warpx.verbose = 1 +warpx.do_dive_cleaning = 0 +warpx.plot_raw_fields = 0 +warpx.plot_raw_fields_guards = 0 +warpx.plot_finepatch = 0 +warpx.plot_crsepatch = 0 +warpx.use_filter = 1 +warpx.cfl = 1. # if 1., the time step is set to its CFL limit +warpx.do_pml = 1 # use Perfectly Matched Layer as boundary condition + +################################# +############ PLASMA ############# +################################# +particles.nspecies = 1 # number of species +particles.species_names = photons +particles.photon_species = photons +################################# + +photons.charge = -q_e +photons.mass = m_e +photons.injection_style = "NUniformPerCell" +photons.profile = "constant" +photons.xmin = -30e-6 +photons.ymin = -30e-6 +photons.zmin = -30e-6 +photons.xmax = 30e-6 +photons.ymax = 30e-6 +photons.zmax = 30e-6 +photons.num_particles_per_cell_each_dim = 2 2 +photons.density = 1e19 +photons.profile = "constant" +photons.momentum_distribution_type = "gaussian" +photons.ux_m = 0.0 +photons.uy_m = 0.0 +photons.uz_m = 0.0 +photons.ux_th = 100. +photons.uy_th = 100. +photons.uz_th = 100. +##########QED#################### +photons.do_qed = 1 +photons.do_qed_breit_wheeler = 1 +################################# 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 diff --git a/Examples/Modules/qed/quantum_synchrotron/inputs.2d_test_tau_init b/Examples/Modules/qed/quantum_synchrotron/inputs.2d_test_tau_init new file mode 100644 index 000000000..7d26aee0c --- /dev/null +++ b/Examples/Modules/qed/quantum_synchrotron/inputs.2d_test_tau_init @@ -0,0 +1,92 @@ +################################# +####### GENERAL PARAMETERS ###### +################################# +max_step = 0 +amr.n_cell = 128 128 +amr.max_grid_size = 128 # maximum size of each AMReX box, used to decompose the domain +amr.blocking_factor = 32 # minimum size of each AMReX box, used to decompose the domain +amr.plot_int = 10 +geometry.coord_sys = 0 # 0: Cartesian +geometry.is_periodic = 0 0 # Is periodic? +geometry.prob_lo = -32.e-6 -32.e-6 # physical domain +geometry.prob_hi = 32.e-6 32.e-6 +amr.max_level = 0 # Maximum level in hierarchy (1 might be unstable, >1 is not supported) +warpx.fine_tag_lo = -5.e-6 -35.e-6 +warpx.fine_tag_hi = 5.e-6 -25.e-6 + +################################# +############ NUMERICS ########### +################################# +algo.current_deposition = esirkepov +algo.charge_deposition = standard +algo.field_gathering = standard +algo.particle_pusher = boris +interpolation.nox = 3 # Particle interpolation order. Must be the same in x, y, and z +interpolation.noy = 3 +interpolation.noz = 3 +warpx.verbose = 1 +warpx.do_dive_cleaning = 0 +warpx.plot_raw_fields = 0 +warpx.plot_raw_fields_guards = 0 +warpx.plot_finepatch = 0 +warpx.plot_crsepatch = 0 +warpx.use_filter = 1 +warpx.cfl = 1. # if 1., the time step is set to its CFL limit +warpx.do_pml = 1 # use Perfectly Matched Layer as boundary condition + +################################# +############ PLASMA ############# +################################# +particles.nspecies = 2 # number of species +particles.species_names = electrons positrons +################################# + +electrons.charge = -q_e +electrons.mass = m_e +electrons.injection_style = "NUniformPerCell" +electrons.profile = "constant" +electrons.xmin = -30e-6 +electrons.ymin = -30e-6 +electrons.zmin = -30e-6 +electrons.xmax = 30e-6 +electrons.ymax = 30e-6 +electrons.zmax = 30e-6 +electrons.num_particles_per_cell_each_dim = 2 2 +electrons.density = 1e19 +electrons.profile = "constant" +electrons.momentum_distribution_type = "gaussian" +electrons.ux_m = 0.0 +electrons.uy_m = 0.0 +electrons.uz_m = 0.0 +electrons.ux_th = 100. +electrons.uy_th = 100. +electrons.uz_th = 100. +##########QED#################### +electrons.do_qed = 1 +electrons.do_qed_quantum_sync = 1 +################################# + +positrons.charge = q_e +positrons.mass = m_e +positrons.injection_style = "NUniformPerCell" +positrons.profile = "constant" +positrons.xmin = -30e-6 +positrons.ymin = -30e-6 +positrons.zmin = -30e-6 +positrons.xmax = 30e-6 +positrons.ymax = 30e-6 +positrons.zmax = 30e-6 +positrons.num_particles_per_cell_each_dim = 2 2 +positrons.density = 1e19 +positrons.profile = "constant" +positrons.momentum_distribution_type = "gaussian" +positrons.ux_m = 0.0 +positrons.uy_m = 0.0 +positrons.uz_m = 0.0 +positrons.ux_th = 100. +positrons.uy_th = 100. +positrons.uz_th = 100. +##########QED#################### +positrons.do_qed = 1 +positrons.do_qed_quantum_sync = 1 +################################# -- 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') 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') 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') 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