20 const std::string fname =
"lbs::PowerIterationKEigen";
24 auto context = wgs_solver->GetContext();
26 std::dynamic_pointer_cast<lbs::WGSContext<Mat,Vec,KSP>>(context);
28 if (not wgs_context)
throw std::logic_error(fname +
": Cast failed.");
42 auto& front_gs = groupsets.front();
43 auto& front_wgs_solver = lbs_solver.
GetWGSSolvers()[front_gs.id_];
44 auto frons_wgs_context = std::dynamic_pointer_cast<lbs::WGSContext<Mat,Vec,KSP>>(
45 front_wgs_solver->GetContext());
49 double k_eff_prev = 1.0;
50 double k_eff_change = 1.0;
55 bool converged =
false;
56 while (nit < max_iterations)
59 for (
auto& groupset : groupsets)
60 active_set_source_function(groupset,
69 primary_ags_solver->Setup();
70 primary_ags_solver->Solve();
74 k_eff = F_new / F_prev * k_eff;
75 double reactivity = (k_eff - 1.0) / k_eff;
78 k_eff_change = fabs(k_eff - k_eff_prev) / k_eff;
83 if (k_eff_change < std::max(tolerance, 1.0e-12))
89 std::stringstream k_iter_info;
92 <<
" Iteration " << std::setw(5) << nit
93 <<
" k_eff " << std::setw(11) << std::setprecision(7) << k_eff
94 <<
" k_eff change " << std::setw(12) << k_eff_change
95 <<
" reactivity " << std::setw(10) << reactivity * 1e5;
96 if (converged) k_iter_info <<
" CONVERGED\n";
101 if (converged)
break;
107 <<
" Final k-eigenvalue : "
108 << std::setprecision(7) << k_eff;
110 <<
" Final change : "
111 << std::setprecision(6) << k_eff_change
112 <<
" (num_TrOps:" << frons_wgs_context->counter_applications_of_inv_op_ <<
")"
static chi::Timer program_timer
LogStream Log(LOG_LVL level=LOG_0)
std::string GetTimeString() const
AGSLinSolverPtr GetPrimaryAGSSolver()
std::vector< double > & PhiNewLocal()
std::vector< double > & QMomentsLocal()
std::vector< LBSGroupset > & Groupsets()
double ComputeFissionProduction(const std::vector< double > &phi)
std::vector< LinSolvePtr > & GetWGSSolvers()
SetSourceFunction GetActiveSetSourceFunction() const
std::vector< double > & PhiOldLocal()
void Scale(VecDbl &x, const double &val)
void Set(VecDbl &x, const double &val)
void PowerIterationKEigen(LBSSolver &lbs_solver, double tolerance, int max_iterations, double &k_eff)
@ APPLY_AGS_FISSION_SOURCES
@ APPLY_WGS_FISSION_SOURCES
@ APPLY_WGS_SCATTER_SOURCES
@ APPLY_AGS_SCATTER_SOURCES
bool verbose_ags_iterations
bool verbose_outer_iterations