www.mooseframework.org
AqueousEquilibriumRxnAux.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<AuxKernel>();
14  params.addParam<Real>("log_k", 0.0, "The equilibrium constant in dissociation form");
15  params.addRequiredParam<std::vector<Real>>("sto_v",
16  "The stoichiometric coefficient of reactants");
17  params.addCoupledVar("v",
18  "The list of primary species participating in this equilibrium species");
19  params.addClassDescription("Concentration of secondary equilibrium species");
20  return params;
21 }
22 
23 AqueousEquilibriumRxnAux::AqueousEquilibriumRxnAux(const InputParameters & parameters)
24  : AuxKernel(parameters),
25  _log_k(getParam<Real>("log_k")),
26  _sto_v(getParam<std::vector<Real>>("sto_v"))
27 {
28  int n = coupledComponents("v");
29  _vals.resize(n);
30  for (unsigned int i = 0; i < _vals.size(); ++i)
31  _vals[i] = &coupledValue("v", i);
32 }
33 
34 Real
36 {
37  Real conc_product = 1.0;
38 
39  for (unsigned int i = 0; i < _vals.size(); ++i)
40  conc_product *= std::pow((*_vals[i])[_qp], _sto_v[i]);
41 
42  return std::pow(10.0, _log_k) * conc_product;
43 }
const std::vector< Real > _sto_v
Stoichiometric coefficients for coupled primary species.
const Real _log_k
Equilibrium constant.
AqueousEquilibriumRxnAux(const InputParameters &parameters)
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
virtual Real computeValue() override
std::vector< const VariableValue * > _vals
Coupled primary species.
InputParameters validParams< AqueousEquilibriumRxnAux >()