16 const std::string fname =
"lbs::acceleration::MakeTwoGridCollapsedInfo";
25 throw std::logic_error(fname +
": list of scattering matrices empty.");
30 for (
int g = 0; g < num_groups; g++)
31 for (
const auto& [row_g, gprime, sigma] : isotropic_transfer_matrix.Row(g))
38 for (
int g = 0; g < num_groups; g++)
42 A[g][g] = sigma_t[g] - S[g][g];
43 for (
int gp = 0; gp < g; gp++)
46 for (
int gp = g + 1; gp < num_groups; gp++)
52 for (
int gp = 0; gp < num_groups; gp++)
63 for (
int g = 0; g < num_groups; g++)
64 if (sigma_t[g] < 1.0e-16) A[g][g] = 1.0;
70 double collapsed_D = 0.0;
71 double collapsed_sig_a = 0.0;
72 std::vector<double> spectrum(num_groups, 1.0);
80 for (
int g = 0; g < num_groups; g++)
81 sum += std::fabs(E[g]);
83 for (
int g = 0; g < num_groups; g++)
84 spectrum[g] = std::fabs(E[g]) / sum;
86 for (
int g = 0; g < num_groups; ++g)
88 collapsed_D += diffusion_coeff[g] * spectrum[g];
90 collapsed_sig_a += sigma_t[g] * spectrum[g];
92 for (
int gp = 0; gp < num_groups; ++gp)
93 collapsed_sig_a -= S[g][gp] * spectrum[gp];
98 std::stringstream outstr;
99 for (
auto& xi : spectrum)
100 outstr << xi <<
'\n';
103 return {collapsed_D, collapsed_sig_a, spectrum};
virtual const unsigned int NumGroups() const =0
virtual const chi_math::SparseMatrix & TransferMatrix(unsigned int ell) const =0
virtual const std::vector< double > & SigmaTotal() const =0
virtual const std::vector< chi_math::SparseMatrix > & TransferMatrices() const =0
virtual const std::vector< double > & DiffusionCoefficient() const =0
double PowerIteration(const MatDbl &A, VecDbl &e_vec, int max_it=2000, double tol=1.0e-13)
MatDbl Inverse(const MatDbl &A)
MatDbl MatMul(const MatDbl &A, const double c)
@ JFULL
Jacobi with full conv. of within-group scattering.
@ JPARTIAL
Jacobi with partially conv. of within-group scattering.
TwoGridCollapsedInfo MakeTwoGridCollapsedInfo(const chi_physics::MultiGroupXS &xs, EnergyCollapseScheme scheme)
std::vector< VecDbl > MatDbl
std::vector< double > VecDbl