https://mooseframework.inl.gov
Public Member Functions | Protected Member Functions | Protected Attributes | 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
 
virtual void generate ()
 
unsigned int getSampleSize ()
 
const std::vector< Real > & getCoefficients ()
 
void setVariables (const std::vector< Real > &x, const std::vector< Real > &y)
 

Protected Member Functions

virtual void fillMatrix () override
 
void doLeastSquares ()
 

Protected Attributes

std::vector< Real_x
 
std::vector< Real_y
 
std::vector< Real_matrix
 
std::vector< Real_coeffs
 
unsigned int _num_coeff
 

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 26 of file EquilibriumConstantFit.h.

Constructor & Destructor Documentation

◆ EquilibriumConstantFit()

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

Definition at line 13 of file EquilibriumConstantFit.C.

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

Member Function Documentation

◆ fillMatrix()

void EquilibriumConstantFit::fillMatrix ( )
overrideprotectedvirtual

Implements LeastSquaresFitBase.

Definition at line 30 of file EquilibriumConstantFit.C.

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

◆ sample()

Real EquilibriumConstantFit::sample ( Real  T)
overridevirtual

Implements LeastSquaresFitBase.

Definition at line 47 of file EquilibriumConstantFit.C.

Referenced by TEST().

48 {
49  Real logK =
50  _coeffs[0] * std::log(T) + _coeffs[1] + _coeffs[2] * T + _coeffs[3] / T + _coeffs[4] / T / T;
51 
52  return logK;
53 }
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< Real > _coeffs

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