1 #ifndef SRC_MICROPHYSICS_CHEMISTRY_SOLVER_HPP
2 #define SRC_MICROPHYSICS_CHEMISTRY_SOLVER_HPP
5 #include <athena/athena.hpp>
16 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
24 template <
typename T1,
typename T2,
typename T3>
25 T1
solveBDF1(T2
const& Rate, T3
const& Jac, Real dt) {
28 return A_.inverse() * Rate;
30 return A_.partialPivLu().solve(Rate);
34 template <
typename T1,
typename T2,
typename T3>
40 return A_.inverse() *
B_;
42 return A_.partialPivLu().solve(
B_);
46 template <
typename T1,
typename T2,
typename T3>
50 auto sol = solveBDF1<T1>(Rate, Jac, dt);
51 for (
int n = 0; n <
Size; ++n)
S1_(n) = c[indx[n]] + sol(n);
54 sol = solveTRBDF2<T1>(Rate, Jac, dt);
55 for (
int n = 0; n <
Size; ++n)
S2_(n) = c[indx[n]] + sol(n);
59 for (
int n = 0; n <
Size; ++n) {
66 for (
int n = 0; n <
Size; ++n)
67 sol(n) = (1. - alpha) *
S1_(n) + alpha *
S2_(n) - c[indx[n]];
75 Eigen::Matrix<Real, N, N>
A_,
I_;
Eigen::Matrix< Real, N, 1 > B_
Eigen::Matrix< Real, N, 1 > S2_
T1 solveBDF1(T2 const &Rate, T3 const &Jac, Real dt)
T1 solveTRBDF2(T2 const &Rate, T3 const &Jac, Real dt)
Eigen::Matrix< Real, N, N > I_
T1 solveTRBDF2Blend(T2 const &Rate, T3 const &Jac, Real dt, Real const c[], int const indx[])
Eigen::Matrix< Real, N, 1 > S1_
Eigen::Matrix< Real, N, N > A_
double min(double x1, double x2, double x3)
double max(double x1, double x2, double x3)