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 "DerivativeMultiPhaseBase.h"
11 :
12 : InputParameters
13 223 : DerivativeMultiPhaseBase::validParams()
14 : {
15 223 : InputParameters params = DerivativeFunctionMaterialBase::validParams();
16 :
17 : // Phase materials 1-n
18 446 : params.addRequiredParam<std::vector<MaterialPropertyName>>(
19 : "fi_names", "List of free energies for the n phases");
20 446 : params.addParam<std::vector<MaterialPropertyName>>(
21 : "hi_names", "Switching Function Materials that provide h(eta_i)");
22 :
23 : // All arguments of the phase free energies
24 446 : params.addCoupledVar("coupled_variables", "Vector of variable arguments of the fi free energies");
25 446 : params.addCoupledVar("displacement_gradients",
26 : "Vector of displacement gradient variables (see "
27 : "Modules/PhaseField/DisplacementGradients "
28 : "action)");
29 :
30 : // Barrier
31 446 : params.addParam<MaterialPropertyName>(
32 : "g", "g", "Barrier Function Material that provides g(eta_i)");
33 446 : params.addParam<Real>("W", 0.0, "Energy barrier for the phase transformation from A to B");
34 :
35 223 : return params;
36 0 : }
37 :
38 171 : DerivativeMultiPhaseBase::DerivativeMultiPhaseBase(const InputParameters & parameters)
39 : : DerivativeFunctionMaterialBase(parameters),
40 171 : _eta_index(_nargs, -1),
41 171 : _num_etas(coupledComponents("etas")),
42 171 : _eta_names(_num_etas),
43 171 : _eta_vars(_num_etas),
44 513 : _fi_names(getParam<std::vector<MaterialPropertyName>>("fi_names")),
45 171 : _num_fi(_fi_names.size()),
46 171 : _prop_Fi(_num_fi),
47 171 : _prop_dFi(_num_fi),
48 171 : _prop_d2Fi(_num_fi),
49 171 : _prop_d3Fi(_num_fi),
50 513 : _hi_names(getParam<std::vector<MaterialPropertyName>>("hi_names")),
51 171 : _num_hi(_hi_names.size()),
52 171 : _hi(_num_hi),
53 342 : _g(getMaterialProperty<Real>("g")),
54 171 : _dg(_num_etas),
55 171 : _d2g(_num_etas),
56 171 : _d3g(_num_etas),
57 513 : _W(getParam<Real>("W"))
58 : {
59 : // check passed in parameter vectors
60 171 : if (_num_fi != _num_hi)
61 0 : mooseError("Need to pass in as many hi_names as fi_names in DerivativeMultiPhaseBase ", name());
62 :
63 : // get order parameter names and libmesh variable names, set barrier function derivatives
64 612 : for (unsigned int i = 0; i < _num_etas; ++i)
65 : {
66 441 : _eta_names[i] = coupledName("etas", i);
67 441 : _eta_vars[i] = coupled("etas", i);
68 :
69 : // for each coupled variable we need to know if it was coupled through "etas"
70 : // and - if so - which coupled component of "etas" it comes from
71 882 : _eta_index[argIndex(_eta_vars[i])] = i;
72 :
73 : // barrier function derivatives
74 441 : _dg[i] = &getMaterialPropertyDerivative<Real>("g", _eta_names[i]);
75 441 : _d2g[i].resize(_num_etas);
76 441 : if (_third_derivatives)
77 81 : _d3g[i].resize(_num_etas);
78 :
79 1620 : for (unsigned int j = 0; j < _num_etas; ++j)
80 : {
81 1179 : _d2g[i][j] = &getMaterialPropertyDerivative<Real>("g", _eta_names[i], _eta_names[j]);
82 :
83 1179 : if (_third_derivatives)
84 : {
85 243 : _d3g[i][j].resize(_num_etas);
86 972 : for (unsigned int k = 0; k < _num_etas; ++k)
87 729 : _d3g[i][j][k] = &getMaterialPropertyDerivative<Real>(
88 729 : "g", _eta_names[i], _eta_names[j], _eta_names[k]);
89 : }
90 : }
91 : }
92 :
93 : // reserve space and set phase material properties
94 612 : for (unsigned int n = 0; n < _num_fi; ++n)
95 : {
96 : // get phase free energy
97 441 : _prop_Fi[n] = &getMaterialPropertyByName<Real>(_fi_names[n]);
98 441 : _prop_dFi[n].resize(_nargs);
99 441 : _prop_d2Fi[n].resize(_nargs);
100 441 : _prop_d3Fi[n].resize(_nargs);
101 :
102 : // get switching function
103 441 : _hi[n] = &getMaterialPropertyByName<Real>(_hi_names[n]);
104 :
105 1845 : for (unsigned int i = 0; i < _nargs; ++i)
106 : {
107 1404 : _prop_dFi[n][i] = &getMaterialPropertyDerivative<Real>(_fi_names[n], _arg_names[i]);
108 1404 : _prop_d2Fi[n][i].resize(_nargs);
109 :
110 1404 : if (_third_derivatives)
111 324 : _prop_d3Fi[n][i].resize(_nargs);
112 :
113 5940 : for (unsigned int j = 0; j < _nargs; ++j)
114 : {
115 4536 : _prop_d2Fi[n][i][j] =
116 4536 : &getMaterialPropertyDerivative<Real>(_fi_names[n], _arg_names[i], _arg_names[j]);
117 :
118 4536 : if (_third_derivatives)
119 : {
120 1296 : _prop_d3Fi[n][i][j].resize(_nargs);
121 :
122 6480 : for (unsigned int k = 0; k < _nargs; ++k)
123 5184 : _prop_d3Fi[n][i][j][k] = &getMaterialPropertyDerivative<Real>(
124 5184 : _fi_names[n], _arg_names[i], _arg_names[j], _arg_names[k]);
125 : }
126 : }
127 : }
128 : }
129 171 : }
130 :
131 : void
132 144 : DerivativeMultiPhaseBase::initialSetup()
133 : {
134 504 : for (unsigned int n = 0; n < _num_fi; ++n)
135 1080 : validateCoupling<Real>(_fi_names[n]);
136 144 : }
137 :
138 : Real
139 1792720 : DerivativeMultiPhaseBase::computeF()
140 : {
141 : Real F = 0.0;
142 6248560 : for (unsigned n = 0; n < _num_fi; ++n)
143 4455840 : F += (*_hi[n])[_qp] * (*_prop_Fi[n])[_qp];
144 1792720 : return F + _W * _g[_qp];
145 : }
|