www.mooseframework.org
KKSMultiFreeEnergy.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 "KKSMultiFreeEnergy.h"
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<TotalFreeEnergyBase>();
14  params.addClassDescription("Total free energy in multi-phase KKS system, including chemical, "
15  "barrier and gradient terms");
16  params.addRequiredParam<std::vector<MaterialPropertyName>>(
17  "Fj_names",
18  "List of free energies for each phase. Place in same order as hj_names and gj_names!");
19  params.addRequiredParam<std::vector<MaterialPropertyName>>(
20  "hj_names",
21  "Switching Function Materials that provide h. Place in same order as Fj_names and gj_names!");
22  params.addRequiredParam<std::vector<MaterialPropertyName>>(
23  "gj_names",
24  "Barrier Function Materials that provide g. Place in same order as Fj_names and hj_names!");
25  params.addRequiredParam<Real>("w", "Double well height parameter");
26  params.addParam<std::vector<MaterialPropertyName>>("kappa_names",
27  std::vector<MaterialPropertyName>(),
28  "Vector of kappa names corresponding to "
29  "each variable name in interfacial_vars "
30  "in the same order.");
31  return params;
32 }
33 
34 KKSMultiFreeEnergy::KKSMultiFreeEnergy(const InputParameters & parameters)
35  : TotalFreeEnergyBase(parameters),
36  _Fj_names(getParam<std::vector<MaterialPropertyName>>("Fj_names")),
37  _num_j(_Fj_names.size()),
38  _prop_Fj(_num_j),
39  _hj_names(getParam<std::vector<MaterialPropertyName>>("hj_names")),
40  _prop_hj(_num_j),
41  _gj_names(getParam<std::vector<MaterialPropertyName>>("gj_names")),
42  _prop_gj(_num_j),
43  _w(getParam<Real>("w")),
44  _kappas(_nkappas)
45 {
46  // Check that same number of Fj, hj, and gj are passed in
47  if (_hj_names.size() != _num_j)
48  mooseError("Size of hj_names is not equal to size of Fj_names in KKSMultiFreeEnergy AuxKernel ",
49  name());
50  if (_gj_names.size() != _num_j)
51  mooseError("Size of gj_names is not equal to size of Fj_names in KKSMultiFreeEnergy AuxKernel ",
52  name());
53 
54  // get bulk properties
55  for (unsigned int i = 0; i < _num_j; ++i)
56  {
57  _prop_Fj[i] = &getMaterialPropertyByName<Real>(_Fj_names[i]);
58  _prop_hj[i] = &getMaterialPropertyByName<Real>(_hj_names[i]);
59  _prop_gj[i] = &getMaterialPropertyByName<Real>(_gj_names[i]);
60  }
61 
62  // Check to ensure size of interfacial_vars is the same as kappa_names
63  if (_nvars != _nkappas)
64  mooseError("Size of interfacial_vars is not equal to the size of kappa_names in "
65  "KKSMultiFreeEnergy AuxKernel ",
66  name());
67 
68  // Assign kappa values
69  for (unsigned int i = 0; i < _nkappas; ++i)
70  _kappas[i] = &getMaterialPropertyByName<Real>(_kappa_names[i]);
71 }
72 
73 Real
75 {
76  // Start with any additional energy contribution, which is 0 if not supplied
78  // Add bulk energy contributions
79  for (unsigned int i = 0; i < _num_j; ++i)
80  total_energy += (*_prop_hj[i])[_qp] * (*_prop_Fj[i])[_qp] + _w * (*_prop_gj[i])[_qp];
81 
82  // Add interfacial energy of each variable
83  for (unsigned int i = 0; i < _nvars; ++i)
84  total_energy += (*_kappas[i])[_qp] / 2.0 * (*_grad_vars[i])[_qp].norm_sq();
85 
86  return total_energy;
87 }
const unsigned int _num_j
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 VariableValue & _additional_free_energy
Additional free energy contribution.
std::vector< const MaterialProperty< Real > * > _prop_hj
Values of the switching functions for each phase .
std::vector< MaterialPropertyName > _Fj_names
Names of free energy functions for each phase .
const Real _w
Barrier term height.
std::vector< const MaterialProperty< Real > * > _prop_gj
Values of the barrier functions for each phase .
std::vector< const MaterialProperty< Real > * > _prop_Fj
Values of the free energy functions for each phase .
InputParameters validParams< TotalFreeEnergyBase >()
std::vector< const MaterialProperty< Real > * > _kappas
Gradient interface free energy coefficients.
virtual Real computeValue()
const std::string total_energy
Definition: NS.h:19
std::vector< MaterialPropertyName > _gj_names
Barrier function names.
KKSMultiFreeEnergy(const InputParameters &parameters)
std::vector< const VariableGradient * > _grad_vars
InputParameters validParams< KKSMultiFreeEnergy >()
std::vector< MaterialPropertyName > _kappa_names
Gradient free energy prefactor kappa.
std::vector< MaterialPropertyName > _hj_names
Switching function names.