www.mooseframework.org
KKSGlobalFreeEnergy.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 #include "KKSGlobalFreeEnergy.h"
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<TotalFreeEnergyBase>();
14  params.addClassDescription(
15  "Total free energy in KKS system, including chemical, barrier and gradient terms");
16  params.addRequiredParam<MaterialPropertyName>("fa_name",
17  "Base name of the free energy function "
18  "F (f_name in the corresponding "
19  "derivative function material)");
20  params.addRequiredParam<MaterialPropertyName>("fb_name",
21  "Base name of the free energy function "
22  "F (f_name in the corresponding "
23  "derivative function material)");
24  params.addParam<MaterialPropertyName>(
25  "h_name", "h", "Base name for the switching function h(eta)");
26  params.addParam<MaterialPropertyName>(
27  "g_name", "g", "Base name for the double well function g(eta)");
28  params.addRequiredParam<Real>("w", "Double well height parameter");
29  params.addParam<std::vector<MaterialPropertyName>>("kappa_names",
30  std::vector<MaterialPropertyName>(),
31  "Vector of kappa names corresponding to "
32  "each variable name in interfacial_vars "
33  "in the same order. For basic KKS, there "
34  "is 1 kappa, 1 interfacial_var.");
35  return params;
36 }
37 
38 KKSGlobalFreeEnergy::KKSGlobalFreeEnergy(const InputParameters & parameters)
39  : TotalFreeEnergyBase(parameters),
40  _prop_fa(getMaterialProperty<Real>("fa_name")),
41  _prop_fb(getMaterialProperty<Real>("fb_name")),
42  _prop_h(getMaterialProperty<Real>("h_name")),
43  _prop_g(getMaterialProperty<Real>("g_name")),
44  _w(getParam<Real>("w")),
45  _kappas(_nkappas)
46 {
47  // Error check to ensure size of interfacial_vars is the same as kappa_names
48  if (_nvars != _nkappas)
49  mooseError(
50  "Size of interfacial_vars is not equal to the size of kappa_names in KKSGlobalFreeEnergy");
51 
52  // Assign kappa values
53  for (unsigned int i = 0; i < _nkappas; ++i)
54  _kappas[i] = &getMaterialPropertyByName<Real>(_kappa_names[i]);
55 }
56 
57 Real
59 {
60  const Real h = _prop_h[_qp];
61 
62  // Include bulk energy and additional contributions
63  Real total_energy = _prop_fa[_qp] * h + _prop_fb[_qp] * (1.0 - h) + _w * _prop_g[_qp] +
65 
66  // Calculate interfacial energy of each variable
67  for (unsigned int i = 0; i < _nvars; ++i)
68  total_energy += (*_kappas[i])[_qp] / 2.0 * (*_grad_vars[i])[_qp].norm_sq();
69 
70  return total_energy;
71 }
Total free energy (both the bulk and gradient parts), where the bulk free energy has been defined in ...
unsigned int _nvars
Coupled interface variables.
const MaterialProperty< Real > & _prop_g
const Real _w
Barrier term height.
virtual Real computeValue()
const VariableValue & _additional_free_energy
Additional free energy contribution.
KKSGlobalFreeEnergy(const InputParameters &parameters)
const MaterialProperty< Real > & _prop_fb
InputParameters validParams< TotalFreeEnergyBase >()
InputParameters validParams< KKSGlobalFreeEnergy >()
std::vector< const MaterialProperty< Real > * > _kappas
Gradient interface free energy coefficients.
const std::string total_energy
Definition: NS.h:19
std::vector< const VariableGradient * > _grad_vars
const MaterialProperty< Real > & _prop_fa
const MaterialProperty< Real > & _prop_h
std::vector< MaterialPropertyName > _kappa_names
Gradient free energy prefactor kappa.