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

Define the Kernel for a CoupledBEEquilibriumSub operator that looks like: grad (diff * grad (weight * 10^log_k * u^sto_u * v^sto_v)). More...

#include <CoupledDiffusionReactionSub.h>

Inheritance diagram for CoupledDiffusionReactionSub:
[legend]

Public Member Functions

 CoupledDiffusionReactionSub (const InputParameters &parameters)
 

Protected Member Functions

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

Private Attributes

const MaterialProperty< Real > & _diffusivity
 Material property of dispersion-diffusion coefficient. More...
 
const Real _weight
 Weight of the equilibrium species concentration in the total primary species concentration. More...
 
const Real _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...
 
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...
 

Detailed Description

Define the Kernel for a CoupledBEEquilibriumSub operator that looks like: grad (diff * grad (weight * 10^log_k * u^sto_u * v^sto_v)).

Definition at line 22 of file CoupledDiffusionReactionSub.h.

Constructor & Destructor Documentation

CoupledDiffusionReactionSub::CoupledDiffusionReactionSub ( const InputParameters &  parameters)

Definition at line 31 of file CoupledDiffusionReactionSub.C.

32  : Kernel(parameters),
33  _diffusivity(getMaterialProperty<Real>("diffusivity")),
34  _weight(getParam<Real>("weight")),
35  _log_k(getParam<Real>("log_k")),
36  _sto_u(getParam<Real>("sto_u")),
37  _sto_v(getParam<std::vector<Real>>("sto_v"))
38 {
39  const unsigned int n = coupledComponents("v");
40  _vars.resize(n);
41  _vals.resize(n);
42  _grad_vals.resize(n);
43 
44  for (unsigned int i = 0; i < n; ++i)
45  {
46  _vars[i] = coupled("v", i);
47  _vals[i] = &coupledValue("v", i);
48  _grad_vals[i] = &coupledGradient("v", i);
49  }
50 }
std::vector< const VariableGradient * > _grad_vals
Coupled gradients of primary species concentrations.
const Real _weight
Weight of the equilibrium species concentration in the total primary species concentration.
std::vector< const VariableValue * > _vals
Coupled primary species concentrations.
const std::vector< Real > _sto_v
Stoichiometric coefficients of the coupled primary species.
const Real _sto_u
Stoichiometric coefficient of the primary species.
const Real _log_k
Equilibrium constant for the equilibrium species in association form.
const MaterialProperty< Real > & _diffusivity
Material property of dispersion-diffusion coefficient.
std::vector< unsigned int > _vars
Coupled primary species variable numbers.

Member Function Documentation

Real CoupledDiffusionReactionSub::computeQpJacobian ( )
overrideprotectedvirtual

Definition at line 78 of file CoupledDiffusionReactionSub.C.

79 {
80  RealGradient diff1_1 = _sto_u * std::pow(_u[_qp], _sto_u - 1.0) * _grad_phi[_j][_qp];
81  RealGradient diff1_2 =
82  _phi[_j][_qp] * _sto_u * (_sto_u - 1.0) * std::pow(_u[_qp], _sto_u - 2.0) * _grad_u[_qp];
83  for (unsigned int i = 0; i < _vals.size(); ++i)
84  {
85  diff1_1 *= std::pow((*_vals[i])[_qp], _sto_v[i]);
86  diff1_2 *= std::pow((*_vals[i])[_qp], _sto_v[i]);
87  }
88 
89  RealGradient diff1 = diff1_1 + diff1_2;
90  Real d_val = _sto_u * std::pow(_u[_qp], _sto_u - 1.0) * _phi[_j][_qp];
91  RealGradient diff2_sum(0.0, 0.0, 0.0);
92  for (unsigned int i = 0; i < _vals.size(); ++i)
93  {
94  RealGradient diff2 =
95  d_val * _sto_v[i] * std::pow((*_vals[i])[_qp], _sto_v[i] - 1.0) * (*_grad_vals[i])[_qp];
96  for (unsigned int j = 0; j < _vals.size(); ++j)
97  if (j != i)
98  diff2 *= std::pow((*_vals[j])[_qp], _sto_v[j]);
99 
100  diff2_sum += diff2;
101  }
102 
103  return _weight * std::pow(10.0, _log_k) * _diffusivity[_qp] * _grad_test[_i][_qp] *
104  (diff1 + diff2_sum);
105 }
std::vector< const VariableGradient * > _grad_vals
Coupled gradients of primary species concentrations.
const Real _weight
Weight of the equilibrium species concentration in the total primary species concentration.
std::vector< const VariableValue * > _vals
Coupled primary species concentrations.
const std::vector< Real > _sto_v
Stoichiometric coefficients of the coupled primary species.
const Real _sto_u
Stoichiometric coefficient of the primary species.
const Real _log_k
Equilibrium constant for the equilibrium species in association form.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const MaterialProperty< Real > & _diffusivity
Material property of dispersion-diffusion coefficient.
Real CoupledDiffusionReactionSub::computeQpOffDiagJacobian ( unsigned int  jvar)
overrideprotectedvirtual

Definition at line 108 of file CoupledDiffusionReactionSub.C.

109 {
110  // If no coupled species, return 0
111  if (_vals.size() == 0)
112  return 0.0;
113 
114  // If jvar is not one of the coupled species, return 0
115  if (std::find(_vars.begin(), _vars.end(), jvar) == _vars.end())
116  return 0.0;
117 
118  RealGradient diff1 = _sto_u * std::pow(_u[_qp], _sto_u - 1.0) * _grad_u[_qp];
119  for (unsigned int i = 0; i < _vals.size(); ++i)
120  {
121  if (jvar == _vars[i])
122  diff1 *= _sto_v[i] * std::pow((*_vals[i])[_qp], _sto_v[i] - 1.0) * _phi[_j][_qp];
123  else
124  diff1 *= std::pow((*_vals[i])[_qp], _sto_v[i]);
125  }
126 
127  Real val_u = std::pow(_u[_qp], _sto_u);
128 
129  RealGradient diff2_1(1.0, 1.0, 1.0);
130  RealGradient diff2_2(1.0, 1.0, 1.0);
131 
132  for (unsigned int i = 0; i < _vals.size(); ++i)
133  if (jvar == _vars[i])
134  {
135  diff2_1 = _sto_v[i] * (_sto_v[i] - 1.0) * std::pow((*_vals[i])[_qp], _sto_v[i] - 2.0) *
136  _phi[_j][_qp] * (*_grad_vals[i])[_qp];
137  diff2_2 = _sto_v[i] * std::pow((*_vals[i])[_qp], _sto_v[i] - 1.0) * _grad_phi[_j][_qp];
138  }
139 
140  RealGradient diff2 = val_u * (diff2_1 + diff2_2);
141 
142  for (unsigned int i = 0; i < _vals.size(); ++i)
143  if (jvar != _vars[i])
144  diff2 *= std::pow((*_vals[i])[_qp], _sto_v[i]);
145 
146  RealGradient diff3;
147  RealGradient diff3_sum(0.0, 0.0, 0.0);
148  Real val_jvar = 0.0;
149  unsigned int var = 0;
150 
151  for (unsigned int i = 0; i < _vals.size(); ++i)
152  if (jvar == _vars[i])
153  {
154  var = i;
155  val_jvar = val_u * _sto_v[i] * std::pow((*_vals[i])[_qp], _sto_v[i] - 1.0) * _phi[_j][_qp];
156  }
157 
158  for (unsigned int i = 0; i < _vals.size(); ++i)
159  if (i != var)
160  {
161  diff3 = val_jvar * _sto_v[i] * std::pow((*_vals[i])[_qp], _sto_v[i] - 1.0) *
162  (*_grad_vals[i])[_qp];
163 
164  for (unsigned int j = 0; j < _vals.size(); ++j)
165  if (j != var && j != i)
166  diff3 *= std::pow((*_vals[j])[_qp], _sto_v[j]);
167 
168  diff3_sum += diff3;
169  }
170 
171  return _weight * std::pow(10.0, _log_k) * _diffusivity[_qp] * _grad_test[_i][_qp] *
172  (diff1 + diff2 + diff3_sum);
173 }
std::vector< const VariableGradient * > _grad_vals
Coupled gradients of primary species concentrations.
const Real _weight
Weight of the equilibrium species concentration in the total primary species concentration.
std::vector< const VariableValue * > _vals
Coupled primary species concentrations.
const std::vector< Real > _sto_v
Stoichiometric coefficients of the coupled primary species.
const Real _sto_u
Stoichiometric coefficient of the primary species.
const Real _log_k
Equilibrium constant for the equilibrium species in association form.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const MaterialProperty< Real > & _diffusivity
Material property of dispersion-diffusion coefficient.
std::vector< unsigned int > _vars
Coupled primary species variable numbers.
Real CoupledDiffusionReactionSub::computeQpResidual ( )
overrideprotectedvirtual

Definition at line 53 of file CoupledDiffusionReactionSub.C.

54 {
55  RealGradient diff1 = _sto_u * std::pow(_u[_qp], _sto_u - 1.0) * _grad_u[_qp];
56  for (unsigned int i = 0; i < _vals.size(); ++i)
57  diff1 *= std::pow((*_vals[i])[_qp], _sto_v[i]);
58 
59  RealGradient diff2_sum(0.0, 0.0, 0.0);
60  const Real d_val = std::pow(_u[_qp], _sto_u);
61  for (unsigned int i = 0; i < _vals.size(); ++i)
62  {
63  RealGradient diff2 =
64  d_val * _sto_v[i] * std::pow((*_vals[i])[_qp], _sto_v[i] - 1.0) * (*_grad_vals[i])[_qp];
65 
66  for (unsigned int j = 0; j < _vals.size(); ++j)
67  if (j != i)
68  diff2 *= std::pow((*_vals[j])[_qp], _sto_v[j]);
69 
70  diff2_sum += diff2;
71  }
72 
73  return _weight * std::pow(10.0, _log_k) * _diffusivity[_qp] * _grad_test[_i][_qp] *
74  (diff1 + diff2_sum);
75 }
std::vector< const VariableGradient * > _grad_vals
Coupled gradients of primary species concentrations.
const Real _weight
Weight of the equilibrium species concentration in the total primary species concentration.
std::vector< const VariableValue * > _vals
Coupled primary species concentrations.
const std::vector< Real > _sto_v
Stoichiometric coefficients of the coupled primary species.
const Real _sto_u
Stoichiometric coefficient of the primary species.
const Real _log_k
Equilibrium constant for the equilibrium species in association form.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const MaterialProperty< Real > & _diffusivity
Material property of dispersion-diffusion coefficient.

Member Data Documentation

const MaterialProperty<Real>& CoupledDiffusionReactionSub::_diffusivity
private

Material property of dispersion-diffusion coefficient.

Definition at line 34 of file CoupledDiffusionReactionSub.h.

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

std::vector<const VariableGradient *> CoupledDiffusionReactionSub::_grad_vals
private

Coupled gradients of primary species concentrations.

Definition at line 55 of file CoupledDiffusionReactionSub.h.

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

const Real CoupledDiffusionReactionSub::_log_k
private

Equilibrium constant for the equilibrium species in association form.

Definition at line 40 of file CoupledDiffusionReactionSub.h.

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

const Real CoupledDiffusionReactionSub::_sto_u
private

Stoichiometric coefficient of the primary species.

Definition at line 43 of file CoupledDiffusionReactionSub.h.

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

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

Stoichiometric coefficients of the coupled primary species.

Definition at line 46 of file CoupledDiffusionReactionSub.h.

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

std::vector<const VariableValue *> CoupledDiffusionReactionSub::_vals
private

Coupled primary species concentrations.

Definition at line 52 of file CoupledDiffusionReactionSub.h.

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

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

Coupled primary species variable numbers.

Definition at line 49 of file CoupledDiffusionReactionSub.h.

Referenced by computeQpOffDiagJacobian(), and CoupledDiffusionReactionSub().

const Real CoupledDiffusionReactionSub::_weight
private

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

Definition at line 37 of file CoupledDiffusionReactionSub.h.

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


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