Skip to content
Open
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
77509bc
Add initial element and integrator routines in draft form.
cemitch99 May 15, 2025
d169e14
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 15, 2025
c812000
Add literals.
cemitch99 May 15, 2025
a1ab4b3
Resolve conflicts, and add comments.
cemitch99 Jun 25, 2025
d5cf7da
Merge branch 'development' into add_user_nonlinear_element
cemitch99 Jun 25, 2025
1048cd3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 25, 2025
5a0c003
Update Integrators.H
cemitch99 Jun 25, 2025
d46ed68
Fix parameter documentation in new integrator step.
cemitch99 Jul 16, 2025
2a27e8a
Add both particle copies as arguments to internal push map.
cemitch99 Jul 16, 2025
9cded9e
Clean-up and addition of map for a general Hamiltonian.
cemitch99 Jul 17, 2025
a0ec35d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 17, 2025
91b5f53
Add preliminary initialization of VectorPotential element.
cemitch99 Jul 17, 2025
3916603
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 17, 2025
1e41d52
Eliminate calls to Print to avoid errors.
cemitch99 Jul 17, 2025
4969aa4
Add maybe_unused to avoid unused variable warnings.
cemitch99 Jul 17, 2025
c5db4f9
Attempt to eliminate host-device error.
cemitch99 Jul 17, 2025
2e8beca
Remove debug print statement.
cemitch99 Jul 17, 2025
606fd2f
Update map using Hamiltonian derivatives.
cemitch99 Jul 17, 2025
a260f86
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 17, 2025
d4dcaf5
Delete unnecessary comments.
cemitch99 Jul 17, 2025
436a2e1
Comment unused az.
cemitch99 Jul 17, 2025
4c2c6cc
Add normalization of field strength.
cemitch99 Jul 17, 2025
f45a5e6
User-Provided Functions
ax3l Jul 19, 2025
f719d99
Fix Doxygen
ax3l Jul 19, 2025
69e4101
Start Python Binding
ax3l Jul 19, 2025
0352e3b
Clean-up and add quad example.
cemitch99 Jul 24, 2025
4ae8893
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 24, 2025
a18d89b
Add maybe_unused to avoid unused variable errors.
cemitch99 Jul 24, 2025
be59b79
Simplify user syntax and add examples to CMake.
cemitch99 Jul 24, 2025
7586bda
Merge branch 'development' into add_user_nonlinear_element
cemitch99 Jul 24, 2025
15880bc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 24, 2025
30d65ee
Update CMakeLists.txt
cemitch99 Jul 24, 2025
cfb68ef
Update CMakeLists.txt
cemitch99 Jul 24, 2025
6548dad
Fix treatment of s-dependence.
cemitch99 Jul 27, 2025
9e36876
Add soft-edge solenoid example.
cemitch99 Jul 27, 2025
514d9fa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 27, 2025
5920daf
Correct Doxygen in VectorPotential.H
cemitch99 Jul 27, 2025
67ed24d
Rename VectorPotential to MagnetostaticVectorPotential.
cemitch99 Jul 29, 2025
cd697cb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 29, 2025
5b3352a
Remove unused t-variable from Parser.
cemitch99 Jul 29, 2025
c7545f6
Add draft of element documentation.
cemitch99 Jul 29, 2025
368c822
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 29, 2025
821ad9e
Add support for 4th-order and 6th-order integration.
cemitch99 Jul 31, 2025
45b451e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 31, 2025
f5fd763
Merge remote-tracking branch 'mainline/development' into add_user_non…
ax3l Aug 6, 2025
6f370ed
CUDA CI: More Disk Space
ax3l Aug 6, 2025
2cd129d
Small Cleanup
ax3l Aug 6, 2025
59abec1
CUDA CI: -j 3
ax3l Aug 7, 2025
2fb715d
CUDA CI: -j 2
ax3l Aug 8, 2025
90d1ffe
Relax tolerance analysis_exact_quad_vector_potential.py
cemitch99 Aug 11, 2025
91b8eb0
Relax tolerance analysis_solenoid_vector_potential.py
cemitch99 Aug 11, 2025
4d2f67d
CUDA CI: -j 1
ax3l Aug 11, 2025
ed67c24
Merge branch 'development' into add_user_nonlinear_element
cemitch99 Aug 12, 2025
66555cb
CMake: Unify Test Names
ax3l Aug 13, 2025
7ff35f6
Relax Tolerances
ax3l Aug 13, 2025
2aa0e1c
Relax Tolerances
ax3l Aug 13, 2025
3be5620
Merge remote-tracking branch 'mainline/development' into add_user_non…
ax3l Aug 13, 2025
ae1ac85
Fix (Some): Py FODO Vector Example
ax3l Aug 13, 2025
0bdf431
Fix (Some): Py Solenoid Vector Example
ax3l Aug 13, 2025
801f5a2
Fix (Some): Py Quad Vector Example
ax3l Aug 13, 2025
ee56530
Make input_exact_quad_vector_potential.in exactly coincide with run_e…
cemitch99 Aug 28, 2025
faf0546
Delete irrelevant comments in input_solenoid_vector_potential.in
cemitch99 Aug 28, 2025
4888129
Merge branch 'development' into add_user_nonlinear_element
cemitch99 Oct 7, 2025
10101e4
Update examples/vector_potential/analysis_fodo_vector_potential.py
cemitch99 Oct 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .github/workflows/cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@ jobs:
CXXFLAGS: "-Werror"
CMAKE_GENERATOR: Ninja
steps:
- uses: actions/checkout@v5
- name: Free More Disk Space
uses: ax3l/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false # apt takes ~1:30min
docker-images: true
swap-storage: false

- uses: actions/checkout@v4

- name: install dependencies
run: |
Expand Down Expand Up @@ -53,4 +64,4 @@ jobs:
-DImpactX_PRECISION=SINGLE \
-DAMReX_CUDA_ERROR_CROSS_EXECUTION_SPACE_CALL=ON \
-DAMReX_CUDA_ERROR_CAPTURE_THIS=ON
cmake --build build -j 4
cmake --build build -j 1
1 change: 1 addition & 0 deletions docs/source/usage/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Single Particle Dynamics
examples/reversibility/README.rst
examples/charge_sign/README.rst
examples/symplectic_integration/README.rst
examples/vector_potential/README.rst


Collective Effects
Expand Down
33 changes: 33 additions & 0 deletions docs/source/usage/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,39 @@ This element requires these additional parameters:
* ``<element_name>.rotation`` (``float``, in degrees) rotation error in the transverse plane


``magnetostatic_vector_potential``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Symplectic integration in a user-defined magnetostatic vector potential, using the exact Hamiltonian, which includes all
nonlinear kinematic effects. Integration is performed with respect to a Cartesian coordinate system local to the body of
the element. A symmetric, semi-explicit symplectic integration scheme is used, based on:

B. Jayawardana and T. Ohsawa, ``Semiexplicit symplectic integrators for non-separable Hamiltonian systems,"
Math. Comput. 92, pp. 251-281 (2022), `DOI:10.1090/mcom/3778 <https://doi.org/10.1090/mcom/3778>`__

This element requires these additional parameters:

* ``<element_name>.ds`` (``float``, in meters) the segment length
* ``<element_name>.unit`` (``integer``) specification of units for the vector potential (default: ``0``)
Copy link
Member

@ax3l ax3l Aug 13, 2025

Choose a reason for hiding this comment

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

This is called unit while the inputs file (app API) calls it units

By default, the vector potential is normalized by magnetic rigidity. Use ``unit=1`` to specify using SI units.
* ``<element_name>.A_x(x,y,z)`` (``float``, dimensionless OR in Tesla-meters) formula for horizontal component of vector potential
* ``<element_name>.A_y(x,y,z)`` (``float``, dimensionless OR in Tesla-meters) formula for vertical component of vector potential
* ``<element_name>.dA_x/dx(x,y,z)`` (``float``, in 1/meters OR in Tesla) formula for x-derivative of A_x component
* ``<element_name>.dA_x/dy(x,y,z)`` (``float``, in 1/meters OR in Tesla) formula for y-derivative of A_x component
* ``<element_name>.dA_y/dx(x,y,z)`` (``float``, in 1/meters OR in Tesla) formula for x-derivative of A_y component
* ``<element_name>.dA_y/dy(x,y,z)`` (``float``, in 1/meters OR in Tesla) formula for y-derivative of A_y component
* ``<element_name>.dA_z/dx(x,y,z)`` (``float``, in 1/meters OR in Tesla) formula for x-derivative of A_z component
* ``<element_name>.dA_z/dy(x,y,z)`` (``float``, in 1/meters OR in Tesla) formula for y-derivative of A_z component
* ``<element_name>.dx`` (``float``, in meters) horizontal translation error
* ``<element_name>.dy`` (``float``, in meters) vertical translation error
* ``<element_name>.rotation`` (``float``, in degrees) rotation error in the transverse plane
* ``<element_name>.aperture_x`` (``float``, in meters) horizontal half-aperture (elliptical)
* ``<element_name>.aperture_y`` (``float``, in meters) vertical half-aperture (elliptical)
* ``<element_name>.int_order`` (``integer``) the order used for symplectic integration (2, 4, or 6) (default: ``2``)
* ``<element_name>.mapsteps`` (``integer``) number of integration steps per slice used for symplectic integration (default: ``5``)
* ``<element_name>.nslice`` (``integer``) number of slices used for the application of space charge (default: ``1``)


``multipole``
^^^^^^^^^^^^^

Expand Down
52 changes: 52 additions & 0 deletions docs/source/usage/python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,58 @@ This module provides elements and methods for the accelerator lattice.
:param rotation: rotation error in the transverse plane [degrees]
:param name: an optional name for the element


.. py:class:: impactx.elements.MagnetostaticVectorPotential(ds, unit=0, ax="0", ay="0", daxdx="0", daxdy="0", daydx="0", daydy="0", dazdx="0", dazdy="0", dx=0, dy=0, rotation=0, aperture_x=0,
aperture_y=0, int_order=2, mapsteps=5, nslice=1, name=None)

Symplectic integration in a user-defined magnetostatic vector potential, using the exact Hamiltonian, which includes all
nonlinear kinematic effects. Integration is performed with respect to a Cartesian coordinate system local to the body of
the element. A symmetric, semi-explicit symplectic integration scheme is used, based on:

B. Jayawardana and T. Ohsawa, ``Semiexplicit symplectic integrators for non-separable Hamiltonian systems,"
Math. Comput. 92, pp. 251-281 (2022), `DOI:10.1090/mcom/3778 <https://doi.org/10.1090/mcom/3778>`__

This element requires these additional parameters:

:param ds: Segment length in m.
:param unit: specification of units for the vector potential and its derivatives
0 (default) normalize all quantities by the magnetic rigidity
1 provide all quantities in SI units
:param ax: formula for horizontal component of vector potential (dimensionless, if unit = 0 OR in T-m if unit = 1)
:param ay: formula for vertical component of vector potential (dimensionless, if unit = 0 OR in T-m if unit = 1)
:param daxdx: formula for x-derivative of A_x component (in 1/meter, if unit = 0 OR in T if unit = 1)
:param daxdy: formula for y-derivative of A_x component (in 1/meter, if unit = 0 OR in T if unit = 1)
:param daydx: formula for x-derivative of A_y component (in 1/meter, if unit = 0 OR in T if unit = 1)
:param daydy: formula for y-derivative of A_y component (in 1/meter, if unit = 0 OR in T if unit = 1)
:param dazdx: formula for x-derivative of A_z component (in 1/meter, if unit = 0 OR in T if unit = 1)
:param dazdy: formula for y-derivative of A_z component (in 1/meter, if unit = 0 OR in T if unit = 1)
:param dx: horizontal translation error in m
:param dy: vertical translation error in m
:param rotation: rotation error in the transverse plane [degrees]
:param aperture_x: horizontal half-aperture (elliptical) in m
:param aperture_y: vertical half-aperture (elliptical) in m
:param int_order: the order used for symplectic integration (2, 4, or 6)
:param mapsteps: number of integration steps per slice used for symplectic integration
:param nslice: number of slices used for the application of space charge
:param name: an optional name for the element

.. py:property:: k

quadrupole strength in 1/m^2 (or T/m)

.. py:property:: unit

unit specification for quad strength

.. py:property:: int_order

the order used for symplectic integration (2, 4, or 6)

.. py:property:: mapsteps

number of integration steps per slice used for symplectic integration


.. py:class:: impactx.elements.ChrPlasmaLens(ds, k, unit=0, dx=0, dy=0, rotation=0, aperture_x=0, aperture_y=0, nslice=1, name=None)

An active cylindrically symmetric plasma lens, with chromatic effects included.
Expand Down
48 changes: 48 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,38 @@ add_impactx_test(dogleg-jitter.py
OFF # no plot script yet
)

# Symplectic Integration in a FODO Cell Based on User-Provided Vector Potential ##############
#
# no space charge
add_impactx_test(fodo-vector-potential
examples/vector_potential/input_fodo_vector_potential.in
ON # ImpactX MPI-parallel
examples/vector_potential/analysis_fodo_vector_potential.py
OFF # no plot script yet
)
add_impactx_test(fodo-vector-potential.py
examples/vector_potential/run_fodo_vector_potential.py
ON # ImpactX MPI-parallel
examples/vector_potential/analysis_fodo_vector_potential.py
OFF # no plot script yet
)

# Symplectic Integration in Exact Quads Based on User-Provided Vector Potential ##############
#
# no space charge
add_impactx_test(exact-quad-vector-potential
examples/vector_potential/input_exact_quad_vector_potential.in
ON # ImpactX MPI-parallel
examples/vector_potential/analysis_exact_quad_vector_potential.py
OFF # no plot script yet
)
add_impactx_test(exact-quad-vector-potential.py
examples/vector_potential/run_exact_quad_vector_potential.py
ON # ImpactX MPI-parallel
examples/vector_potential/analysis_exact_quad_vector_potential.py
OFF # no plot script yet
)

# HTU Beamline Model ##############
#
# no space charge
Expand Down Expand Up @@ -1559,6 +1591,22 @@ add_impactx_test(exact-cfbend_multipole.py
OFF # no plot script yet
)

# Symplectic Integration Through a Soft-Edge Solenoid Using a User-Provided Vector Potential ##############
#
# no space charge
add_impactx_test(solenoid-vector-potential
examples/vector_potential/input_solenoid_vector_potential.in
ON # ImpactX MPI-parallel
examples/vector_potential/analysis_solenoid_vector_potential.py
OFF # no plot script yet
)
add_impactx_test(solenoid-vector-potential.py
examples/vector_potential/run_solenoid_vector_potential.py
ON # ImpactX MPI-parallel
examples/vector_potential/analysis_solenoid_vector_potential.py
OFF # no plot script yet
)

# FODO Cell Based on PALS-Compliant Lattice Input ##############
#
# copy PALS lattice file
Expand Down
128 changes: 128 additions & 0 deletions examples/vector_potential/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
.. _examples-fodo-vector-potential:

Symplectic Integration in a FODO Cell Based on User-Provided Vector Potential
=============================================================================

This benchmark tests the implementation of the element MagnetostaticVectorPotential, which uses symplectic integration based on the exact nonlinear Hamiltonian for a user-provided vector
potential. The physical example is identical to examples-fodo, except that the vector potential in the quadrupoles is provided in formulae by the user.

The analysis script is identical to the analysis script used for ``examples-fodo``.

Run
---

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

* **Python** script: ``python3 run_fodo_vector_potential.py`` or
* ImpactX **executable** using an input file: ``impactx input_fodo_vector_potential.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_fodo_vector_potential.py
:language: python3
:caption: You can copy this file from ``examples/vector_potential/run_fodo_vector_potential.py``.

.. tab-item:: Executable: Input File

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


Analyze
-------

We run the following script to analyze correctness:

.. dropdown:: Script ``analysis_fodo_vector_potential.py``

.. literalinclude:: analysis_fodo_vector_potential.py
:language: python3
:caption: You can copy this file from ``examples/vector_potential/analysis_vector_potential.py``.


.. _examples-exact-quad-vector-potential:

Symplectic Integration in Exact Quads Based on User-Provided Vector Potential
=============================================================================

This benchmark tests the implementation of the element MagnetostaticVectorPotential, which uses symplectic integration based on the exact nonlinear Hamiltonian for a user-provided vector
potential. The physical example is identical to examples-exact-quad, except that the vector potential in the quadrupoles is provided in formulae by the user.

The analysis script is identical to the analysis script used for ``examples-exact-quad``.

Run
---

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

* **Python** script: ``python3 run_exact_quad_vector_potential.py`` or
* ImpactX **executable** using an input file: ``impactx input_exact_quad_vector_potential.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_exact_quad_vector_potential.py
:language: python3
:caption: You can copy this file from ``examples/vector_potential/run_exact_quad_vector_potential.py``.

.. tab-item:: Executable: Input File

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


Analyze
-------

We run the following script to analyze correctness:

.. dropdown:: Script ``analysis_exact_quad_vector_potential.py``

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



.. _examples-solenoid-vector-potential:

Symplectic Integration Through a Soft-Edge Solenoid Based on User-Provided Vector Potential
============================================================================================

This benchmark tests the implementation of the element MagnetostaticVectorPotential, which uses symplectic integration based on the exact nonlinear Hamiltonian for a user-provided vector
potential. The physical example is identical to examples-solenoid-softedge, except that the vector potential of the solenoid is provided in formulae by the user.

The analysis script is identical to the analysis script used for ``examples-solenoid-softedge``.

Run
---

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

* **Python** script: ``python3 run_solenoid_vector_potential.py`` or
* ImpactX **executable** using an input file: ``impactx input_solenoid_vector_potential.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_solenoid_vector_potential.py
:language: python3
:caption: You can copy this file from ``examples/vector_potential/run_solenoid_vector_potential.py``.

.. tab-item:: Executable: Input File

.. literalinclude:: input_solenoid_vector_potential.in
:language: ini
:caption: You can copy this file from ``examples/vector_potential/input_solenoid_vector_potential.in``.
Loading
Loading