18 params.
addParam<Real>(
"weight", 1.0,
"Weight of the equilibrium species");
19 params.
addCoupledVar(
"log_k", 0.0,
"Equilibrium constant of dissociation equilibrium reaction");
22 "Stoichiometric coef of the primary species the kernel "
23 "operates on in the equilibrium reaction");
25 "gamma_u", 1.0,
"Activity coefficient of primary species that this kernel operates on");
29 "The stoichiometric coefficients of coupled primary species in equilibrium reaction");
32 params.
addCoupledVar(
"gamma_v", 1.0,
"Activity coefficients of coupled primary species");
33 params.
addCoupledVar(
"gamma_eq", 1.0,
"Activity coefficient of this equilibrium species");
34 RealVectorValue g(0, 0, 0);
35 params.
addParam<RealVectorValue>(
"gravity", g,
"Gravity vector (default is (0, 0, 0))");
42 _weight(getParam<Real>(
"weight")),
43 _log_k(coupledValue(
"log_k")),
44 _sto_u(getParam<Real>(
"sto_u")),
45 _sto_v(getParam<
std::vector<Real>>(
"sto_v")),
46 _cond(getMaterialProperty<Real>(
"conductivity")),
47 _gravity(getParam<RealVectorValue>(
"gravity")),
48 _density(getDefaultMaterialProperty<Real>(
"density")),
49 _grad_p(coupledGradient(
"p")),
51 _vars(coupledIndices(
"v")),
52 _vals(coupledValues(
"v")),
53 _grad_vals(coupledGradients(
"v")),
54 _gamma_u(coupledValue(
"gamma_u")),
55 _gamma_v(isCoupled(
"gamma_v")
56 ? coupledValues(
"gamma_v")
58 &coupledValue(
"gamma_v"))),
59 _gamma_eq(coupledValue(
"gamma_eq"))
61 const unsigned int n = coupledComponents(
"v");
65 mooseError(
"The number of stoichiometric coefficients in sto_v is not equal to the number of "
66 "coupled species in ",
69 if (isCoupled(
"gamma_v"))
70 if (coupledComponents(
"gamma_v") != n)
71 mooseError(
"The number of activity coefficients in gamma_v is not equal to the number of "
72 "coupled species in ",
82 RealGradient d_var_sum(0.0, 0.0, 0.0);
85 for (
unsigned int i = 0; i <
_vals.size(); ++i)
93 for (
unsigned int j = 0; j <
_vals.size(); ++j)
100 mooseAssert(
_gamma_eq[_qp] > 0.0,
"Activity coefficient must be greater than zero");
101 return _weight * std::pow(10.0,
_log_k[_qp]) * _test[_i][_qp] * darcy_vel * (d_u + d_var_sum) /
115 RealGradient d_var_sum(0.0, 0.0, 0.0);
119 for (
unsigned int i = 0; i <
_vals.size(); ++i)
127 for (
unsigned int j = 0; j <
_vals.size(); ++j)
134 RealGradient d_u_j = d_u_1 + d_u_2;
135 return _weight * std::pow(10.0,
_log_k[_qp]) * _test[_i][_qp] * darcy_vel * (d_u_j + d_var_sum) /
144 RealVectorValue ddarcy_vel_dp = -
_cond[_qp] * _grad_phi[_j][_qp];
148 RealGradient d_var_sum(0.0, 0.0, 0.0);
151 for (
unsigned int i = 0; i <
_vals.size(); ++i)
158 for (
unsigned int j = 0; j <
_vals.size(); ++j)
164 return _weight * std::pow(10.0,
_log_k[_qp]) * _test[_i][_qp] * ddarcy_vel_dp *
168 if (
_vals.size() == 0)
174 for (
unsigned int i = 0; i <
_vals.size(); ++i)
176 if (jvar ==
_vars[i])
184 RealGradient diff2_1(1.0, 1.0, 1.0);
185 RealGradient diff2_2(1.0, 1.0, 1.0);
186 for (
unsigned int i = 0; i <
_vals.size(); ++i)
187 if (jvar ==
_vars[i])
197 RealGradient diff2 = val_u * (diff2_1 + diff2_2);
198 for (
unsigned int i = 0; i <
_vals.size(); ++i)
199 if (jvar !=
_vars[i])
205 RealGradient diff3_sum(0.0, 0.0, 0.0);
207 unsigned int var = 0;
209 for (
unsigned int i = 0; i <
_vals.size(); ++i)
210 if (jvar ==
_vars[i])
217 for (
unsigned int i = 0; i <
_vals.size(); ++i)
224 for (
unsigned int j = 0; j <
_vals.size(); ++j)
225 if (j != var && j != i)
231 return _weight * std::pow(10.0,
_log_k[_qp]) * _test[_i][_qp] * darcy_vel *
232 (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