https://mooseframework.inl.gov
SLKKSPhaseConcentration.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 
13 
16 {
17  auto params = Kernel::validParams();
18  params.addClassDescription(
19  "Sublattice KKS model kernel to enforce the decomposition of concentration into "
20  "phase and sublattice concentrations The non-linear variable of this kernel is a sublattice "
21  "concentration of phase b.");
22  params.addRequiredCoupledVar("ca", "Phase a sublattice concentrations");
23  params.addRequiredParam<std::vector<Real>>("aa", "Phase a sublattice site fraction");
24  params.addRequiredCoupledVar(
25  "cb", "Phase b sublattice concentrations (except for the kernel variable)");
26  params.addRequiredParam<std::vector<Real>>("ab", "Phase b sublattice site fraction");
27  params.addRequiredParam<Real>("a",
28  "Sublattice site fraction for the kernel variable (in phase b)");
29  params.addRequiredCoupledVar("c", "Global concentration");
30  params.addRequiredCoupledVar("eta", "Phase a/b order parameter");
31  params.addParam<MaterialPropertyName>(
32  "h_name", "h", "Base name for the switching function h(eta)");
33  return params;
34 }
35 
36 // Phase interpolation func
39  _nca(coupledComponents("ca")),
40  _ca(_nca),
41  _a_ca(getParam<std::vector<Real>>("aa")),
42  _ca_map(getParameterJvarMap("ca")),
43  _ncb(coupledComponents("cb")),
44  _cb(_ncb),
45  _a_cb(getParam<std::vector<Real>>("ab")),
46  _cb_map(getParameterJvarMap("cb")),
47  _a_u(getParam<Real>("a")),
48  _c(coupledValue("c")),
49  _c_var(coupled("c")),
50  _eta(coupledValue("eta")),
51  _eta_var(coupled("eta")),
52  _prop_h(getMaterialProperty<Real>("h_name")),
53  _prop_dh(getMaterialPropertyDerivative<Real>("h_name", coupledName("eta", 0)))
54 {
55  if (_a_ca.size() != _nca)
56  paramError("aa", "Specify one sublattice site fraction per sublattice concentration variable");
57  if (_a_cb.size() != _ncb)
58  paramError("ab", "Specify one sublattice site fraction per sublattice concentration variable");
59 
60  // check and re-normalize sublattice A site fractions
61  Real sum = 0.0;
62  for (std::size_t i = 0; i < _nca; ++i)
63  sum += _a_ca[i];
64  if (sum <= 0.0)
65  paramError("aa", "The sum of the aa values must be greater than zero");
66  for (std::size_t i = 0; i < _nca; ++i)
67  _a_ca[i] /= sum;
68 
69  // check and re-normalize sublattice B site fractions
70  sum = _a_u;
71  for (std::size_t i = 0; i < _ncb; ++i)
72  sum += _a_cb[i];
73  if (sum <= 0.0)
74  paramError("ab", "The sum of the ab values and k must be greater than zero");
75  for (std::size_t i = 0; i < _ncb; ++i)
76  _a_cb[i] /= sum;
77  _a_u /= sum;
78 
79  // fetch coupled concentrations
80  for (std::size_t i = 0; i < _nca; ++i)
81  _ca[i] = &coupledValue("ca", i);
82  for (std::size_t i = 0; i < _ncb; ++i)
83  _cb[i] = &coupledValue("cb", i);
84 }
85 
86 Real
88 {
89  computeSums();
90  return _test[_i][_qp] * ((1.0 - _prop_h[_qp]) * _casum + _prop_h[_qp] * _cbsum - _c[_qp]);
91 }
92 
93 Real
95 {
96  return _test[_i][_qp] * _prop_h[_qp] * _phi[_j][_qp] * _a_u;
97 }
98 
99 Real
101 {
102  if (jvar == _c_var)
103  return -_test[_i][_qp] * _phi[_j][_qp];
104 
105  if (jvar == _eta_var)
106  {
107  computeSums();
108  return _test[_i][_qp] * (_cbsum - _casum) * _prop_dh[_qp] * _phi[_j][_qp];
109  }
110 
111  auto cavar = mapJvarToCvar(jvar, _ca_map);
112  if (cavar >= 0)
113  return _test[_i][_qp] * (1.0 - _prop_h[_qp]) * _phi[_j][_qp] * _a_ca[cavar];
114 
115  auto cbvar = mapJvarToCvar(jvar, _cb_map);
116  if (cbvar >= 0)
117  return _test[_i][_qp] * _prop_h[_qp] * _phi[_j][_qp] * _a_cb[cbvar];
118 
119  return 0.0;
120 }
121 
122 void
124 {
125  _casum = 0.0;
126  for (std::size_t i = 0; i < _nca; ++i)
127  _casum += (*_ca[i])[_qp] * _a_ca[i];
128 
129  _cbsum = _u[_qp] * _a_u;
130  for (std::size_t i = 0; i < _ncb; ++i)
131  _cbsum += (*_cb[i])[_qp] * _a_cb[i];
132 }
Enforce sum of phase concentrations to be the real concentration.
static InputParameters validParams()
unsigned int _ncb
sublattice B variables
static InputParameters validParams()
const VariableValue & _c
global concentration variable
unsigned int _nca
sublattice A variables
std::vector< const VariableValue * > _cb
Real _a_u
sublattice fraction for the sublattice B concentration represented by the kernel variable ...
virtual const VariableValue & coupledValue(const std::string &var_name, unsigned int comp=0) const
const MaterialProperty< Real > & _prop_dh
Derivative of the switching function .
registerMooseObject("PhaseFieldApp", SLKKSPhaseConcentration)
std::vector< const VariableValue * > _ca
Real _casum
updated by computeSums
const MaterialProperty< Real > & _prop_h
Switching function .
void paramError(const std::string &param, Args... args) const
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
SLKKSPhaseConcentration(const InputParameters &parameters)
void computeSums()
update the _casum and _cbsum members