20 params.
addParam<Real>(
"weight", 1.0,
"Weight of the equilibrium species");
21 params.
addCoupledVar(
"log_k", 0.0,
"Equilibrium constant of dissociation equilibrium reaction");
24 "Stoichiometric coef of the primary species the kernel "
25 "operates on in the equilibrium reaction");
27 "gamma_u", 1.0,
"Activity coefficient of primary species that this kernel operates on");
31 "The stoichiometric coefficients of coupled primary species in equilibrium reaction");
34 params.
addCoupledVar(
"gamma_v", 1.0,
"Activity coefficients of coupled primary species");
35 params.
addCoupledVar(
"gamma_eq", 1.0,
"Activity coefficient of this equilibrium species");
36 RealVectorValue g(0, 0, 0);
37 params.
addParam<RealVectorValue>(
"gravity", g,
"Gravity vector (default is (0, 0, 0))");
44 _weight(getParam<Real>(
"weight")),
45 _log_k(coupledValue(
"log_k")),
46 _sto_u(getParam<Real>(
"sto_u")),
47 _sto_v(getParam<
std::vector<Real>>(
"sto_v")),
48 _cond(getMaterialProperty<Real>(
"conductivity")),
49 _gravity(getParam<RealVectorValue>(
"gravity")),
50 _density(getDefaultMaterialProperty<Real>(
"density")),
51 _grad_p(coupledGradient(
"p")),
53 _vars(coupledIndices(
"v")),
54 _vals(coupledValues(
"v")),
55 _grad_vals(coupledGradients(
"v")),
56 _gamma_u(coupledValue(
"gamma_u")),
57 _gamma_v(isCoupled(
"gamma_v")
58 ? coupledValues(
"gamma_v")
60 &coupledValue(
"gamma_v"))),
61 _gamma_eq(coupledValue(
"gamma_eq"))
63 const unsigned int n = coupledComponents(
"v");
67 mooseError(
"The number of stoichiometric coefficients in sto_v is not equal to the number of "
68 "coupled species in ",
71 if (isCoupled(
"gamma_v"))
72 if (coupledComponents(
"gamma_v") != n)
73 mooseError(
"The number of activity coefficients in gamma_v is not equal to the number of "
74 "coupled species in ",
84 RealGradient d_var_sum(0.0, 0.0, 0.0);
87 for (
unsigned int i = 0; i <
_vals.size(); ++i)
95 for (
unsigned int j = 0; j <
_vals.size(); ++j)
102 mooseAssert(
_gamma_eq[_qp] > 0.0,
"Activity coefficient must be greater than zero");
103 return _weight * std::pow(10.0,
_log_k[_qp]) * _test[_i][_qp] * darcy_vel * (d_u + d_var_sum) /
117 RealGradient d_var_sum(0.0, 0.0, 0.0);
121 for (
unsigned int i = 0; i <
_vals.size(); ++i)
129 for (
unsigned int j = 0; j <
_vals.size(); ++j)
136 RealGradient d_u_j = d_u_1 + d_u_2;
137 return _weight * std::pow(10.0,
_log_k[_qp]) * _test[_i][_qp] * darcy_vel * (d_u_j + d_var_sum) /
146 RealVectorValue ddarcy_vel_dp = -
_cond[_qp] * _grad_phi[_j][_qp];
150 RealGradient d_var_sum(0.0, 0.0, 0.0);
153 for (
unsigned int i = 0; i <
_vals.size(); ++i)
160 for (
unsigned int j = 0; j <
_vals.size(); ++j)
166 return _weight * std::pow(10.0,
_log_k[_qp]) * _test[_i][_qp] * ddarcy_vel_dp *
170 if (
_vals.size() == 0)
176 for (
unsigned int i = 0; i <
_vals.size(); ++i)
178 if (jvar ==
_vars[i])
186 RealGradient diff2_1(1.0, 1.0, 1.0);
187 RealGradient diff2_2(1.0, 1.0, 1.0);
188 for (
unsigned int i = 0; i <
_vals.size(); ++i)
189 if (jvar ==
_vars[i])
199 RealGradient diff2 = val_u * (diff2_1 + diff2_2);
200 for (
unsigned int i = 0; i <
_vals.size(); ++i)
201 if (jvar !=
_vars[i])
207 RealGradient diff3_sum(0.0, 0.0, 0.0);
209 unsigned int var = 0;
211 for (
unsigned int i = 0; i <
_vals.size(); ++i)
212 if (jvar ==
_vars[i])
219 for (
unsigned int i = 0; i <
_vals.size(); ++i)
226 for (
unsigned int j = 0; j <
_vals.size(); ++j)
227 if (j != var && j != i)
233 return _weight * std::pow(10.0,
_log_k[_qp]) * _test[_i][_qp] * darcy_vel *
234 (diff1 + diff2 + diff3_sum) /
_gamma_eq[_qp];
registerMooseObject("ChemicalReactionsApp", CoupledConvectionReactionSub)
void mooseError(Args &&... args)
Convection of primary species in given equilibrium species.
virtual Real computeQpResidual() override
const std::vector< const VariableValue * > _gamma_v
Activity coefficients of coupled primary species in the equilibrium species.
const VariableGradient & _grad_p
Pressure gradient.
const MaterialProperty< Real > & _cond
Hydraulic conductivity.
const Real _sto_u
Stoichiometric coefficient of the primary species.
const VariableValue & _log_k
Equilibrium constant for the equilibrium species in association form.
const std::vector< const VariableValue * > _vals
Coupled primary species concentrations.
virtual Real computeQpJacobian() override
const unsigned int _pvar
Pressure variable number.
const std::vector< const VariableGradient * > _grad_vals
Coupled gradients of primary species concentrations.
const VariableValue & _gamma_u
Activity coefficient of primary species in the equilibrium species.
const Real _weight
Weight of the equilibrium species concentration in the total primary species concentration.
CoupledConvectionReactionSub(const InputParameters ¶meters)
const std::vector< unsigned int > _vars
Coupled primary species variable numbers.
const VariableValue & _gamma_eq
Activity coefficient of equilibrium species.
const MaterialProperty< Real > & _density
Fluid density.
const RealVectorValue _gravity
Gravity.
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
const std::vector< Real > _sto_v
Stoichiometric coefficients of the coupled primary species.
static InputParameters validParams()
static InputParameters validParams()
VariableValueTempl< false > VariableValue