https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
11#include "MathUtils.h"
12
13using namespace MathUtils;
14
16
19{
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("coupled_variables",
29 "Vector of variable arguments to the free energy function");
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
64void
66{
67 validateNonlinearCoupling<Real>("F");
68}
69
70Real
72{
73 return _test[_i][_qp] * (_dFdu[_qp] / _a_u - _dFdcs[_qp] / _a_cs);
74}
75
76Real
78{
79 return _test[_i][_qp] * _phi[_j][_qp] * (_d2Fdu2[_qp] / _a_u - _d2Fdcsu[_qp] / _a_cs);
80}
81
82Real
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}
registerMooseObject("PhaseFieldApp", SLKKSChemicalPotential)
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 addClassDescription(const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
const std::string & name() const
Enforce the equality of the chemical potentials in sublattices of the same phase D.
SLKKSChemicalPotential(const InputParameters &parameters)
std::vector< const MaterialProperty< Real > * > _d2Fdudarg
free energy derivatives
std::vector< const MaterialProperty< Real > * > _d2Fdcsdarg
static InputParameters validParams()
const Real _a_u
sublattice site fractions
const MaterialProperty< Real > & _d2Fdu2
const MaterialProperty< Real > & _dFdu
chemical potentials and their derivatives w.r.t. the two sublattice concentrations
const MaterialProperty< Real > & _dFdcs
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
const MaterialProperty< Real > & _d2Fdcsu