Skip to content

Commit

Permalink
Add README documentation for distgen (#583)
Browse files Browse the repository at this point in the history
* Examples for 3D space charge benchmarking

- Modified the initial beam size in the IOTA lens benchmark example.
- Added 2 benchmarks of 3D space charge for initial testing.
- Add documentation for 2 benchmarks with space charge.
- Add a benchmark example with space charge and periodic s-dependent focusing.
- Added an s-dependent example using a Kurth beam without space charge.
- Modified tolerance for IOTA lens benchmark example.
  Reduced tolerance to account for smaller initial beam size and
  improved preservation of invariants of motion.
- Modified tolerances of space charge examples to allow CI tests to
  pass when space charge is not active.

- Modified tolerance for space charge examples.
  These should fail unless space charge is turned on.

* Update input_kurth_10nC.in

Selected numerical values for amr.n_cell, lattice.nslice, and geometry.prob_relative.

* Add README documentation for examples/distgen

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

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

* Delete examples/kurth/input_kurth_10nC.in

Not part of this PR.

* Update README.rst

Fix line breaks.

* Add examples/distgen in docs/source/usage/examples.rst

* Update README.rst

Changed t, pt to math mode.

* Update README.rst

Modify README to create tabs/subheadings

* Update examples.rst

Modify docs/source/usage/examples.rst to add subheading for distgen.

* Update README.rst

Try modifying headings.

* Update examples.rst

Reduce :maxdepth: for initialize_from_array/README.

* Clear duplicate line

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Axel Huebl <[email protected]>
  • Loading branch information
3 people authored May 1, 2024
1 parent 006c2af commit 0c5e85b
Show file tree
Hide file tree
Showing 2 changed files with 264 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/source/usage/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ Beam Distributions
.. toctree::
:maxdepth: 1

examples/initialize_from_array/README.rst
examples/initialize_from_array/README

.. note::

We need to document the ``examples/distgen/`` examples here.
.. toctree::
:maxdepth: 2

examples/distgen/README

Lattice Design & Optimization
-----------------------------
Expand Down
260 changes: 260 additions & 0 deletions examples/distgen/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@

Generation of beam distributions
***************************************

The following examples are tests of beam initialization for distributions of various types.

In each example, we use a 2 GeV electron beam with initial unnormalized rms emittance of 2 nm.

The matched Twiss parameters are the same as those used in the FODO example:

* :math:`\beta_\mathrm{x} = 2.82161941` m
* :math:`\alpha_\mathrm{x} = -1.59050035`
* :math:`\beta_\mathrm{y} = 2.82161941` m
* :math:`\alpha_\mathrm{y} = 1.59050035`

The second moments of the particle distribution after the FODO cell should coincide with the second moments of the particle distribution before the FODO cell, to within the level expected due to noise due to statistical sampling.

In this test, the initial and final values of :math:`\lambda_x`, :math:`\lambda_y`, :math:`\lambda_t`, :math:`\epsilon_x`, :math:`\epsilon_y`, and :math:`\epsilon_t` must agree with nominal values.


.. _examples-distgen-gaussian:

A 6d Gaussian distribution
=============================

A Gaussian distribution in all 6 phase space variables.

In this test, the initial and final values of :math:`\lambda_x`, :math:`\lambda_y`, :math:`\lambda_t`, :math:`\epsilon_x`, :math:`\epsilon_y`, and :math:`\epsilon_t` must agree with nominal values.


Run
---

This example can be run **either** as:

* **Python** script: ``python3 run_gaussian.py`` or
* ImpactX **executable** using an input file: ``impactx input_gaussian.in``

For `MPI-parallel <https://www.mpi-forum.org>`__ runs, prefix these lines with ``mpiexec -n 4 ...`` or ``srun -n 4 ...``, depending on the system.

.. tab-set::

.. tab-item:: Python: Script

.. literalinclude:: run_gaussian.py
:language: python3
:caption: You can copy this file from ``examples/distgen/run_gaussian.py``.

.. tab-item:: Executable: Input File

.. literalinclude:: input_gaussian.in
:language: ini
:caption: You can copy this file from ``examples/distgen/input_gaussian.in``.


Analyze
-------

We run the following script to analyze correctness:

.. dropdown:: Script ``analysis_gaussian.py``

.. literalinclude:: analysis_gaussian.py
:language: python3
:caption: You can copy this file from ``examples/distgen/analysis_gaussian.py``.



.. _examples-distgen-kvdist:

A Kapchinskij-Vladimirskij (K-V) distribution
===============================================

A 4D K-V distribution in the transverse phase space variables ( + a longitudinally uniform distribution in :math:`t` + a Gaussian distribution in :math:`p_t` ).

In this test, the initial and final values of :math:`\lambda_x`, :math:`\lambda_y`, :math:`\lambda_t`, :math:`\epsilon_x`, :math:`\epsilon_y`, and :math:`\epsilon_t` must agree with nominal values.


Run
---

This example can be run **either** as:

* **Python** script: ``python3 run_kvdist.py`` or
* ImpactX **executable** using an input file: ``impactx input_kvdist.in``

For `MPI-parallel <https://www.mpi-forum.org>`__ runs, prefix these lines with ``mpiexec -n 4 ...`` or ``srun -n 4 ...``, depending on the system.

.. tab-set::

.. tab-item:: Python: Script

.. literalinclude:: run_kvdist.py
:language: python3
:caption: You can copy this file from ``examples/distgen/run_kvdist.py``.

.. tab-item:: Executable: Input File

.. literalinclude:: input_kvdist.in
:language: ini
:caption: You can copy this file from ``examples/distgen/input_kvdist.in``.


Analyze
-------

We run the following script to analyze correctness:

.. dropdown:: Script ``analysis_kvdist.py``

.. literalinclude:: analysis_kvdist.py
:language: python3
:caption: You can copy this file from ``examples/distgen/analysis_kvdist.py``.




.. _examples-distgen-kvdist_from_twiss:

A K-V distribution initialized from Twiss functions
======================================================

Identical to the previous example (examples-kvdist), but initialized using Courant-Snyder Twiss functions.

In this test, the initial and final values of :math:`\lambda_x`, :math:`\lambda_y`, :math:`\lambda_t`, :math:`\epsilon_x`, :math:`\epsilon_y`, and :math:`\epsilon_t` must agree with nominal values.


Run
---

This example can be run **either** as:

* **Python** script: ``python3 run_kvdist_from_twiss.py`` or
* ImpactX **executable** using an input file: ``impactx input_kvdist_from_twiss.in``

For `MPI-parallel <https://www.mpi-forum.org>`__ runs, prefix these lines with ``mpiexec -n 4 ...`` or ``srun -n 4 ...``, depending on the system.

.. tab-set::

.. tab-item:: Python: Script

.. literalinclude:: run_kvdist_from_twiss.py
:language: python3
:caption: You can copy this file from ``examples/distgen/run_kvdist_from_twiss.py``.

.. tab-item:: Executable: Input File

.. literalinclude:: input_kvdist_from_twiss.in
:language: ini
:caption: You can copy this file from ``examples/distgen/input_kvdist_from_twiss.in``.


Analyze
-------

We run the following script to analyze correctness:

.. dropdown:: Script ``analysis_kvdist_from_twiss.py``

.. literalinclude:: analysis_kvdist_from_twiss.py
:language: python3
:caption: You can copy this file from ``examples/distgen/analysis_kvdist_from_twiss.py``.




.. _examples-distgen-kurth4d:

A 4D Kurth Distribution
============================

A 4D Kurth distribution in the transverse phase space variables ( + a longitudinally uniform distribution in :math:`t` + a Gaussian distribution in :math:`p_t` ).


In this test, the initial and final values of :math:`\lambda_x`, :math:`\lambda_y`, :math:`\lambda_t`, :math:`\epsilon_x`, :math:`\epsilon_y`, and :math:`\epsilon_t` must agree with nominal values.

Run
---

This example can be run **either** as:

* **Python** script: ``python3 run_kurth4d.py`` or
* ImpactX **executable** using an input file: ``impactx input_kurth4d.in``

For `MPI-parallel <https://www.mpi-forum.org>`__ runs, prefix these lines with ``mpiexec -n 4 ...`` or ``srun -n 4 ...``, depending on the system.

.. tab-set::

.. tab-item:: Python: Script

.. literalinclude:: run_kurth4d.py
:language: python3
:caption: You can copy this file from ``examples/distgen/run_kurth4d.py``.

.. tab-item:: Executable: Input File

.. literalinclude:: input_kurth4d.in
:language: ini
:caption: You can copy this file from ``examples/distgen/input_kurth4d.in``.


Analyze
-------

We run the following script to analyze correctness:

.. dropdown:: Script ``analysis_kurth4d.py``

.. literalinclude:: analysis_kurth4d.py
:language: python3
:caption: You can copy this file from ``examples/distgen/analysis_kurth4d.py``.




.. _examples-distgen-semigaussian:

A Semigaussian distribution
=============================

A 6D semigaussian distribution (uniform in position, Gaussian in momentum).

In this test, the initial and final values of :math:`\lambda_x`, :math:`\lambda_y`, :math:`\lambda_t`, :math:`\epsilon_x`, :math:`\epsilon_y`, and :math:`\epsilon_t` must agree with nominal values.


Run
---

This example can be run **either** as:

* **Python** script: ``python3 run_semigaussian.py`` or
* ImpactX **executable** using an input file: ``impactx input_semigaussian.in``

For `MPI-parallel <https://www.mpi-forum.org>`__ runs, prefix these lines with ``mpiexec -n 4 ...`` or ``srun -n 4 ...``, depending on the system.

.. tab-set::

.. tab-item:: Python: Script

.. literalinclude:: run_semigaussian.py
:language: python3
:caption: You can copy this file from ``examples/distgen/run_semigaussian.py``.

.. tab-item:: Executable: Input File

.. literalinclude:: input_semigaussian.in
:language: ini
:caption: You can copy this file from ``examples/distgen/input_semigaussian.in``.


Analyze
-------

We run the following script to analyze correctness:

.. dropdown:: Script ``analysis_semigaussian.py``

.. literalinclude:: analysis_semigaussian.py
:language: python3
:caption: You can copy this file from ``examples/distgen/analysis_semigaussian.py``.

0 comments on commit 0c5e85b

Please sign in to comment.