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