Line data Source code
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 : 12 : registerMooseObject("PhaseFieldApp", KKSGlobalFreeEnergy); 13 : 14 : InputParameters 15 166 : KKSGlobalFreeEnergy::validParams() 16 : { 17 166 : InputParameters params = TotalFreeEnergyBase::validParams(); 18 166 : params.addClassDescription( 19 : "Total free energy in KKS system, including chemical, barrier and gradient terms"); 20 332 : 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 332 : 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 332 : params.addParam<MaterialPropertyName>( 29 : "h_name", "h", "Base name for the switching function h(eta)"); 30 332 : params.addParam<MaterialPropertyName>( 31 : "g_name", "g", "Base name for the double well function g(eta)"); 32 332 : params.addRequiredParam<Real>("w", "Double well height parameter"); 33 166 : params.addParam<std::vector<MaterialPropertyName>>("kappa_names", 34 166 : 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 166 : return params; 40 0 : } 41 : 42 87 : KKSGlobalFreeEnergy::KKSGlobalFreeEnergy(const InputParameters & parameters) 43 : : TotalFreeEnergyBase(parameters), 44 87 : _prop_fa(getMaterialProperty<Real>("fa_name")), 45 87 : _prop_fb(getMaterialProperty<Real>("fb_name")), 46 87 : _prop_h(getMaterialProperty<Real>("h_name")), 47 87 : _prop_g(getMaterialProperty<Real>("g_name")), 48 174 : _w(getParam<Real>("w")), 49 174 : _kappas(_nkappas) 50 : { 51 : // Error check to ensure size of interfacial_vars is the same as kappa_names 52 87 : if (_nvars != _nkappas) 53 0 : mooseError( 54 : "Size of interfacial_vars is not equal to the size of kappa_names in KKSGlobalFreeEnergy"); 55 : 56 : // Assign kappa values 57 87 : for (unsigned int i = 0; i < _nkappas; ++i) 58 0 : _kappas[i] = &getMaterialPropertyByName<Real>(_kappa_names[i]); 59 87 : } 60 : 61 : Real 62 2085320 : KKSGlobalFreeEnergy::computeValue() 63 : { 64 2085320 : const Real h = _prop_h[_qp]; 65 : 66 : // Include bulk energy and additional contributions 67 2085320 : Real total_energy = _prop_fa[_qp] * (1.0 - h) + _prop_fb[_qp] * h + _w * _prop_g[_qp] + 68 2085320 : _additional_free_energy[_qp]; 69 : 70 : // Calculate interfacial energy of each variable 71 2085320 : for (unsigned int i = 0; i < _nvars; ++i) 72 0 : total_energy += (*_kappas[i])[_qp] / 2.0 * (*_grad_vars[i])[_qp].norm_sq(); 73 : 74 2085320 : return total_energy; 75 : }