13 #include "libmesh/utility.h" 18 const std::vector<Real> & logk,
19 const std::string type,
25 mooseError(
"The temperature and logk data sets must be equal in length in " 26 "EquilibriumConstantInterpolator");
29 std::vector<Real> useful_temperature, useful_logk;
30 for (
unsigned int i = 0; i <
temperature.size(); ++i)
34 useful_logk.push_back(logk[i]);
40 if (type ==
"fourth-order")
42 else if (type ==
"maier-kelly")
44 else if (type ==
"piecewise-linear")
49 _linear_interp = std::make_unique<LinearInterpolation>(useful_temperature, useful_logk);
51 catch (std::domain_error & e)
53 mooseError(
"EquilibriumConstantInterpolation: ", e.what());
57 mooseError(
"Type ", type,
" is not supported in EquilibriumConstantInterpolator");
60 if (useful_temperature.size() >= 5)
73 mooseError(
"A Maier-Kelly fit cannot be used when the temperature points include 0. Use a " 74 "fourth-order fit instead");
80 const unsigned int num_rows =
_x.size();
82 _matrix.resize(num_rows * num_cols);
89 for (
unsigned int row = 0; row < num_rows; ++row)
93 _matrix[(2 * num_rows) + row] = Utility::pow<2>(
_x[row]);
94 _matrix[(3 * num_rows) + row] = Utility::pow<3>(
_x[row]);
95 _matrix[(4 * num_rows) + row] = Utility::pow<4>(
_x[row]);
102 for (
unsigned int row = 0; row < num_rows; ++row)
107 _matrix[(3 * num_rows) + row] = 1.0 /
_x[row];
108 _matrix[(4 * num_rows) + row] = 1.0 / Utility::pow<2>(
_x[row]);
118 for (
unsigned int row = 0; row < num_rows; ++row)
135 _coeffs[3] * Utility::pow<3>(T) +
_coeffs[4] * Utility::pow<4>(T);
139 _coeffs[4] / Utility::pow<2>(T);
156 4.0 *
_coeffs[4] * Utility::pow<3>(T);
160 2.0 *
_coeffs[4] / Utility::pow<3>(T);
177 _coeffs[3] * Utility::pow<3>(T) +
_coeffs[4] * Utility::pow<4>(T);
181 _coeffs[4] / Utility::pow<2>(T);
187 mooseError(
"Dual cannot be used for specified fit type in EquilibriumConstantInterpolator");
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
void mooseError(Args &&... args)
enum EquilibriumConstantInterpolator::FitTypeEnum _fit_type
static const std::string temperature
std::unique_ptr< LinearInterpolation > _linear_interp
helper object to perform the linear interpolation of the function data
DualNumber< Real, DNDerivativeType, true > ADReal
virtual Real sample(Real T) override
Real sampleDerivative(Real T)
Sample derivative of function at temperature T.
EquilibriumConstantInterpolator(const std::vector< Real > &temperature, const std::vector< Real > &logk, const std::string type, const Real no_value=500.0)
virtual void fillMatrix() override
void setVariables(const std::vector< Real > &x, const std::vector< Real > &y)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< Real > _coeffs
std::vector< Real > _matrix