https://mooseframework.inl.gov
KKSGlobalFreeEnergy.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 "KKSGlobalFreeEnergy.h"
11 
13 
16 {
18  params.addClassDescription(
19  "Total free energy in KKS system, including chemical, barrier and gradient terms");
20  params.addRequiredParam<MaterialPropertyName>("fa_name",
21  "Base name of the free energy function "
22  "F (f_name in the corresponding "
23  "derivative function material)");
24  params.addRequiredParam<MaterialPropertyName>("fb_name",
25  "Base name of the free energy function "
26  "F (f_name in the corresponding "
27  "derivative function material)");
28  params.addParam<MaterialPropertyName>(
29  "h_name", "h", "Base name for the switching function h(eta)");
30  params.addParam<MaterialPropertyName>(
31  "g_name", "g", "Base name for the double well function g(eta)");
32  params.addRequiredParam<Real>("w", "Double well height parameter");
33  params.addParam<std::vector<MaterialPropertyName>>("kappa_names",
34  std::vector<MaterialPropertyName>(),
35  "Vector of kappa names corresponding to "
36  "each variable name in interfacial_vars "
37  "in the same order. For basic KKS, there "
38  "is 1 kappa, 1 interfacial_var.");
39  return params;
40 }
41 
43  : TotalFreeEnergyBase(parameters),
44  _prop_fa(getMaterialProperty<Real>("fa_name")),
45  _prop_fb(getMaterialProperty<Real>("fb_name")),
46  _prop_h(getMaterialProperty<Real>("h_name")),
47  _prop_g(getMaterialProperty<Real>("g_name")),
48  _w(getParam<Real>("w")),
49  _kappas(_nkappas)
50 {
51  // Error check to ensure size of interfacial_vars is the same as kappa_names
52  if (_nvars != _nkappas)
53  mooseError(
54  "Size of interfacial_vars is not equal to the size of kappa_names in KKSGlobalFreeEnergy");
55 
56  // Assign kappa values
57  for (unsigned int i = 0; i < _nkappas; ++i)
58  _kappas[i] = &getMaterialPropertyByName<Real>(_kappa_names[i]);
59 }
60 
61 Real
63 {
64  const Real h = _prop_h[_qp];
65 
66  // Include bulk energy and additional contributions
67  Real total_energy = _prop_fa[_qp] * (1.0 - h) + _prop_fb[_qp] * h + _w * _prop_g[_qp] +
69 
70  // Calculate interfacial energy of each variable
71  for (unsigned int i = 0; i < _nvars; ++i)
72  total_energy += (*_kappas[i])[_qp] / 2.0 * (*_grad_vars[i])[_qp].norm_sq();
73 
74  return total_energy;
75 }
registerMooseObject("PhaseFieldApp", KKSGlobalFreeEnergy)
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
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const Real _w
Barrier term height.
Compute the global free energy in the KKS Model .
virtual Real computeValue()
const VariableValue & _additional_free_energy
Additional free energy contribution.
void addRequiredParam(const std::string &name, const std::string &doc_string)
KKSGlobalFreeEnergy(const InputParameters &parameters)
static InputParameters validParams()
const MaterialProperty< Real > & _prop_fb
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
auto norm_sq(const T &a) -> decltype(std::norm(a))
std::vector< const MaterialProperty< Real > * > _kappas
Gradient interface free energy coefficients.
void mooseError(Args &&... args) const
const std::vector< const VariableGradient * > _grad_vars
void addClassDescription(const std::string &doc_string)
const MaterialProperty< Real > & _prop_fa
const MaterialProperty< Real > & _prop_h
std::vector< MaterialPropertyName > _kappa_names
Gradient free energy prefactor kappa.