https://mooseframework.inl.gov
Loading...
Searching...
No Matches
KKSPhaseChemicalPotential.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#include "MathUtils.h"
12
13using 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$.");
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
81void
83{
84 validateNonlinearCoupling<Real>("fa_name");
85 validateNonlinearCoupling<Real>("fb_name");
86}
87
88Real
90{
91 // enforce _dfadca==_dfbdcb
92 return _test[_i][_qp] * (_dfadca[_qp] / _ka - _dfbdcb[_qp] / _kb);
93}
94
95Real
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
102Real
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}
registerMooseObject("PhaseFieldApp", KKSPhaseChemicalPotential)
const std::string name
Definition Setup.h:21
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
Enforce the equality of the chemical potentials in the two phases.
const MaterialProperty< Real > & _dfadca
material properties we need to access
static InputParameters validParams()
const MaterialProperty< Real > & _dfbdcb
std::vector< const MaterialProperty< Real > * > _d2fbdcbdarg
const MaterialProperty< Real > & _d2fadca2
const MaterialProperty< Real > & _d2fbdcbca
std::vector< const MaterialProperty< Real > * > _d2fadcadarg
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
KKSPhaseChemicalPotential(const InputParameters &parameters)
static InputParameters validParams()
const std::string & name() const