Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Save the normal components in the particle buffer when there is EB #4598

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
180 commits
Select commit Hold shift + click to select a range
1bac67a
modifying the function ParticleSraper using bisection method
EyaDammak Nov 15, 2023
43fe665
adding a variable const amrex::dt for the ScraperParticle function
EyaDammak Nov 15, 2023
8a454fc
adding the variable dt to ScraperParticle function
EyaDammak Nov 15, 2023
be5f813
adding the variable dt in the ScraperParticle function
EyaDammak Nov 15, 2023
88c143a
not real change
EyaDammak Nov 15, 2023
0246c9d
Fix compilation
RemiLehe Nov 16, 2023
a0e0b8b
Remove mutable
RemiLehe Nov 16, 2023
e445ed9
new folder for the test of calculation of the point of contact in the…
EyaDammak Nov 28, 2023
e7b5d86
make it quicker
EyaDammak Nov 29, 2023
f33719d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 29, 2023
4712585
make it quicker
EyaDammak Nov 30, 2023
4b11e52
case in 3D
EyaDammak Nov 30, 2023
c36f654
deleating diags files
EyaDammak Nov 30, 2023
92ae43c
fix some issues
EyaDammak Nov 30, 2023
2f55c99
EB as a sphere
EyaDammak Nov 30, 2023
159ea8e
first draft of analysis
EyaDammak Dec 1, 2023
ef1e962
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 1, 2023
8e2e3f5
add of getPosition but doesn t work
EyaDammak Dec 2, 2023
a1050ec
some changes
EyaDammak Dec 2, 2023
b1c6db2
some changes
EyaDammak Dec 2, 2023
aa815a6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 2, 2023
f2fe1e9
version Rémi non modifiée
EyaDammak Dec 7, 2023
4637c7e
reset the version of ParticleScraper.H with the branch development
EyaDammak Dec 7, 2023
ee906ae
adding the dt variable to make the file consistent with the modificat…
EyaDammak Dec 7, 2023
f3c6cc3
still 2 errors
EyaDammak Dec 8, 2023
a0f42ee
still one error
EyaDammak Dec 8, 2023
92006da
some changes but still errors
EyaDammak Dec 13, 2023
d3c724b
WORKSgit add Source/Particles/ParticleBoundaryBuffer.cpp, but only in…
EyaDammak Dec 13, 2023
3bc6f30
Update ParticleBoundaryBuffer.cpp
EyaDammak Dec 18, 2023
8302c77
works for GPU
EyaDammak Dec 18, 2023
82a10ea
works for GPU
EyaDammak Dec 18, 2023
5a258cf
works
EyaDammak Dec 19, 2023
e5b4152
works but not for RZ
EyaDammak Dec 19, 2023
2c4d125
adding a test for a tolerance of 0.1%
EyaDammak Dec 19, 2023
2a27a08
comma missed
EyaDammak Dec 19, 2023
6df7c14
addind checkout + change of some details
EyaDammak Dec 19, 2023
d02aaa4
add point_of_contact_EB_3d
EyaDammak Dec 19, 2023
627029c
updates with checksum and changes in calling diags folders
EyaDammak Dec 22, 2023
f48e9ac
ready to be tested
EyaDammak Dec 22, 2023
1f08fe9
ready to be tested
EyaDammak Dec 22, 2023
3f58e1b
midification of one comment
EyaDammak Dec 22, 2023
374f388
adding test for 3d
EyaDammak Dec 22, 2023
e2c46d6
the code works for RZ
EyaDammak Dec 22, 2023
ac1387f
Merge branch 'development' into FindBoundaryIntersection
EyaDammak Dec 22, 2023
178812d
json file for the point_of_contact test in 3D
EyaDammak Dec 22, 2023
2ffeb97
json file for the point_of_contact test in rz
EyaDammak Dec 22, 2023
f402ff5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 22, 2023
118782c
Delete Examples/Tests/point_of_contact_EB/.ipynb_checkpoints/inputs_r…
EyaDammak Dec 22, 2023
484ebf6
Update analysis.py
EyaDammak Jan 2, 2024
0743311
Update ParticleBoundaryBuffer.cpp
EyaDammak Jan 2, 2024
f35f945
Merge branch 'development' into FindBoundaryIntersection
RemiLehe Jan 2, 2024
0596e1d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 2, 2024
cbf29a2
Apply suggestions from code review
RemiLehe Jan 2, 2024
c78a69b
Update Source/EmbeddedBoundary/ParticleScraper.H
RemiLehe Jan 2, 2024
a036ad2
Update Source/EmbeddedBoundary/ParticleScraper.H
RemiLehe Jan 2, 2024
3284676
Update Source/EmbeddedBoundary/ParticleScraper.H
RemiLehe Jan 2, 2024
260387e
Update Source/Particles/ParticleBoundaryBuffer.cpp
RemiLehe Jan 2, 2024
f8125b7
Add type for phi_value
RemiLehe Jan 2, 2024
d14ac6a
Fix compilation
RemiLehe Jan 2, 2024
f5c2bbd
Update ParticleScraper.H
EyaDammak Jan 2, 2024
0d41550
first draft
EyaDammak Jan 2, 2024
87fdf2a
Update Source/Particles/ParticleBoundaryBuffer.cpp
RemiLehe Jan 2, 2024
21312f6
warpx can be built without errors but codes not running
EyaDammak Jan 2, 2024
05971ee
draft, still doesn't run
EyaDammak Jan 2, 2024
72b62d0
Avoid GPU compilation errors
RemiLehe Jan 3, 2024
9555497
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 3, 2024
70e960c
everything runs but check needed for the analysis
EyaDammak Jan 3, 2024
b83de1c
Update Source/Particles/ParticleBoundaryBuffer.cpp
RemiLehe Jan 3, 2024
f893b08
Update Source/Particles/ParticleBoundaryBuffer.cpp
RemiLehe Jan 3, 2024
1484440
Merge branch 'FindBoundaryIntersection' into correct_timestamp
EyaDammak Jan 3, 2024
616612e
update
EyaDammak Jan 3, 2024
820abff
Update Source/Particles/ParticleBoundaryBuffer.cpp
RemiLehe Jan 3, 2024
aafda68
Update WarpX-test.ini
RemiLehe Jan 3, 2024
7ea6c88
simplify the time sample dt
EyaDammak Jan 3, 2024
29db5b0
works
EyaDammak Jan 3, 2024
5917382
adding test on the time of hitting
EyaDammak Jan 3, 2024
404e54f
simplification of dt
EyaDammak Jan 3, 2024
48ba80c
clean
EyaDammak Jan 3, 2024
7ced5ab
Merge branch 'FindBoundaryIntersection' into correct_timestamp
EyaDammak Jan 3, 2024
2c6c014
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 3, 2024
7659813
Remove particles that are initialized in the EB
RemiLehe Jan 6, 2024
2e7cc9b
non-merge
EyaDammak Jan 6, 2024
b567918
merge with branch FindBoundaryIntersection
EyaDammak Jan 6, 2024
645324b
Fix error whereby the momentum was not particle-dependent
RemiLehe Jan 9, 2024
a49a22a
Add back the BeamBeam test
RemiLehe Jan 9, 2024
7a15a19
merge
EyaDammak Jan 9, 2024
c34ed70
adding the components of the normal on the buffer when using EB
EyaDammak Jan 9, 2024
58deff9
fix the uknowm parameters i,j,k
EyaDammak Jan 9, 2024
04fbc24
fix segfault issue: adding in the buffer the normal component by comp…
EyaDammak Jan 9, 2024
b0c1a18
considering the different cases of dimensions
EyaDammak Jan 9, 2024
eee5c9b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 9, 2024
102830e
keeping 3 components for the normal whatever the dimension is
EyaDammak Jan 9, 2024
750208c
keeping 3 components for the normal vector whatever the dimension
EyaDammak Jan 9, 2024
b8d001e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 9, 2024
d91b8c8
adding the test on the normal components
EyaDammak Jan 10, 2024
02e5b5e
update
EyaDammak Jan 10, 2024
e068c45
Update ParticleBoundaryBuffer.cpp
EyaDammak Jan 10, 2024
4bb4f82
Update ParticleBoundaryBuffer.cpp
EyaDammak Jan 10, 2024
31b2f1e
Apply suggestions from code review
RemiLehe Jan 10, 2024
5cef88c
Apply suggestions from code review
RemiLehe Jan 10, 2024
9e9997c
Make analysis script executable
RemiLehe Jan 10, 2024
a80873e
try to fix the error defining EmbeddedToEB
EyaDammak Jan 10, 2024
afb21d1
previous version of includes
EyaDammak Jan 10, 2024
48d47eb
Apply suggestions from code review
EyaDammak Jan 10, 2024
176e542
merge
EyaDammak Jan 11, 2024
d7a794a
modifications of Remi for calculation of normal vector
EyaDammak Jan 12, 2024
6b22b15
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 12, 2024
293c486
Update ParticleBoundaryBuffer.cpp
EyaDammak Jan 12, 2024
39b86df
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 12, 2024
70d2d9c
change of how we calculate the normal
EyaDammak Jan 16, 2024
1c41feb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 16, 2024
e91dbd1
neglect warning kc for 2d and rz
EyaDammak Jan 17, 2024
0034a9e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 17, 2024
ae55d74
issues fixed for RZ
EyaDammak Jan 17, 2024
d66a5ae
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 17, 2024
007fc0d
Update DistanceToEB.H
EyaDammak Jan 18, 2024
7826878
adding the option nodal=0 or 1 in NodalFieldGather to simplify the code
EyaDammak Jan 18, 2024
1134389
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 18, 2024
a04d65e
right version of NodalFieldGather.H
EyaDammak Jan 19, 2024
6613238
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 19, 2024
4f55956
Update NodalFieldGather.H
EyaDammak Jan 19, 2024
6dc58ca
python coupling changed
EyaDammak Jan 23, 2024
79a7c51
analysis refined
EyaDammak Jan 23, 2024
a15e913
int into real for the time stamp in the Python file
EyaDammak Jan 23, 2024
aff3b1d
read in the dictionnary of the buffer rather than the one of the pc
EyaDammak Jan 24, 2024
13ad20a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 24, 2024
f7cffc9
extracting in the pc dictionary and buffer dictionnary with two cases
EyaDammak Jan 24, 2024
dc6c1c5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 24, 2024
63a5116
Update particle_containers.py
EyaDammak Jan 26, 2024
aa7ff3a
Merge branch 'development' into FindBoundaryIntersection
RemiLehe Jan 29, 2024
5926109
Correct format of analysis file
RemiLehe Jan 29, 2024
c6e2079
Update ParticleBoundaryBuffer.cpp
EyaDammak Jan 30, 2024
ce29405
Update ParticleBoundaryBuffer.cpp
EyaDammak Jan 30, 2024
e60c8e8
Update ParticleBoundaryBuffer.cpp
EyaDammak Jan 30, 2024
66d0c67
Update ParticleBoundaryBuffer.cpp
EyaDammak Jan 30, 2024
816d30d
Update ParticleBoundaryBuffer.cpp
EyaDammak Jan 30, 2024
a06a85f
Merge branch 'FindBoundaryIntersection' into correct_timestamp
EyaDammak Jan 30, 2024
bbf8262
merge
EyaDammak Jan 30, 2024
28a9f67
Update ParticleBoundaryBuffer.cpp
EyaDammak Jan 31, 2024
00965b5
Merge branch 'FindBoundaryIntersection' into correct_timestamp
EyaDammak Jan 31, 2024
db080b2
back to the previous version theta='theta' in RZ
EyaDammak Jan 31, 2024
6450e52
back to the previous syntax in RZ using the attribute 'theta' rather …
EyaDammak Jan 31, 2024
e786c5c
Merge branch 'development' into FindBoundaryIntersection
EyaDammak Jan 31, 2024
fb55833
udate syntax to be consistent with the merge
EyaDammak Jan 31, 2024
2a9b986
Update ParticleScraper.H
EyaDammak Feb 1, 2024
25c2938
merge with the last version of FinfBoundaryIntersection
EyaDammak Feb 1, 2024
82b2283
Merge branch 'FindBoundaryIntersection' into correct_timestamp
EyaDammak Feb 1, 2024
46c9d8b
Merge branch 'correct_timestamp' into adding_normal_buffer
EyaDammak Feb 1, 2024
71fff65
Update analysis.py
EyaDammak Feb 1, 2024
ef88272
Merge branch 'FindBoundaryIntersection' into correct_timestamp
EyaDammak Feb 1, 2024
8935858
Merge branch 'correct_timestamp' into adding_normal_buffer
EyaDammak Feb 1, 2024
d7a1b0d
Update ParticleBoundaryBuffer.cpp
EyaDammak Feb 2, 2024
e8ffb44
merge
EyaDammak Feb 2, 2024
c1494e9
merge
EyaDammak Feb 2, 2024
764d74e
merge
EyaDammak Feb 2, 2024
69b0158
Merge remote-tracking branch 'eyadammak/development' into FindBoundar…
EyaDammak Feb 2, 2024
adff002
Merge branch 'development' into correct_timestamp
EyaDammak Feb 2, 2024
d2ffedc
Merge branch 'development' into adding_normal_buffer
EyaDammak Feb 2, 2024
5a040cd
modification due to the merge
EyaDammak Feb 2, 2024
9ac9165
Merge branch 'FindBoundaryIntersection' into correct_timestamp
EyaDammak Feb 2, 2024
973f060
Merge branch 'correct_timestamp' into adding_normal_buffer
EyaDammak Feb 2, 2024
7de3936
Update analysis.py
EyaDammak Feb 3, 2024
e615801
Update analysis.py
EyaDammak Feb 3, 2024
227e25b
Update analysis.py
EyaDammak Feb 3, 2024
514dcdf
Merge branch 'FindBoundaryIntersection' into correct_timestamp
EyaDammak Feb 5, 2024
7939cb4
Merge branch 'development' into correct_timestamp
EyaDammak Feb 5, 2024
aa7263a
Update analysis.py
EyaDammak Feb 6, 2024
77678c6
Update Point_of_contact_EB_rz.json
EyaDammak Feb 7, 2024
6970d28
Merge branch 'FindBoundaryIntersection' into correct_timestamp
EyaDammak Feb 7, 2024
3811320
Update Point_of_contact_EB_rz.json
EyaDammak Feb 7, 2024
fa46a89
Update particle_containers.py
EyaDammak Feb 7, 2024
f9f13ce
Add Python access to the PinnedMemoryParticleContainers dictionary
RemiLehe Feb 7, 2024
493752e
step-scraped --> timestamp
EyaDammak Feb 7, 2024
523c0a7
Merge branch 'correct_timestamp' into adding_normal_buffer
EyaDammak Feb 7, 2024
7818629
changes of coordinates analysis in RZ
EyaDammak Feb 7, 2024
eef06c3
Update Point_of_contact_EB_rz.json
EyaDammak Feb 7, 2024
2264bc0
Update WarpXOpenPMD.cpp
EyaDammak Feb 7, 2024
1c72811
Merge branch 'FindBoundaryIntersection' into correct_timestamp
EyaDammak Feb 7, 2024
8a2bf37
Merge branch 'correct_timestamp' into adding_normal_buffer
EyaDammak Feb 7, 2024
b6027ee
Update ParticleBoundaryBuffer.cpp
EyaDammak Feb 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Docs/source/usage/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2752,8 +2752,9 @@ The data collected at each boundary is written out to a subdirectory of the diag
By default, all of the collected particle data is written out at the end of the simulation. Optionally, the ``<diag_name>.intervals`` parameter can be given to specify writing out the data more often.
This can be important if a large number of particles are lost, avoiding filling up memory with the accumulated lost particle data.

In addition to their usual attributes, the saved particles have an integer attribute ``timestamp``, which
indicates the PIC iteration at which each particle was absorbed at the boundary.
In addition to their usual attributes, the saved particles have real attributes
``timestamp``, which indicates the exact time at which each particle was absorbed at the boundary ;
And ``nx``, ``ny``, ``nz``, which indicate the components of the normal vector to the EB on the exact position.

``BoundaryScrapingDiagnostics`` can be used with ``<diag_name>.<species>.random_fraction``, ``<diag_name>.<species>.uniform_stride``, and ``<diag_name>.<species>.plot_filter_function``, which have the same behavior as for ``FullDiagnostics``. For ``BoundaryScrapingDiagnostics``, these filters are applied at the time the data is written to file. An implication of this is that more particles may initially be accumulated in memory than are ultimately written. ``t`` in ``plot_filter_function`` refers to the time the diagnostic is written rather than the time the particle crossed the boundary.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@
print("Number of electrons in lower buffer:", n)
assert n == 67

scraped_steps = buffer.get_particle_boundary_buffer("electrons", 'z_hi', 'step_scraped', 0)
scraped_steps = buffer.get_particle_boundary_buffer("electrons", 'z_hi', 'timestamp', 0)
for arr in scraped_steps:
# print(arr)
assert all(arr == 4)

scraped_steps = buffer.get_particle_boundary_buffer("electrons", 'z_lo', 'step_scraped', 0)
scraped_steps = buffer.get_particle_boundary_buffer("electrons", 'z_lo', 'timestamp', 0)
for arr in scraped_steps:
# print(arr)
assert all(arr == 8)
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
print(f"Number of electrons in buffer (proc #{my_id}): {n}")
assert n == 612

scraped_steps = particle_buffer.get_particle_boundary_buffer("electrons", 'eb', 'step_scraped', 0)
scraped_steps = particle_buffer.get_particle_boundary_buffer("electrons", 'eb', 'timestamp', 0)
for arr in scraped_steps:
assert all(np.array(arr, copy=False) > 40)

Expand Down
63 changes: 63 additions & 0 deletions Examples/Tests/point_of_contact_EB/analysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env python

import os
import sys

import numpy as np
from openpmd_viewer import OpenPMDTimeSeries
import yt

yt.funcs.mylog.setLevel(0)
sys.path.insert(1, '../../../../warpx/Regression/Checksum/')
import checksumAPI

# Open plotfile specified in command line
filename = sys.argv[1]
test_name = os.path.split(os.getcwd())[1]
checksumAPI.evaluate_checksum(test_name, filename, output_format='openpmd')

ts_scraping = OpenPMDTimeSeries('./diags/diag2/particles_at_eb/')


it=ts_scraping.iterations
timestamp,x,y,z,nx,ny,nz=ts_scraping.get_particle( ['timestamp','x','y','z','nx','ny','nz'], species='electron', iteration=it )

timestamp_analytic=3.58
x_analytic=-0.1983
y_analytic=0.02584
z_analytic=0.0000
nx_analytic=-0.99
ny_analytic=0.13
nz_analytic=0.0

timestamp=timestamp[0]*1e10
print('\n')
print('NUMERICAL coordinates of the point of contact:')
print('time_stamp=%5.4f e-10, x=%5.4f, y=%5.4f, z=%5.4f, nx=%5.4f, ny=%5.4f, nz=%5.4f' % (timestamp, x[0], y[0], z[0], nx[0], ny[0], nz[0]))
print('\n')
print('ANALYTICAL coordinates of the point of contact:')
print('time_stamp=%5.2f, x=%5.4f, y=%5.4f, z=%5.4f, nx=%5.4f, ny=%5.4f, nz=%5.4f' % (timestamp_analytic, x_analytic, y_analytic, z_analytic, nx_analytic, ny_analytic, nz_analytic))

tolerance=0.001
tolerance_t=0.003
tolerance_n=0.01
print('\n')
print("tolerance = "+ str(tolerance *100) + '%')
print("tolerance for the time_stamp = "+ str(tolerance_t *100) + '%')
print("tolerance for the normal components = "+ str(tolerance_n *100) + '%')
diff_timestamp=np.abs((timestamp-timestamp_analytic)/timestamp_analytic)
diff_x=np.abs((x[0]-x_analytic)/x_analytic)
diff_y=np.abs((y[0]-y_analytic)/y_analytic)
diff_nx=np.abs((nx[0]-nx_analytic)/nx_analytic)
diff_ny=np.abs((ny[0]-ny_analytic)/ny_analytic)

print('\n')
print("percentage error for timestamp = %5.4f %%" %(diff_timestamp *100))
print("percentage error for x = %5.4f %%" %(diff_x *100))
print("percentage error for y = %5.4f %%" %(diff_y *100))
print("percentage error for nx = %5.2f %%" %(diff_nx *100))
print("percentage error for ny = %5.2f %%" %(diff_ny *100))
print("nz = %5.2f " %(nz[0]))


assert (diff_timestamp < tolerance_t) and (diff_x < tolerance) and (diff_y < tolerance) and (diff_nx < tolerance_n) and (diff_ny < tolerance_n) and (np.abs(nz) < tolerance_n), 'Test point_of_contact did not pass'
44 changes: 44 additions & 0 deletions Examples/Tests/point_of_contact_EB/analysis_rz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python

import os
import sys

import numpy as np
from openpmd_viewer import OpenPMDTimeSeries
import yt

yt.funcs.mylog.setLevel(0)
sys.path.insert(1, '../../../../warpx/Regression/Checksum/')
import checksumAPI

# Open plotfile specified in command line
filename = sys.argv[1]
test_name = os.path.split(os.getcwd())[1]
checksumAPI.evaluate_checksum(test_name, filename, output_format='openpmd')

ts_scraping = OpenPMDTimeSeries('./diags/diag2/particles_at_eb/')


it=ts_scraping.iterations
r,theta,z=ts_scraping.get_particle( ['x','theta','z'], species='electron', iteration=it )

r_analytic=0.2
theta_analytic=3.0
z_analytic=0.0000

print('NUMERICAL coordinates of the point of contact:')
print('r=%5.4f, theta=%5.4f, z=%5.4f' % (r[0], theta[0], z[0]))
print('\n')
print('ANALYTICAL coordinates of the point of contact:')
print('x=%5.4f, y=%5.4f, z=%5.4f' % (r_analytic, theta_analytic, z_analytic))

tolerance=0.001
print("tolerance = "+ str(tolerance *100) + '%')

diff_x=np.abs((x[0]-x_analytic)/x_analytic)
diff_y=np.abs((y[0]-y_analytic)/y_analytic)

print("percentage error for x = %5.4f %%" %(diff_x *100))
print("percentage error for y = %5.4f %%" %(diff_y *100))

assert (diff_x < tolerance) and (diff_y < tolerance) and (np.abs(z[0]) < tolerance), 'Test point_of_contact did not pass'
51 changes: 51 additions & 0 deletions Examples/Tests/point_of_contact_EB/inputs_3d
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
amr.max_level = 0

max_step = 3


amr.n_cell = 64 64 64
amr.blocking_factor = 8
amr.max_grid_size = 128

geometry.dims = 3
geometry.prob_lo = -0.26 -0.26 -0.26
geometry.prob_hi = 0.26 0.26 0.26

boundary.field_lo = pec pec pec
boundary.field_hi = pec pec pec
boundary.potential_lo_x = 0
boundary.potential_hi_x = 0
boundary.potential_lo_y = 0
boundary.potential_hi_y = 0
boundary.potential_lo_z = 0
boundary.potential_hi_z = 0

warpx.const_dt = 1.0e-10
warpx.eb_implicit_function = "-(x**2+y**2+z**2-0.2**2)"

# Do not evolve the E and B fields
algo.maxwell_solver = none
algo.field_gathering = momentum-conserving
algo.particle_shape = 1

particles.species_names = electron
electron.charge = -q_e
electron.mass = m_e
electron.injection_style = "SingleParticle"
electron.single_particle_pos = -0.25 0 0
electron.single_particle_u = 1 0.5 0.0
electron.single_particle_weight = 1



electron.save_particles_at_eb = 1

diagnostics.diags_names = diag1 diag2

diag1.intervals = 1
diag1.diag_type = Full
diag1.fields_to_plot = Ex
diag1.format = openpmd

diag2.diag_type = BoundaryScraping
diag2.format = openpmd
53 changes: 53 additions & 0 deletions Examples/Tests/point_of_contact_EB/inputs_rz
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
amr.max_level = 1
warpx.fine_tag_lo = 0.0 -0.5
warpx.fine_tag_hi = 0.25 0.0

max_step = 3


amr.n_cell = 64 64
amr.blocking_factor = 8
amr.max_grid_size = 128

geometry.dims = RZ
geometry.prob_lo = 0.0 -0.5
geometry.prob_hi = 0.5 0.5

boundary.field_lo = none periodic
boundary.field_hi = pec periodic
boundary.potential_lo_x = 0
boundary.potential_hi_x = 0
boundary.potential_lo_y = 0
boundary.potential_hi_y = 0
boundary.potential_lo_z = 0
boundary.potential_hi_z = 0

warpx.const_dt = 1.0e-10
warpx.eb_implicit_function = "-(x**2 -0.2**2)"

# Do not evolve the E and B fields
algo.maxwell_solver = none
algo.field_gathering = momentum-conserving
algo.particle_shape = 1

particles.species_names = electron
electron.charge = -q_e
electron.mass = m_e
electron.injection_style = "SingleParticle"
electron.single_particle_pos = -0.25 0 0
electron.single_particle_u = 1 0.5 0.0
electron.single_particle_weight = 1



electron.save_particles_at_eb = 1

diagnostics.diags_names = diag1 diag2

diag1.intervals = 1
diag1.diag_type = Full
diag1.fields_to_plot = Er
diag1.format = openpmd

diag2.diag_type = BoundaryScraping
diag2.format = openpmd
24 changes: 8 additions & 16 deletions Python/pywarpx/particle_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,9 +772,9 @@ def get_particle_boundary_buffer(self, species_name, boundary, comp_name, level)
form x/y/z_hi/lo or eb.

comp_name : str
The component of the array data that will be returned. If
"step_scraped" the special attribute holding the timestep at
which a particle was scraped will be returned.
The component of the array data that will be returned.
"x", "y", "z", "ux", "uy", "uz", "w"
"timestamp", "nx", "ny", "nz"

level : int
Which AMR level to retrieve scraped particle data from.
Expand All @@ -784,21 +784,13 @@ def get_particle_boundary_buffer(self, species_name, boundary, comp_name, level)
part_container = self.particle_buffer.get_particle_container(
species_name, self._get_boundary_number(boundary)
)
comp_idx = part_container.get_comp_index(comp_name)
data_array = []
if comp_name == 'step_scraped':
# the step scraped is always the final integer component
comp_idx = part_container.num_int_comps - 1
for ii, pti in enumerate(libwarpx.libwarpx_so.BoundaryBufferParIter(part_container, level)):
soa = pti.soa()
data_array.append(xp.array(soa.GetIntData(comp_idx), copy=False))
else:
container_wrapper = ParticleContainerWrapper(species_name)
comp_idx = container_wrapper.particle_container.get_comp_index(comp_name)
for ii, pti in enumerate(libwarpx.libwarpx_so.BoundaryBufferParIter(part_container, level)):
soa = pti.soa()
data_array.append(xp.array(soa.GetRealData(comp_idx), copy=False))
return data_array

for ii, pti in enumerate(libwarpx.libwarpx_so.BoundaryBufferParIter(part_container, level)):
soa = pti.soa()
data_array.append(xp.array(soa.GetRealData(comp_idx), copy=False))
return data_array

def clear_buffer(self):
'''
Expand Down
14 changes: 14 additions & 0 deletions Regression/Checksum/benchmarks_json/Point_of_contact_EB_3d.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"electron": {
"particle_momentum_x": 0.0,
"particle_momentum_y": 0.0,
"particle_momentum_z": 0.0,
"particle_position_x": 0.0,
"particle_position_y": 0.0,
"particle_position_z": 0.0,
"particle_weight": 0.0
},
"lev=0": {
"Ex": 0.0
}
}
19 changes: 19 additions & 0 deletions Regression/Checksum/benchmarks_json/Point_of_contact_EB_rz.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"lev=0": {
"Er": 0.0
},
"lev=1": {
"Er": 0.0
},
"electron": {
"particle_position/theta": 0.0,
"particle_positionOffset/y": 0.0,
"particle_theta": 0.0,
"particle_position_x": 0.0,
"particle_position_z": 0.0,
"particle_momentum_x": 0.0,
"particle_momentum_y": 0.0,
"particle_momentum_z": 0.0,
"particle_weight": 0.0
}
}
39 changes: 39 additions & 0 deletions Regression/WarpX-tests.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4498,6 +4498,45 @@ doVis = 0
outputFile = BeamBeamCollision_plt
analysisRoutine = Examples/analysis_default_openpmd_regression.py

[Point_of_contact_EB_3d]
buildDir = .
inputFile = Examples/Tests/point_of_contact_EB/inputs_3d
runtime_params =
dim = 3
addToCompileString = USE_EB=TRUE
cmakeSetupOpts = -DWarpX_DIMS=3 -DWarpX_EB=ON
restartTest = 0
useMPI = 1
numprocs = 2
useOMP = 0
numthreads = 1
compileTest = 0
doVis = 0
compareParticles = 0
particleTypes = electrons
outputFile = Point_of_contact_EB_3d_plt
analysisRoutine = Examples/Tests/point_of_contact_EB/analysis.py

[Point_of_contact_EB_rz]
buildDir = .
inputFile = Examples/Tests/point_of_contact_EB/inputs_rz
runtime_params =
dim = 2
addToCompileString = USE_RZ=TRUE USE_EB=TRUE
cmakeSetupOpts = -DWarpX_DIMS=RZ -DWarpX_EB=ON
restartTest = 0
useMPI = 1
numprocs = 2
useOMP = 0
numthreads = 1
compileTest = 0
doVis = 0
compareParticles = 0
particleTypes = electrons
outputFile = Point_of_contact_EB_rz_plt
analysisRoutine = Examples/Tests/point_of_contact_EB/analysis_rz.py


[ImplicitPicard_1d]
buildDir = .
inputFile = Examples/Tests/Implicit/inputs_1d
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/WarpXOpenPMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ namespace detail
// and I/O in Cartesian.
// Other attributes like momentum are consequently
// stored in x,y,z internally.
positionComponents = vs{"x", "y", "z"};
positionComponents = vs{"x", "theta", "z"};
#elif defined(WARPX_DIM_3D)
positionComponents = vs{"x", "y", "z"};
#else
Expand Down
Loading
Loading