https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
11#include "MooseError.h"
12
13EquilibriumConstantFit::EquilibriumConstantFit(const std::vector<Real> & temperature,
14 const std::vector<Real> & logk)
15 : LeastSquaresFitBase(temperature, 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())
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
29void
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
46Real
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}
const double T
void mooseError(Args &&... args)
virtual void fillMatrix() override
virtual Real sample(Real T) override
EquilibriumConstantFit(const std::vector< Real > &temperature, const std::vector< Real > &logk)
std::vector< Real > _x
std::vector< Real > _coeffs
unsigned int _num_coeff
std::vector< Real > _matrix