From 5adcc212f138a0403c1892b0e7c997448db0ce5b Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Thu, 3 Oct 2024 17:18:21 -0700 Subject: [PATCH] Rename: `cycle` -> `period` --- .../run_ml_surrogate_15_stage.py | 4 ++-- src/particles/Push.H | 4 ++-- src/particles/Push.cpp | 6 +++--- src/particles/PushAll.H | 4 ++-- src/particles/elements/Empty.H | 2 +- src/particles/elements/Marker.H | 2 +- src/particles/elements/Programmable.H | 6 +++--- src/particles/elements/Programmable.cpp | 6 +++--- src/particles/elements/diagnostics/openPMD.H | 6 +++--- src/particles/elements/diagnostics/openPMD.cpp | 4 ++-- src/particles/elements/mixin/beamoptic.H | 6 +++--- src/python/elements.cpp | 10 +++++----- 12 files changed, 30 insertions(+), 30 deletions(-) diff --git a/examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py b/examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py index a0ac965b2..004f79bdb 100644 --- a/examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py +++ b/examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py @@ -169,7 +169,7 @@ def __init__(self, stage_i, surrogate_model, surrogate_length, stage_start): self.push = self.surrogate_push self.ds = surrogate_length - def surrogate_push(self, pc, step, cycle): + def surrogate_push(self, pc, step, period): ref_part = pc.ref_particle() ref_z_i = ref_part.z ref_z_i_LPA = ref_z_i - self.stage_start @@ -304,7 +304,7 @@ def __init__(self, sim, stage_i, lattice_index, x_or_y): self.x_or_y = x_or_y self.push = self.set_lens - def set_lens(self, pc, step, cycle): + def set_lens(self, pc, step, period): # get envelope parameters rbc = pc.reduced_beam_characteristics() alpha = rbc[f"alpha_{self.x_or_y}"] diff --git a/src/particles/Push.H b/src/particles/Push.H index ef0d72563..268a65e28 100644 --- a/src/particles/Push.H +++ b/src/particles/Push.H @@ -23,13 +23,13 @@ namespace impactx * @param[inout] pc container of the particles to push * @param[inout] element_variant a single element to push the particles through * @param[in] step global step for diagnostics - * @param[in] cycle for periodic lattices, this is the cycle or turn + * @param[in] period for periodic lattices, this is the current period (turn or cycle) */ void Push ( ImpactXParticleContainer & pc, KnownElements & element_variant, int step, - int cycle + int period ); } // namespace impactx diff --git a/src/particles/Push.cpp b/src/particles/Push.cpp index 5d088e97d..54f8cd8b4 100644 --- a/src/particles/Push.cpp +++ b/src/particles/Push.cpp @@ -20,16 +20,16 @@ namespace impactx ImpactXParticleContainer & pc, KnownElements & element_variant, int step, - int cycle + int period ) { // here we just access the element by its respective type - std::visit([&pc, step, cycle](auto&& element) + std::visit([&pc, step, period](auto&& element) { BL_PROFILE("impactx::Push"); // push reference particle & all particles - element(pc, step, cycle); + element(pc, step, period); }, element_variant); } diff --git a/src/particles/PushAll.H b/src/particles/PushAll.H index 0cde87ce4..3fec0f3bc 100644 --- a/src/particles/PushAll.H +++ b/src/particles/PushAll.H @@ -26,7 +26,7 @@ namespace impactx * @param[in,out] pc particle container to push * @param[in,out] element the beamline element * @param[in] step global step for diagnostics - * @param[in] cycle for periodic lattices, this is the cycle or turn + * @param[in] period for periodic lattices, this is the current period (turn or cycle) * @param[in] omp_parallel allow threading via OpenMP for the particle iterator loop (note: if OMP backend is active) */ template @@ -34,7 +34,7 @@ namespace impactx ImpactXParticleContainer & pc, T_Element & element, [[maybe_unused]] int step, - [[maybe_unused]] int cycle, + [[maybe_unused]] int period, [[maybe_unused]] bool omp_parallel = true ) { diff --git a/src/particles/elements/Empty.H b/src/particles/elements/Empty.H index df94ada9f..9ce3eece8 100644 --- a/src/particles/elements/Empty.H +++ b/src/particles/elements/Empty.H @@ -38,7 +38,7 @@ namespace impactx void operator() ( ImpactXParticleContainer & /* pc */, int /* step */, - int /* cycle */ + int /* period */ ) { // nothing to do } diff --git a/src/particles/elements/Marker.H b/src/particles/elements/Marker.H index 4b756e49c..3291aff79 100644 --- a/src/particles/elements/Marker.H +++ b/src/particles/elements/Marker.H @@ -42,7 +42,7 @@ namespace impactx void operator() ( ImpactXParticleContainer & /* pc */, int /* step */, - int /* cycle */ + int /* period */ ) { // nothing to do } diff --git a/src/particles/elements/Programmable.H b/src/particles/elements/Programmable.H index 0d12f1994..89b6afa8e 100644 --- a/src/particles/elements/Programmable.H +++ b/src/particles/elements/Programmable.H @@ -46,12 +46,12 @@ namespace impactx * * @param[in,out] pc particle container to push * @param[in] step global step for diagnostics - * @param[in] cycle for periodic lattices, this is the cycle or turn + * @param[in] period for periodic lattices, this is the current period (turn or cycle) */ void operator() ( ImpactXParticleContainer & pc, int step, - int cycle + int period ) const; /** Push all particles relative to the reference particle */ @@ -105,7 +105,7 @@ namespace impactx */ bool m_threadsafe = false; - std::function m_push; //! hook for push of whole container (pc, step, cycle) + std::function m_push; //! hook for push of whole container (pc, step, period) std::function m_beam_particles; //! hook for beam particles std::function m_ref_particle; //! hook for reference particle std::function m_finalize; //! hook for finalize cleanup diff --git a/src/particles/elements/Programmable.cpp b/src/particles/elements/Programmable.cpp index d3af7c9b1..43f37aa73 100644 --- a/src/particles/elements/Programmable.cpp +++ b/src/particles/elements/Programmable.cpp @@ -20,16 +20,16 @@ namespace impactx Programmable::operator() ( ImpactXParticleContainer & pc, int step, - int cycle + int period ) const { if (m_push == nullptr) { // TODO: print if verbose mode is set - push_all(pc, *this, step, cycle, m_threadsafe); + push_all(pc, *this, step, period, m_threadsafe); } else { BL_PROFILE("impactx::Push::Programmable"); - m_push(&pc, step, cycle); + m_push(&pc, step, period); } } diff --git a/src/particles/elements/diagnostics/openPMD.H b/src/particles/elements/diagnostics/openPMD.H index 578db4570..f5ee0d4a8 100644 --- a/src/particles/elements/diagnostics/openPMD.H +++ b/src/particles/elements/diagnostics/openPMD.H @@ -109,12 +109,12 @@ namespace detail * * @param[in,out] pc particle container to push * @param[in] step global step for diagnostics - * @param[in] cycle for periodic lattices, this is the cycle or turn + * @param[in] period for periodic lattices, this is the current period (turn or cycle) */ void operator() ( ImpactXParticleContainer & pc, int step, - int cycle + int period ); /** Write a tile of particles @@ -159,7 +159,7 @@ namespace detail int m_file_min_digits = 6; //! minimum number of digits to iteration number in file name - int m_period_sample_intervals = 1; //! only output every N cycles (turns) of periodic lattices + int m_period_sample_intervals = 1; //! only output every Nth period (turn or cycle) of periodic lattices /** This rank's offset in the MPI-global particle array, by level * diff --git a/src/particles/elements/diagnostics/openPMD.cpp b/src/particles/elements/diagnostics/openPMD.cpp index 5680a1a24..8b215d3e2 100644 --- a/src/particles/elements/diagnostics/openPMD.cpp +++ b/src/particles/elements/diagnostics/openPMD.cpp @@ -314,11 +314,11 @@ namespace detail BeamMonitor::operator() ( ImpactXParticleContainer & pc, int step, - int cycle + int period ) { // filter out this turn? - if (cycle % m_period_sample_intervals != 0) + if (period % m_period_sample_intervals != 0) return; #ifdef ImpactX_USE_OPENPMD diff --git a/src/particles/elements/mixin/beamoptic.H b/src/particles/elements/mixin/beamoptic.H index 3150115c5..0616b5374 100644 --- a/src/particles/elements/mixin/beamoptic.H +++ b/src/particles/elements/mixin/beamoptic.H @@ -151,12 +151,12 @@ namespace detail * * @param[inout] pc container of the particles to push * @param[in] step global step for diagnostics - * @param[in] cycle for periodic lattices, this is the cycle or turn + * @param[in] period for periodic lattices, this is the current period (turn or cycle) */ void operator() ( ImpactXParticleContainer & pc, int step, - int cycle + int period ) { static_assert( @@ -165,7 +165,7 @@ namespace detail ); T_Element& element = *static_cast(this); - push_all(pc, element, step, cycle); + push_all(pc, element, step, period); } /** This pushes the particles on a particle iterator tile or box. diff --git a/src/python/elements.cpp b/src/python/elements.cpp index 5c9cd4b72..b6403e71b 100644 --- a/src/python/elements.cpp +++ b/src/python/elements.cpp @@ -57,10 +57,10 @@ namespace using Element = typename T_PyClass::type; // py::class cl.def("push", - [](Element & el, ImpactXParticleContainer & pc, int step, int cycle) { - el(pc, step, cycle); + [](Element & el, ImpactXParticleContainer & pc, int step, int period) { + el(pc, step, period); }, - py::arg("pc"), py::arg("step")=0, py::arg("cycle")=0, + py::arg("pc"), py::arg("step")=0, py::arg("period")=0, "Push first the reference particle, then all other particles." ); } @@ -917,7 +917,7 @@ void init_elements(py::module& m) [](Programmable & p, std::function new_hook ) { p.m_push = std::move(new_hook); }, - "hook for push of whole container (pc, step, cycle)" + "hook for push of whole container (pc, step, period)" ) .def_property("beam_particles", [](Programmable & p) { return p.m_beam_particles; }, @@ -1483,7 +1483,7 @@ void init_elements(py::module& m) // freestanding push function m.def("push", &Push, - py::arg("pc"), py::arg("element"), py::arg("step")=0, py::arg("cycle")=0, + py::arg("pc"), py::arg("element"), py::arg("step")=0, py::arg("period")=0, "Push particles through an element" );