www.mooseframework.org
KKSPhaseChemicalPotential.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 #include "MathUtils.h"
12 
13 using namespace MathUtils;
14 
16 
19 {
21  params.addClassDescription("KKS model kernel to enforce the pointwise equality of phase chemical "
22  "potentials $dF_a/dc_a = dF_b/dc_b$. The non-linear variable of this "
23  "kernel is $c_a$.");
24  params.addRequiredCoupledVar(
25  "cb", "Phase b concentration"); // note that ca is u, the non-linear variable!
26  params.addRequiredParam<MaterialPropertyName>("fa_name",
27  "Base name of the free energy function "
28  "Fa (f_name in the corresponding "
29  "derivative function material)");
30  params.addRequiredParam<MaterialPropertyName>("fb_name",
31  "Base name of the free energy function "
32  "Fb (f_name in the corresponding "
33  "derivative function material)");
34  params.addParam<Real>("ka",
35  1.0,
36  "Site fraction for the ca variable (specify this if ca is a sublattice "
37  "concentration, and make sure it is a true site fraction eg. 0.6666666) ");
38  params.addParam<Real>("kb",
39  1.0,
40  "Site fraction for the cb variable (specify this if ca is a sublattice "
41  "concentration, and make sure it is a true site fraction eg. 0.6666666) ");
42  params.addCoupledVar(
43  "args_a",
44  "Vector of further parameters to Fa (optional, to add in second cross derivatives of Fa)");
45  params.addCoupledVar(
46  "args_b",
47  "Vector of further parameters to Fb (optional, to add in second cross derivatives of Fb)");
48  return params;
49 }
50 
53  _cb_var(coupled("cb")),
54  _cb_name(coupledName("cb", 0)),
55  // first derivatives
56  _dfadca(getMaterialPropertyDerivative<Real>("fa_name", _var.name())),
57  _dfbdcb(getMaterialPropertyDerivative<Real>("fb_name", _cb_name)),
58  // second derivatives d2F/dx*dca for jacobian diagonal elements
59  _d2fadca2(getMaterialPropertyDerivative<Real>("fa_name", _var.name(), _var.name())),
60  _d2fbdcbca(getMaterialPropertyDerivative<Real>("fb_name", _cb_name, _var.name())),
61  _d2fadcadarg(_n_args),
62  _d2fbdcbdarg(_n_args),
63  // site fractions
64  _ka(getParam<Real>("ka")),
65  _kb(getParam<Real>("kb"))
66 {
67 #ifdef DEBUG
68  _console << "KKSPhaseChemicalPotential(" << name() << ") " << _var.name() << ' ' << _cb_name
69  << '\n';
70 #endif
71 
72  // lookup table for the material properties representing the derivatives needed for the
73  // off-diagonal jacobian
74  for (std::size_t i = 0; i < _n_args; ++i)
75  {
76  _d2fadcadarg[i] = &getMaterialPropertyDerivative<Real>("fa_name", _var.name(), i);
77  _d2fbdcbdarg[i] = &getMaterialPropertyDerivative<Real>("fb_name", _cb_name, i);
78  }
79 }
80 
81 void
83 {
84  validateNonlinearCoupling<Real>("fa_name");
85  validateNonlinearCoupling<Real>("fb_name");
86 }
87 
88 Real
90 {
91  // enforce _dfadca==_dfbdcb
92  return _test[_i][_qp] * (_dfadca[_qp] / _ka - _dfbdcb[_qp] / _kb);
93 }
94 
95 Real
97 {
98  // for on diagonal we return the d/dca derivative of the residual
99  return _test[_i][_qp] * _phi[_j][_qp] * (_d2fadca2[_qp] / _ka - _d2fbdcbca[_qp] / _kb);
100 }
101 
102 Real
104 {
105  // get the coupled variable jvar is referring to
106  const unsigned int cvar = mapJvarToCvar(jvar);
107 
108  return _test[_i][_qp] * _phi[_j][_qp] *
109  ((*_d2fadcadarg[cvar])[_qp] / _ka - (*_d2fbdcbdarg[cvar])[_qp] / _kb);
110 }
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const MaterialProperty< Real > & _dfadca
material properties we need to access
const std::string & name() const override
void addRequiredParam(const std::string &name, const std::string &doc_string)
const std::string name
Definition: Setup.h:20
std::vector< const MaterialProperty< Real > * > _d2fbdcbdarg
void addCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
registerMooseObject("PhaseFieldApp", KKSPhaseChemicalPotential)
const Real _ka
site fractions
const MaterialProperty< Real > & _d2fbdcbca
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
const MaterialProperty< Real > & _d2fadca2
std::vector< const MaterialProperty< Real > * > _d2fadcadarg
const MaterialProperty< Real > & _dfbdcb
KKSPhaseChemicalPotential(const InputParameters &parameters)
Enforce the equality of the chemical potentials in the two phases.
static InputParameters validParams()