aboutsummaryrefslogtreecommitdiff
path: root/Examples/Modules/ParticleBoundaryScrape/PICMI_inputs_scrape.py
diff options
context:
space:
mode:
authorGravatar Peter Scherpelz <31747262+peterscherpelz@users.noreply.github.com> 2021-12-22 15:32:36 -0800
committerGravatar GitHub <noreply@github.com> 2021-12-22 23:32:36 +0000
commitd411310e45a370cfde872b25baa7a9f20bcf4966 (patch)
treecbb12f8fc9ba701a9d2a08701aaf46a99ea9ba31 /Examples/Modules/ParticleBoundaryScrape/PICMI_inputs_scrape.py
parentf73b3cd49c430c59b6750d5e65dfd19dcf44c752 (diff)
downloadWarpX-d411310e45a370cfde872b25baa7a9f20bcf4966.tar.gz
WarpX-d411310e45a370cfde872b25baa7a9f20bcf4966.tar.zst
WarpX-d411310e45a370cfde872b25baa7a9f20bcf4966.zip
Change _libwarpx.py functions to LibWarpX class methods (#2696)
* Initial attempt at moving function into LibWarpX * Bugfix - undefined structs in get_particle_theta This is untested, identified by IDE/visual inspection only * Unify newlines * Delete libwarpx.clight (duplicated picmi.py) See picmi.constants.c * Change function descriptive comment to docstring Also remove extra newline in __init__ beginning. * Replace pywarpx/_libwarpx calls appropriately * Fix atexit register of finalize function * Reorder WarpX.py imports for pre-commit * Use picmi.Simulation.extension = libwarpx alias This will hopefully preempt user script changes if we restructure things to allow multiple WarpX runs to be done within a single Python script. * Fix libwarpx ref in WarpX.getProbLo/getProbHi * Update get_particle_boundary_buffer doc reference
Diffstat (limited to 'Examples/Modules/ParticleBoundaryScrape/PICMI_inputs_scrape.py')
-rwxr-xr-xExamples/Modules/ParticleBoundaryScrape/PICMI_inputs_scrape.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/Examples/Modules/ParticleBoundaryScrape/PICMI_inputs_scrape.py b/Examples/Modules/ParticleBoundaryScrape/PICMI_inputs_scrape.py
index 90f526e4b..8009da0cc 100755
--- a/Examples/Modules/ParticleBoundaryScrape/PICMI_inputs_scrape.py
+++ b/Examples/Modules/ParticleBoundaryScrape/PICMI_inputs_scrape.py
@@ -3,7 +3,6 @@
# --- Input file to test the particle scraper and the Python wrappers
# --- to access the buffer of scraped particles.
-import pywarpx
from pywarpx import picmi
##########################
@@ -117,25 +116,25 @@ sim.step(max_steps)
from mpi4py import MPI as mpi
-my_id = pywarpx.getMyProc()
+my_id = sim.extension.getMyProc()
-n = pywarpx.get_particle_boundary_buffer_size("electrons", 'eb')
+n = sim.extension.get_particle_boundary_buffer_size("electrons", 'eb')
print(f"Number of electrons in buffer (proc #{my_id}): {n}")
assert n == 612
-scraped_steps = pywarpx.get_particle_boundary_buffer("electrons", 'eb', 'step_scraped', 0)
+scraped_steps = sim.extension.get_particle_boundary_buffer("electrons", 'eb', 'step_scraped', 0)
for arr in scraped_steps:
assert all(arr > 40)
-weights = pywarpx.get_particle_boundary_buffer("electrons", 'eb', 'w', 0)
+weights = sim.extension.get_particle_boundary_buffer("electrons", 'eb', 'w', 0)
n = sum(len(arr) for arr in weights)
print(f"Number of electrons in this proc's buffer (proc #{my_id}): {n}")
n_sum = mpi.COMM_WORLD.allreduce(n, op=mpi.SUM)
assert n_sum == 612
# clear the particle buffer
-pywarpx.clearParticleBoundaryBuffer()
+sim.extension.clearParticleBoundaryBuffer()
# confirm that the buffer was cleared
-n = pywarpx.get_particle_boundary_buffer_size("electrons", 'eb')
+n = sim.extension.get_particle_boundary_buffer_size("electrons", 'eb')
print(f"Number of electrons in buffer (proc #{my_id}): {n}")
assert n == 0