https://mooseframework.inl.gov
EquilibriumConstantFit.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "EquilibriumConstantFit.h"
11 #include "MooseError.h"
12 
14  const std::vector<Real> & logk)
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 }
28 
29 void
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 }
45 
46 Real
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 }
virtual void fillMatrix() override
void mooseError(Args &&... args)
static const std::string temperature
Definition: NS.h:59
unsigned int _num_coeff
std::vector< Real > _x
EquilibriumConstantFit(const std::vector< Real > &temperature, const std::vector< Real > &logk)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< Real > _coeffs
std::vector< Real > _matrix
virtual Real sample(Real T) override