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

Convection of primary species in given equilibrium species. More...

#include <CoupledConvectionReactionSub.h>

Inheritance diagram for CoupledConvectionReactionSub:
[legend]

Public Member Functions

 CoupledConvectionReactionSub (const InputParameters &parameters)
 

Protected Member Functions

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

Protected Attributes

const Real _weight
 Weight of the equilibrium species concentration in the total primary species concentration. More...
 
const VariableValue & _log_k
 Equilibrium constant for the equilibrium species in association form. More...
 
const Real _sto_u
 Stoichiometric coefficient of the primary species. More...
 
const std::vector< Real > _sto_v
 Stoichiometric coefficients of the coupled primary species. More...
 
const MaterialProperty< Real > & _cond
 Hydraulic conductivity. More...
 
const RealVectorValue _gravity
 Gravity. More...
 
const MaterialProperty< Real > & _density
 Fluid density. More...
 
const VariableGradient & _grad_p
 Pressure gradient. More...
 
const unsigned int _pvar
 Pressure variable number. More...
 
std::vector< unsigned int > _vars
 Coupled primary species variable numbers. More...
 
std::vector< const VariableValue * > _vals
 Coupled primary species concentrations. More...
 
std::vector< const VariableGradient * > _grad_vals
 Coupled gradients of primary species concentrations. More...
 
const VariableValue & _gamma_u
 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...
 
const VariableValue & _gamma_eq
 Activity coefficient of equilibrium species. More...
 

Detailed Description

Convection of primary species in given equilibrium species.

Definition at line 24 of file CoupledConvectionReactionSub.h.

Constructor & Destructor Documentation

◆ CoupledConvectionReactionSub()

CoupledConvectionReactionSub::CoupledConvectionReactionSub ( const InputParameters &  parameters)

Definition at line 40 of file CoupledConvectionReactionSub.C.

41  : DerivativeMaterialInterface<Kernel>(parameters),
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")),
50  _pvar(coupled("p")),
51  _gamma_u(coupledValue("gamma_u")),
52  _gamma_eq(coupledValue("gamma_eq"))
53 {
54  const unsigned int n = coupledComponents("v");
55 
56  // Check that the correct number of coupled values have been provided
57  if (_sto_v.size() != n)
58  mooseError("The number of stoichiometric coefficients in sto_v is not equal to the number of "
59  "coupled species in ",
60  _name);
61 
62  if (isCoupled("gamma_v"))
63  if (coupledComponents("gamma_v") != n)
64  mooseError("The number of activity coefficients in gamma_v is not equal to the number of "
65  "coupled species in ",
66  _name);
67  _vars.resize(n);
68  _vals.resize(n);
69  _grad_vals.resize(n);
70  _gamma_v.resize(n);
71 
72  for (unsigned int i = 0; i < n; ++i)
73  {
74  _vars[i] = coupled("v", i);
75  _vals[i] = &coupledValue("v", i);
76  _grad_vals[i] = &coupledGradient("v", i);
77  // If gamma_v has been supplied, use those values, but if not, use the default value
78  _gamma_v[i] = (isCoupled("gamma_v") ? &coupledValue("gamma_v", i) : &coupledValue("gamma_v"));
79  }
80 }
const VariableValue & _gamma_eq
Activity coefficient of equilibrium species.
std::vector< const VariableValue * > _gamma_v
Activity coefficients of coupled primary species in the equilibrium species.
std::vector< const VariableGradient * > _grad_vals
Coupled gradients of primary species concentrations.
const MaterialProperty< Real > & _density
Fluid density.
const std::vector< Real > _sto_v
Stoichiometric coefficients of the coupled primary species.
const VariableGradient & _grad_p
Pressure gradient.
const unsigned int _pvar
Pressure variable number.
const VariableValue & _log_k
Equilibrium constant for the equilibrium species in association form.
const Real _weight
Weight of the equilibrium species concentration in the total primary species concentration.
const RealVectorValue _gravity
Gravity.
std::vector< unsigned int > _vars
Coupled primary species variable numbers.
const Real _sto_u
Stoichiometric coefficient of the primary species.
const MaterialProperty< Real > & _cond
Hydraulic conductivity.
const VariableValue & _gamma_u
Activity coefficient of primary species in the equilibrium species.
std::vector< const VariableValue * > _vals
Coupled primary species concentrations.

Member Function Documentation

◆ computeQpJacobian()

Real CoupledConvectionReactionSub::computeQpJacobian ( )
overrideprotectedvirtual

Definition at line 112 of file CoupledConvectionReactionSub.C.

113 {
114  RealVectorValue darcy_vel = -_cond[_qp] * (_grad_p[_qp] - _density[_qp] * _gravity);
115 
116  RealGradient d_u_1 =
117  _sto_u * _gamma_u[_qp] * std::pow(_gamma_u[_qp] * _u[_qp], _sto_u - 1.0) * _grad_phi[_j][_qp];
118  RealGradient d_u_2 = _phi[_j][_qp] * _sto_u * (_sto_u - 1.0) * _gamma_u[_qp] * _gamma_u[_qp] *
119  std::pow(_gamma_u[_qp] * _u[_qp], _sto_u - 2.0) * _grad_u[_qp];
120 
121  RealGradient d_var_sum(0.0, 0.0, 0.0);
122  const Real d_v_u =
123  _sto_u * _gamma_u[_qp] * std::pow(_gamma_u[_qp] * _u[_qp], _sto_u - 1.0) * _phi[_j][_qp];
124 
125  for (unsigned int i = 0; i < _vals.size(); ++i)
126  {
127  d_u_1 *= std::pow((*_gamma_v[i])[_qp] * (*_vals[i])[_qp], _sto_v[i]);
128  d_u_2 *= std::pow((*_gamma_v[i])[_qp] * (*_vals[i])[_qp], _sto_v[i]);
129 
130  RealGradient d_var = d_v_u * _sto_v[i] * (*_gamma_v[i])[_qp] *
131  std::pow((*_gamma_v[i])[_qp] * (*_vals[i])[_qp], _sto_v[i] - 1.0) *
132  (*_grad_vals[i])[_qp];
133  for (unsigned int j = 0; j < _vals.size(); ++j)
134  if (j != i)
135  d_var *= std::pow((*_gamma_v[i])[_qp] * (*_vals[j])[_qp], _sto_v[j]);
136 
137  d_var_sum += d_var;
138  }
139 
140  RealGradient d_u_j = d_u_1 + d_u_2;
141  return _weight * std::pow(10.0, _log_k[_qp]) * _test[_i][_qp] * darcy_vel * (d_u_j + d_var_sum) /
142  _gamma_eq[_qp];
143 }
const VariableValue & _gamma_eq
Activity coefficient of equilibrium species.
std::vector< const VariableValue * > _gamma_v
Activity coefficients of coupled primary species in the equilibrium species.
std::vector< const VariableGradient * > _grad_vals
Coupled gradients of primary species concentrations.
const MaterialProperty< Real > & _density
Fluid density.
const std::vector< Real > _sto_v
Stoichiometric coefficients of the coupled primary species.
const VariableGradient & _grad_p
Pressure gradient.
const VariableValue & _log_k
Equilibrium constant for the equilibrium species in association form.
const Real _weight
Weight of the equilibrium species concentration in the total primary species concentration.
const RealVectorValue _gravity
Gravity.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const Real _sto_u
Stoichiometric coefficient of the primary species.
const MaterialProperty< Real > & _cond
Hydraulic conductivity.
const VariableValue & _gamma_u
Activity coefficient of primary species in the equilibrium species.
std::vector< const VariableValue * > _vals
Coupled primary species concentrations.

◆ computeQpOffDiagJacobian()

Real CoupledConvectionReactionSub::computeQpOffDiagJacobian ( unsigned int  jvar)
overrideprotectedvirtual

Definition at line 146 of file CoupledConvectionReactionSub.C.

147 {
148  if (jvar == _pvar)
149  {
150  RealVectorValue ddarcy_vel_dp = -_cond[_qp] * _grad_phi[_j][_qp];
151 
152  RealGradient d_u =
153  _sto_u * _gamma_u[_qp] * std::pow(_gamma_u[_qp] * _u[_qp], _sto_u - 1.0) * _grad_u[_qp];
154  RealGradient d_var_sum(0.0, 0.0, 0.0);
155  const Real d_v_u = std::pow(_gamma_u[_qp] * _u[_qp], _sto_u);
156 
157  for (unsigned int i = 0; i < _vals.size(); ++i)
158  {
159  d_u *= std::pow((*_gamma_v[i])[_qp] * (*_vals[i])[_qp], _sto_v[i]);
160 
161  RealGradient d_var = d_v_u * _sto_v[i] * (*_gamma_v[i])[_qp] *
162  std::pow((*_gamma_v[i])[_qp] * (*_vals[i])[_qp], _sto_v[i] - 1.0) *
163  (*_grad_vals[i])[_qp];
164  for (unsigned int j = 0; j < _vals.size(); ++j)
165  if (j != i)
166  d_var *= std::pow((*_gamma_v[i])[_qp] * (*_vals[j])[_qp], _sto_v[j]);
167 
168  d_var_sum += d_var;
169  }
170  return _weight * std::pow(10.0, _log_k[_qp]) * _test[_i][_qp] * ddarcy_vel_dp *
171  (d_u + d_var_sum) / _gamma_eq[_qp];
172  }
173 
174  if (_vals.size() == 0)
175  return 0.0;
176 
177  RealVectorValue darcy_vel = -_cond[_qp] * (_grad_p[_qp] - _density[_qp] * _gravity);
178  RealGradient diff1 =
179  _sto_u * _gamma_u[_qp] * std::pow(_gamma_u[_qp] * _u[_qp], _sto_u - 1.0) * _grad_u[_qp];
180  for (unsigned int i = 0; i < _vals.size(); ++i)
181  {
182  if (jvar == _vars[i])
183  diff1 *= _sto_v[i] * (*_gamma_v[i])[_qp] *
184  std::pow((*_gamma_v[i])[_qp] * (*_vals[i])[_qp], _sto_v[i] - 1.0) * _phi[_j][_qp];
185  else
186  diff1 *= std::pow((*_gamma_v[i])[_qp] * (*_vals[i])[_qp], _sto_v[i]);
187  }
188 
189  Real val_u = std::pow(_gamma_u[_qp] * _u[_qp], _sto_u);
190  RealGradient diff2_1(1.0, 1.0, 1.0);
191  RealGradient diff2_2(1.0, 1.0, 1.0);
192  for (unsigned int i = 0; i < _vals.size(); ++i)
193  if (jvar == _vars[i])
194  {
195  diff2_1 = _sto_v[i] * (*_gamma_v[i])[_qp] * (*_gamma_v[i])[_qp] * (_sto_v[i] - 1.0) *
196  std::pow((*_gamma_v[i])[_qp] * (*_vals[i])[_qp], _sto_v[i] - 2.0) * _phi[_j][_qp] *
197  (*_grad_vals[i])[_qp];
198  diff2_2 = _sto_v[i] * (*_gamma_v[i])[_qp] *
199  std::pow((*_gamma_v[i])[_qp] * (*_vals[i])[_qp], _sto_v[i] - 1.0) *
200  _grad_phi[_j][_qp];
201  }
202 
203  RealGradient diff2 = val_u * (diff2_1 + diff2_2);
204  for (unsigned int i = 0; i < _vals.size(); ++i)
205  if (jvar != _vars[i])
206  {
207  diff2 *= std::pow((*_gamma_v[i])[_qp] * (*_vals[i])[_qp], _sto_v[i]);
208  }
209 
210  RealGradient diff3;
211  RealGradient diff3_sum(0.0, 0.0, 0.0);
212  Real val_jvar = 0.0;
213  unsigned int var = 0;
214 
215  for (unsigned int i = 0; i < _vals.size(); ++i)
216  if (jvar == _vars[i])
217  {
218  var = i;
219  val_jvar = val_u * _sto_v[i] * (*_gamma_v[i])[_qp] *
220  std::pow((*_gamma_v[i])[_qp] * (*_vals[i])[_qp], _sto_v[i] - 1.0) * _phi[_j][_qp];
221  }
222 
223  for (unsigned int i = 0; i < _vals.size(); ++i)
224  if (i != var)
225  {
226  diff3 = val_jvar * _sto_v[i] * (*_gamma_v[i])[_qp] *
227  std::pow((*_gamma_v[i])[_qp] * (*_vals[i])[_qp], _sto_v[i] - 1.0) *
228  (*_grad_vals[i])[_qp];
229 
230  for (unsigned int j = 0; j < _vals.size(); ++j)
231  if (j != var && j != i)
232  diff3 *= std::pow((*_gamma_v[i])[_qp] * (*_vals[j])[_qp], _sto_v[j]);
233 
234  diff3_sum += diff3;
235  }
236 
237  return _weight * std::pow(10.0, _log_k[_qp]) * _test[_i][_qp] * darcy_vel *
238  (diff1 + diff2 + diff3_sum) / _gamma_eq[_qp];
239 }
const VariableValue & _gamma_eq
Activity coefficient of equilibrium species.
std::vector< const VariableValue * > _gamma_v
Activity coefficients of coupled primary species in the equilibrium species.
std::vector< const VariableGradient * > _grad_vals
Coupled gradients of primary species concentrations.
const MaterialProperty< Real > & _density
Fluid density.
const std::vector< Real > _sto_v
Stoichiometric coefficients of the coupled primary species.
const VariableGradient & _grad_p
Pressure gradient.
const unsigned int _pvar
Pressure variable number.
const VariableValue & _log_k
Equilibrium constant for the equilibrium species in association form.
const Real _weight
Weight of the equilibrium species concentration in the total primary species concentration.
const RealVectorValue _gravity
Gravity.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
std::vector< unsigned int > _vars
Coupled primary species variable numbers.
const Real _sto_u
Stoichiometric coefficient of the primary species.
const MaterialProperty< Real > & _cond
Hydraulic conductivity.
const VariableValue & _gamma_u
Activity coefficient of primary species in the equilibrium species.
std::vector< const VariableValue * > _vals
Coupled primary species concentrations.

◆ computeQpResidual()

Real CoupledConvectionReactionSub::computeQpResidual ( )
overrideprotectedvirtual

Definition at line 83 of file CoupledConvectionReactionSub.C.

84 {
85  RealVectorValue darcy_vel = -_cond[_qp] * (_grad_p[_qp] - _density[_qp] * _gravity);
86  RealGradient d_u =
87  _sto_u * _gamma_u[_qp] * std::pow(_gamma_u[_qp] * _u[_qp], _sto_u - 1.0) * _grad_u[_qp];
88  RealGradient d_var_sum(0.0, 0.0, 0.0);
89  const Real d_v_u = std::pow(_gamma_u[_qp] * _u[_qp], _sto_u);
90 
91  for (unsigned int i = 0; i < _vals.size(); ++i)
92  {
93  d_u *= std::pow((*_gamma_v[i])[_qp] * (*_vals[i])[_qp], _sto_v[i]);
94 
95  RealGradient d_var = d_v_u * _sto_v[i] * (*_gamma_v[i])[_qp] *
96  std::pow((*_gamma_v[i])[_qp] * (*_vals[i])[_qp], _sto_v[i] - 1.0) *
97  (*_grad_vals[i])[_qp];
98 
99  for (unsigned int j = 0; j < _vals.size(); ++j)
100  if (j != i)
101  d_var *= std::pow((*_gamma_v[i])[_qp] * (*_vals[j])[_qp], _sto_v[j]);
102 
103  d_var_sum += d_var;
104  }
105 
106  mooseAssert(_gamma_eq[_qp] > 0.0, "Activity coefficient must be greater than zero");
107  return _weight * std::pow(10.0, _log_k[_qp]) * _test[_i][_qp] * darcy_vel * (d_u + d_var_sum) /
108  _gamma_eq[_qp];
109 }
const VariableValue & _gamma_eq
Activity coefficient of equilibrium species.
std::vector< const VariableValue * > _gamma_v
Activity coefficients of coupled primary species in the equilibrium species.
std::vector< const VariableGradient * > _grad_vals
Coupled gradients of primary species concentrations.
const MaterialProperty< Real > & _density
Fluid density.
const std::vector< Real > _sto_v
Stoichiometric coefficients of the coupled primary species.
const VariableGradient & _grad_p
Pressure gradient.
const VariableValue & _log_k
Equilibrium constant for the equilibrium species in association form.
const Real _weight
Weight of the equilibrium species concentration in the total primary species concentration.
const RealVectorValue _gravity
Gravity.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const Real _sto_u
Stoichiometric coefficient of the primary species.
const MaterialProperty< Real > & _cond
Hydraulic conductivity.
const VariableValue & _gamma_u
Activity coefficient of primary species in the equilibrium species.
std::vector< const VariableValue * > _vals
Coupled primary species concentrations.

Member Data Documentation

◆ _cond

const MaterialProperty<Real>& CoupledConvectionReactionSub::_cond
protected

Hydraulic conductivity.

Definition at line 43 of file CoupledConvectionReactionSub.h.

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

◆ _density

const MaterialProperty<Real>& CoupledConvectionReactionSub::_density
protected

Fluid density.

Definition at line 47 of file CoupledConvectionReactionSub.h.

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

◆ _gamma_eq

const VariableValue& CoupledConvectionReactionSub::_gamma_eq
protected

Activity coefficient of equilibrium species.

Definition at line 63 of file CoupledConvectionReactionSub.h.

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

◆ _gamma_u

const VariableValue& CoupledConvectionReactionSub::_gamma_u
protected

Activity coefficient of primary species in the equilibrium species.

Definition at line 59 of file CoupledConvectionReactionSub.h.

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

◆ _gamma_v

std::vector<const VariableValue *> CoupledConvectionReactionSub::_gamma_v
protected

Activity coefficients of coupled primary species in the equilibrium species.

Definition at line 61 of file CoupledConvectionReactionSub.h.

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

◆ _grad_p

const VariableGradient& CoupledConvectionReactionSub::_grad_p
protected

◆ _grad_vals

std::vector<const VariableGradient *> CoupledConvectionReactionSub::_grad_vals
protected

Coupled gradients of primary species concentrations.

Definition at line 57 of file CoupledConvectionReactionSub.h.

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

◆ _gravity

const RealVectorValue CoupledConvectionReactionSub::_gravity
protected

◆ _log_k

const VariableValue& CoupledConvectionReactionSub::_log_k
protected

Equilibrium constant for the equilibrium species in association form.

Definition at line 37 of file CoupledConvectionReactionSub.h.

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

◆ _pvar

const unsigned int CoupledConvectionReactionSub::_pvar
protected

Pressure variable number.

Definition at line 51 of file CoupledConvectionReactionSub.h.

Referenced by computeQpOffDiagJacobian().

◆ _sto_u

const Real CoupledConvectionReactionSub::_sto_u
protected

Stoichiometric coefficient of the primary species.

Definition at line 39 of file CoupledConvectionReactionSub.h.

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

◆ _sto_v

const std::vector<Real> CoupledConvectionReactionSub::_sto_v
protected

Stoichiometric coefficients of the coupled primary species.

Definition at line 41 of file CoupledConvectionReactionSub.h.

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

◆ _vals

std::vector<const VariableValue *> CoupledConvectionReactionSub::_vals
protected

Coupled primary species concentrations.

Definition at line 55 of file CoupledConvectionReactionSub.h.

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

◆ _vars

std::vector<unsigned int> CoupledConvectionReactionSub::_vars
protected

Coupled primary species variable numbers.

Definition at line 53 of file CoupledConvectionReactionSub.h.

Referenced by computeQpOffDiagJacobian(), and CoupledConvectionReactionSub().

◆ _weight

const Real CoupledConvectionReactionSub::_weight
protected

Weight of the equilibrium species concentration in the total primary species concentration.

Definition at line 35 of file CoupledConvectionReactionSub.h.

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


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