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

Equilibrium constant (in the form log10(Keq)) calculated using a least-squares fit to the data provided (typically taken from a geochemical database). More...

#include <EquilibriumConstantAux.h>

Inheritance diagram for EquilibriumConstantAux:
[legend]

Public Member Functions

 EquilibriumConstantAux (const InputParameters &parameters)
 

Protected Member Functions

virtual Real computeValue () override
 

Protected Attributes

const VariableValue & _temperature
 Temperature (in K) More...
 
const std::vector< Real > & _temperature_points
 Temperature points in data set (in K) More...
 
const std::vector< Real > & _logk_points
 log(Keq) values at each temperature point More...
 
std::unique_ptr< EquilibriumConstantFit_logk
 Least-squares fit to data. More...
 
std::unique_ptr< PolynomialFit > _linear_logk
 Linear least-squares fit. More...
 

Detailed Description

Equilibrium constant (in the form log10(Keq)) calculated using a least-squares fit to the data provided (typically taken from a geochemical database).

Fitted function is a Maier-Kelly type function for the equilibrium constant

log10(Keq)= 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 5 data values must be provided in order to use the Maier-Kelley fit. In some cases, insufficient data may be available. In these cases, the following fits are used instead:

If only one data point is available, log10(Keq) is set to a constant equal to the given point.

If between 2 and 4 data points are provided, a linear least squares fit is used.

Definition at line 42 of file EquilibriumConstantAux.h.

Constructor & Destructor Documentation

◆ EquilibriumConstantAux()

EquilibriumConstantAux::EquilibriumConstantAux ( const InputParameters &  parameters)

Definition at line 30 of file EquilibriumConstantAux.C.

31  : AuxKernel(parameters),
32  _temperature(coupledValue("temperature")),
33  _temperature_points(getParam<std::vector<Real>>("temperature_points")),
34  _logk_points(getParam<std::vector<Real>>("logk_points"))
35 {
36  // Check that the number of temperature_points and logk_points are equal
37  if (_temperature_points.size() != _logk_points.size())
38  mooseError("The number of temperature_points and logk_points must be equal in ", _name);
39 
40  if (_temperature_points.size() >= 5)
41  {
42  // If there at least 5 values, then use the Maier-Kelley fit
43  _logk = libmesh_make_unique<EquilibriumConstantFit>(_temperature_points, _logk_points);
44  _logk->generate();
45  }
46  else if ((_temperature_points.size() >= 2) && (_temperature_points.size() <= 4))
47  {
48  // If between 2 and 4 values are provided, use a linear fit
49  _linear_logk = libmesh_make_unique<PolynomialFit>(_temperature_points, _logk_points, 1);
50  _linear_logk->generate();
51  }
52 }
std::unique_ptr< PolynomialFit > _linear_logk
Linear least-squares fit.
const std::vector< Real > & _logk_points
log(Keq) values at each temperature point
const std::vector< Real > & _temperature_points
Temperature points in data set (in K)
std::unique_ptr< EquilibriumConstantFit > _logk
Least-squares fit to data.
const VariableValue & _temperature
Temperature (in K)

Member Function Documentation

◆ computeValue()

Real EquilibriumConstantAux::computeValue ( )
overrideprotectedvirtual

Definition at line 55 of file EquilibriumConstantAux.C.

56 {
57  if (_temperature_points.size() == 1)
58  return -_logk_points[0];
59 
60  if (_temperature_points.size() > 5)
61  return -_logk->sample(_temperature[_qp]);
62 
63  return -_linear_logk->sample(_temperature[_qp]);
64 }
std::unique_ptr< PolynomialFit > _linear_logk
Linear least-squares fit.
const std::vector< Real > & _logk_points
log(Keq) values at each temperature point
const std::vector< Real > & _temperature_points
Temperature points in data set (in K)
std::unique_ptr< EquilibriumConstantFit > _logk
Least-squares fit to data.
const VariableValue & _temperature
Temperature (in K)

Member Data Documentation

◆ _linear_logk

std::unique_ptr<PolynomialFit> EquilibriumConstantAux::_linear_logk
protected

Linear least-squares fit.

Definition at line 59 of file EquilibriumConstantAux.h.

Referenced by computeValue(), and EquilibriumConstantAux().

◆ _logk

std::unique_ptr<EquilibriumConstantFit> EquilibriumConstantAux::_logk
protected

Least-squares fit to data.

Definition at line 57 of file EquilibriumConstantAux.h.

Referenced by computeValue(), and EquilibriumConstantAux().

◆ _logk_points

const std::vector<Real>& EquilibriumConstantAux::_logk_points
protected

log(Keq) values at each temperature point

Definition at line 55 of file EquilibriumConstantAux.h.

Referenced by computeValue(), and EquilibriumConstantAux().

◆ _temperature

const VariableValue& EquilibriumConstantAux::_temperature
protected

Temperature (in K)

Definition at line 51 of file EquilibriumConstantAux.h.

Referenced by computeValue().

◆ _temperature_points

const std::vector<Real>& EquilibriumConstantAux::_temperature_points
protected

Temperature points in data set (in K)

Definition at line 53 of file EquilibriumConstantAux.h.

Referenced by computeValue(), and EquilibriumConstantAux().


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