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