Skip to content

Commit

Permalink
Rename cycle_intervals -> period_sample_intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
ax3l committed Oct 4, 2024
1 parent 56d9b4e commit 987fd3d
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions docs/source/usage/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,9 @@ Lattice Elements
openPMD `iteration encoding <https://openpmd-api.readthedocs.io/en/0.14.0/usage/concepts.html#iteration-and-series>`__: (v)ariable based, (f)ile based, (g)roup based (default)
variable based is an `experimental feature with ADIOS2 <https://openpmd-api.readthedocs.io/en/0.14.0/backends/adios2.html#experimental-new-adios2-schema>`__.

* ``<element_name>.cycle_intervals`` (``int``, default value: ``1``)
* ``<element_name>.period_sample_intervals`` (``int``, default value: ``1``)

For periodic lattice, only output every N cycles (turns).
for periodic lattice, only output every Nth period (turn).
By default, diagnostics are returned every cycle.

* ``<element_name>.nonlinear_lens_invariants`` (``boolean``, default value: ``false``)
Expand Down
4 changes: 2 additions & 2 deletions docs/source/usage/python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ 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.BeamMonitor(name, backend="default", encoding="g", cycle_intervals=1)
.. py:class:: impactx.elements.BeamMonitor(name, backend="default", encoding="g", period_sample_intervals=1)
A beam monitor, writing all beam particles at fixed ``s`` to openPMD files.

Expand All @@ -649,7 +649,7 @@ This module provides elements for the accelerator lattice.
:param name: name of the series
:param backend: I/O backend, e.g., ``bp``, ``h5``, ``json``
:param encoding: openPMD iteration encoding: (v)ariable based, (f)ile based, (g)roup based (default)
:param cycle_intervals: for periodic lattice, only output every N cycles (turns)
:param period_sample_intervals: for periodic lattice, only output every Nth period (turn)

.. py:property:: name
Expand Down
2 changes: 1 addition & 1 deletion examples/fodo_channel/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ We use a 2 GeV electron beam with initial unnormalized rms emittance of 2 nm.
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.
This test also demonstrates the ``cycle_intervals`` capability of our beam monitor diagnostics, only creating output every 10th FODO cell
This test also demonstrates the ``period_sample_intervals`` capability of our beam monitor diagnostics, only creating output every 10th FODO cell


Run
Expand Down
2 changes: 1 addition & 1 deletion examples/fodo_channel/input_fodo.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ lattice.nslice = 5
lattice.periods = 101 # FODO channel of 101 periods

monitor.type = beam_monitor
monitor.cycle_intervals = 10
monitor.period_sample_intervals = 10
monitor.backend = h5

drift1.type = drift
Expand Down
2 changes: 1 addition & 1 deletion examples/fodo_channel/run_fodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
sim.add_particles(bunch_charge_C, distr, npart)

# add beam diagnostics
monitor = elements.BeamMonitor("monitor", backend="h5", cycle_intervals=10)
monitor = elements.BeamMonitor("monitor", backend="h5", period_sample_intervals=10)

# design the accelerator lattice)
ns = 5 # number of slices per ds in the element
Expand Down
8 changes: 4 additions & 4 deletions src/ImpactX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ namespace impactx {
}

// periods through the lattice
int periods = 1;
amrex::ParmParse("lattice").queryAdd("periods", periods);
int num_periods = 1;
amrex::ParmParse("lattice").queryAdd("periods", num_periods);

for (int cycle=0; cycle < periods; ++cycle) {
for (int period=0; period < num_periods; ++period) {
// loop over all beamline elements
for (auto &element_variant: m_lattice) {
// update element edge of the reference particle
Expand Down Expand Up @@ -263,7 +263,7 @@ namespace impactx {
// assuming that the distribution did not change

// push all particles with external maps
Push(*amr_data->m_particle_container, element_variant, step, cycle);
Push(*amr_data->m_particle_container, element_variant, step, period);

// move "lost" particles to another particle container
collect_lost_particles(*amr_data->m_particle_container);
Expand Down
6 changes: 3 additions & 3 deletions src/initialization/InitElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ namespace detail
pp_element.queryAdd("backend", openpmd_backend);
std::string openpmd_encoding{"g"};
pp_element.queryAdd("encoding", openpmd_encoding);
int cycle_intervals = 1;
pp_element.queryAdd("cycle_intervals", cycle_intervals);
int period_sample_intervals = 1;
pp_element.queryAdd("period_sample_intervals", period_sample_intervals);

// optional: add and calculate additional particle properties
// property: nonlinear lens invariants
Expand All @@ -414,7 +414,7 @@ namespace detail
pp_element.queryAdd("cn", cn);
}

m_lattice.emplace_back(diagnostics::BeamMonitor(openpmd_name, openpmd_backend, openpmd_encoding, cycle_intervals));
m_lattice.emplace_back(diagnostics::BeamMonitor(openpmd_name, openpmd_backend, openpmd_encoding, period_sample_intervals));
} else if (element_type == "line")
{
// Parse the lattice elements for the sub-lattice in the line
Expand Down
6 changes: 3 additions & 3 deletions src/particles/elements/diagnostics/openPMD.H
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ namespace detail
* @param series_name name of the data series, usually the element name
* @param backend file format backend for openPMD, e.g., "bp" or "h5"
* @param encoding openPMD iteration encoding: "v"ariable based, "f"ile based, "g"roup based (default)
* @param cycle_intervals for periodic lattice, only output every N cycles (turns)
* @param period_sample_intervals for periodic lattice, only output every Nth period (turn)
*/
BeamMonitor (std::string series_name, std::string backend="default", std::string encoding="g", int cycle_intervals=1);
BeamMonitor (std::string series_name, std::string backend="default", std::string encoding="g", int period_sample_intervals=1);

BeamMonitor (BeamMonitor const & other) = default;
BeamMonitor (BeamMonitor && other) = default;
Expand Down Expand Up @@ -159,7 +159,7 @@ namespace detail

int m_file_min_digits = 6; //! minimum number of digits to iteration number in file name

int m_cycle_intervals = 1; //! only output every N cycles (turns) of periodic lattices
int m_period_sample_intervals = 1; //! only output every N cycles (turns) of periodic lattices

/** This rank's offset in the MPI-global particle array, by level
*
Expand Down
8 changes: 4 additions & 4 deletions src/particles/elements/diagnostics/openPMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ namespace detail
#endif // ImpactX_USE_OPENPMD
}

BeamMonitor::BeamMonitor (std::string series_name, std::string backend, std::string encoding, int cycle_intervals) :
m_series_name(std::move(series_name)), m_OpenPMDFileType(std::move(backend)), m_cycle_intervals(cycle_intervals)
BeamMonitor::BeamMonitor (std::string series_name, std::string backend, std::string encoding, int period_sample_intervals) :
m_series_name(std::move(series_name)), m_OpenPMDFileType(std::move(backend)), m_period_sample_intervals(period_sample_intervals)
{
#ifdef ImpactX_USE_OPENPMD
// pick first available backend if default is chosen
Expand All @@ -181,7 +181,7 @@ namespace detail

amrex::ParmParse pp_diag("diag");
// turn filter
pp_diag.queryAdd("cycle_intervals", m_cycle_intervals);
pp_diag.queryAdd("period_sample_intervals", m_period_sample_intervals);
// legacy options from other diagnostics
pp_diag.queryAdd("file_min_digits", m_file_min_digits);

Expand Down Expand Up @@ -318,7 +318,7 @@ namespace detail
)
{
// filter out this turn?
if (cycle % m_cycle_intervals != 0)
if (cycle % m_period_sample_intervals != 0)
return;

#ifdef ImpactX_USE_OPENPMD
Expand Down
2 changes: 1 addition & 1 deletion src/python/elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void init_elements(py::module& m)
py::arg("name"),
py::arg("backend") = "default",
py::arg("encoding") = "g",
py::arg("cycle_intervals") = 1,
py::arg("period_sample_intervals") = 1,
"This element writes the particle beam out to openPMD data."
)
.def_property_readonly("name",
Expand Down

0 comments on commit 987fd3d

Please sign in to comment.