Skip to content

Commit

Permalink
add additional diagnostics for the predictor corrector loop (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
SeverinDiederichs authored Mar 17, 2021
1 parent a9c97ce commit e6106a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Hipace.H
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ public:
/** Maximum number of iterations in the predictor corrector loop
*/
static int m_predcorr_max_iterations;
/** Average number of iterations in the predictor corrector loop
*/
amrex::Real m_predcorr_avg_iterations = 0.;
/** Average transverse B field error in the predictor corrector loop
*/
amrex::Real m_predcorr_avg_B_error = 0.;
/** Mixing factor between the transverse B field iterations in the predictor corrector loop
*/
static amrex::Real m_predcorr_B_mixing_factor;
Expand Down
15 changes: 15 additions & 0 deletions src/Hipace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ Hipace::Evolve ()
m_adaptive_time_step.Calculate(m_dt, m_multi_beam, m_plasma_container,
it, m_box_sorters, false);

// averaging predictor corrector loop diagnostics
m_predcorr_avg_iterations /= (bx.bigEnd(Direction::z) + 1 - bx.smallEnd(Direction::z));
m_predcorr_avg_B_error /= (bx.bigEnd(Direction::z) + 1 - bx.smallEnd(Direction::z));
#ifdef HIPACE_USE_OPENPMD
WriteDiagnostics(step+1, it);
#else
Expand All @@ -335,6 +338,13 @@ Hipace::Evolve ()
Notify(step, it);
}

// printing and resetting predictor corrector loop diagnostics
if (m_verbose>=2) amrex::AllPrint()<<"Rank "<<rank<<": avg. number of iterations "
<< m_predcorr_avg_iterations << " avg. transverse B field error "
<< m_predcorr_avg_B_error << "\n";
m_predcorr_avg_iterations = 0.;
m_predcorr_avg_B_error = 0.;

m_physical_time += m_dt;
}
// For consistency, decrement the physical time, so the last time step is like the others:
Expand Down Expand Up @@ -474,6 +484,8 @@ Hipace::PredictorCorrectorLoopToSolveBxBy (const int islice, const int lev)
&& ( i_iter < m_predcorr_max_iterations ))
{
i_iter++;
m_predcorr_avg_iterations += 1.0;

/* Push particles to the next slice */
AdvancePlasmaParticles(m_plasma_container, m_fields, geom[lev],
true, true, false, false, lev);
Expand Down Expand Up @@ -541,6 +553,9 @@ Hipace::PredictorCorrectorLoopToSolveBxBy (const int islice, const int lev)
"hipace.predcorr_max_iterations (hidden default: 5)\n"
"- higher longitudinal resolution");
}

// adding relative B field error for diagnostic
m_predcorr_avg_B_error += relative_Bfield_error;
if (m_verbose >= 2) amrex::Print()<<"islice: " << islice << " n_iter: "<<i_iter<<
" relative B field error: "<<relative_Bfield_error<< "\n";
}
Expand Down

0 comments on commit e6106a3

Please sign in to comment.