Skip to content

Commit

Permalink
Fix issue with AB5 pusher and MR (#1204)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSinn authored Feb 6, 2025
1 parent d840991 commit c0ac640
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Hipace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ Hipace::SolveOneSlice (int islice, int step)

// Push plasma particles
for (int lev=0; lev<current_N_level; ++lev) {
m_multi_plasma.AdvanceParticles(m_fields, m_3D_geom, false, lev);
m_multi_plasma.AdvanceParticles(m_fields, m_3D_geom, false, lev, current_N_level);
}

// get minimum beam acceleration on level 0
Expand Down Expand Up @@ -968,7 +968,7 @@ Hipace::PredictorCorrectorLoopToSolveBxBy (const int islice, const int current_N

for (int lev=0; lev<current_N_level; ++lev) {
// Push particles to the next temp slice
m_multi_plasma.AdvanceParticles(m_fields, m_3D_geom, true, lev);
m_multi_plasma.AdvanceParticles(m_fields, m_3D_geom, true, lev, current_N_level);
}

if (m_N_level > 1) {
Expand Down
4 changes: 3 additions & 1 deletion src/particles/plasma/MultiPlasma.H
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ public:
* \param[in] gm Geometry of the simulation, to get the cell size etc.
* \param[in] temp_slice if true, the temporary data (x_temp, ...) will be used
* \param[in] lev MR level
* \param[in] current_N_level number of MR levels
*/
void AdvanceParticles (
const Fields & fields, amrex::Vector<amrex::Geometry> const& gm, bool temp_slice, int lev);
const Fields & fields, amrex::Vector<amrex::Geometry> const& gm, bool temp_slice, int lev,
int const current_N_level);

/** \brief Loop over plasma species and deposit their neutralizing background, if needed
*
Expand Down
5 changes: 3 additions & 2 deletions src/particles/plasma/MultiPlasma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,11 @@ MultiPlasma::ExplicitDeposition (Fields& fields, amrex::Vector<amrex::Geometry>

void
MultiPlasma::AdvanceParticles (
const Fields & fields, amrex::Vector<amrex::Geometry> const& gm, bool temp_slice, int lev)
const Fields & fields, amrex::Vector<amrex::Geometry> const& gm, bool temp_slice, int lev,
int const current_N_level)
{
for (int i=0; i<m_nplasmas; i++) {
AdvancePlasmaParticles(m_all_plasmas[i], fields, gm, temp_slice, lev);
AdvancePlasmaParticles(m_all_plasmas[i], fields, gm, temp_slice, lev, current_N_level);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/particles/pusher/PlasmaParticleAdvance.H
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
* \param[in] gm Geometry of the simulation, to get the cell size etc.
* \param[in] temp_slice if true, the temporary data (x_temp, ...) will be used
* \param[in] lev MR level
* \param[in] current_N_level number of MR levels
*/
void
AdvancePlasmaParticles (PlasmaParticleContainer& plasma, const Fields & fields,
amrex::Vector<amrex::Geometry> const& gm, const bool temp_slice,
int const lev);
int const lev, int const current_N_level);

#endif // PLASMAPARTICLEADVANCE_H_
4 changes: 2 additions & 2 deletions src/particles/pusher/PlasmaParticleAdvance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ template struct PlasmaMomentumDerivative<DualNumber>;
void
AdvancePlasmaParticles (PlasmaParticleContainer& plasma, const Fields & fields,
amrex::Vector<amrex::Geometry> const& gm, const bool temp_slice,
int const lev)
int const lev, int const current_N_level)
{
HIPACE_PROFILE("AdvancePlasmaParticles()");
using namespace amrex::literals;
Expand Down Expand Up @@ -272,7 +272,7 @@ AdvancePlasmaParticles (PlasmaParticleContainer& plasma, const Fields & fields,
});

#ifdef HIPACE_USE_AB5_PUSH
if (!temp_slice) {
if (!temp_slice && lev == current_N_level - 1) {
auto& rd = pti.GetStructOfArrays().GetRealData();

// shift force terms
Expand Down
3 changes: 2 additions & 1 deletion src/salame/Salame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ SalameModule (Hipace* hipace, const int n_iter, const bool do_advance, int& last

for (int lev=0; lev<current_N_level; ++lev) {
// advance plasma to the temp slice
hipace->m_multi_plasma.AdvanceParticles(hipace->m_fields, hipace->m_3D_geom, true, lev);
hipace->m_multi_plasma.AdvanceParticles(hipace->m_fields, hipace->m_3D_geom, true, lev,
current_N_level);

hipace->m_fields.duplicate(lev, WhichSlice::Salame, {"jx", "jy"},
WhichSlice::Next, {"jx_beam", "jy_beam"});
Expand Down

0 comments on commit c0ac640

Please sign in to comment.