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 "ThirdPhaseSuppressionMaterial.h" 11 : 12 : registerMooseObject("PhaseFieldApp", ThirdPhaseSuppressionMaterial); 13 : 14 : InputParameters 15 31 : ThirdPhaseSuppressionMaterial::validParams() 16 : { 17 31 : InputParameters params = Material::validParams(); 18 62 : params.addParam<std::string>("function_name", "g", "actual name for g(eta_i)"); 19 62 : params.addRequiredCoupledVar("etas", "eta_i order parameters, one for each h"); 20 31 : params.addClassDescription( 21 : "Free Energy contribution that penalizes more than two order parameters being non-zero"); 22 31 : return params; 23 0 : } 24 : 25 24 : ThirdPhaseSuppressionMaterial::ThirdPhaseSuppressionMaterial(const InputParameters & parameters) 26 : : DerivativeMaterialInterface<Material>(parameters), 27 24 : _function_name(getParam<std::string>("function_name")), 28 24 : _num_eta(coupledComponents("etas")), 29 24 : _eta(coupledValues("etas")), 30 24 : _prop_g(declareProperty<Real>(_function_name)), 31 24 : _prop_dg(_num_eta), 32 48 : _prop_d2g(_num_eta) 33 : { 34 24 : const auto eta_name = coupledNames("etas"); 35 : 36 96 : for (unsigned int i = 0; i < _num_eta; ++i) 37 72 : _prop_d2g[i].resize(_num_eta); 38 : 39 96 : for (unsigned int i = 0; i < _num_eta; ++i) 40 : { 41 72 : _prop_dg[i] = &declarePropertyDerivative<Real>(_function_name, eta_name[i]); 42 216 : for (unsigned int j = i; j < _num_eta; ++j) 43 : { 44 144 : _prop_d2g[i][j] = _prop_d2g[j][i] = 45 288 : &declarePropertyDerivative<Real>(_function_name, eta_name[i], eta_name[j]); 46 : } 47 : } 48 24 : } 49 : 50 : void 51 250 : ThirdPhaseSuppressionMaterial::computeQpProperties() 52 : { 53 : // Initialize properties to zero before accumulating 54 250 : _prop_g[_qp] = 0.0; 55 1000 : for (unsigned int i = 0; i < _num_eta; ++i) 56 : { 57 750 : (*_prop_dg[i])[_qp] = 0.0; 58 2250 : for (unsigned int j = i; j < _num_eta; ++j) 59 1500 : (*_prop_d2g[i][j])[_qp] = 0.0; 60 : } 61 : 62 : // Create Interface barrier preventing interfaces involving more than two order parameters 63 1000 : for (unsigned int i = 0; i < _num_eta; ++i) 64 1500 : for (unsigned int j = 0; j < i; ++j) 65 1000 : for (unsigned int k = 0; k < j; ++k) 66 : { 67 250 : const Real ni = (*_eta[i])[_qp]; 68 250 : const Real nj = (*_eta[j])[_qp]; 69 250 : const Real nk = (*_eta[k])[_qp]; 70 : 71 250 : _prop_g[_qp] += ni * ni * nj * nj * nk * nk; 72 250 : (*_prop_dg[i])[_qp] += 2 * ni * nj * nj * nk * nk; 73 250 : (*_prop_dg[j])[_qp] += 2 * ni * ni * nj * nk * nk; 74 250 : (*_prop_dg[k])[_qp] += 2 * ni * ni * nj * nj * nk; 75 250 : (*_prop_d2g[i][i])[_qp] += 2 * nj * nj * nk * nk; 76 250 : (*_prop_d2g[j][j])[_qp] += 2 * ni * ni * nk * nk; 77 250 : (*_prop_d2g[k][k])[_qp] += 2 * ni * ni * nj * nj; 78 250 : (*_prop_d2g[i][j])[_qp] += 4 * ni * nj * nk * nk; 79 250 : (*_prop_d2g[i][k])[_qp] += 4 * ni * nj * nj * nk; 80 250 : (*_prop_d2g[k][j])[_qp] += 4 * ni * ni * nj * nk; 81 : } 82 250 : }