diff options
Diffstat (limited to 'Examples/Tests')
-rwxr-xr-x | Examples/Tests/scraping/analysis_rz.py | 23 | ||||
-rw-r--r-- | Examples/Tests/scraping/inputs_rz | 6 |
2 files changed, 28 insertions, 1 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) diff --git a/Examples/Tests/scraping/inputs_rz b/Examples/Tests/scraping/inputs_rz index edc48f40b..e8994bb18 100644 --- a/Examples/Tests/scraping/inputs_rz +++ b/Examples/Tests/scraping/inputs_rz @@ -40,8 +40,9 @@ electron.momentum_function_ux(x,y,z) = "if(x*x+y*y>0.0, -1.0*x/sqrt(x*x+y*y), 0. electron.momentum_function_uy(x,y,z) = "if(x*x+y*y>0.0, -1.0*y/sqrt(x*x+y*y), 0.0)" electron.momentum_function_uz(x,y,z) = "0" electron.do_not_deposit = 1 +electron.save_particles_at_eb = 1 -diagnostics.diags_names = diag1 diag2 +diagnostics.diags_names = diag1 diag2 diag3 diag1.intervals = 1 diag1.diag_type = Full @@ -51,3 +52,6 @@ diag2.intervals = 1 diag2.diag_type = Full diag2.fields_to_plot = Er diag2.format = openpmd + +diag3.diag_type = BoundaryScraping +diag3.format = openpmd |