Skip to content

Commit

Permalink
Merge branch 'hackathon-field-register' of github.com:ax3l/WarpX into…
Browse files Browse the repository at this point in the history
… hackathon-field-register
  • Loading branch information
RemiLehe committed Sep 18, 2024
2 parents f146fee + 9a7d864 commit 4608c21
Show file tree
Hide file tree
Showing 35 changed files with 948 additions and 251 deletions.
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.6.4
rev: v0.6.5
hooks:
# Run the linter
- id: ruff
Expand Down
2 changes: 2 additions & 0 deletions Docs/source/developers/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ If you need a new Python package dependency for testing, please add it in `Regre

Sometimes two or more tests share a large number of input parameters. The shared input parameters can be collected in a "base" input file that can be passed as a runtime parameter in the actual test input files through the parameter ``FILE``.

If the new test is added in a new directory that did not exist before, please add the name of that directory with the command ``add_subdirectory`` in `Physics_applications/CMakeLists.txt <https://github.com/ECP-WarpX/WarpX/tree/development/Examples/Physics_applications/CMakeLists.txt>`__ or `Tests/CMakeLists.txt <https://github.com/ECP-WarpX/WarpX/tree/development/Examples/Tests/CMakeLists.txt>`__, depending on where the new test directory is located.

Naming conventions for automated tests
--------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion Docs/source/install/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Optional dependencies include:
- `FFTW3 <http://www.fftw.org>`__: for spectral solver (PSATD or IGF) support when running on CPU or SYCL

- also needs the ``pkg-config`` tool on Unix
- `heFFTe 2.4.0+ <https://github.com/icl-utk-edu/heffte`__: for multi-node spectral solver (IGF) support
- `heFFTe 2.4.0+ <https://github.com/icl-utk-edu/heffte>`__: for multi-node spectral solver (IGF) support
- `BLAS++ <https://github.com/icl-utk-edu/blaspp>`__ and `LAPACK++ <https://github.com/icl-utk-edu/lapackpp>`__: for spectral solver (PSATD) support in RZ geometry
- `Boost 1.66.0+ <https://www.boost.org/>`__: for QED lookup tables generation support
- `openPMD-api 0.15.1+ <https://github.com/openPMD/openPMD-api>`__: we automatically download and compile a copy of openPMD-api for openPMD I/O support
Expand Down
4 changes: 2 additions & 2 deletions Docs/source/theory/kinetic_fluid_hybrid_model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ integrating over velocity), also called the generalized Ohm's law, is given by:

.. math::
en_e\vec{E} = \frac{m}{e}\frac{\partial \vec{J}_e}{\partial t} + \frac{m}{e^2}\left( \vec{U}_e\cdot\nabla \right) \vec{J}_e - \nabla\cdot {\overleftrightarrow P}_e - \vec{J}_e\times\vec{B}+\vec{R}_e
en_e\vec{E} = \frac{m}{e}\frac{\partial \vec{J}_e}{\partial t} + \frac{m}{e}\left( \vec{U}_e\cdot\nabla \right) \vec{J}_e - \nabla\cdot {\overleftrightarrow P}_e - \vec{J}_e\times\vec{B}+\vec{R}_e
where :math:`\vec{U}_e = \vec{J}_e/(en_e)` is the electron fluid velocity,
:math:`{\overleftrightarrow P}_e` is the electron pressure tensor and
Expand All @@ -64,7 +64,7 @@ Plugging this back into the generalized Ohm' law gives:
\left(en_e +\frac{m}{e\mu_0}\nabla\times\nabla\times\right)\vec{E} =&
- \frac{m}{e}\left( \frac{\partial\vec{J}_{ext}}{\partial t} + \sum_{s\neq e}\frac{\partial\vec{J}_s}{\partial t} \right) \\
&+ \frac{m}{e^2}\left( \vec{U}_e\cdot\nabla \right) \vec{J}_e - \nabla\cdot {\overleftrightarrow P}_e - \vec{J}_e\times\vec{B}+\vec{R}_e.
&+ \frac{m}{e}\left( \vec{U}_e\cdot\nabla \right) \vec{J}_e - \nabla\cdot {\overleftrightarrow P}_e - \vec{J}_e\times\vec{B}+\vec{R}_e.
If we now further assume electrons are inertialess (i.e. :math:`m=0`), the above equation simplifies to,

Expand Down
6 changes: 3 additions & 3 deletions Docs/source/theory/multiphysics/ionization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ where :math:`\mathrm{d}\tau` is the simulation timestep, which is divided by the
Empirical Extension to Over-the-Barrier Regime for Hydrogen
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For hydrogen, WarpX offers the modified empirical ADK extension to the Over-the-Barrier (OTB) published in :cite:t:`mpion-zhang_empirical_2014` Eq. (8).
For hydrogen, WarpX offers the modified empirical ADK extension to the Over-the-Barrier (OTB) published in :cite:t:`mpion-zhang_empirical_2014` Eq. (8) (note there is a typo in the paper and there should not be a minus sign in Eq. 8).

.. math::
W_\mathrm{M} = \exp\left[ -\left( a_1 \frac{E^2}{E_\mathrm{b}} + a_2 \frac{E}{E_\mathrm{b}} + a_3 \right) \right] W_\mathrm{ADK}
W_\mathrm{M} = \exp\left[ a_1 \frac{E^2}{E_\mathrm{b}} + a_2 \frac{E}{E_\mathrm{b}} + a_3 \right] W_\mathrm{ADK}
The parameters :math:`a_1` through :math:`a_3` are independent of :math:`E` and can be found in the same reference. :math:`E_\mathrm{b}` is the classical Barrier Suppresion Ionization (BSI) field strength :math:`E_\mathrm{b} = U_\mathrm{ion}^2 / (4 Z)` given here in atomic units (AU). For a detailed description of conversion between unit systems consider the book by :cite:t:`mpion-Mulser2010`.

Testing
^^^^^^^

* `Testing the field ionization module <../../../../Examples/Tests/field_ionization/README.rst>`_.
* `Testing the field ionization module <../../../../en/latest/usage/examples/field_ionization/README.html>`_.

.. bibliography::
:keyprefix: mpion-
65 changes: 39 additions & 26 deletions Docs/source/usage/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2129,14 +2129,24 @@ Time step
The ratio between the actual timestep that is used in the simulation
and the Courant-Friedrichs-Lewy (CFL) limit. (e.g. for `warpx.cfl=1`,
the timestep will be exactly equal to the CFL limit.)
This parameter will only be used with the electromagnetic solver.
For some speed v and grid spacing dx, this limits the timestep to `warpx.cfl * dx / v`.
When used with the electromagnetic solver, `v` is the speed of light.
For the electrostatic solver, `v` is the maximum speed among all particles in the domain.

* ``warpx.const_dt`` (`float`)
Allows direct specification of the time step size, in units of seconds.
When the electrostatic solver is being used, this must be supplied.
When the electrostatic solver is being used, this must be supplied if not using adaptive timestepping.
This can be used with the electromagnetic solver, overriding ``warpx.cfl``, but
it is up to the user to ensure that the CFL condition is met.

* ``warpx.dt_update_interval`` (`string`) optional (default `-1`)
How many iterations pass between timestep adaptations when using the electrostatic solver.
Must be greater than `0` to use adaptive timestepping, or else ``warpx.const_dt`` must be specified.

* ``warpx.max_dt`` (`float`) optional
The maximum timestep permitted for the electrostatic solver, when using adaptive timestepping.
If supplied, also sets the initial timestep for these simulations, before the first timestep update.

Filtering
^^^^^^^^^

Expand Down Expand Up @@ -3448,39 +3458,42 @@ Reduced Diagnostics
For 1D-Z, :math:`x`-related and :math:`y`-related quantities are not outputted.
RZ geometry is not supported yet.

* ``DifferentialLuminosity``
This type computes the differential luminosity between two species, defined as:
* ``DifferentialLuminosity``
This type computes the differential luminosity between two species, defined as:

.. math::
.. math::
\frac{d\mathcal{L}}{d\mathcal{E}^*}(\mathcal{E}^*, t) = \int_0^t dt'\int d\boldsymbol{x}\,d\boldsymbol{p}_1 d\boldsymbol{p}_2\;
\sqrt{ |\boldsymbol{v}_1 - \boldsymbol{v}_2|^2 - |\boldsymbol{v}_1\times\boldsymbol{v}_2|^2/c^2} \\ f_1(\boldsymbol{x}, \boldsymbol{p}_1, t')f_2(\boldsymbol{x}, \boldsymbol{p}_2, t') \delta(\mathcal{E}^* - \mathcal{E}^*(\boldsymbol{p}_1, \boldsymbol{p}_2))
\frac{d\mathcal{L}}{d\mathcal{E}^*}(\mathcal{E}^*, t) = \int_0^t dt'\int d\boldsymbol{x}\,d\boldsymbol{p}_1 d\boldsymbol{p}_2\;
\sqrt{ |\boldsymbol{v}_1 - \boldsymbol{v}_2|^2 - |\boldsymbol{v}_1\times\boldsymbol{v}_2|^2/c^2} \\ f_1(\boldsymbol{x}, \boldsymbol{p}_1, t')f_2(\boldsymbol{x}, \boldsymbol{p}_2, t') \delta(\mathcal{E}^* - \mathcal{E}^*(\boldsymbol{p}_1, \boldsymbol{p}_2))
where :math:`\mathcal{E}^*(\boldsymbol{p}_1, \boldsymbol{p}_2) = \sqrt{m_1^2c^4 + m_2^2c^4 + 2(m_1 m_2 c^4
\gamma_1 \gamma_2 - \boldsymbol{p}_1\cdot\boldsymbol{p}_2 c^2)}` is the energy in the center-of-mass frame,
and :math:`f_i` is the distribution function of species :math:`i`. Note that, if :math:`\sigma^*(\mathcal{E}^*)`
is the center-of-mass cross-section of a given collision process, then
:math:`\int d\mathcal{E}^* \frac{d\mathcal{L}}{d\mathcal{E}^*} (\mathcal{E}^*, t)\sigma^*(\mathcal{E}^*)`
gives the total number of collisions of that process (from the beginning of the simulation up until time :math:`t`).

where :math:`\mathcal{E}^*(\boldsymbol{p}_1, \boldsymbol{p}_2) = \sqrt{m_1^2c^4 + m_2^2c^4 + 2(m_1 m_2 c^4
\gamma_1 \gamma_2 - \boldsymbol{p}_1\cdot\boldsymbol{p}_2 c^2)}` is the energy in the center-of-mass frame,
and :math:`f_i` is the distribution function of species :math:`i`. Note that, if :math:`\sigma^*(\mathcal{E}^*)`
is the center-of-mass cross-section of a given collision process, then
:math:`\int d\mathcal{E}^* \frac{d\mathcal{L}}{d\mathcal{E}^*} (\mathcal{E}^*, t)\sigma^*(\mathcal{E}^*)`
gives the total number of collisions of that process (from the beginning of the simulation up until time :math:`t`).
The differential luminosity is given in units of :math:`\text{m}^{-2}.\text{eV}^{-1}`. For collider-relevant WarpX simulations
involving two crossing, high-energy beams of particles, the differential luminosity in :math:`\text{s}^{-1}.\text{m}^{-2}.\text{eV}^{-1}`
can be obtained by multiplying the above differential luminosity by the expected repetition rate of the beams.

The differential luminosity is given in units of :math:`\text{m}^{-2}.\text{eV}^{-1}`. For collider-relevant WarpX simulations
involving two crossing, high-energy beams of particles, the differential luminosity in :math:`\text{s}^{-1}.\text{m}^{-2}.\text{eV}^{-1}`
can be obtained by multiplying the above differential luminosity by the expected repetition rate of the beams.
In practice, the above expression of the differential luminosity is evaluated over discrete bins in energy :math:`\mathcal{E}^*`,
and by summing over macroparticles.

In practice, the above expression of the differential luminosity is evaluated over discrete bins in energy :math:`\mathcal{E}^*`,
and by summing over macroparticles.
* ``<reduced_diags_name>.species`` (`list of two strings`)
The names of the two species for which the differential luminosity is computed.

* ``<reduced_diags_name>.species`` (`list of two strings`)
The names of the two species for which the differential luminosity is computed.
* ``<reduced_diags_name>.bin_number`` (`int` > 0)
The number of bins in energy :math:`\mathcal{E}^*`

* ``<reduced_diags_name>.bin_number`` (`int` > 0)
The number of bins in energy :math:`\mathcal{E}^*`
* ``<reduced_diags_name>.bin_max`` (`float`, in eV)
The minimum value of :math:`\mathcal{E}^*` for which the differential luminosity is computed.

* ``<reduced_diags_name>.bin_max`` (`float`, in eV)
The minimum value of :math:`\mathcal{E}^*` for which the differential luminosity is computed.
* ``<reduced_diags_name>.bin_min`` (`float`, in eV)
The maximum value of :math:`\mathcal{E}^*` for which the differential luminosity is computed.

* ``<reduced_diags_name>.bin_min`` (`float`, in eV)
The maximum value of :math:`\mathcal{E}^*` for which the differential luminosity is computed.
* ``Timestep``
This type outputs the simulation's physical timestep (in seconds) at each mesh refinement level.

* ``<reduced_diags_name>.intervals`` (`string`)
Using the `Intervals Parser`_ syntax, this string defines the timesteps at which reduced
Expand Down
49 changes: 45 additions & 4 deletions Examples/Physics_applications/beam_beam_collision/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ We turn on the Quantum Synchrotron QED module for photon emission (also known as
the Breit-Wheeler QED module for the generation of electron-positron pairs (also known as coherent pair generation in the collider community).

To solve for the electromagnetic field we use the nodal version of the electrostatic relativistic solver.
This solver computes the average velocity of each species, and solves the corresponding relativistic Poisson equation (see the WarpX documentation for `warpx.do_electrostatic = relativistic` for more detail). This solver accurately reproduced the subtle cancellation that occur for some component of the ``E + v x B`` terms which are crucial in simulations of relativistic particles.
This solver computes the average velocity of each species, and solves the corresponding relativistic Poisson equation (see the WarpX documentation for `warpx.do_electrostatic = relativistic` for more detail).
This solver accurately reproduces the subtle cancellation that occur for some component of ``E + v x B``, which are crucial in simulations of relativistic particles.


This example is based on the following paper :cite:t:`ex-Yakimenko2019`.
Expand All @@ -26,20 +27,23 @@ For `MPI-parallel <https://www.mpi-forum.org>`__ runs, prefix these lines with `

.. literalinclude:: inputs_test_3d_beam_beam_collision
:language: ini
:caption: You can copy this file from ``Examples/Physics_applications/beam-beam_collision/inputs_test_3d_beam_beam_collision``.
:caption: You can copy this file from ``Examples/Physics_applications/beam_beam_collision/inputs_test_3d_beam_beam_collision``.


Visualize
---------

The figure below shows the number of photons emitted per beam particle (left) and the number of secondary pairs generated per beam particle (right).

We compare different results:
We compare different results for the reduced diagnostics with the literature:
* (red) simplified WarpX simulation as the example stored in the directory ``/Examples/Physics_applications/beam-beam_collision``;
* (blue) large-scale WarpX simulation (high resolution and ad hoc generated tables ;
* (black) literature results from :cite:t:`ex-Yakimenko2019`.

The small-scale simulation has been performed with a resolution of ``nx = 64, ny = 64, nz = 64`` grid cells, while the large-scale one has a much higher resolution of ``nx = 512, ny = 512, nz = 1024``. Moreover, the large-scale simulation uses dedicated QED lookup tables instead of the builtin tables. To generate the tables within WarpX, the code must be compiled with the flag ``-DWarpX_QED_TABLE_GEN=ON``. For the large-scale simulation we have used the following options:
The small-scale simulation has been performed with a resolution of ``nx = 64, ny = 64, nz = 64`` grid cells, while the large-scale one has a much higher resolution of ``nx = 512, ny = 512, nz = 1024``.
Moreover, the large-scale simulation uses dedicated QED lookup tables instead of the builtin tables.
To generate the tables within WarpX, the code must be compiled with the flag ``-DWarpX_QED_TABLE_GEN=ON``.
For the large-scale simulation we have used the following options:

.. code-block:: ini
Expand All @@ -63,8 +67,45 @@ The small-scale simulation has been performed with a resolution of ``nx = 64, ny
qed_bw.tab_pair_frac_how_many=512
qed_bw.save_table_in=my_bw_table.txt
.. figure:: https://gist.github.com/user-attachments/assets/2dd43782-d039-4faa-9d27-e3cf8fb17352
:alt: Beam-beam collision benchmark against :cite:t:`ex-Yakimenko2019`.
:width: 100%

Beam-beam collision benchmark against :cite:t:`ex-Yakimenko2019`.


Below are two visualizations scripts that provide examples to graph the field and reduced diagnostics.
They are available in the ``Examples/Physics_applications/beam-beam_collision/`` folder and can be run as simply as ``python3 plot_fields.py`` and ``python3 plot_reduced.py``.

.. tab-set::

.. tab-item:: Field Diagnostics

This script visualizes the evolution of the fields (:math:`|E|, |B|, \rho`) during the collision between the two ultra-relativistic lepton beams.
The magnitude of E and B and the charge densities of the primary beams and of the secondary pairs are sliced along either one of the two transverse coordinates (:math:`x` and :math:`y`).

.. literalinclude:: plot_fields.py
:language: python3
:caption: You can copy this file from ``Examples/Physics_applications/beam-beam_collision/plot_fields.py``.

.. figure:: https://gist.github.com/user-attachments/assets/04c9c0ec-b580-446f-a11a-437c1b244a41
:alt: Slice across :math:`x` of different fields (:math:`|E|, |B|, \rho`) at timestep 45, in the middle of the collision.
:width: 100%

Slice across :math:`x` of different fields (:math:`|E|, |B|, \rho`) at timestep 45, in the middle of the collision.


.. tab-item:: Reduced Diagnostics

A similar script to the one below was used to produce the image showing the benchmark against :cite:t:`ex-Yakimenko2019`.

.. literalinclude:: plot_reduced.py
:language: python3
:caption: You can copy this file from ``Examples/Physics_applications/beam-beam_collision/plot_reduced.py``.

.. figure:: https://gist.github.com/user-attachments/assets/c280490a-f1f2-4329-ad3c-46817d245dc1
:alt: Photon and pair production rates in time throughout the collision.
:width: 100%

Photon and pair production rates in time throughout the collision.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ warpx.do_qed_schwinger = 0.
# FULL
diagnostics.diags_names = diag1

diag1.intervals = 0
diag1.intervals = 15
diag1.diag_type = Full
diag1.write_species = 1
diag1.fields_to_plot = Ex Ey Ez Bx By Bz rho_beam1 rho_beam2 rho_ele1 rho_pos1 rho_ele2 rho_pos2
Expand Down
Loading

0 comments on commit 4608c21

Please sign in to comment.