diff options
author | 2022-06-01 14:02:34 -0700 | |
---|---|---|
committer | 2022-06-01 14:02:34 -0700 | |
commit | aaedf159f69f6803a00957a5a0ebe728d248c52b (patch) | |
tree | 6ff62a4c28a7980c055738200f5bc7d21c3244a1 /Examples/Tests/scraping/analysis_rz.py | |
parent | d6eeed0790bcfe02b6b1182c39be02b6943a6ebc (diff) | |
download | WarpX-aaedf159f69f6803a00957a5a0ebe728d248c52b.tar.gz WarpX-aaedf159f69f6803a00957a5a0ebe728d248c52b.tar.zst WarpX-aaedf159f69f6803a00957a5a0ebe728d248c52b.zip |
Boundary scraping diagnostic (#3064)
* Initialize boundary scraping diagnostic
* Add new file
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Start fixing diagnostics
* Define ReadParameters function
* Define stubs for all required functions
* Enable new diagnostics in one of the tests
* Dump all particles at the end of the run
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Use the same types for different pinned-memory particles
* Use the same types for different pinned-memory particles
* Fix compilation error
* Finalize dumping buffer
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Clean up file
* Activate recording of particles at the boundary
* New function getParticleBufferPointer
* Pass a WarpXParticleContainer to the ParticleDiag
* Handle timestamp
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Revert to multi-level simulation
* Add documentation and a few checks
* Fix error with MPI
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update varnames for RZ openPMD
* Add automated test
* Add automatic check
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Create new named component particle container
* Fix compilation
* Make WarpXParticleContainer derive from NamedParticleContainer
* Transfer functions that are specific to the particle component maps
* Move PIdx
* Make PinnedMemoryParticleContainer derive from NamedComponentParticleContainer
* Fix compilation
* Avoid unnecessary MPI communications
* Fix brittle code
* Define function `make_alike`
* Fix compilation
* Add back const anotations
* Fix typo
* Update code
* Fix compilation error
* Fix indentation
* Fix indentation
* Apply suggestions from code review
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Fix namespace
* Improve Error Messages Further
* Doxygen: Parameters of the Diag Constructor
* Update `WarpX-tests.ini`
... so we can filter the test out if we build w/o openPMD.
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Diffstat (limited to 'Examples/Tests/scraping/analysis_rz.py')
-rwxr-xr-x | Examples/Tests/scraping/analysis_rz.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Examples/Tests/scraping/analysis_rz.py b/Examples/Tests/scraping/analysis_rz.py index 6c493fb0f..4af31e48a 100755 --- a/Examples/Tests/scraping/analysis_rz.py +++ b/Examples/Tests/scraping/analysis_rz.py @@ -13,6 +13,8 @@ # Upon reaching the surface, particles should be removed. # At the end of the simulation, i.e., at time step 37, # there should be 512 particles left. +# In addition, the test checks the boundary scraping diagnostic +# by making sure that all removed particles are properly recorded. # Possible errors: 0 # tolerance: 0 @@ -21,6 +23,8 @@ import os import sys +import numpy as np +from openpmd_viewer import OpenPMDTimeSeries import yt sys.path.insert(1, '../../../../warpx/Regression/Checksum/') @@ -38,5 +42,24 @@ print('error = ', error) print('tolerance = ', tolerance) assert(error==tolerance) +# Check that all the removed particles are properly recorded +# by making sure that, at each iteration, the sum of the number of +# remaining particles and scraped particles is equal to the +# original number of particles +ts_full = OpenPMDTimeSeries('./diags/diag2/') +ts_scraping = OpenPMDTimeSeries('./diags/diag3/') + +def n_remaining_particles( iteration ): + w, = ts_full.get_particle(['w'], iteration=iteration) + return len(w) +def n_scraped_particles( iteration ): + timestamp = ts_scraping.get_particle( ['timestamp'] ) + return (timestamp <= iteration).sum() +n_remaining = np.array([ n_remaining_particles(iteration) for iteration in ts_full.iterations ]) +n_scraped = np.array([ n_scraped_particles(iteration) for iteration in ts_full.iterations ]) +n_total = n_remaining[0] +assert np.all( n_scraped+n_remaining == n_total) + +# Checksum test test_name = os.path.split(os.getcwd())[1] checksumAPI.evaluate_checksum(test_name, fn, do_particles=False) |