Skip to content

Commit

Permalink
Python: Expose Properties of ConstF (ECP-WarpX#464)
Browse files Browse the repository at this point in the history
Expose the focusing strength of the constant focusing element
to Python for manipulation.
  • Loading branch information
ax3l authored Nov 19, 2023
1 parent 6cfcf2d commit 82200fe
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
12 changes: 12 additions & 0 deletions docs/source/usage/python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,18 @@ This module provides elements for the accelerator lattice.
:param kt: Focusing strength for t in 1/m.
:param nslice: number of slices used for the application of space charge

.. py:property:: kx
focusing x strength in 1/m

.. py:property:: ky
focusing y strength in 1/m

.. py:property:: kt
focusing t strength in 1/m

.. py:class:: impactx.elements.DipEdge(psi, rc, g, K2)
Edge focusing associated with bend entry or exit
Expand Down
1 change: 0 additions & 1 deletion src/particles/elements/ConstF.H
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ namespace impactx

}

private:
amrex::ParticleReal m_kx; //! focusing x strength in 1/m
amrex::ParticleReal m_ky; //! focusing y strength in 1/m
amrex::ParticleReal m_kt; //! focusing t strength in 1/m
Expand Down
15 changes: 15 additions & 0 deletions src/python/elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,21 @@ void init_elements(py::module& m)
py::arg("ds"), py::arg("kx"), py::arg("ky"), py::arg("kt"), py::arg("nslice") = 1,
"A linear Constant Focusing element."
)
.def_property("kx",
[](ConstF & cf) { return cf.m_kx; },
[](ConstF & cf, amrex::ParticleReal kx) { cf.m_kx = kx; },
"focusing x strength in 1/m"
)
.def_property("ky",
[](ConstF & cf) { return cf.m_ky; },
[](ConstF & cf, amrex::ParticleReal ky) { cf.m_ky = ky; },
"focusing y strength in 1/m"
)
.def_property("kt",
[](ConstF & cf) { return cf.m_kt; },
[](ConstF & cf, amrex::ParticleReal kt) { cf.m_kt = kt; },
"focusing t strength in 1/m"
)
;
register_beamoptics_push(py_ConstF);

Expand Down

0 comments on commit 82200fe

Please sign in to comment.