Line data Source code
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 : 13 12 : EquilibriumConstantFit::EquilibriumConstantFit(const std::vector<Real> & temperature, 14 12 : const std::vector<Real> & logk) 15 12 : : LeastSquaresFitBase(temperature, logk) 16 : { 17 12 : _num_coeff = 5; 18 : 19 : // The number of temperature points and logk points must be equal 20 12 : if (temperature.size() != logk.size()) 21 0 : 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 12 : if (temperature.size() < 5) 26 0 : mooseError("At least five data points are required in EquilibriumConstantFit"); 27 12 : } 28 : 29 : void 30 11 : EquilibriumConstantFit::fillMatrix() 31 : { 32 11 : unsigned int num_rows = _x.size(); 33 11 : unsigned int num_cols = _num_coeff; 34 11 : _matrix.resize(num_rows * num_cols); 35 : 36 99 : for (unsigned int row = 0; row < num_rows; ++row) 37 : { 38 88 : _matrix[row] = std::log(_x[row]); 39 88 : _matrix[num_rows + row] = 1.0; 40 88 : _matrix[(2 * num_rows) + row] = _x[row]; 41 88 : _matrix[(3 * num_rows) + row] = 1.0 / _x[row]; 42 88 : _matrix[(4 * num_rows) + row] = 1.0 / _x[row] / _x[row]; 43 : } 44 11 : } 45 : 46 : Real 47 1325 : EquilibriumConstantFit::sample(Real T) 48 : { 49 : Real logK = 50 1325 : _coeffs[0] * std::log(T) + _coeffs[1] + _coeffs[2] * T + _coeffs[3] / T + _coeffs[4] / T / T; 51 : 52 1325 : return logK; 53 : }