Skip to content

Commit

Permalink
Rename: cycle -> period
Browse files Browse the repository at this point in the history
  • Loading branch information
ax3l committed Oct 4, 2024
1 parent f7fd9bd commit 5adcc21
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"]
Expand Down
4 changes: 2 additions & 2 deletions src/particles/Push.H
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/particles/Push.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions src/particles/PushAll.H
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ 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<typename T_Element>
void push_all (
ImpactXParticleContainer & pc,
T_Element & element,
[[maybe_unused]] int step,
[[maybe_unused]] int cycle,
[[maybe_unused]] int period,
[[maybe_unused]] bool omp_parallel = true
)
{
Expand Down
2 changes: 1 addition & 1 deletion src/particles/elements/Empty.H
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace impactx
void operator() (
ImpactXParticleContainer & /* pc */,
int /* step */,
int /* cycle */
int /* period */
) {
// nothing to do
}
Expand Down
2 changes: 1 addition & 1 deletion src/particles/elements/Marker.H
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace impactx
void operator() (
ImpactXParticleContainer & /* pc */,
int /* step */,
int /* cycle */
int /* period */
) {
// nothing to do
}
Expand Down
6 changes: 3 additions & 3 deletions src/particles/elements/Programmable.H
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -105,7 +105,7 @@ namespace impactx
*/
bool m_threadsafe = false;

std::function<void(ImpactXParticleContainer *, int, int)> m_push; //! hook for push of whole container (pc, step, cycle)
std::function<void(ImpactXParticleContainer *, int, int)> m_push; //! hook for push of whole container (pc, step, period)
std::function<void(ImpactXParticleContainer::iterator *, RefPart &)> m_beam_particles; //! hook for beam particles
std::function<void(RefPart &)> m_ref_particle; //! hook for reference particle
std::function<void()> m_finalize; //! hook for finalize cleanup
Expand Down
6 changes: 3 additions & 3 deletions src/particles/elements/Programmable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

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 @@ -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
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_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
*
Expand Down
4 changes: 2 additions & 2 deletions src/particles/elements/diagnostics/openPMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/particles/elements/mixin/beamoptic.H
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -165,7 +165,7 @@ namespace detail
);

T_Element& element = *static_cast<T_Element*>(this);
push_all(pc, element, step, cycle);
push_all(pc, element, step, period);
}

/** This pushes the particles on a particle iterator tile or box.
Expand Down
10 changes: 5 additions & 5 deletions src/python/elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ namespace
using Element = typename T_PyClass::type; // py::class<T, options...>

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."
);
}
Expand Down Expand Up @@ -917,7 +917,7 @@ void init_elements(py::module& m)
[](Programmable & p,
std::function<void(ImpactXParticleContainer *, int, int)> 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; },
Expand Down Expand Up @@ -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"
);

Expand Down

0 comments on commit 5adcc21

Please sign in to comment.