www.mooseframework.org
Public Member Functions | Protected Member Functions | List of all members
EquilibriumConstantFit Class Reference

Fit the equilibrium constant values read from a databse at specified temperature values with a Maier-Kelly type function for the equilibrium constant. More...

#include <EquilibriumConstantFit.h>

Inheritance diagram for EquilibriumConstantFit:
[legend]

Public Member Functions

 EquilibriumConstantFit (const std::vector< Real > &temperature, const std::vector< Real > &logk)
 
virtual Real sample (Real T) override
 

Protected Member Functions

virtual void fillMatrix () override
 

Detailed Description

Fit the equilibrium constant values read from a databse at specified temperature values with a Maier-Kelly type function for the equilibrium constant.

log(K)= a_0 ln(T) + a_1 + a_2 T + a_3 / T + a_4 / T^2

where T is the temperature in Kelvin.

Note: at least five data points must be provided to generate a fit

Definition at line 28 of file EquilibriumConstantFit.h.

Constructor & Destructor Documentation

◆ EquilibriumConstantFit()

EquilibriumConstantFit::EquilibriumConstantFit ( const std::vector< Real > &  temperature,
const std::vector< Real > &  logk 
)

Definition at line 14 of file EquilibriumConstantFit.C.

16  : LeastSquaresFitBase(temperature, logk)
17 {
18  _num_coeff = 5;
19 
20  // The number of temperature points and logk points must be equal
21  if (temperature.size() != logk.size())
22  mooseError(
23  "The temperature and logk data sets must be equal in length in EquilibriumConstantFit");
24 
25  // At least five data points must be supplied for this functional fit
26  if (temperature.size() < 5)
27  mooseError("At least five data points are required in EquilibriumConstantFit");
28 }
const std::string temperature
Definition: NS.h:27

Member Function Documentation

◆ fillMatrix()

void EquilibriumConstantFit::fillMatrix ( )
overrideprotectedvirtual

Definition at line 31 of file EquilibriumConstantFit.C.

32 {
33  unsigned int num_rows = _x.size();
34  unsigned int num_cols = _num_coeff;
35  _matrix.resize(num_rows * num_cols);
36 
37  for (unsigned int row = 0; row < num_rows; ++row)
38  {
39  _matrix[row] = std::log(_x[row]);
40  _matrix[num_rows + row] = 1.0;
41  _matrix[(2 * num_rows) + row] = _x[row];
42  _matrix[(3 * num_rows) + row] = 1.0 / _x[row];
43  _matrix[(4 * num_rows) + row] = 1.0 / _x[row] / _x[row];
44  }
45 }

◆ sample()

Real EquilibriumConstantFit::sample ( Real  T)
overridevirtual

Definition at line 48 of file EquilibriumConstantFit.C.

49 {
50  Real logK =
51  _coeffs[0] * std::log(T) + _coeffs[1] + _coeffs[2] * T + _coeffs[3] / T + _coeffs[4] / T / T;
52 
53  return logK;
54 }

The documentation for this class was generated from the following files: