Fit the equilibrium constant values read from the thermodynamic databse at specified temperature values with one of three types of fits: More...
#include <EquilibriumConstantInterpolator.h>
Public Member Functions | |
EquilibriumConstantInterpolator (const std::vector< Real > &temperature, const std::vector< Real > &logk, const std::string type, const Real no_value=500.0) | |
virtual Real | sample (Real T) override |
ADReal | sample (const ADReal &T) |
Real | sampleDerivative (Real T) |
Sample derivative of function at temperature T. More... | |
virtual void | generate () |
unsigned int | getSampleSize () |
const std::vector< Real > & | getCoefficients () |
void | setVariables (const std::vector< Real > &x, const std::vector< Real > &y) |
Protected Types | |
enum | FitTypeEnum { FitTypeEnum::FOURTHORDER, FitTypeEnum::MAIERKELLY, FitTypeEnum::LINEAR, FitTypeEnum::PIECEWISELINEAR } |
Functional form of fit. More... | |
Protected Member Functions | |
virtual void | fillMatrix () override |
void | doLeastSquares () |
Protected Attributes | |
enum EquilibriumConstantInterpolator::FitTypeEnum | _fit_type |
std::unique_ptr< LinearInterpolation > | _linear_interp |
helper object to perform the linear interpolation of the function data More... | |
std::vector< Real > | _x |
std::vector< Real > | _y |
std::vector< Real > | _matrix |
std::vector< Real > | _coeffs |
unsigned int | _num_coeff |
Fit the equilibrium constant values read from the thermodynamic databse at specified temperature values with one of three types of fits:
(1) a fourth-order polynomial fit (for GWB databses)
log(K)= a_0 + a_1 T + a_2 T^2 + a_3 T^3 + a_4 T^4
(2) a Maier-Kelly type fit (for EQ3/6 databases)
log(K)= a_0 ln(T) + a_1 + a_2 T + a_3 / T + a_4 / T^2
(3) a piecewise linear function (for testing purposes) defined by the (temperature, logk) values, with no extrapolation (if T<T_min then the first data value is used, while if T>T_max then the last data value is used)
where T is the temperature in C.
Note: at least five data points must be provided to generate a fit of type (1) or (2), while at least one data point must be provided to generate a piecewise linear function. If fewer data points exist (where 500.0000 represents no value), then a linear fit is used.
The type of fit is specified during construction using the type parameter. The value of "no value" used in the database is provided using the optional no_value parameter. The default value of 500 is used if this parameter is not specified.
Definition at line 43 of file EquilibriumConstantInterpolator.h.
|
strongprotected |
Functional form of fit.
Enumerator | |
---|---|
FOURTHORDER | |
MAIERKELLY | |
LINEAR | |
PIECEWISELINEAR |
Definition at line 65 of file EquilibriumConstantInterpolator.h.
EquilibriumConstantInterpolator::EquilibriumConstantInterpolator | ( | const std::vector< Real > & | temperature, |
const std::vector< Real > & | logk, | ||
const std::string | type, | ||
const Real | no_value = 500.0 |
||
) |
Definition at line 16 of file EquilibriumConstantInterpolator.C.
|
overrideprotectedvirtual |
Implements LeastSquaresFitBase.
Definition at line 78 of file EquilibriumConstantInterpolator.C.
Implements LeastSquaresFitBase.
Definition at line 129 of file EquilibriumConstantInterpolator.C.
Referenced by GeochemistryActivityCoefficientsDebyeHuckel::setInternalParameters(), and TEST().
Definition at line 171 of file EquilibriumConstantInterpolator.C.
Sample derivative of function at temperature T.
T | temperature |
Definition at line 150 of file EquilibriumConstantInterpolator.C.
Referenced by TEST().
|
protected |
Referenced by EquilibriumConstantInterpolator(), fillMatrix(), sample(), and sampleDerivative().
|
protected |
helper object to perform the linear interpolation of the function data
Definition at line 74 of file EquilibriumConstantInterpolator.h.
Referenced by EquilibriumConstantInterpolator(), sample(), and sampleDerivative().