Skip to content

Diagnostics : EM fields on particles #5637

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

Open
wants to merge 127 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 112 commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
e9a44ff
add m_plot_EM flag
grobertdautun Jan 17, 2025
bb1947c
create storeEMFieldsOnParticles function
grobertdautun Jan 17, 2025
3638175
First particle EM fields diagnostics draft (not working)
grobertdautun Jan 17, 2025
7179fde
Merge remote-tracking branch 'upstream/development' into diags_EM_on_…
grobertdautun Jan 21, 2025
dafb2ac
fixed nan
grobertdautun Jan 21, 2025
c010ec5
added CI tests for EM diags on particles
grobertdautun Feb 4, 2025
1ae4b55
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 4, 2025
0142f2e
deleted unused variables
grobertdautun Feb 4, 2025
536756f
Merge remote-tracking branch 'origin/diags_EM_on_particles' into HEAD
grobertdautun Feb 4, 2025
a0d50b5
Merge remote-tracking branch 'upstream/development' into diags_em_on_…
grobertdautun Feb 4, 2025
bb5a285
Fixed example lambda function and inputs name
grobertdautun Feb 4, 2025
addaf67
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 4, 2025
4de0408
removed unused variable geom
grobertdautun Feb 4, 2025
3f5062a
Merge branch 'diags_em_on_particles_2' of github.com:grobertdautun/Wa…
grobertdautun Feb 4, 2025
3c08a8b
Fixed undefined identifier
grobertdautun Feb 4, 2025
18275a2
fixed no member error
grobertdautun Feb 4, 2025
8c50b0b
Removed adios2 from test
grobertdautun Feb 5, 2025
c381d56
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 5, 2025
800494e
Update Source/Diagnostics/ParticleIO.cpp
grobertdautun Feb 5, 2025
041e9a8
Update Source/Diagnostics/ParticleIO.cpp
grobertdautun Feb 5, 2025
4a7f71e
Update Source/Diagnostics/WarpXOpenPMD.cpp
grobertdautun Feb 5, 2025
8500064
Added postprocessing script and updated documentation
grobertdautun Feb 5, 2025
3b11e01
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 5, 2025
a0cae43
removed comment
grobertdautun Feb 6, 2025
1aea782
Update analysis_2d.py
grobertdautun Feb 6, 2025
cab9f6c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 6, 2025
f8b9335
Merge branch 'development' into diags_em_on_particles_2
grobertdautun Feb 13, 2025
7644c3a
added output docstring in script
grobertdautun Feb 13, 2025
6c601be
fixed merge conflict
grobertdautun Feb 13, 2025
86f86d8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 13, 2025
028b139
updated syntax for runtime components
grobertdautun Feb 13, 2025
dccd20c
fix args in GetRealCompIndex
grobertdautun Feb 13, 2025
fe605a2
changed fields from fp to aux
grobertdautun Feb 26, 2025
6f49cb7
clarified is_full_diagnostics
grobertdautun Feb 26, 2025
f0070a7
added external fields (testing)
grobertdautun Feb 26, 2025
46164da
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 26, 2025
e2fc011
removed temporary variable
grobertdautun Feb 26, 2025
52014a2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 26, 2025
92328fc
include getExternalFields.H
grobertdautun Feb 26, 2025
9c80e82
Merge branch 'diags_em_on_particles_2' of github.com:grobertdautun/Wa…
grobertdautun Feb 26, 2025
c79e5bc
Merge remote-tracking branch 'upstream/development' into diags_em_on_…
grobertdautun Mar 5, 2025
aa469d0
updating to current development version
grobertdautun Mar 28, 2025
76661f6
removed variable based adios2 script
grobertdautun Mar 28, 2025
1e75602
[NOT WORKING] add runtime compile options
grobertdautun Mar 31, 2025
a6f2615
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 31, 2025
4d9fc82
[NOT WORKING] tests
grobertdautun Mar 31, 2025
9cebf78
Merge branch 'diags_em_on_particles_2' of github.com:grobertdautun/Wa…
grobertdautun Mar 31, 2025
f70ca45
[NOT WORKING] tests
grobertdautun Mar 31, 2025
2f9740c
[NW] added tmp arrays
grobertdautun Apr 1, 2025
1c4801a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 1, 2025
ddef521
[NW] add runtime options
grobertdautun Apr 1, 2025
b1fb78e
added runtime options
grobertdautun Apr 1, 2025
910ad1e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 1, 2025
29a3345
this should work
grobertdautun Apr 1, 2025
fdc274e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 1, 2025
ae4900c
defined unused fields as nullptr
grobertdautun Apr 1, 2025
454b7f7
fixed undefined type
grobertdautun Apr 1, 2025
e3e74cd
storeEMFieldsOnParticles parameters consistency
grobertdautun Apr 1, 2025
7ace39b
array is const
grobertdautun Apr 1, 2025
872858f
adapted template params
grobertdautun Apr 1, 2025
5557af7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 1, 2025
cf4d694
trying to fix WarpXParIter issue
grobertdautun Apr 1, 2025
887a117
removed external fields (temporary)
grobertdautun Apr 1, 2025
851dd6b
fixed { not matching and removed redefinition of flags
grobertdautun Apr 1, 2025
a7b7655
ignore_unused and remove 1 constexpr
grobertdautun Apr 1, 2025
fa2686c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 1, 2025
3ab1d6e
changed lambda function capture
grobertdautun Apr 1, 2025
9ac5c8f
ref
grobertdautun Apr 1, 2025
2c11d11
try to capture before constexpr
grobertdautun Apr 2, 2025
ba3645a
ignore unused
grobertdautun Apr 2, 2025
57dd705
changed some def, adapted capture oustside constexpr
grobertdautun Apr 2, 2025
74df3eb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 2, 2025
f76a161
updated test
grobertdautun Apr 2, 2025
a019251
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 2, 2025
3b8f9bf
code cleanup
grobertdautun Apr 2, 2025
cf8aa6e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 2, 2025
493699b
corrected with shape function
grobertdautun Apr 3, 2025
100bba2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 3, 2025
c480bb7
constexpr
grobertdautun Apr 3, 2025
8c83e76
no constexpr
grobertdautun Apr 3, 2025
4e8d413
test workaround for constant expressions
grobertdautun Apr 3, 2025
d2100a6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 3, 2025
e48b7f7
please work
grobertdautun Apr 3, 2025
93f0036
def gatherE gatherB outside of if else scope
grobertdautun Apr 3, 2025
ddd7da0
corrected types
grobertdautun Apr 3, 2025
f548c45
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 3, 2025
2e429ac
removed old var from ignore unused
grobertdautun Apr 3, 2025
265a5f6
always initialise funcs
grobertdautun Apr 3, 2025
f284f50
wrong types
grobertdautun Apr 3, 2025
ada5051
first capture of variable outside constexpr
grobertdautun Apr 3, 2025
c61947e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 3, 2025
a252513
template function to fix SYCL compilation
grobertdautun Apr 4, 2025
1f7f414
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 4, 2025
34fde58
changed template typename
grobertdautun Apr 4, 2025
0a0b73f
changed template name
grobertdautun Apr 4, 2025
3d7c961
changed templates types
grobertdautun Apr 4, 2025
20d5d4b
code cleanup + documentation
grobertdautun Apr 4, 2025
c926f9a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 4, 2025
b75e0d6
check for illegal memory access
grobertdautun Apr 7, 2025
8158c05
removed deleted function
grobertdautun Apr 7, 2025
424492a
Merge branch 'BLAST-WarpX:development' into diags_em_on_particles_2
grobertdautun Apr 7, 2025
d436f2d
changes in doc
grobertdautun Apr 7, 2025
f969804
removed const
grobertdautun Apr 7, 2025
645e35e
changed template description
grobertdautun Apr 7, 2025
c6ddf57
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 7, 2025
d9a9cc7
add const
grobertdautun Apr 7, 2025
a1ac46b
add const
grobertdautun Apr 7, 2025
c97d4e2
clearer comment
grobertdautun Apr 7, 2025
befb305
changes requested
grobertdautun Apr 7, 2025
2449295
Merge branch 'diags_em_on_particles_2' of github.com:grobertdautun/Wa…
grobertdautun Apr 7, 2025
f04bca0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 7, 2025
9ee6575
reverted const changes
grobertdautun Apr 7, 2025
7f0d1b5
change in constexpr
grobertdautun Apr 7, 2025
1068708
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 7, 2025
1624f30
add comments in test case analysis
grobertdautun Apr 8, 2025
3911734
add docygen comment
grobertdautun Apr 8, 2025
13b38a6
changed C-style array to amrex::Array<bool, 6>
grobertdautun Apr 8, 2025
615d198
added warning
grobertdautun Apr 8, 2025
92f397d
fixed broken finestLevel()
grobertdautun Apr 8, 2025
4c4faa8
Merge branch 'BLAST-WarpX:development' into diags_em_on_particles_2
grobertdautun Apr 8, 2025
09f3183
updated test and checksum
grobertdautun Apr 8, 2025
7e8e928
update checksum again?
grobertdautun Apr 9, 2025
d2d3cb2
Update Regression/Checksum/benchmarks_json/test_2d_particle_EM_diagno…
lucafedeli88 Apr 9, 2025
c4c9d67
Merge branch 'BLAST-WarpX:development' into diags_em_on_particles_2
grobertdautun Apr 12, 2025
e55ff68
added a doGatherShapeN call instead of 2 doDirectGatherVectorField wh…
grobertdautun Apr 14, 2025
c924f2f
Merge branch 'diags_em_on_particles_2' of github.com:grobertdautun/Wa…
grobertdautun Apr 14, 2025
07f517f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 14, 2025
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
7 changes: 5 additions & 2 deletions Docs/source/usage/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2966,11 +2966,14 @@ In-situ capabilities can be used by turning on Sensei or Ascent (provided they a
* ``<diag_name>.<species_name>.variables`` (list of `strings` separated by spaces, optional)
List of particle quantities to write to output.
Choices are ``x``, ``y``, ``z`` for the particle positions (3D and RZ), ``x`` & ``z`` in 2D, ``z`` in 1D,
``w`` for the particle weight and ``ux``, ``uy``, ``uz`` for the particle momenta.
``w`` for the particle weight, ``ux``, ``uy``, ``uz`` for the particle momenta, and ``Ex``, ``Ey``, ``Ez``, ``Bx``, ``By``, ``Bz`` for the electromagnetic fields.
When using the lab-frame electrostatic solver, ``phi`` (electrostatic potential, on the macroparticles) is also available.
By default, all particle quantities (except ``phi``) are written.
By default, positions, momenta and particle weight are written.
If ``<diag_name>.<species_name>.variables = none``, no particle data are written.

.. note::
The electromagnetic fields diagnostics will not display the external fields.

* ``<diag_name>.<species_name>.random_fraction`` (`float`) optional
If provided ``<diag_name>.<species_name>.random_fraction = a``, only `a` fraction of the particle data of this species will be dumped randomly in diag ``<diag_name>``, i.e. if `rand() < a`, this particle will be dumped, where `rand()` denotes a random number generator.
The value `a` provided should be between 0 and 1.
Expand Down
1 change: 1 addition & 0 deletions Examples/Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ add_subdirectory(embedded_boundary_em_particle_absorption)
add_subdirectory(embedded_boundary_python_api)
add_subdirectory(embedded_boundary_rotated_cube)
add_subdirectory(embedded_circle)
add_subdirectory(EM_fields_on_particles)
add_subdirectory(energy_conserving_thermal_plasma)
add_subdirectory(field_probe)
add_subdirectory(flux_injection)
Expand Down
11 changes: 11 additions & 0 deletions Examples/Tests/EM_fields_on_particles/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# add tests

add_warpx_test(
test_2d_particle_EM_diagnostics # name
2 # dims
2 # nprocs
inputs_test_2d_particle_EM_diagnostics # inputs
"analysis_2d.py" # analysis
"analysis_default_regression.py --path diags/diag_checksum/" # checksum
OFF # dependency
)
158 changes: 158 additions & 0 deletions Examples/Tests/EM_fields_on_particles/analysis_2d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#!/usr/bin/env python3

import numpy as np
from openpmd_viewer import OpenPMDTimeSeries
from scipy.interpolate import interp1d
from scipy.optimize import minimize
from scipy.signal import hilbert

c = 3e8
lambda_laser = 800e-9
T_laser = lambda_laser / c

E_max = 3.26e10
T_peak = 10e-15
tau = 5e-15
delta_t = 1.6e-6 / c # time for the laser to reach the particle

ts_particle = OpenPMDTimeSeries("diags/diag1/")

ex_t, ey_t, ez_t, bx_t, by_t, bz_t = ts_particle.iterate(
ts_particle.get_particle, ["ex", "ey", "ez", "bx", "by", "bz"], species="electron"
)

ex_t = np.squeeze(ex_t)
ey_t = np.squeeze(ey_t)
ez_t = np.squeeze(ez_t)
bx_t = np.squeeze(bx_t)
by_t = np.squeeze(by_t)
bz_t = np.squeeze(bz_t)

n_diags = 401

DT = 6.324524234e-17 # @ CFL = 0.99
iterations = np.linspace(0, n_diags - 1, n_diags)
T = (iterations * DT) - DT / 2

T_peak_part = T_peak + delta_t
Ey_max = E_max * 1 / np.sqrt(5) # polarisation vector (0 1 2)
Ez_max = E_max * np.sqrt(1 - 1 / 5)
By_max = Ez_max / c
Bz_max = Ey_max / c


def get_laser_th(E_0, T_p, T, tau, T_laser, phi=0):
alpha = np.exp(-((T - T_peak_part) ** 2) / (tau**2))
return E_0 * alpha * np.cos(2 * np.pi * (T - T_p) / T_laser + phi)


Ey_th = get_laser_th(Ey_max, T_peak_part, T, tau, T_laser)
Ez_th = get_laser_th(Ez_max, T_peak_part, T, tau, T_laser)
By_th = get_laser_th(By_max, T_peak_part, T, tau, T_laser, phi=np.pi)
Bz_th = get_laser_th(Bz_max, T_peak_part, T, tau, T_laser)

Ey_th = np.where(T >= delta_t, Ey_th, 0)
Ez_th = np.where(T >= delta_t, Ez_th, 0)
By_th = np.where(T >= delta_t, By_th, 0)
Bz_th = np.where(T >= delta_t, Bz_th, 0)


# due to injection method the simulated fields have a slight dephasing
# wrt the theoretical field
# here we compute the dephasing and correct it on the theoretical field
def align_cost(shift, sig1, sig2, time):
# Create an interpolation function for the signal to be shifted
interp_func = interp1d(time, sig1, kind="linear", fill_value="extrapolate")
shifted_sig1 = interp_func(time + shift)
# MSE
cost = np.mean((shifted_sig1 - sig2) ** 2)
return cost


init_shift = 0.0
res = minimize(
align_cost,
init_shift,
args=(Ey_th, ey_t, T),
method="Nelder-Mead",
options={"xatol": 1e-20, "fatol": 1e-20, "maxiter": 10000},
)
opt_shift = res.x[0]

interp_func_ey = interp1d(T, Ey_th, kind="cubic", fill_value="extrapolate")
interp_func_ez = interp1d(T, Ez_th, kind="cubic", fill_value="extrapolate")
interp_func_by = interp1d(T, By_th, kind="cubic", fill_value="extrapolate")
interp_func_bz = interp1d(T, Bz_th, kind="cubic", fill_value="extrapolate")

Ey_aligned = interp_func_ey(T + opt_shift)
Ez_aligned = interp_func_ez(T + opt_shift)
By_aligned = interp_func_by(T + opt_shift)
Bz_aligned = interp_func_bz(T + opt_shift)

# verif

# E.1

assert np.allclose(np.zeros(ex_t.shape), ex_t, rtol=0, atol=5e-4)

# E.2

ey_p = ey_t[T >= delta_t]
Ey_p = Ey_aligned[T >= delta_t]
ey_p += 1e11
Ey_p += 1e11

ez_p = ez_t[T >= delta_t]
Ez_p = Ez_aligned[T >= delta_t]
ez_p += 1e11
Ez_p += 1e11

assert np.allclose(ey_p, Ey_p, rtol=8e-4, atol=0)
assert np.allclose(ez_p, Ez_p, rtol=2e-3, atol=0)

# E.3

ey_m = ey_t[T < delta_t - DT * 4]
ez_m = ez_t[T < delta_t - DT * 4]
assert np.allclose(ey_m, np.zeros(ey_m.shape), atol=1e-10, rtol=0)
assert np.allclose(ez_m, np.zeros(ey_m.shape), atol=1e-10, rtol=0)

# E.4

env_ez_t = np.abs(hilbert(ez_t))
env_ey_t = np.abs(hilbert(ey_t))
assert np.isclose(np.max(env_ez_t) / np.max(env_ey_t), 2, rtol=2e-3, atol=0)
assert np.allclose(2 * env_ey_t[85:390], env_ez_t[85:390], rtol=8e-3, atol=0)

# B.1

assert np.allclose(np.zeros(bx_t.shape), bx_t, rtol=0, atol=5e-4)

# B.2

by_p = by_t[T >= delta_t]
By_p = By_aligned[T >= delta_t]
by_p += 1e3
By_p += 1e3

bz_p = bz_t[T >= delta_t]
Bz_p = Bz_aligned[T >= delta_t]
bz_p += 1e3
Bz_p += 1e3

assert np.allclose(by_p, By_p, rtol=8e-4, atol=0)
assert np.allclose(bz_p, Bz_p, rtol=4e-4, atol=0)

# B.3

by_m = by_t[T < delta_t - DT * 4]
bz_m = bz_t[T < delta_t - DT * 4]
assert np.allclose(by_m, np.zeros(by_m.shape), atol=1e-10, rtol=0)
assert np.allclose(bz_m, np.zeros(by_m.shape), atol=1e-10, rtol=0)

# B.4

env_bz_t = np.abs(hilbert(bz_t))
env_by_t = np.abs(hilbert(by_t))
assert np.isclose(np.max(env_by_t) / np.max(env_bz_t), 2, rtol=2e-3, atol=0)
assert np.allclose(0.5 * env_by_t[85:390], env_bz_t[85:390], rtol=8e-3, atol=0)
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#################################
####### GENERAL PARAMETERS ######
#################################

# Parameters
max_step = 400
amr.n_cell = 256 256
warpx.numprocs = 2 1
amr.max_level = 0
geometry.dims = 2
geometry.prob_lo = 0 0 # physical domain
geometry.prob_hi = 5e-6 2.5e-5

# BC

boundary.field_lo = pml pml
boundary.field_hi = pml pml

#################################
############ NUMERICS ###########
#################################
warpx.serialize_initial_conditions = 1
warpx.verbose = 1
warpx.cfl = 0.99
warpx.use_filter = 0

# Order of particle shape factors
algo.particle_shape = 2

#################################
########### "PLASMA" ############
#################################

particles.species_names = electron

electron.species_type = electron
electron.injection_style = "SingleParticle"
electron.single_particle_pos = 2.5e-6 0 1.25e-5
electron.single_particle_u = 0 0 0
electron.single_particle_weight = 0

electron.do_not_push = 1
electron.do_not_deposit = 1

#################################
######### LASER #################
#################################

lasers.names = las1

las1.position = 0.9e-6 326 1.25e-5
las1.polarization = 0 1 2
las1.direction = 1 0 0
las1.e_max = 3.26e10
las1.wavelength = 800e-9
las1.profile = "Gaussian"
las1.profile_t_peak = 10e-15
las1.profile_duration = 5e-15
las1.profile_waist = 5e-6
las1.profile_focal_distance = 1.6e-6

#################################
############# DIAGS #############
#################################

diagnostics.diags_names = diag1 diag_checksum

diag1.intervals = 1
diag1.diag_type = Full
diag1.format = openpmd
diag1.openpmd_backend = h5
diag1.fields_to_plot = none
diag1.write_species = 1
diag1.species = electron
diag1.electron.variables = Ex Ey Ez Bx By Bz # will emit a warning because no position is asked

diag_checksum.intervals = 400:400
diag_checksum.diag_type = Full
diag_checksum.format = openpmd
diag_checksum.openpmd_backend = h5
diag_checksum.fields_to_plot = Ex Ey Ez Bx By Bz
diag_checksum.write_species = 1
diag_checksum.species = electron
diag_checksum.electron.variables = x z ux uy uz w Ex Ey Ez Bx By Bz
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"electron": {
"particle_bx": 3.890980310565517e-07,
"particle_by": 0.34760630481899957,
"particle_bz": 0.1737192637399916,
"particle_ex": 0.00013839455641573295,
"particle_ey": 50608854.55959022,
"particle_ez": 111088826.0524848,
"particle_momentum_x": 0.0,
"particle_momentum_y": 0.0,
"particle_momentum_z": 0.0,
"particle_position_x": 2.5e-06,
"particle_position_y": 0.0,
"particle_position_z": 1.25e-05,
"particle_weight": 0.0
},
"lev=0": {
"Bx": 3864.690332686649,
"By": 239757.36697091258,
"Bz": 119878.42982987352,
"Ex": 2396689176285.191,
"Ey": 35934018061852.125,
"Ez": 71884648325008.73
}
}
2 changes: 2 additions & 0 deletions Source/Diagnostics/ParticleDiag/ParticleDiag.H
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public:
[[nodiscard]] std::string getSpeciesName() const { return m_name; }
amrex::Vector<int> m_plot_flags;
bool m_plot_phi = false; // Whether to output the potential phi on the particles
bool m_plot_EM = false; // Whether to output the E and B fields on the particles
bool m_plot_EM_flags[6] = {false, false, false, false, false, false}; // E and B fields

bool m_do_random_filter = false;
bool m_do_uniform_filter = false;
Expand Down
12 changes: 9 additions & 3 deletions Source/Diagnostics/ParticleDiag/ParticleDiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,16 @@ ParticleDiag::ParticleDiag (
if (var == "y") { var = "theta"; }
#endif
if (var == "phi") {
// User requests phi on particle. This is *not* part of the variables that
// the particle container carries, and is only added to particles during output.
// Therefore, this case needs to be treated specifically.
m_plot_phi = true;
} else if (var == "Ex" || var == "Ey" || var == "Ez" ||
var == "Bx" || var == "By" || var == "Bz") {
m_plot_EM = true;
if (var == "Ex") {m_plot_EM_flags[0] = true;}
if (var == "Ey") {m_plot_EM_flags[1] = true;}
if (var == "Ez") {m_plot_EM_flags[2] = true;}
if (var == "Bx") {m_plot_EM_flags[3] = true;}
if (var == "By") {m_plot_EM_flags[4] = true;}
if (var == "Bz") {m_plot_EM_flags[5] = true;}
} else {
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(pc->HasRealComp(var),
"variables argument '" + var
Expand Down
Loading
Loading