www.mooseframework.org
GrandPotentialInterface.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
11 #include "Conversion.h"
12 #include "IndirectSort.h"
13 #include "libmesh/utility.h"
14 
16 
17 template <>
18 InputParameters
20 {
21  InputParameters params = validParams<Material>();
22  params.addClassDescription("Calculate Grand Potential interface parameters for a specified "
23  "interfacial free energy and width");
24  params.addRequiredParam<std::vector<Real>>("sigma", "Interfacial free energies");
25  params.addRequiredRangeCheckedParam<Real>(
26  "width", "width > 0", "Interfacial width (for the interface with gamma = 1.5)");
27  params.addParam<std::vector<MaterialPropertyName>>(
28  "gamma_names",
29  "Interfacial / grain boundary gamma parameter names (leave empty for gamma0... gammaN)");
30  params.addParam<MaterialPropertyName>("kappa_name", "kappa", "Gradient interface parameter name");
31  params.addParam<MaterialPropertyName>("mu_name", "mu", "Grain growth bulk energy parameter name");
32  params.addParam<unsigned int>(
33  "sigma_index",
34  "Sigma index to choose gamma = 1.5 for. Omit this to automatically chose the median sigma.");
35  params.addParamNamesToGroup("mu_name sigma_index", "Advanced");
36  return params;
37 }
38 
39 GrandPotentialInterface::GrandPotentialInterface(const InputParameters & parameters)
40  : Material(parameters),
41  _sigma(getParam<std::vector<Real>>("sigma")),
42  _width(getParam<Real>("width")),
43  _n_pair(_sigma.size()),
44  _gamma(_n_pair),
45  _gamma_name(getParam<std::vector<MaterialPropertyName>>("gamma_names")),
46  _gamma_prop(_n_pair),
47  _kappa_prop(declareProperty<Real>(getParam<MaterialPropertyName>("kappa_name"))),
48  _mu_prop(declareProperty<Real>(getParam<MaterialPropertyName>("mu_name")))
49 {
50  // error check parameters
51  if (_n_pair == 0)
52  paramError("sigma", "Specify at least one interfacial energy");
53 
54  if (_gamma_name.size() != 0 && _gamma_name.size() != _n_pair)
55  paramError("gamma_names",
56  "Specify either as many entries are sigma values or none at all for auto-naming the "
57  "gamma material properties.");
58 
59  // automatic names for the gamma properties
60  if (_gamma_name.size() == 0)
61  for (unsigned int i = 0; i < _n_pair; i++)
62  _gamma_name[i] = "gamma" + Moose::stringify(i);
63 
64  // declare gamma material properties
65  for (unsigned int i = 0; i < _n_pair; i++)
66  _gamma_prop[i] = &declareProperty<Real>(_gamma_name[i]);
67 
68  // determine median interfacial free energy (or use explicit user choice)
69  unsigned int median;
70  if (isParamValid("sigma_index"))
71  median = getParam<unsigned int>("sigma_index");
72  else
73  {
74  std::vector<size_t> indices;
75  Moose::indirectSort(_sigma.begin(), _sigma.end(), indices);
76  median = indices[(indices.size() - 1) / 2];
77  }
78 
79  // set the median gamma to 1.5 and use analytical expression for kappa and mu (m)
80  _gamma[median] = 1.5;
81  _kappa = 3.0 / 4.0 * _sigma[median] * _width;
82  _mu = 6.0 * _sigma[median] / _width;
83 
84  // set all other gammas
85  for (unsigned int i = 0; i < _n_pair; ++i)
86  {
87  // skip the already calculated median value
88  if (i == median)
89  continue;
90 
91  const Real g = _sigma[i] / std::sqrt(_mu * _kappa);
92 
93  // estimate for gamma from polynomial expansion
94  Real gamma = 1.0 / (-5.288 * Utility::pow<8>(g) - 0.09364 * Utility::pow<6>(g) +
95  9.965 * Utility::pow<4>(g) - 8.183 * Utility::pow<2>(g) + 2.007);
96 
97  _gamma[i] = gamma;
98  }
99 }
100 
101 void
103 {
104  _kappa_prop[_qp] = _kappa;
105  _mu_prop[_qp] = _mu;
106  for (unsigned int i = 0; i < _n_pair; ++i)
107  (*_gamma_prop[i])[_qp] = _gamma[i];
108 }
GrandPotentialInterface::computeQpProperties
virtual void computeQpProperties() override
Definition: GrandPotentialInterface.C:102
GrandPotentialInterface::_sigma
const std::vector< Real > _sigma
list of interfacial free energies
Definition: GrandPotentialInterface.h:31
GrandPotentialInterface::GrandPotentialInterface
GrandPotentialInterface(const InputParameters &parameters)
Definition: GrandPotentialInterface.C:39
GrandPotentialInterface::_gamma_prop
std::vector< MaterialProperty< Real > * > _gamma_prop
Material properties for all interface pairs.
Definition: GrandPotentialInterface.h:49
GrandPotentialInterface::_mu
Real _mu
Definition: GrandPotentialInterface.h:42
GrandPotentialInterface.h
GrandPotentialInterface
Calculate Grand Potential interface parameters for a specified interfacial free energy and width.
Definition: GrandPotentialInterface.h:22
GrandPotentialInterface::_n_pair
const unsigned int _n_pair
number of interface pairs
Definition: GrandPotentialInterface.h:37
GrandPotentialInterface::_gamma
std::vector< Real > _gamma
Calculated gamma parameter values.
Definition: GrandPotentialInterface.h:40
GrandPotentialInterface::_gamma_name
std::vector< MaterialPropertyName > _gamma_name
gamma material property names
Definition: GrandPotentialInterface.h:46
validParams< GrandPotentialInterface >
InputParameters validParams< GrandPotentialInterface >()
Definition: GrandPotentialInterface.C:19
GrandPotentialInterface::_kappa
Real _kappa
Definition: GrandPotentialInterface.h:41
GrandPotentialInterface::_width
const Real _width
Interface width for the interface with the median interfacial free energy.
Definition: GrandPotentialInterface.h:34
registerMooseObject
registerMooseObject("PhaseFieldApp", GrandPotentialInterface)
GrandPotentialInterface::_mu_prop
MaterialProperty< Real > & _mu_prop
Definition: GrandPotentialInterface.h:51
GrandPotentialInterface::_kappa_prop
MaterialProperty< Real > & _kappa_prop
Definition: GrandPotentialInterface.h:50