https://mooseframework.inl.gov
SLKKSChemicalPotential.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 
10 #include "SLKKSChemicalPotential.h"
11 #include "MathUtils.h"
12 
13 using namespace MathUtils;
14 
16 
19 {
21  params.addClassDescription(
22  "SLKKS model kernel to enforce the pointwise equality of sublattice chemical "
23  "potentials in the same phase.");
24  params.addRequiredCoupledVar("cs", "other sublattice concentration in the same phase");
25  params.addRequiredParam<Real>("a", "sublattice site fraction for the kernel variable");
26  params.addRequiredParam<Real>("as", "other sublattice site fraction in the same phase");
27  params.addRequiredParam<MaterialPropertyName>("F", "Base name of the free energy function");
28  params.addCoupledVar("args", "Vector of variable arguments to the free energy function");
29  params.deprecateCoupledVar("args", "coupled_variables", "02/27/2024");
30 
31  return params;
32 }
33 
36  _cs_var(coupled("cs")),
37  _cs_name(coupledName("cs", 0)),
38  // first derivatives
39  _dFdu(getMaterialPropertyDerivative<Real>("F", _var.name())),
40  _dFdcs(getMaterialPropertyDerivative<Real>("F", _cs_name)),
41  // second derivatives d2F/dx*dca for jacobian diagonal elements
42  _d2Fdu2(getMaterialPropertyDerivative<Real>("F", _var.name(), _var.name())),
43  _d2Fdcsu(getMaterialPropertyDerivative<Real>("F", _cs_name, _var.name())),
44  // site fractions
45  _a_u(getParam<Real>("a")),
46  _a_cs(getParam<Real>("as"))
47 {
48  const auto nvar = _coupled_moose_vars.size();
49  _d2Fdudarg.resize(nvar);
50  _d2Fdcsdarg.resize(nvar);
51 
52  for (std::size_t i = 0; i < nvar; ++i)
53  {
54  // get the moose variable
55  const auto & arg_name = _coupled_moose_vars[i]->name();
56 
57  // lookup table for the material properties representing the derivatives
58  // needed for the off-diagonal Jacobian
59  _d2Fdudarg[i] = &getMaterialPropertyDerivative<Real>("F", _var.name(), arg_name);
60  _d2Fdcsdarg[i] = &getMaterialPropertyDerivative<Real>("F", _cs_name, arg_name);
61  }
62 }
63 
64 void
66 {
67  validateNonlinearCoupling<Real>("F");
68 }
69 
70 Real
72 {
73  return _test[_i][_qp] * (_dFdu[_qp] / _a_u - _dFdcs[_qp] / _a_cs);
74 }
75 
76 Real
78 {
79  return _test[_i][_qp] * _phi[_j][_qp] * (_d2Fdu2[_qp] / _a_u - _d2Fdcsu[_qp] / _a_cs);
80 }
81 
82 Real
84 {
85  // get the coupled variable jvar is referring to
86  const unsigned int cvar = mapJvarToCvar(jvar);
87 
88  return _test[_i][_qp] * _phi[_j][_qp] *
89  ((*_d2Fdudarg[cvar])[_qp] / _a_u - (*_d2Fdcsdarg[cvar])[_qp] / _a_cs);
90 }
static InputParameters validParams()
static InputParameters validParams()
Enforce the equality of the chemical potentials in sublattices of the same phase D.
const std::string & name() const override
const Real _a_u
sublattice site fractions
const MaterialProperty< Real > & _dFdu
chemical potentials and their derivatives w.r.t. the two sublattice concentrations ...
void addRequiredParam(const std::string &name, const std::string &doc_string)
const MaterialProperty< Real > & _dFdcs
const std::string name
Definition: Setup.h:20
const MaterialProperty< Real > & _d2Fdcsu
registerMooseObject("PhaseFieldApp", SLKKSChemicalPotential)
void deprecateCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &removal_date)
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
const MaterialProperty< Real > & _d2Fdu2
void addCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
std::vector< MooseVariableFieldBase *> _coupled_moose_vars
SLKKSChemicalPotential(const InputParameters &parameters)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
std::vector< const MaterialProperty< Real > * > _d2Fdudarg
free energy derivatives
std::vector< const MaterialProperty< Real > * > _d2Fdcsdarg