aboutsummaryrefslogtreecommitdiff
path: root/Examples/Tests/particles_in_PML/analysis_particles_in_pml.py
diff options
context:
space:
mode:
authorGravatar MaxThevenet <mthevenet@lbl.gov> 2019-10-25 13:32:32 -0700
committerGravatar GitHub <noreply@github.com> 2019-10-25 13:32:32 -0700
commitc30cda342d7b4521b35706040e7159411168caed (patch)
tree2a7f2b4e26783359ab965c6aa84efbe1c2e04529 /Examples/Tests/particles_in_PML/analysis_particles_in_pml.py
parent398166af23cfadfbf989f73c9e973518ed7aca3c (diff)
parent7a2fe4f3c115eeb9bfb8d48268be53111ffd40e3 (diff)
downloadWarpX-c30cda342d7b4521b35706040e7159411168caed.tar.gz
WarpX-c30cda342d7b4521b35706040e7159411168caed.tar.zst
WarpX-c30cda342d7b4521b35706040e7159411168caed.zip
Merge pull request #477 from MaxThevenet/test_examples
Clean Examples and make sure all are tested
Diffstat (limited to 'Examples/Tests/particles_in_PML/analysis_particles_in_pml.py')
-rwxr-xr-xExamples/Tests/particles_in_PML/analysis_particles_in_pml.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/Examples/Tests/particles_in_PML/analysis_particles_in_pml.py b/Examples/Tests/particles_in_PML/analysis_particles_in_pml.py
new file mode 100755
index 000000000..96406d717
--- /dev/null
+++ b/Examples/Tests/particles_in_PML/analysis_particles_in_pml.py
@@ -0,0 +1,37 @@
+#! /usr/bin/env python
+"""
+This script tests the absorption of particles in the PML.
+
+The input file inputs_2d/inputs is used: it features a positive and a
+negative particle, going in opposite direction and eventually
+leaving the box. This script tests that the field in the box
+is close to 0 once the particles have left. With regular
+PML, this test fails, since the particles leave a spurious
+charge, with associated fields, behind them.
+"""
+import sys
+import yt
+import numpy as np
+yt.funcs.mylog.setLevel(0)
+
+# Open plotfile specified in command line
+filename = sys.argv[1]
+ds = yt.load( filename )
+
+# Check that the field is low enough
+ad0 = ds.covering_grid(level=0, left_edge=ds.domain_left_edge, dims=ds.domain_dimensions)
+Ex_array = ad0['Ex'].to_ndarray()
+Ey_array = ad0['Ey'].to_ndarray()
+Ez_array = ad0['Ez'].to_ndarray()
+max_Efield = max(Ex_array.max(), Ey_array.max(), Ez_array.max())
+print( "max_Efield = %s" %max_Efield )
+
+# The field associated with the particle does not have
+# the same amplitude in 2d and 3d
+if ds.dimensionality == 2:
+ assert max_Efield < 0.0003
+elif ds.dimensionality == 3:
+ assert max_Efield < 10
+else:
+ raise ValueError("Unknown dimensionality")
+