Skip to content

Commit

Permalink
Field probe line detector (#2513)
Browse files Browse the repository at this point in the history
* FieldProbe using Particle

Update FieldProbe.cpp

Update FieldProbeParticleContainer.H

Updates FieldProbe and FieldProbeParticleContainer

* Make <diag>.integrate optional

The param parser query keeps te default value if no entry is found.

* Fixed number particle needed for AddNParticles

* Removing unnecessary type definition

* Added Doxygen-style comments to FieldProbe.cpp
Corrected Poynting calculation by implementing vacuum permeability

* Added Doxygen comments

* Implement virtual function ReducedDiags::AllocData() + comments

* InitData implemented

* Fixed Doxygen commenting.

* Now uses WarpX physics constant for vaccuum permeability

* forgotton comments to MultiReducedDiags

* Update Source/Diagnostics/ReducedDiags/FieldProbe.H

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.H

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.H

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.H

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update FieldProbe.H

* Update FieldProbe.cpp

* Update Source/Diagnostics/ReducedDiags/ReducedDiags.H

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/MultiReducedDiags.H

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/MultiReducedDiags.H

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update FieldProbeParticleContainer.H

* Update Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.H

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update FieldProbeParticleContainer.cpp

* Update FieldProbe.cpp

* Update FieldProbe.H

* Update Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.H

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.H

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update FieldProbeParticleContainer.cpp

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/ReducedDiags.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Changed enumerated class to struct w/ enumeration. Can remove "static_cast<int>"

* FieldProbeParticleContainer::iterator implemented

* Cleaned up output += operator, fixed output comments

* style fix

* Replaces Tabs with 4 spaces

* Defined modes and interp order to avoid GPU compilation errors

* 1 more tab fix

* EoL white spaces

* fixed a typoX

* Explicitly capturing "this" in parallel for to combat error saying "error #3223-D: Implicit capture of 'this' in extended lambda expression"

* removed unncessacesy double define

* moved output out of ParallelFor. temp variable for integrate

* Parse integrate, integrate all time steps, output setup for integrate and regular

* Fixed integrate bug.

* ammend header. integreate variable name change.

* Integrate values in input file

* updates to timing for integrate

* Update Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* whitespace

* Update Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Functionality to create 2D line of particles. Input included. No output yet

* ammend compiler errors

* Apply suggestions from code review - Style

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update reduce_diag_names

* 2D array setup- not complete

* field_probe_integrate change

* review amends

* Apply suggestions from code review - Style

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Vectors + AddNParticles

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update FieldProbe.cpp

* Update FieldProbe.H

* bug fix and inputs

* reintroduce raw_fields functionality

* docs update and correction

* whitespaces

* Fix GPU Compile (raw_fields)

* changed f_probe to m_probe apropriately

* Typos

Co-authored-by: David Grote <dpgrote@lbl.gov>
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Better name for ParticleVal

* used map for observables and units

* Apply suggestions from code review

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Simplified output. Fixed double integration error

* Update FieldProbe.H

Removed unneeded variable

* comments and fixed rawFields

* white spaces

* Apply suggestions from code review

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Update FieldProbe.H

* Guard on write

* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Fix Syntax Error in Write

* Fix Init: Only 1 Particle (MPI)

Only one MPI rank adds a particle, which we done distribute
into the right rank.

* Fix MPI Deadlock: No Early Return

We just want to skip the write to `m_data`, not the rest
of the logic.

* Vector storage, Add N particle, debugging

* Fix Probe in Domain Logic

General global check, not only on a single rank.

* comments

* Container: Add `const_iterator`

* Fix MPI Comms

* Cleaning

* Remove PrintAll Leftover

* 1-D Output vector

* Reduced Diags: Support LoadBalance

* Cleaning of "Definitions ()"

* Updating inputs for testing Line

* data type specification

* IO

* Update inputs

* Update inputs

* error in header. Send to IO CPU

* Apply suggestions from code review

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* moved rank communication out of tile loop

* change m_data_vector. IO particle count

* Fixed input for rename. Gather particle number

* Apply suggestions from code review

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Gather

* Changed data output method to pushing values on vector
MPI Gather and Gatherv for data
Tell Evolve to run Load Balance
Tell InitData to run Load Balance
Define output method by printing valid particles

NOTE! Needs cleaning, commenting, removing some debugging tools

* Apply suggestions from code review

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Suggestions from review

* defensive programming on if / if else
added comments throughout
removed temporary debugging lines

* Documentation for line detector option

* Whitespaces

* MPI_Gather -> amrex::ParallelDescriptor::Gather

* ParallelDiscriptor, vectors at the end, no more 1990's malloc for capacity allocation

* whitespaces

* output optimized for CSV

* Python notebook for reference

* Input file for current test on CORI

* 2D plane functionality

* Regression test

* Delete DoubleSlit_2021_11_17.ipynb

* Whitespace fix

* pandas

* Error set to 2.5%, fixed source

* style

* zenodo orcid

* Apply suggestions from code review

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Review changes and swapped MPI direct call for Amrex::ParallelDescriptor

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update WarpX-tests.ini

Fix Regression Test

* Update WarpX-tests.ini

Open PMD in cmakeSetupOpts

* Update dependencies.rst

* Update analysis_field_probe.py

* Update WarpX-tests.ini

* Analysis Script: Executable

```
chmod a+x scriptname.py
```

and use explicitly `python3`

* openPMD: optional for this test

* Inputs: add `geometry.dims = 2`

* Remove: diag1.write_species = 0

- segfaults for plotfiles (bug?)
- not needed, since we have no particles anyway

* Fix: typo in analysis

* test requirements: pandas

* Fix: Types

* as string: `<red_diag>.probe_geometry`

change this to a string, which is more user-friendly

* Python Script: Simplify + Style

* C++: Clean Up

* Azure: Run `apt update`

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Co-authored-by: David Grote <dpgrote@lbl.gov>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Jan 14, 2022
1 parent 400f536 commit 2efde6c
Show file tree
Hide file tree
Showing 15 changed files with 533 additions and 105 deletions.
3 changes: 2 additions & 1 deletion .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ jobs:
set -eu -o pipefail
cat /proc/cpuinfo | grep "model name" | sort -u
df -h
sudo apt update
sudo apt install -y ccache curl gcc gfortran git g++ ninja-build \
openmpi-bin libopenmpi-dev \
libfftw3-dev libfftw3-mpi-dev libhdf5-openmpi-dev pkg-config make \
python3 python3-pip python3-venv python3-setuptools libblas-dev liblapack-dev
python3 python3-pandas python3-pip python3-venv python3-setuptools libblas-dev liblapack-dev
ccache --set-config=max_size=10.0G
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade setuptools
Expand Down
5 changes: 5 additions & 0 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@
"name": "Myers, Andrew",
"orcid": "0000-0001-8427-8330"
},
{
"affiliation": "Lawrence Berkeley National Laboratory",
"name": "Rheaume, Tiberius",
"orcid": "0000-0002-6710-0650"
},
{
"affiliation": "Lawrence Berkeley National Laboratory",
"name": "Rowan, Michael E.",
Expand Down
8 changes: 4 additions & 4 deletions Docs/source/install/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ If you also want to run runtime tests and added Python (``spack add python`` and

.. code-block:: bash
python3 -m pip install matplotlib yt scipy numpy openpmd-api virtualenv
python3 -m pip install matplotlib yt scipy pandas numpy openpmd-api virtualenv
If you want to run the ``./run_test.sh`` :ref:`test script <developers-testing>`, which uses our legacy GNUmake build system, you need to set the following environment hints after ``spack env activate warpx-dev`` for dependent software:

Expand Down Expand Up @@ -125,7 +125,7 @@ Without MPI:

.. code-block:: bash
conda create -n warpx-dev -c conda-forge blaspp ccache cmake compilers git lapackpp openpmd-api python numpy scipy yt fftw matplotlib mamba ninja pip virtualenv
conda create -n warpx-dev -c conda-forge blaspp ccache cmake compilers git lapackpp openpmd-api python numpy pandas scipy yt fftw matplotlib mamba ninja pip virtualenv
source activate warpx-dev
# compile WarpX with -DWarpX_MPI=OFF
Expand All @@ -134,7 +134,7 @@ With MPI (only Linux/macOS):

.. code-block:: bash
conda create -n warpx-dev -c conda-forge blaspp ccache cmake compilers git lapackpp "openpmd-api=*=mpi_openmpi*" python numpy scipy yt "fftw=*=mpi_openmpi*" matplotlib mamba ninja openmpi pip virtualenv
conda create -n warpx-dev -c conda-forge blaspp ccache cmake compilers git lapackpp "openpmd-api=*=mpi_openmpi*" python numpy pandas scipy yt "fftw=*=mpi_openmpi*" matplotlib mamba ninja openmpi pip virtualenv
source activate warpx-dev
For legacy ``GNUmake`` builds, after each ``source activate warpx-dev``, you also need to set:
Expand All @@ -152,7 +152,7 @@ Apt (Debian/Ubuntu)
.. code-block:: bash
sudo apt update
sudo apt install build-essential ccache cmake g++ git libfftw3-mpi-dev libfftw3-dev libhdf5-openmpi-dev libopenmpi-dev pkg-config python3 python3-matplotlib python3-numpy python3-pip python3-scipy python3-venv
sudo apt install build-essential ccache cmake g++ git libfftw3-mpi-dev libfftw3-dev libhdf5-openmpi-dev libopenmpi-dev pkg-config python3 python3-matplotlib python3-numpy python3-pandas python3-pip python3-scipy python3-venv
# optional:
# for CUDA, either install
Expand Down
1 change: 1 addition & 0 deletions Docs/source/install/hpc/summit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Optionally, download and install Python packages for :ref:`PICMI <usage-picmi>`
python3 -m pip install --upgrade wheel
python3 -m pip install --upgrade cython
python3 -m pip install --upgrade numpy
python3 -m pip install --upgrade pandas
python3 -m pip install --upgrade scipy
python3 -m pip install --upgrade mpi4py --no-binary mpi4py
python3 -m pip install --upgrade openpmd-api
Expand Down
25 changes: 20 additions & 5 deletions Docs/source/usage/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2132,10 +2132,26 @@ Reduced Diagnostics

* ``FieldProbe``
This type computes the value of each component of the electric and magnetic fields
and of the Poynting vector (a measure of electromagnetic flux) at a point in the domain.
The point where the fields are measured is specified through the input parameters
``<reduced_diags_name>.x_probe``, ``<reduced_diags_name>.y_probe`` and
``<reduced_diags_name>.z_probe``.
and of the Poynting vector (a measure of electromagnetic flux) at points in the domain.

Multiple geometries for point probes can be specified via ``<reduced_diags_name>.probe_geometry = ...``:

* ``Point`` (default): a single point
* ``Line``: a line of points with equal spacing
* ``Plane``: a plane of points with equal spacing

**Point**: The point where the fields are measured is specified through the input parameters ``<reduced_diags_name>.x_probe``, ``<reduced_diags_name>.y_probe`` and ``<reduced_diags_name>.z_probe``.

**Line**: probe a 1 dimensional line of points to create a line detector.
Initial input parameters ``x_probe``, ``y_probe``, and ``z_probe`` designate one end of the line detector, while the far end is specified via ``<reduced_diags_name>.x1_probe``, ``<reduced_diags_name>.y1_probe``, ``<reduced_diags_name>.z1_probe``.
Additionally, ``<reduced_diags_name>.resolution`` must be defined to give the number of detector points along the line (equally spaced) to probe.

**Plane**: probe a 2 dimensional plane of points to create a square plane detector.
Initial input parameters ``x_probe``, ``y_probe``, and ``z_probe`` designate the center of the detector.
The detector plane is normal to a vector specified by ``<reduced_diags_name>.target_normal_x``, ``<reduced_diags_name>.target_normal_y``, and ``<reduced_diags_name>.target_normal_z``.
The top of the plane is perpendicular to an "up" vector denoted by ``<reduced_diags_name>.target_up_x``, ``<reduced_diags_name>.target_up_y``, and ``<reduced_diags_name>.target_up_z``.
The detector has a square radius to be determined by ``<reduced_diags_name>.detector_radius``.
Similarly to the line detector, the plane detector requires a resolution ``<reduced_diags_name>.resolution``, which denotes the number of detector particles along each side of the square detector.

The output columns are
the value of the :math:`E_x` field,
Expand All @@ -2157,7 +2173,6 @@ Reduced Diagnostics
Integrated electric and magnetic field components can instead be obtained by specifying
``<reduced_diags_name>.integrate == true``.


* ``RhoMaximum``
This type computes the maximum and minimum values of the total charge density as well as
the maximum absolute value of the charge density of each charged species.
Expand Down
57 changes: 57 additions & 0 deletions Examples/Tests/FieldProbe/analysis_field_probe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env python3
#
# Copyright 2021-2022 Tiberius Rheaume
#
# This file is part of WarpX.
#
# License: BSD-3-Clause-LBNL

"""
This script tests the accuracy of the FieldProbe diagnostic by observing a plane
wave undergoing single slit diffraction. The input file inputs_2d is used. This
file defines the simulation box, laser pulse, embeded boundary with single slit,
and line of detector points. The plane wave initializes near the negative Z end
of the simulation box. The wave interacts with the embeded boundary at Z=0. The
wave undergoes diffraction at the slit. The electromagnetic flux is calculated
at the line detector which is placed perpendicular to Z beyond the slit. This
test will check if the detected EM flux matches expected values,
which can be solved analytically.
"""
import numpy as np
import pandas as pd

filename = "diags/reducedfiles/FP_line.txt"

# Open data file
df = pd.read_csv(filename, sep=' ')
df = df.sort_values(by=['[2]part_x_lev0-(m)'])

# Select position and Intensity of timestep 500
x = df.query('`[0]step()` == 500')['[2]part_x_lev0-(m)']
S = df.query('`[0]step()` == 500')['[11]part_S_lev0-(W*s/m^2)']
xvals = x.to_numpy()
svals = S.to_numpy()

# Default intensity is highest measured value for plane
# wave interacting with single slit
I_0 = np.max(S)
def I_envelope (x, lam = 0.2e-6, a = 0.3e-6, D = 1.7e-6):
arg = np.pi * a / lam * np.sin(np.arctan(x / D))
return np.sinc( arg / np.pi )**2

# Count non-outlyer values away from simulation boundaries
counter = np.arange(60, 140, 2)

# Count average error from expected values
error = 0
for a in counter:
b = I_0 * I_envelope(xvals[a])
c = svals[a]
error += abs((c-b)/b) * 100.0
averror = error / (len(counter) - 1)

# average error range set at 2.5%
if averror > 2.5:
print('Average error greater than 2.5%')

assert averror < 2.5
83 changes: 83 additions & 0 deletions Examples/Tests/FieldProbe/inputs_2d
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#################################
# Domain, Resolution & Numerics
#

# time-scale
stop_time = 0.016e-12 # [s]

# Coarse resolution with cell size = lambda/16 allows for quick CI tests
amr.n_cell = 320 192

# simulation box, no MR
# note: increase z (space & cells) for converging ion energy
amr.max_level = 0
geometry.dims = 2
geometry.prob_lo = -2e-6 -.4e-6 # [m]
geometry.prob_hi = 2e-6 2e-6

# Boundary condition
boundary.field_lo = absorbing_silver_mueller absorbing_silver_mueller
boundary.field_hi = absorbing_silver_mueller absorbing_silver_mueller

# Order of particle shape factors
algo.particle_shape = 1

# numerical tuning
warpx.cfl = 0.999
warpx.use_filter = 1 # bilinear current/charge filter

# field solver yee (default) ckc psatd (fft)
algo.maxwell_solver = yee

##################################
## Embedded Boundary

my_constants.sheetRadius = 6.25e-9 # [m] 1/2 cell
my_constants.slitWidth = 0.3e-6 # [m] width of slit = lambda * 2
warpx.eb_implicit_function = "(
if(abs(z)<=sheetRadius and abs(x)>=(slitWidth/2.0), 1.0, -1.0) )"

#################################
## Laser Pulse Profile
#
# Note: we make the beam really wide so it behaves like a plane wave
##
lasers.names = laser1
laser1.position = 0. 0. -.35e-6 # point the laser plane (antenna)
laser1.direction = 0. 0. 1. # the plane's (antenna's) normal direction
laser1.polarization = 1. 0. 0. # the main polarization vector
laser1.a0 = 0.001 # maximum amplitude of the laser field [V/m]
laser1.wavelength = .2e-6 # central wavelength of the laser pulse [m]
laser1.profile = Gaussian
laser1.profile_waist = 2.2e-5 # beam waist (E(w_0)=E_0/e) [m]
laser1.profile_duration = 5.e-15 # pulse length (E(tau)=E_0/e; tau=tau_E=FWHM_I/1.17741) [s]
laser1.profile_t_peak = 5.e-15 # time until peak intensity reached at the laser plane [s]
laser1.profile_focal_distance = .35e-6 # focal distance from the antenna [m]

#################################
## Diagnostics
##
diagnostics.diags_names = diag1
diag1.intervals = 100
diag1.diag_type = Full
#diag1.format = openpmd
diag1.fields_to_plot = Ex Ey Ez Bx By Bz

#################################
## Reduced Diagnostics
##
#
warpx.reduced_diags_names = FP_line
FP_line.type = FieldProbe
FP_line.intervals = 100
FP_line.integrate = 1
FP_line.probe_geometry = Line
FP_line.x_probe = -1.5e-6
FP_line.y_probe = 0.
FP_line.z_probe = 1.7e-6
FP_line.x1_probe = 1.5e-6
FP_line.y1_probe = 0.
FP_line.z1_probe = 1.7e-6
FP_line.resolution = 201

authors = "Tiberius Rheaume <tiberiusrheaume@lbl.gov>, Axel Huebl <axelhuebl@lbl.gov>"
29 changes: 27 additions & 2 deletions Examples/Tests/reduced_diags/inputs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ photons.uz_th = 0.2
#################################
###### REDUCED DIAGS ############
#################################
warpx.reduced_diags_names = EP NP EF PP PF MF FP FP_integrate MR FR_Max FR_Min FR_Integral
warpx.reduced_diags_names = EP NP EF PP PF MF MR FP FP_integrate FP_line FP_plane FR_Max FR_Min FR_Integral
EP.type = ParticleEnergy
EP.intervals = 200
EF.type = FieldEnergy
Expand All @@ -86,11 +86,36 @@ FP.x_probe = 0.53125
FP.y_probe = 0.53125
FP.z_probe = 0.53125
FP_integrate.type = FieldProbe
FP_integrate.intervals = 200
FP_integrate.intervals = 20
FP_integrate.probe_geometry = Point
FP_integrate.x_probe = 0.53125
FP_integrate.y_probe = 0.53125
FP_integrate.z_probe = 0.53125
FP_integrate.integrate = 1
FP_line.type = FieldProbe
FP_line.intervals = 200
FP_line.probe_geometry = Line
FP_line.x_probe = 0.53125
FP_line.y_probe = 0.53125
FP_line.z_probe = 0.53125
FP_line.x1_probe = 0.70225
FP_line.y1_probe = 0.70225
FP_line.z1_probe = 0.70225
FP_line.resolution = 100
FP_plane.type = FieldProbe
FP_plane.intervals = 200
FP_plane.probe_geometry = Plane
FP_plane.x_probe = 0.5
FP_plane.y_probe = 0.5
FP_plane.z_probe = 0.5
FP_plane.target_normal_x = 0
FP_plane.target_normal_y = 0
FP_plane.target_normal_z = 1
FP_plane.target_up_x = 0
FP_plane.target_up_y = 1
FP_plane.target_up_z = 0
FP_plane.detector_radius = 0.25
FP_plane.resolution = 10
MR.type = RhoMaximum
MR.intervals = 200
NP.type = ParticleNumber
Expand Down
17 changes: 17 additions & 0 deletions Regression/WarpX-tests.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2527,6 +2527,23 @@ doVis = 0
compareParticles = 0
analysisRoutine = Examples/Tests/ElectrostaticSphere/analysis_electrostatic_sphere.py

[FieldProbe]
buildDir = .
inputFile = Examples/Tests/FieldProbe/inputs_2d
runtime_params =
dim = 2
addToCompileString = USE_EB=TRUE
cmakeSetupOpts = -DWarpX_DIMS=2 -DWarpX_EB=ON
restartTest = 0
useMPI = 1
numprocs = 2
useOMP = 1
numthreads = 1
compileTest = 0
doVis = 0
compareParticles = 0
analysisRoutine = Examples/Tests/FieldProbe/analysis_field_probe.py

[embedded_circle]
buildDir = .
inputFile = Examples/Tests/embedded_circle/inputs_2d
Expand Down
1 change: 1 addition & 0 deletions Regression/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ matplotlib
mpi4py
numpy
openpmd-api
pandas
scipy
yt
40 changes: 37 additions & 3 deletions Source/Diagnostics/ReducedDiags/FieldProbe.H
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@

#include <unordered_map>
#include <string>
#include <vector>

/**
* This enumeration is used for assigning structural geometry levels (point vs line vs plane)
*/
enum struct DetectorGeometry
{
Point = 0,
Line,
Plane
};

/**
* This class mainly contains a function that computes the value of each component
Expand Down Expand Up @@ -52,18 +63,41 @@ public:
* Define constants used throughout FieldProbe
*/

//! noutputs is 7 (Ex, Ey, Ez, Bx, By, Bz, S)
static constexpr int noutputs = FieldProbePIdx::nattribs;
//! noutputs is 10 (x, y, z, Ex, Ey, Ez, Bx, By, Bz, S)
static constexpr int noutputs = FieldProbePIdx::nattribs + 3;

private:
amrex::Real x_probe, y_probe, z_probe;
amrex::Real x1_probe, y1_probe, z1_probe;
amrex::Real target_normal_x, target_normal_y, target_normal_z;
amrex::Real target_up_x, target_up_y, target_up_z;
amrex::Real detector_radius;

//! counts number of particles for all MPI ranks
long m_valid_particles {0};

//! determines geometry of detector point distribution
DetectorGeometry m_probe_geometry = DetectorGeometry::Point;

//! determines number of particles places for non-point geometries
int m_resolution = 0;

//! Empty vector for to which data is pushed
amrex::Vector<amrex::Real> m_data;

//! Empty array to be used by IOProcessor node to store and output data
amrex::Vector<amrex::Real> m_data_out;

//! this is the particle container in which probe particles are stored
FieldProbeParticleContainer m_probe;

//! if true, integrate values over time instead of probing instantaneous values
//! if true, integrate values over time instead of probing instantaneous values
bool m_field_probe_integrate = false;

//! particle shape used for field gather
int interp_order = 1;

//! Judges whether to gather raw fields or interpolated data
bool raw_fields = false;

/**
Expand Down
Loading

0 comments on commit 2efde6c

Please sign in to comment.