https://mooseframework.inl.gov
Loading...
Searching...
No Matches
DerivativeTwoPhaseMaterial.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
13
16{
19 "Two phase material that combines two single phase materials using a switching function.");
20
21 // Two base materials
22 params.addRequiredParam<MaterialPropertyName>("fa_name", "Phase A material (at eta=0)");
23 params.addRequiredParam<MaterialPropertyName>("fb_name", "Phase A material (at eta=1)");
24 params.addParam<MaterialPropertyName>(
25 "h", "h", "Switching Function Material that provides h(eta)");
26 params.addParam<MaterialPropertyName>("g", "g", "Barrier Function Material that provides g(eta)");
27
28 // All arguments of the phase free energies
29 params.addCoupledVar("coupled_variables", "Vector of variable arguments of fa and fb");
30 params.addCoupledVar("displacement_gradients",
31 "Vector of displacement gradient variables (see "
32 "Modules/PhaseField/DisplacementGradients "
33 "action)");
34
35 // Order parameter which determines the phase
36 params.addRequiredCoupledVar("eta", "Order parameter");
37
38 // Variables with applied tolerances and their tolerance values
39 params.addParam<Real>("W", 0.0, "Energy barrier for the phase transformation from A to B");
40
41 return params;
42}
43
46 _eta(coupledValue("eta")),
47 _eta_name(coupledName("eta", 0)),
48 _eta_var(coupled("eta")),
49 _h(getMaterialProperty<Real>("h")),
50 _dh(getMaterialPropertyDerivative<Real>("h", _eta_name)),
51 _d2h(getMaterialPropertyDerivative<Real>("h", _eta_name, _eta_name)),
52 _d3h(getMaterialPropertyDerivative<Real>("h", _eta_name, _eta_name, _eta_name)),
53 _g(getMaterialProperty<Real>("g")),
54 _dg(getMaterialPropertyDerivative<Real>("g", _eta_name)),
55 _d2g(getMaterialPropertyDerivative<Real>("g", _eta_name, _eta_name)),
56 _d3g(getMaterialPropertyDerivative<Real>("g", _eta_name, _eta_name, _eta_name)),
57 _W(getParam<Real>("W")),
58 _prop_Fa(getMaterialProperty<Real>("fa_name")),
59 _prop_Fb(getMaterialProperty<Real>("fb_name"))
60{
61 // reserve space for phase A and B material properties
62 _prop_dFa.resize(_nargs);
63 _prop_d2Fa.resize(_nargs);
64 _prop_d3Fa.resize(_nargs);
65 _prop_dFb.resize(_nargs);
66 _prop_d2Fb.resize(_nargs);
67 _prop_d3Fb.resize(_nargs);
68 for (unsigned int i = 0; i < _nargs; ++i)
69 {
70 _prop_dFa[i] = &getMaterialPropertyDerivative<Real>("fa_name", _arg_names[i]);
71 _prop_dFb[i] = &getMaterialPropertyDerivative<Real>("fb_name", _arg_names[i]);
72
73 _prop_d2Fa[i].resize(_nargs);
74 _prop_d2Fb[i].resize(_nargs);
75
76 // TODO: maybe we should reserve and initialize to NULL...
78 {
79 _prop_d3Fa[i].resize(_nargs);
80 _prop_d3Fb[i].resize(_nargs);
81 }
82
83 for (unsigned int j = 0; j < _nargs; ++j)
84 {
85 _prop_d2Fa[i][j] =
86 &getMaterialPropertyDerivative<Real>("fa_name", _arg_names[i], _arg_names[j]);
87 _prop_d2Fb[i][j] =
88 &getMaterialPropertyDerivative<Real>("fb_name", _arg_names[i], _arg_names[j]);
89
91 {
92 _prop_d3Fa[i][j].resize(_nargs);
93 _prop_d3Fb[i][j].resize(_nargs);
94
95 for (unsigned int k = 0; k < _nargs; ++k)
96 {
97 _prop_d3Fa[i][j][k] = &getMaterialPropertyDerivative<Real>(
98 "fa_name", _arg_names[i], _arg_names[j], _arg_names[k]);
99 _prop_d3Fb[i][j][k] = &getMaterialPropertyDerivative<Real>(
100 "fb_name", _arg_names[i], _arg_names[j], _arg_names[k]);
101 }
102 }
103 }
104 }
105}
106
107void
109{
110 validateCoupling<Real>("fa_name");
111 validateCoupling<Real>("fb_name");
112}
113
114Real
116{
117 return _h[_qp] * _prop_Fb[_qp] + (1.0 - _h[_qp]) * _prop_Fa[_qp] + _W * _g[_qp];
118}
119
120Real
122{
123 if (i_var == _eta_var)
124 return _dh[_qp] * (_prop_Fb[_qp] - _prop_Fa[_qp]) + _W * _dg[_qp];
125 else
126 {
127 unsigned int i = argIndex(i_var);
128 return _h[_qp] * (*_prop_dFb[i])[_qp] + (1.0 - _h[_qp]) * (*_prop_dFa[i])[_qp];
129 }
130}
131
132Real
133DerivativeTwoPhaseMaterial::computeD2F(unsigned int i_var, unsigned int j_var)
134{
135 if (i_var == _eta_var && j_var == _eta_var)
136 return _d2h[_qp] * (_prop_Fb[_qp] - _prop_Fa[_qp]) + _W * _d2g[_qp];
137
138 unsigned int i = argIndex(i_var);
139 unsigned int j = argIndex(j_var);
140
141 if (i_var == _eta_var)
142 return _dh[_qp] * ((*_prop_dFb[j])[_qp] - (*_prop_dFa[j])[_qp]);
143 if (j_var == _eta_var)
144 return _dh[_qp] * ((*_prop_dFb[i])[_qp] - (*_prop_dFa[i])[_qp]);
145
146 return _h[_qp] * (*_prop_d2Fb[i][j])[_qp] + (1.0 - _h[_qp]) * (*_prop_d2Fa[i][j])[_qp];
147}
148
149Real
150DerivativeTwoPhaseMaterial::computeD3F(unsigned int i_var, unsigned int j_var, unsigned int k_var)
151{
152 if (i_var == _eta_var && j_var == _eta_var && k_var == _eta_var)
153 return _d3h[_qp] * (_prop_Fb[_qp] - _prop_Fa[_qp]) + _W * _d3g[_qp];
154
155 unsigned int i = argIndex(i_var);
156 unsigned int j = argIndex(j_var);
157 unsigned int k = argIndex(k_var);
158
159 if (j_var == _eta_var && k_var == _eta_var)
160 return _d2h[_qp] * ((*_prop_dFb[i])[_qp] - (*_prop_dFa[i])[_qp]);
161 if (i_var == _eta_var && k_var == _eta_var)
162 return _d2h[_qp] * ((*_prop_dFb[j])[_qp] - (*_prop_dFa[j])[_qp]);
163 if (i_var == _eta_var && j_var == _eta_var)
164 return _d2h[_qp] * ((*_prop_dFb[k])[_qp] - (*_prop_dFa[k])[_qp]);
165
166 if (i_var == _eta_var)
167 return _dh[_qp] * (*_prop_d2Fb[j][k])[_qp] + (1.0 - _dh[_qp]) * (*_prop_d2Fa[j][k])[_qp];
168 if (j_var == _eta_var)
169 return _dh[_qp] * (*_prop_d2Fb[i][k])[_qp] + (1.0 - _dh[_qp]) * (*_prop_d2Fa[i][k])[_qp];
170 if (k_var == _eta_var)
171 return _dh[_qp] * (*_prop_d2Fb[i][j])[_qp] + (1.0 - _dh[_qp]) * (*_prop_d2Fa[i][j])[_qp];
172
173 return _h[_qp] * (*_prop_d3Fb[i][j][k])[_qp] + (1.0 - _h[_qp]) * (*_prop_d3Fa[i][j][k])[_qp];
174}
registerMooseObject("PhaseFieldApp", DerivativeTwoPhaseMaterial)
static InputParameters validParams()
DerivativeMaterial child class to evaluate a parsed function for the free energy and automatically pr...
DerivativeTwoPhaseMaterial(const InputParameters &parameters)
std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _prop_d3Fb
std::vector< const MaterialProperty< Real > * > _prop_dFa
Derivatives of Fa and Fb with respect to arg[i].
const MaterialProperty< Real > & _dg
const MaterialProperty< Real > & _dh
const MaterialProperty< Real > & _prop_Fa
Function value of the A and B phase.
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_d2Fa
Second derivatives of Fa and Fb.
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_d2Fb
const MaterialProperty< Real > & _d2h
virtual Real computeDF(unsigned int i_var) override
const MaterialProperty< Real > & _prop_Fb
Real _W
Phase transformatuion energy barrier.
std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _prop_d3Fa
Third derivatives of Fa and Fb.
virtual Real computeD3F(unsigned int i_var, unsigned int j_var, unsigned int k_var) override
const MaterialProperty< Real > & _h
std::vector< const MaterialProperty< Real > * > _prop_dFb
static InputParameters validParams()
unsigned int _eta_var
libMesh variable number for eta
const MaterialProperty< Real > & _g
virtual Real computeD2F(unsigned int i_var, unsigned int j_var) override
const MaterialProperty< Real > & _d3g
const MaterialProperty< Real > & _d3h
const MaterialProperty< Real > & _d2g
std::vector< std::string > _arg_names
unsigned int argIndex(unsigned int i_var) const
void addRequiredCoupledVar(const std::string &name, 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)
void addCoupledVar(const std::string &name, const std::string &doc_string)