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

Add automated test for particle absorption on new stair-case approximation #5562

Merged
merged 34 commits into from
Jan 22, 2025

Conversation

RemiLehe
Copy link
Member

@RemiLehe RemiLehe commented Jan 15, 2025

This introduces automated tests in 2D, 3D and RZ, as a follow up to #5534, to check that a particle does not leave a spurious charge behind, when absorbed by the embedded boundary, and when using an EM solver.

In this test, the embedded boundary is a cylinder aligned with the z axis. (In 2D, this reduces to two parallel plates.)

The tests fail on the development branch, before #5534 is merged. They pass after #5534 is merged.

movie

Note that these tests fails for higher-order shapes. This will be fixed in #5209

@RemiLehe RemiLehe changed the title [WIP] Add automated test for new stair-case approximation [WIP] Add automated test for particle absorption on new stair-case approximation Jan 15, 2025
Add file for checksum tests

Update comment
roelof-groenewald pushed a commit that referenced this pull request Jan 21, 2025
# Overview

This PR changes the definition of the stair-case approximation of the EB
(used in the Yee solver), so that the actual EB boundary (where e.g.
particles are removed from the simulation) is **inside** the
stair-case-approximated boundary - as opposed to the definition used in
the current `development` branch, for which the actual EB is **outside**
the stair-case-approximated boundary.

This ensures that the algorithm remains charge conserving, when charged
particles are absorbed or emitted by the embedded boundary, **for
particle shape of order 1**. (Higher-order particle shapes will be
addressed in #5209.) As illustrated in the figure below (and as
discussed in [this
paper](https://www.researchgate.net/publication/318642364_Charge_Conserving_Emission_from_Conformal_Boundaries_in_Electromagnetic_PIC_simulations)),
this is fundamentally because the particle does not deposit any charge
in the valid cells, at the time when it is removed/emitted.

<img width="608" alt="Screenshot 2025-01-12 at 8 56 17 AM"
src="https://github.com/user-attachments/assets/bd803ef0-faf8-4ea5-973b-240c15b2ba4b"
/>

(The black crosses show the locations where the electric field is not
updated, and thus usually remains equal to 0. The red dots show the
locations where the particle deposits charge, for particle shape of
order 1.)

The better behavior with respect to charge-conservation can be observed
in the following animations, which show two particles of opposing charge
separating and going into the embedded boundary. (Note that a static
error in `divE` remains at the position where the particle was absorbed,
with the `development` branch. The propagating errors in `divE` are
expected: they are due to electromagnetic waves reflecting on the EB.)

- **development branch**

![movie](https://github.com/user-attachments/assets/d486663d-a182-4751-b1d1-709b1a74ea44)

- **this PR**

![movie](https://github.com/user-attachments/assets/94a5dea3-2bb8-4548-b320-7615cac86fe7)

Input script:
[inputs.txt](https://github.com/user-attachments/files/18428873/inputs.txt)
Analysis script:
[openPMD-visualization.ipynb.txt](https://github.com/user-attachments/files/18428878/openPMD-visualization.ipynb.txt)

(An automated tests using a similar configuration has been added in a
separate, follow-up PR: #5562)

Note that, as part of this PR, the above new definition has been adopted
for all the finite-difference solvers, except for the ECT solver (which
uses a cut-cell representation instead of a stair-case representation).

# Implementation

This PR uses the changes of #5574. It still uses `MarkUpdateECellsECT`
and `MarkUpdateBCellsECT` for the ECT sover - which preserve the
previous behavior of the embedded boundary for this solver, but now uses
`MarkUpdateCellsStairCase` for the other FDTD solvers - which introduce
the above-mentioned new stair-case definition.
@RemiLehe RemiLehe changed the title [WIP] Add automated test for particle absorption on new stair-case approximation Add automated test for particle absorption on new stair-case approximation Jan 22, 2025
Copy link
Member

@roelof-groenewald roelof-groenewald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice test! There was just one typo I spotted in the comment below, then it should be ready to merge.

…is.py

Co-authored-by: Roelof Groenewald <40245517+roelof-groenewald@users.noreply.github.com>
@RemiLehe RemiLehe enabled auto-merge (squash) January 22, 2025 17:25
@RemiLehe RemiLehe merged commit f13c05a into BLAST-WarpX:development Jan 22, 2025
37 checks passed
@ax3l ax3l added the component: boundary PML, embedded boundaries, et al. label Jan 28, 2025
RemiLehe added a commit that referenced this pull request Jan 28, 2025
**Description edited by @RemiLehe**

# Overview

This PR reduces the particle shape to order 1, when the particle gets
closer to the embedded boundary:
<img width="991" alt="Screenshot 2025-01-23 at 8 46 34 AM"
src="https://github.com/user-attachments/assets/2e206606-110e-4018-aedc-385567fe43e7"
/>

This ensures that the particle does not deposit charge in valid cells,
at the time when it is removed, which in turn ensures proper charge
conservation with the electromagnetic solver.

# Implementation

- This PR allocates and initializes a new mask
`eb_reduce_particle_shape` (and `iMultiFab`) that indicates in which
cells to reduce the particle shape.
- The deposition kernels have been modified to use this flag. In order
to make sure that this PR does not affect the performance of the
deposition kernel in the absence of EB, two versions of the deposition
kernel are compiled.

# Tests

This PR adds tests similar to the ones introduced in
#5562 to check for charge
conservation near the embedded boundary, but with higher-order shape
factors:

- The 2D tests fail on `development` for shape 2 and 3 but pass on this
PR.
- For some reason, the 3D and RZ tests only fail on `development` for
shape 3 ; they do pass for this PR. It is not clear why the tests do not
fail on `development` with shape 2.

**Note:** For now, this PR only modifies the current deposition (and
only the Esirkepov kernel). A follow-up PR will also modify the charge
deposition.

---------

Co-authored-by: Remi Lehe <remi.lehe@normalesup.org>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: boundary PML, embedded boundaries, et al.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants