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

Time derivative of primary species in given equilibrium species. More...

#include <CoupledBEEquilibriumSub.h>

Inheritance diagram for CoupledBEEquilibriumSub:
[legend]

Public Member Functions

 CoupledBEEquilibriumSub (const InputParameters &parameters)
 

Protected Member Functions

virtual Real computeQpResidual () override
 
virtual Real computeQpJacobian () override
 
virtual Real computeQpOffDiagJacobian (unsigned int jvar) override
 

Private Attributes

const Real _weight
 Weight of the equilibrium species in the total primary species. More...
 
const VariableValue & _log_k
 Equilibrium constant for the equilibrium species. More...
 
const Real _sto_u
 Stoichiometric coefficient of the primary species in the equilibrium species. More...
 
const std::vector< Real > _sto_v
 Stoichiometric coefficients of the coupled primary species in the equilibrium species. More...
 
const VariableValue & _gamma_u
 Activity coefficient of primary species in the equilibrium species. More...
 
const VariableValue & _gamma_u_old
 Old activity coefficient of primary species in the equilibrium species. More...
 
std::vector< const VariableValue * > _gamma_v
 Activity coefficients of coupled primary species in the equilibrium species. More...
 
std::vector< const VariableValue * > _gamma_v_old
 Old activity coefficients of coupled primary species in the equilibrium species. More...
 
const VariableValue & _gamma_eq
 Activity coefficient of equilibrium species. More...
 
const VariableValue & _gamma_eq_old
 Old activity coefficient of equilibrium species. More...
 
const MaterialProperty< Real > & _porosity
 Porosity. More...
 
std::vector< unsigned int > _vars
 Coupled primary species variable numbers. More...
 
std::vector< const VariableValue * > _v_vals
 Coupled primary species concentrations. More...
 
std::vector< const VariableValue * > _v_vals_old
 Old values of coupled primary species concentrations. More...
 
const VariableValue & _u_old
 Old value of the primary species concentration. More...
 

Detailed Description

Time derivative of primary species in given equilibrium species.

Definition at line 23 of file CoupledBEEquilibriumSub.h.

Constructor & Destructor Documentation

◆ CoupledBEEquilibriumSub()

CoupledBEEquilibriumSub::CoupledBEEquilibriumSub ( const InputParameters &  parameters)

Definition at line 37 of file CoupledBEEquilibriumSub.C.

38  : TimeDerivative(parameters),
39  _weight(getParam<Real>("weight")),
40  _log_k(coupledValue("log_k")),
41  _sto_u(getParam<Real>("sto_u")),
42  _sto_v(getParam<std::vector<Real>>("sto_v")),
43  _gamma_u(coupledValue("gamma_u")),
44  _gamma_u_old(coupledValueOld("gamma_u")),
45  _gamma_eq(coupledValue("gamma_eq")),
46  _gamma_eq_old(coupledValueOld("gamma_eq")),
47  _porosity(getMaterialProperty<Real>("porosity")),
48  _u_old(valueOld())
49 {
50  const unsigned int n = coupledComponents("v");
51 
52  // Check that the correct number of coupled values have been provided
53  if (_sto_v.size() != n)
54  mooseError("The number of stoichiometric coefficients in sto_v is not equal to the number of "
55  "coupled species in ",
56  _name);
57 
58  if (isCoupled("gamma_v"))
59  if (coupledComponents("gamma_v") != n)
60  mooseError("The number of activity coefficients in gamma_v is not equal to the number of "
61  "coupled species in ",
62  _name);
63 
64  _vars.resize(n);
65  _v_vals.resize(n);
66  _v_vals_old.resize(n);
67  _gamma_v.resize(n);
68  _gamma_v_old.resize(n);
69 
70  for (unsigned int i = 0; i < _vars.size(); ++i)
71  {
72  _vars[i] = coupled("v", i);
73  _v_vals[i] = &coupledValue("v", i);
74  _v_vals_old[i] = &coupledValueOld("v", i);
75  // If gamma_v has been supplied, use those values, but if not, use the default value
76  _gamma_v[i] = (isCoupled("gamma_v") ? &coupledValue("gamma_v", i) : &coupledValue("gamma_v"));
77  _gamma_v_old[i] =
78  (isCoupled("gamma_v") ? &coupledValueOld("gamma_v", i) : &coupledValue("gamma_v"));
79  }
80 }
std::vector< const VariableValue * > _gamma_v_old
Old activity coefficients of coupled primary species in the equilibrium species.
const VariableValue & _gamma_eq_old
Old activity coefficient of equilibrium species.
const VariableValue & _gamma_eq
Activity coefficient of equilibrium species.
const VariableValue & _gamma_u
Activity coefficient of primary species in the equilibrium species.
std::vector< unsigned int > _vars
Coupled primary species variable numbers.
std::vector< const VariableValue * > _v_vals
Coupled primary species concentrations.
const VariableValue & _gamma_u_old
Old activity coefficient of primary species in the equilibrium species.
const MaterialProperty< Real > & _porosity
Porosity.
std::vector< const VariableValue * > _gamma_v
Activity coefficients of coupled primary species in the equilibrium species.
const Real _sto_u
Stoichiometric coefficient of the primary species in the equilibrium species.
const std::vector< Real > _sto_v
Stoichiometric coefficients of the coupled primary species in the equilibrium species.
const VariableValue & _u_old
Old value of the primary species concentration.
std::vector< const VariableValue * > _v_vals_old
Old values of coupled primary species concentrations.
const Real _weight
Weight of the equilibrium species in the total primary species.
const VariableValue & _log_k
Equilibrium constant for the equilibrium species.

Member Function Documentation

◆ computeQpJacobian()

Real CoupledBEEquilibriumSub::computeQpJacobian ( )
overrideprotectedvirtual

Definition at line 104 of file CoupledBEEquilibriumSub.C.

105 {
106  Real val_new = std::pow(10.0, _log_k[_qp]) * _sto_u * _gamma_u[_qp] *
107  std::pow(_gamma_u[_qp] * _u[_qp], _sto_u - 1.0) * _phi[_j][_qp] / _gamma_eq[_qp];
108 
109  for (unsigned int i = 0; i < _vars.size(); ++i)
110  val_new *= std::pow((*_gamma_v[i])[_qp] * (*_v_vals[i])[_qp], _sto_v[i]);
111 
112  return _porosity[_qp] * _test[_i][_qp] * _weight * val_new / _dt;
113 }
const VariableValue & _gamma_eq
Activity coefficient of equilibrium species.
const VariableValue & _gamma_u
Activity coefficient of primary species in the equilibrium species.
std::vector< unsigned int > _vars
Coupled primary species variable numbers.
std::vector< const VariableValue * > _v_vals
Coupled primary species concentrations.
const MaterialProperty< Real > & _porosity
Porosity.
std::vector< const VariableValue * > _gamma_v
Activity coefficients of coupled primary species in the equilibrium species.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const Real _sto_u
Stoichiometric coefficient of the primary species in the equilibrium species.
const std::vector< Real > _sto_v
Stoichiometric coefficients of the coupled primary species in the equilibrium species.
const Real _weight
Weight of the equilibrium species in the total primary species.
const VariableValue & _log_k
Equilibrium constant for the equilibrium species.

◆ computeQpOffDiagJacobian()

Real CoupledBEEquilibriumSub::computeQpOffDiagJacobian ( unsigned int  jvar)
overrideprotectedvirtual

Definition at line 116 of file CoupledBEEquilibriumSub.C.

117 {
118  // If no coupled species, return 0
119  if (_v_vals.size() == 0)
120  return 0.0;
121 
122  // If jvar is not one of the coupled species, return 0
123  if (std::find(_vars.begin(), _vars.end(), jvar) == _vars.end())
124  return 0.0;
125 
126  Real val_new =
127  std::pow(10.0, _log_k[_qp]) * std::pow(_gamma_u[_qp] * _u[_qp], _sto_u) / _gamma_eq[_qp];
128 
129  for (unsigned int i = 0; i < _vars.size(); ++i)
130  {
131  if (jvar == _vars[i])
132  val_new *= _sto_v[i] * (*_gamma_v[i])[_qp] *
133  std::pow((*_gamma_v[i])[_qp] * (*_v_vals[i])[_qp], _sto_v[i] - 1.0) *
134  _phi[_j][_qp];
135  else
136  val_new *= std::pow((*_gamma_v[i])[_qp] * (*_v_vals[i])[_qp], _sto_v[i]);
137  }
138 
139  return _porosity[_qp] * _test[_i][_qp] * _weight * val_new / _dt;
140 }
const VariableValue & _gamma_eq
Activity coefficient of equilibrium species.
const VariableValue & _gamma_u
Activity coefficient of primary species in the equilibrium species.
std::vector< unsigned int > _vars
Coupled primary species variable numbers.
std::vector< const VariableValue * > _v_vals
Coupled primary species concentrations.
const MaterialProperty< Real > & _porosity
Porosity.
std::vector< const VariableValue * > _gamma_v
Activity coefficients of coupled primary species in the equilibrium species.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const Real _sto_u
Stoichiometric coefficient of the primary species in the equilibrium species.
const std::vector< Real > _sto_v
Stoichiometric coefficients of the coupled primary species in the equilibrium species.
const Real _weight
Weight of the equilibrium species in the total primary species.
const VariableValue & _log_k
Equilibrium constant for the equilibrium species.

◆ computeQpResidual()

Real CoupledBEEquilibriumSub::computeQpResidual ( )
overrideprotectedvirtual

Definition at line 83 of file CoupledBEEquilibriumSub.C.

84 {
85  mooseAssert(_gamma_eq[_qp] > 0.0, "Activity coefficient must be greater than zero");
86 
87  // Contribution due to primary species that this kernel acts on
88  Real val_new =
89  std::pow(10.0, _log_k[_qp]) * std::pow(_gamma_u[_qp] * _u[_qp], _sto_u) / _gamma_eq[_qp];
90  Real val_old = std::pow(10.0, _log_k[_qp]) * std::pow(_gamma_u_old[_qp] * _u_old[_qp], _sto_u) /
91  _gamma_eq_old[_qp];
92 
93  // Contribution due to coupled primary species
94  for (unsigned int i = 0; i < _vars.size(); ++i)
95  {
96  val_new *= std::pow((*_gamma_v[i])[_qp] * (*_v_vals[i])[_qp], _sto_v[i]);
97  val_old *= std::pow((*_gamma_v_old[i])[_qp] * (*_v_vals_old[i])[_qp], _sto_v[i]);
98  }
99 
100  return _porosity[_qp] * _weight * _test[_i][_qp] * (val_new - val_old) / _dt;
101 }
std::vector< const VariableValue * > _gamma_v_old
Old activity coefficients of coupled primary species in the equilibrium species.
const VariableValue & _gamma_eq_old
Old activity coefficient of equilibrium species.
const VariableValue & _gamma_eq
Activity coefficient of equilibrium species.
const VariableValue & _gamma_u
Activity coefficient of primary species in the equilibrium species.
std::vector< unsigned int > _vars
Coupled primary species variable numbers.
std::vector< const VariableValue * > _v_vals
Coupled primary species concentrations.
const VariableValue & _gamma_u_old
Old activity coefficient of primary species in the equilibrium species.
const MaterialProperty< Real > & _porosity
Porosity.
std::vector< const VariableValue * > _gamma_v
Activity coefficients of coupled primary species in the equilibrium species.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const Real _sto_u
Stoichiometric coefficient of the primary species in the equilibrium species.
const std::vector< Real > _sto_v
Stoichiometric coefficients of the coupled primary species in the equilibrium species.
const VariableValue & _u_old
Old value of the primary species concentration.
std::vector< const VariableValue * > _v_vals_old
Old values of coupled primary species concentrations.
const Real _weight
Weight of the equilibrium species in the total primary species.
const VariableValue & _log_k
Equilibrium constant for the equilibrium species.

Member Data Documentation

◆ _gamma_eq

const VariableValue& CoupledBEEquilibriumSub::_gamma_eq
private

Activity coefficient of equilibrium species.

Definition at line 51 of file CoupledBEEquilibriumSub.h.

Referenced by computeQpJacobian(), computeQpOffDiagJacobian(), and computeQpResidual().

◆ _gamma_eq_old

const VariableValue& CoupledBEEquilibriumSub::_gamma_eq_old
private

Old activity coefficient of equilibrium species.

Definition at line 53 of file CoupledBEEquilibriumSub.h.

Referenced by computeQpResidual().

◆ _gamma_u

const VariableValue& CoupledBEEquilibriumSub::_gamma_u
private

Activity coefficient of primary species in the equilibrium species.

Definition at line 43 of file CoupledBEEquilibriumSub.h.

Referenced by computeQpJacobian(), computeQpOffDiagJacobian(), and computeQpResidual().

◆ _gamma_u_old

const VariableValue& CoupledBEEquilibriumSub::_gamma_u_old
private

Old activity coefficient of primary species in the equilibrium species.

Definition at line 45 of file CoupledBEEquilibriumSub.h.

Referenced by computeQpResidual().

◆ _gamma_v

std::vector<const VariableValue *> CoupledBEEquilibriumSub::_gamma_v
private

Activity coefficients of coupled primary species in the equilibrium species.

Definition at line 47 of file CoupledBEEquilibriumSub.h.

Referenced by computeQpJacobian(), computeQpOffDiagJacobian(), computeQpResidual(), and CoupledBEEquilibriumSub().

◆ _gamma_v_old

std::vector<const VariableValue *> CoupledBEEquilibriumSub::_gamma_v_old
private

Old activity coefficients of coupled primary species in the equilibrium species.

Definition at line 49 of file CoupledBEEquilibriumSub.h.

Referenced by computeQpResidual(), and CoupledBEEquilibriumSub().

◆ _log_k

const VariableValue& CoupledBEEquilibriumSub::_log_k
private

Equilibrium constant for the equilibrium species.

Definition at line 37 of file CoupledBEEquilibriumSub.h.

Referenced by computeQpJacobian(), computeQpOffDiagJacobian(), and computeQpResidual().

◆ _porosity

const MaterialProperty<Real>& CoupledBEEquilibriumSub::_porosity
private

Porosity.

Definition at line 55 of file CoupledBEEquilibriumSub.h.

Referenced by computeQpJacobian(), computeQpOffDiagJacobian(), and computeQpResidual().

◆ _sto_u

const Real CoupledBEEquilibriumSub::_sto_u
private

Stoichiometric coefficient of the primary species in the equilibrium species.

Definition at line 39 of file CoupledBEEquilibriumSub.h.

Referenced by computeQpJacobian(), computeQpOffDiagJacobian(), and computeQpResidual().

◆ _sto_v

const std::vector<Real> CoupledBEEquilibriumSub::_sto_v
private

Stoichiometric coefficients of the coupled primary species in the equilibrium species.

Definition at line 41 of file CoupledBEEquilibriumSub.h.

Referenced by computeQpJacobian(), computeQpOffDiagJacobian(), computeQpResidual(), and CoupledBEEquilibriumSub().

◆ _u_old

const VariableValue& CoupledBEEquilibriumSub::_u_old
private

Old value of the primary species concentration.

Definition at line 63 of file CoupledBEEquilibriumSub.h.

Referenced by computeQpResidual().

◆ _v_vals

std::vector<const VariableValue *> CoupledBEEquilibriumSub::_v_vals
private

Coupled primary species concentrations.

Definition at line 59 of file CoupledBEEquilibriumSub.h.

Referenced by computeQpJacobian(), computeQpOffDiagJacobian(), computeQpResidual(), and CoupledBEEquilibriumSub().

◆ _v_vals_old

std::vector<const VariableValue *> CoupledBEEquilibriumSub::_v_vals_old
private

Old values of coupled primary species concentrations.

Definition at line 61 of file CoupledBEEquilibriumSub.h.

Referenced by computeQpResidual(), and CoupledBEEquilibriumSub().

◆ _vars

std::vector<unsigned int> CoupledBEEquilibriumSub::_vars
private

Coupled primary species variable numbers.

Definition at line 57 of file CoupledBEEquilibriumSub.h.

Referenced by computeQpJacobian(), computeQpOffDiagJacobian(), computeQpResidual(), and CoupledBEEquilibriumSub().

◆ _weight

const Real CoupledBEEquilibriumSub::_weight
private

Weight of the equilibrium species in the total primary species.

Definition at line 35 of file CoupledBEEquilibriumSub.h.

Referenced by computeQpJacobian(), computeQpOffDiagJacobian(), and computeQpResidual().


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