Skip to content

Commit

Permalink
fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
lucafedeli88 committed Feb 11, 2025
2 parents 809c5a5 + 2cc4fd2 commit 8fc7415
Show file tree
Hide file tree
Showing 99 changed files with 1,203 additions and 1,034 deletions.
6 changes: 4 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Checks: '
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-init-variables,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-missing-std-forward,
-cppcoreguidelines-narrowing-conversions,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-owning-memory,
Expand All @@ -29,6 +30,7 @@ Checks: '
misc-*,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-misc-include-cleaner,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-return-braced-init-list,
Expand All @@ -44,7 +46,6 @@ Checks: '
-readability-implicit-bool-conversion,
-readability-isolate-declaration,
-readability-magic-numbers,
-readability-misleading-indentation,
-readability-named-parameter,
-readability-uppercase-literal-suffix
'
Expand All @@ -58,6 +59,7 @@ CheckOptions:
value: "true"
- key: misc-use-anonymous-namespace.HeaderFileExtensions
value: "H,"

- key: performance-move-const-arg.CheckTriviallyCopyableMove
value: "false"

HeaderFilterRegex: 'Source[a-z_A-Z0-9\/]+\.H$'
8 changes: 4 additions & 4 deletions .github/workflows/clang_tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- uses: actions/checkout@v4
- name: install dependencies
run: |
.github/workflows/dependencies/clang.sh 16
.github/workflows/dependencies/clang.sh 17
- name: set up cache
uses: actions/cache@v4
with:
Expand All @@ -43,8 +43,8 @@ jobs:
export CCACHE_LOGFILE=${{ github.workspace }}/ccache.log.txt
ccache -z
export CXX=$(which clang++-16)
export CC=$(which clang-16)
export CXX=$(which clang++-17)
export CC=$(which clang-17)
cmake -S . -B build_clang_tidy \
-DCMAKE_VERBOSE_MAKEFILE=ON \
Expand All @@ -62,7 +62,7 @@ jobs:
${{github.workspace}}/.github/workflows/source/makeMakefileForClangTidy.py --input ${{github.workspace}}/ccache.log.txt
make -j4 --keep-going -f clang-tidy-ccache-misses.mak \
CLANG_TIDY=clang-tidy-16 \
CLANG_TIDY=clang-tidy-17 \
CLANG_TIDY_ARGS="--config-file=${{github.workspace}}/.clang-tidy --warnings-as-errors=*"
ccache -s
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
which nvcc || echo "nvcc not in PATH!"
git clone https://github.com/AMReX-Codes/amrex.git ../amrex
cd ../amrex && git checkout --detach 78bdf0faabc4101d5333ebb421e553efcc7ec04e && cd -
cd ../amrex && git checkout --detach 198da4879a63f1bc8c4e8d674bf9185525318f61 && cd -
make COMP=gcc QED=FALSE USE_MPI=TRUE USE_GPU=TRUE USE_OMP=FALSE USE_FFT=TRUE USE_CCACHE=TRUE -j 4
ccache -s
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ repos:
# Python: Ruff linter & formatter
# https://docs.astral.sh/ruff/
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.4
rev: v0.9.6
hooks:
# Run the linter
- id: ruff
Expand Down
1 change: 1 addition & 0 deletions Docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ sphinx-copybutton
sphinx-design
sphinx_rtd_theme>=1.1.1
sphinxcontrib-bibtex
sphinxcontrib-googleanalytics
sphinxcontrib-napoleon
yt # for checksumAPI
5 changes: 5 additions & 0 deletions Docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@
"sphinx_design",
"breathe",
"sphinxcontrib.bibtex",
"sphinxcontrib.googleanalytics",
]

# Google Analytics
googleanalytics_id = "G-QZGY5060MZ"
googleanalytics_enabled = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

Expand Down
2 changes: 1 addition & 1 deletion Docs/source/developers/particles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Attribute name ``int``/``real`` Description Wher
Wheeler process physics is used.
==================== ================ ================================== ===== ==== ======================

WarpX allows extra runtime attributes to be added to particle containers (through ``NewRealComp("attrname")`` or ``NewIntComp("attrname")``).
WarpX allows extra runtime attributes to be added to particle containers (through ``AddRealComp("attrname")`` or ``AddIntComp("attrname")``).
The attribute name can then be used to access the values of that attribute.
For example, using a particle iterator, ``pti``, to loop over the particles the command ``pti.GetAttribs(particle_comps["attrname"]).dataPtr();`` will return the values of the ``"attrname"`` attribute.

Expand Down
17 changes: 16 additions & 1 deletion Docs/source/highlights.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ Plasma-Based Acceleration

Scientific works in laser-plasma and beam-plasma acceleration.

#. Shrock JE, Rockafellow E, Miao B, Le M, Hollinger RC, Wang S, Gonsalves AJ, Picksley A, Rocca JJ, and Milchberg HM
#. Ma M, Zeng M, Wang J, Lu G, Yan W, Chen L, and Li D.
**Particle-in-cell simulation of laser wakefield accelerators with oblique lasers in quasicylindrical geometry**.
Phys. Rev. Accel. Beams **28**, 021301, 2025
`DOI:10.1103/PhysRevAccelBeams.28.021301 <https://doi.org/10.1103/PhysRevAccelBeams.28.021301>`__

#. Shrock JE, Rockafellow E, Miao B, Le M, Hollinger RC, Wang S, Gonsalves AJ, Picksley A, Rocca JJ, and Milchberg HM.
**Guided Mode Evolution and Ionization Injection in Meter-Scale Multi-GeV Laser Wakefield Accelerators**.
Phys. Rev. Lett. **133**, 045002, 2024
`DOI:10.1103/PhysRevLett.133.045002 <https://link.aps.org/doi/10.1103/PhysRevLett.133.045002>`__
Expand Down Expand Up @@ -154,6 +159,16 @@ High Energy Astrophysical Plasma Physics

Scientific works in astrophysical plasma modeling.

#. Jambunathan R, Jones H, Corrales L, Klion H, Roward ME, Myers A, Zhang W, Vay J-L.
**Application of mesh refinement to relativistic magnetic reconnection**.
Physics of Plasmas ***32*** 1, 2025
`DOI:10.1063/5.0233583 <https://doi.org/10.1063/5.0233583>`__

#. Ghosh S, Bhat P.
**Magnetic Reconnection: An Alternative Explanation of Radio Emission in Galaxy Clusters**.
The Astrophysical Journal Letters **979** 1, 2025.
`DOI:10.3847/2041-8213/ad9f2d <https://doi.org/10.3847/2041-8213/ad9f2d>`__

#. Klion H, Jambunathan R, Rowan ME, Yang E, Willcox D, Vay J-L, Lehe R, Myers A, Huebl A, Zhang W.
**Particle-in-Cell simulations of relativistic magnetic reconnection with advanced Maxwell solver algorithms**.
The Astrophysical Journal **952** 8, 2023.
Expand Down
11 changes: 11 additions & 0 deletions Docs/source/refs.bib
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ @ARTICLE{Birdsall1991
year = {1991}
}

@misc{Janssen2016
author = {Janssen, J. F. J. and Pitchford L. C. and Hagelaar G. J. M. and van Dijk J.},
doi = {10.1088/0963-0252/25/5/055026},
journal = {Plasma Sources Science and Technology},
number = {5},
pages = {055026},
title = {{Evaluation of angular scattering models for electron-neutral collisions in Monte Carlo simulations}},
volume = {25},
year = {2016}
}

@misc{Lim2007,
author = {Lim, Chul-Hyun},
issn = {0419-4217},
Expand Down
20 changes: 20 additions & 0 deletions Docs/source/theory/boundary_conditions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,23 @@ the right boundary is reflecting.

.. bibliography::
:keyprefix: bc-

.. _theory-bc-pmc:

Perfect Magnetic Conductor
----------------------------

This boundary can be used to model a symmetric surface, where charges and current are
symmetric across the boundary.
This is equivalent to the Neumann (zero-derivative) boundary condition.
For the electromagnetic solve, at PMC, the tangential magnetic field and the normal electric
field are odd across the boundary and set to 0 on the boundary.
In the guard-cell region, those fields are set equal and
opposite to the respective field component in the mirror location across the PMC boundary.
The other components, the normal magnetic field and tangential electric field, are even
and set equal to the field component in the mirror location in the domain across the PMC boundary.

The PMC boundary condition also impacts the deposition of charge and current density.
The charge and current densities deposited into the guard cells are reflected back into
the domain, adding them to the mirror cells in the domain.
This represents the charge and current from the virtual symmetric particles in the guard cells.
12 changes: 11 additions & 1 deletion Docs/source/theory/multiphysics/collisions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,23 @@ The particle velocity in the COM frame is then isotropically scattered using the
Back scattering
^^^^^^^^^^^^^^^

The process is the same as for elastic scattering above expect the scattering angle is fixed at :math:`\pi`, meaning the particle velocity in the COM frame is updated to :math:`-\vec{u}_c`.
The process is the same as for elastic scattering above except the scattering angle is fixed at :math:`\pi`, meaning the particle velocity in the COM frame is updated to :math:`-\vec{u}_c`.

Excitation
^^^^^^^^^^

The process is also the same as for elastic scattering except the excitation energy cost is subtracted from the particle energy. This is done by reducing the velocity before a scattering angle is chosen.

Forward scattering
^^^^^^^^^^^^^^^^^^

This process operates in two ways:

1. If an excitation energy cost is provided, the energy cost is subtracted from the particle energy and no scattering is performed.
2. If an excitation energy cost is not provided, the particle is not scattered and the velocity is unchanged (corresponding to a scattering angle of :math:`0` in the elastic scattering process above).

See :cite:t:`b-Janssen2016` for a recommended use of this process.

Benchmarks
----------

Expand Down
6 changes: 4 additions & 2 deletions Docs/source/usage/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,8 @@ Domain Boundary Conditions

* ``pec``: This option can be used to set a Perfect Electric Conductor at the simulation boundary. Please see the :ref:`PEC theory section <theory-bc-pec>` for more details. Note that PEC boundary is invalid at `r=0` for the RZ solver. Please use ``none`` option. This boundary condition does not work with the spectral solver.

* ``pmc``: This option can be used to set a Perfect Magnetic Conductor at the simulation boundary. Please see the :ref:`PEC theory section <theory-bc-pmc>` for more details. This is equivalent to ``Neumann``. This boundary condition does not work with the spectral solver.

* ``pec_insulator``: This option specifies a mixed perfect electric conductor and insulator boundary, where some part of the
boundary is PEC and some is insulator. In the insulator portion, the normal fields are extrapolated and the tangential fields
are either set to the specified value or extrapolated. The region that is insulator is specified using a spatially dependent expression with the insulator being in the area where the value of the expression is greater than zero.
Expand Down Expand Up @@ -2167,8 +2169,8 @@ Details about the collision models can be found in the :ref:`theory section <mul

* ``<collision_name>.scattering_processes`` (`strings` separated by spaces)
Only for ``dsmc`` and ``background_mcc``. The scattering processes that should be
included. Available options are ``elastic``, ``back`` & ``charge_exchange``
for ions and ``elastic``, ``excitationX`` & ``ionization`` for electrons.
included. Available options are ``elastic``, ``excitationX``, ``forward``, ``back``, and ``charge_exchange``
for ions and ``elastic``, ``excitationX``, ``ionization`` & ``forward`` for electrons.
Multiple excitation events can be included for electrons corresponding to
excitation to different levels, the ``X`` above can be changed to a unique
identifier for each excitation process. For each scattering process specified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ def add_particles():
##########################

assert elec_wrapper.nps == 270 / (2 - args.unique)
assert elec_wrapper.particle_container.get_comp_index("w") == 2
assert elec_wrapper.particle_container.get_comp_index("newPid") == 6
assert elec_wrapper.particle_container.get_real_comp_index("w") == 2
assert elec_wrapper.particle_container.get_real_comp_index("newPid") == 6

new_pid_vals = elec_wrapper.get_particle_real_arrays("newPid", 0)
for vals in new_pid_vals:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@
elec_count = elec_wrapper.nps

# check that the runtime attributes have the right indices
assert elec_wrapper.particle_container.get_comp_index("prev_x") == 6
assert elec_wrapper.particle_container.get_comp_index("prev_z") == 7
assert elec_wrapper.particle_container.get_real_comp_index("prev_x") == 6
assert elec_wrapper.particle_container.get_real_comp_index("prev_z") == 7

# sanity check that the prev_z values are reasonable and
# that the correct number of values are returned
Expand Down
10 changes: 10 additions & 0 deletions Examples/Tests/pec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ add_warpx_test(
OFF # dependency
)

add_warpx_test(
test_3d_pmc_field # name
3 # dims
2 # nprocs
inputs_test_3d_pmc_field # inputs
"analysis_pec.py diags/diag1000134" # analysis
"analysis_default_regression.py --path diags/diag1000134" # checksum
OFF # dependency
)

add_warpx_test(
test_2d_pec_field_insulator_implicit # name
2 # dims
Expand Down
54 changes: 54 additions & 0 deletions Examples/Tests/pec/inputs_test_3d_pmc_field
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Set-up to test the PMC Boundary condition for the fields
# Constructive interference between the incident and reflected wave result in a
# standing wave.

# max step
max_step = 134

# number of grid points
amr.n_cell = 32 32 256

# Maximum allowable size of each subdomain
amr.max_grid_size = 1024
amr.blocking_factor = 32

amr.max_level = 0

# Geometry
geometry.dims = 3
geometry.prob_lo = -8.e-6 -8.e-6 -4.e-6
geometry.prob_hi = 8.e-6 8.e-6 4.e-6

# Boundary condition
boundary.field_lo = periodic periodic pmc
boundary.field_hi = periodic periodic pmc

warpx.serialize_initial_conditions = 1

# Verbosity
warpx.verbose = 1

# Algorithms
algo.current_deposition = esirkepov
# CFL
warpx.cfl = 0.9


my_constants.z1 = -2.e-6
my_constants.z2 = 2.e-6
my_constants.wavelength = 1.e-6
warpx.E_ext_grid_init_style = parse_E_ext_grid_function
warpx.Ez_external_grid_function(x,y,z) = "0."
warpx.Ex_external_grid_function(x,y,z) = "0."
warpx.Ey_external_grid_function(x,y,z) = "((1.e5*sin(2*pi*(z)/wavelength)) * (z<z2) * (z>z1))"

warpx.B_ext_grid_init_style = parse_B_ext_grid_function
warpx.Bx_external_grid_function(x,y,z)= "(((-1.e5*sin(2*pi*(z)/wavelength))/clight))*(z<z2) * (z>z1) "
warpx.By_external_grid_function(x,y,z)= "0."
warpx.Bz_external_grid_function(x,y,z) = "0."

# Diagnostics
diagnostics.diags_names = diag1
diag1.intervals = 134
diag1.diag_type = Full
diag1.fields_to_plot = Ey Bx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@
np.random.seed(30025025)

electron_wrapper = particle_containers.ParticleContainerWrapper("electrons")
electron_wrapper.add_real_comp("newPid")
if not sim.amr_restart:
electron_wrapper.add_real_comp("newPid")


def add_particles():
Expand Down Expand Up @@ -140,8 +141,8 @@ def add_particles():
##########################

assert electron_wrapper.nps == 90
assert electron_wrapper.particle_container.get_comp_index("w") == 2
assert electron_wrapper.particle_container.get_comp_index("newPid") == 6
assert electron_wrapper.particle_container.get_real_comp_index("w") == 2
assert electron_wrapper.particle_container.get_real_comp_index("newPid") == 6

new_pid_vals = electron_wrapper.get_particle_real_arrays("newPid", 0)
for vals in new_pid_vals:
Expand Down
16 changes: 9 additions & 7 deletions Python/pywarpx/particle_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ def add_particles(
# --- Note that the velocities are handled separately and not included in attr
# --- (even though they are stored as attributes in the C++)
for key, vals in kwargs.items():
attr[:, self.particle_container.get_comp_index(key) - built_in_attrs] = vals
attr[
:, self.particle_container.get_real_comp_index(key) - built_in_attrs
] = vals

nattr_int = 0
attr_int = np.empty([0], dtype=np.int32)
Expand Down Expand Up @@ -264,7 +266,7 @@ def get_particle_real_arrays(self, comp_name, level, copy_to_host=False):
List of arrays
The requested particle array data
"""
comp_idx = self.particle_container.get_comp_index(comp_name)
comp_idx = self.particle_container.get_real_comp_index(comp_name)

data_array = []
for pti in libwarpx.libwarpx_so.WarpXParIter(self.particle_container, level):
Expand Down Expand Up @@ -309,7 +311,7 @@ def get_particle_int_arrays(self, comp_name, level, copy_to_host=False):
List of arrays
The requested particle array data
"""
comp_idx = self.particle_container.get_icomp_index(comp_name)
comp_idx = self.particle_container.get_int_comp_index(comp_name)

data_array = []
for pti in libwarpx.libwarpx_so.WarpXParIter(self.particle_container, level):
Expand Down Expand Up @@ -842,16 +844,16 @@ def get_particle_boundary_buffer(self, species_name, boundary, comp_name, level)
)
data_array = []
# loop over the real attributes
if comp_name in part_container.real_comp_names:
comp_idx = part_container.real_comp_names[comp_name]
if comp_name in part_container.real_soa_names:
comp_idx = part_container.get_real_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.get_real_data(comp_idx), copy=False))
# loop over the integer attributes
elif comp_name in part_container.int_comp_names:
comp_idx = part_container.int_comp_names[comp_name]
elif comp_name in part_container.int_soa_names:
comp_idx = part_container.get_int_comp_index(comp_name)
for ii, pti in enumerate(
libwarpx.libwarpx_so.BoundaryBufferParIter(part_container, level)
):
Expand Down
Loading

0 comments on commit 8fc7415

Please sign in to comment.