aboutsummaryrefslogtreecommitdiff
path: root/Examples/Tests/particles_in_PML/analysis.py
diff options
context:
space:
mode:
authorGravatar Remi Lehe <remi.lehe@normalesup.org> 2019-08-30 13:44:58 -0700
committerGravatar Remi Lehe <remi.lehe@normalesup.org> 2019-08-30 13:44:58 -0700
commitbe92ecd49cac666c05d1b9e73fb2ac74bb75a1c6 (patch)
tree30aa9fae9591af00ef280d87d77bdb1b3da83c9f /Examples/Tests/particles_in_PML/analysis.py
parent7e5d673cf801949c647b9890b9af278f097e8e72 (diff)
parenta7105f2e97c79de807e1ff57a2f7d9df6d471cb8 (diff)
downloadWarpX-be92ecd49cac666c05d1b9e73fb2ac74bb75a1c6.tar.gz
WarpX-be92ecd49cac666c05d1b9e73fb2ac74bb75a1c6.tar.zst
WarpX-be92ecd49cac666c05d1b9e73fb2ac74bb75a1c6.zip
Merge branch 'dev' into picsar_cleanup
Diffstat (limited to 'Examples/Tests/particles_in_PML/analysis.py')
-rwxr-xr-xExamples/Tests/particles_in_PML/analysis.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/Examples/Tests/particles_in_PML/analysis.py b/Examples/Tests/particles_in_PML/analysis.py
new file mode 100755
index 000000000..9d0c95d35
--- /dev/null
+++ b/Examples/Tests/particles_in_PML/analysis.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 )
+
+# 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")
+