Skip to content

Commit

Permalink
Add Python bindings and element docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
cemitch99 committed Mar 25, 2024
1 parent 88b2ce3 commit f70ba83
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/source/usage/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,22 @@ Lattice Elements
* ``<element_name>.dy`` (``float``, in meters) vertical translation error
* ``<element_name>.rotation`` (``float``, in degrees) rotation error in the transverse plane

* ``tapered_pl`` for a thin nonlinear (tapered) plasma lens.
This requires these additional parameters:

* ``<element_name>.k`` (``float``, in inverse meters OR in T) the integrated plasma lens focusing strength
= (length in m) * (azimuthal magnetic field gradient in T/m) / (magnetic rigidity in T-m) - if units = 0

OR = (length in m) * (azimuthal magnetic field gradient in T/m) - if units = 1

* ``<element_name>.units`` (``integer``) specification of units (default: ``0``)
* ``<element_name>.taper`` (``float``, in 1/meters) horizontal taper parameter
= 1 / (target horizontal dispersion in m)

* ``<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

* ``beam_monitor`` a beam monitor, writing all beam particles at fixed ``s`` to openPMD files.
If the same element name is used multiple times, then an output series is created with multiple outputs.

Expand Down
29 changes: 29 additions & 0 deletions docs/source/usage/python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,35 @@ This module provides elements for the accelerator lattice.

* G. Ripken and F. Schmidt, Thin-Lens Formalism for Tracking, CERN/SL/95-12 (AP), 1995.

.. py:class:: impactx.elements.TaperedPL(k, taper, units, dx=0, dy=0, rotation=0)
An active cylindrically symmetric plasma lens, with chromatic effects included.
The Hamiltonian is expanded through second order in the transverse variables
(x,px,y,py), with the exact pt dependence retained.

:param k: integrated focusing strength in m^(-1) (if units = 0)
= (length in m) * (azimuthal magnetic field gradient in T/m) / (rigidity in T-m)
OR integrated focusing strength in T (if units = 1)
= (length in m) * (azimuthal magnetic field gradient in T/m)
:param taper: horizontal taper parameter in m^(-1)
= 1 / (target horizontal dispersion in m)
:param units: specification of units for plasma lens focusing strength
:param dx: horizontal translation error in m
:param dy: vertical translation error in m
:param rotation: rotation error in the transverse plane [degrees]

.. py:property:: k
integrated plasma lens focusing strength in 1/m (or T)

.. py:property:: taper
horizontal taper parameter in 1/m

.. py:property:: units
unit specification for plasma lens focusing strength


Coordinate Transformation
-------------------------
Expand Down
32 changes: 32 additions & 0 deletions src/python/elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,38 @@ void init_elements(py::module& m)
;
register_beamoptics_push(py_ThinDipole);

py::class_<TaperedPL, elements::Thin, elements::Alignment> py_TaperedPL(me, "TaperedPL");
py_TaperedPL
.def("__repr__",
[](TaperedPL const & taperedpl) {
std::string r = "<impactx.elements.TaperedPL (taperedpl=";
r.append(std::to_string(taperedpl.m_k))
.append(", k=")
.append(std::to_string(taperedpl.m_taper))
.append(", taper=")
.append(")>");
return r;
}
)
.def(py::init<
amrex::ParticleReal,
amrex::ParticleReal,
int,
amrex::ParticleReal,
amrex::ParticleReal,
amrex::ParticleReal
>(),
py::arg("k"),
py::arg("taper"),
py::arg("units") = 0,
py::arg("dx") = 0,
py::arg("dy") = 0,
py::arg("rotation") = 0,
"A thin nonlinear plasma lens with transverse taper."
)
;
register_beamoptics_push(py_TaperedPL);


// free-standing push function
m.def("push", &Push,
Expand Down

0 comments on commit f70ba83

Please sign in to comment.