Skip to content

Commit

Permalink
Modify naming x_aperture -> aperture_x.
Browse files Browse the repository at this point in the history
  • Loading branch information
cemitch99 committed Jan 10, 2025
1 parent fb572fe commit 68bb406
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 43 deletions.
4 changes: 2 additions & 2 deletions docs/source/usage/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ Lattice Elements
* ``<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>.x_aperture`` (``float``, in meters) horizontal half-aperture (elliptical)
* ``<element_name>.y_aperture`` (``float``, in meters) vertical half-aperture (elliptical)
* ``<element_name>.aperture_x`` (``float``, in meters) horizontal half-aperture (elliptical)
* ``<element_name>.aperture_y`` (``float``, in meters) vertical half-aperture (elliptical)
* ``<element_name>.nslice`` (``integer``) number of slices used for the application of space charge (default: ``1``)

* ``drift_chromatic`` for a free drift, with chromatic effects included.
Expand Down
6 changes: 3 additions & 3 deletions docs/source/usage/python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -570,16 +570,16 @@ This module provides elements 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.Drift(ds, dx=0, dy=0, rotation=0, x_aperture=0, y_aperture=0, nslice=1, name=None)
.. py:class:: impactx.elements.Drift(ds, dx=0, dy=0, rotation=0, aperture_x=0, aperture_y=0, nslice=1, name=None)
A drift.

:param ds: Segment length in m
:param dx: horizontal translation error in m
:param dy: vertical translation error in m
:param rotation: rotation error in the transverse plane [degrees]
:param x_aperture: horizontal half-aperture (elliptical) in m
:param y_aperture: vertical half-aperture (elliptical) in m
:param aperture_x: horizontal half-aperture (elliptical) in m
:param aperture_y: vertical half-aperture (elliptical) in m
:param nslice: number of slices used for the application of space charge
:param name: an optional name for the element

Expand Down
4 changes: 2 additions & 2 deletions examples/aperture/input_aperture_thick.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ monitor.backend = h5

drift.type = drift
drift.ds = 0.123
drift.x_aperture = 1.0e-3
drift.y_aperture = 1.5e-3
drift.aperture_x = 1.0e-3
drift.aperture_y = 1.5e-3


###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion examples/aperture/run_aperture_thick.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
sim.lattice.extend(
[
monitor,
elements.Drift(name="drift", ds=0.123, x_aperture=1.0e-3, y_aperture=1.5e-3),
elements.Drift(name="drift", ds=0.123, aperture_x=1.0e-3, aperture_y=1.5e-3),
monitor,
]
)
Expand Down
18 changes: 9 additions & 9 deletions src/initialization/InitElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,22 @@ namespace detail
return values;
}

/** Read the Aperture parameters x_aperture and y_aperture from inputs
/** Read the Aperture parameters aperture_x and aperture_y from inputs
*
* @param pp_element the element being read
* @return key-value pairs for x_aperture and y_aperture
* @return key-value pairs for aperture_x and aperture_y
*/
std::map<std::string, amrex::ParticleReal>
query_aperture (amrex::ParmParse& pp_element)
{
amrex::ParticleReal x_aperture = 0;
amrex::ParticleReal y_aperture = 0;
pp_element.query("x_aperture", x_aperture);
pp_element.query("y_aperture", y_aperture);
amrex::ParticleReal aperture_x = 0;
amrex::ParticleReal aperture_y = 0;
pp_element.query("aperture_x", aperture_x);
pp_element.query("aperture_y", aperture_y);

std::map<std::string, amrex::ParticleReal> values = {
{"x_aperture", x_aperture},
{"y_aperture", y_aperture}
{"aperture_x", aperture_x},
{"aperture_y", aperture_y}
};

return values;
Expand Down Expand Up @@ -152,7 +152,7 @@ namespace detail
auto a = detail::query_alignment(pp_element);
auto b = detail::query_aperture(pp_element);

m_lattice.emplace_back( Drift(ds, a["dx"], a["dy"], a["rotation_degree"], b["x_aperture"], b["y_aperture"], nslice, element_name) );
m_lattice.emplace_back( Drift(ds, a["dx"], a["dy"], a["rotation_degree"], b["aperture_x"], b["y_aperture"], nslice, element_name) );
} else if (element_type == "sbend")
{
auto const [ds, nslice] = detail::query_ds(pp_element, nslice_default);
Expand Down
10 changes: 5 additions & 5 deletions src/particles/elements/Drift.H
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ namespace impactx
* @param dx horizontal translation error in m
* @param dy vertical translation error in m
* @param rotation_degree rotation error in the transverse plane [degrees]
* @param x_aperture horizontal half-aperture in m
* @param y_aperture vertical half-aperture in m
* @param aperture_x horizontal half-aperture in m
* @param aperture_y vertical half-aperture in m
* @param nslice number of slices used for the application of space charge
* @param name a user defined and not necessarily unique name of the element
*/
Expand All @@ -54,15 +54,15 @@ namespace impactx
amrex::ParticleReal dx = 0,
amrex::ParticleReal dy = 0,
amrex::ParticleReal rotation_degree = 0,
amrex::ParticleReal x_aperture = 0,
amrex::ParticleReal y_aperture = 0,
amrex::ParticleReal aperture_x = 0,
amrex::ParticleReal aperture_y = 0,
int nslice = 1,
std::optional<std::string> name = std::nullopt
)
: Named(std::move(name)),
Thick(ds, nslice),
Alignment(dx, dy, rotation_degree),
Aperture(x_aperture, y_aperture)
Aperture(aperture_x, aperture_y)
{
}

Expand Down
30 changes: 15 additions & 15 deletions src/particles/elements/mixin/aperture.H
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ namespace impactx::elements

/** A finite-length element
*
* @param x_aperture horizontal half-aperture size in m
* @param y_aperture vertical half-aperture size in m
* @param aperture_x horizontal half-aperture size in m
* @param aperture_y vertical half-aperture size in m
*/
Aperture (
amrex::ParticleReal x_aperture,
amrex::ParticleReal y_aperture
amrex::ParticleReal aperture_x,
amrex::ParticleReal aperture_y
)
: m_x_aperture(x_aperture), m_y_aperture(y_aperture)
: m_aperture_x(aperture_x), m_aperture_y(aperture_y)
{
}

Expand All @@ -59,12 +59,12 @@ namespace impactx::elements
) const {
using namespace amrex::literals; // for _rt and _prt

// skip aperture application if x_aperture <= 0 or y_aperture <= 0
if (m_x_aperture > 0 && m_y_aperture > 0) {
// skip aperture application if aperture_x <= 0 or aperture_y <= 0
if (m_aperture_x > 0 && m_aperture_y > 0) {

// scale horizontal and vertical coordinates
amrex::ParticleReal const u = x / m_x_aperture;
amrex::ParticleReal const v = y / m_y_aperture;
amrex::ParticleReal const u = x / m_aperture_x;
amrex::ParticleReal const v = y / m_aperture_y;

// compare against the aperture boundary
if (std::pow(u,2) + std::pow(v,2) > 1_prt) {
Expand All @@ -79,23 +79,23 @@ namespace impactx::elements
* @return horizontal aperture size in m
*/
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
amrex::ParticleReal x_aperture () const
amrex::ParticleReal aperture_x () const
{
return m_x_aperture;
return m_aperture_x;
}

/** Vertical aperture size
*
* @return vertical aperture size in m
*/
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
amrex::ParticleReal y_aperture () const
amrex::ParticleReal aperture_y () const
{
return m_y_aperture;
return m_aperture_y;
}

amrex::ParticleReal m_x_aperture = 0; //! horizontal aperture size [m]
amrex::ParticleReal m_y_aperture = 0; //! vertical aperture size [m]
amrex::ParticleReal m_aperture_x = 0; //! horizontal aperture size [m]
amrex::ParticleReal m_aperture_y = 0; //! vertical aperture size [m]
};

} // namespace impactx::elements
Expand Down
12 changes: 6 additions & 6 deletions src/python/elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,12 @@ void init_elements(py::module& m)
.def(py::init<>(),
"Mixin class for lattice elements with a transverse aperture."
)
.def_property_readonly("x_aperture",
&elements::Aperture::x_aperture,
.def_property_readonly("aperture_x",
&elements::Aperture::aperture_x,
"horizontal aperture in m"
)
.def_property_readonly("y_aperture",
&elements::Aperture::y_aperture,
.def_property_readonly("aperture_y",
&elements::Aperture::aperture_y,
"vertical aperture in m"
)
;
Expand Down Expand Up @@ -693,8 +693,8 @@ void init_elements(py::module& m)
py::arg("dx") = 0,
py::arg("dy") = 0,
py::arg("rotation") = 0,
py::arg("x_aperture") = 0,
py::arg("y_aperture") = 0,
py::arg("aperture_x") = 0,
py::arg("aperture_y") = 0,
py::arg("nslice") = 1,
py::arg("name") = py::none(),
"A drift."
Expand Down

0 comments on commit 68bb406

Please sign in to comment.