LCOV - code coverage report
Current view: top level - src/materials - GBEvolutionBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 60 62 96.8 %
Date: 2025-09-04 07:55:36 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          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 "GBEvolutionBase.h"
      11             : 
      12             : template <bool is_ad>
      13             : InputParameters
      14        3520 : GBEvolutionBaseTempl<is_ad>::validParams()
      15             : {
      16        3520 :   InputParameters params = Material::validParams();
      17        3520 :   params.addClassDescription(
      18             :       "Computes necessary material properties for the isotropic grain growth model");
      19        7040 :   params.addRequiredCoupledVar("T", "Temperature in Kelvin");
      20        7040 :   params.addParam<Real>("f0s", 0.125, "The GB energy constant ");
      21        7040 :   params.addRequiredParam<Real>("wGB", "Diffuse GB width in the length scale of the model");
      22        7040 :   params.addParam<Real>("length_scale", 1.0e-9, "Length scale in m, where default is nm");
      23        7040 :   params.addParam<Real>("time_scale", 1.0e-9, "Time scale in s, where default is ns");
      24        7040 :   params.addParam<Real>(
      25             :       "GBMobility",
      26        7040 :       -1,
      27             :       "GB mobility input in m^4/(J*s), that overrides the temperature dependent calculation");
      28        7040 :   params.addParam<Real>("GBmob0", 0, "Grain boundary mobility prefactor in m^4/(J*s)");
      29        7040 :   params.addParam<Real>("Q", 0, "Grain boundary migration activation energy in eV");
      30        7040 :   params.addParam<Real>("molar_volume",
      31        7040 :                         24.62e-6,
      32             :                         "Molar volume in m^3/mol, needed for temperature gradient driving force");
      33        3520 :   return params;
      34           0 : }
      35             : 
      36             : template <bool is_ad>
      37        2709 : GBEvolutionBaseTempl<is_ad>::GBEvolutionBaseTempl(const InputParameters & parameters)
      38             :   : DerivativeMaterialInterface<Material>(parameters),
      39        2709 :     _f0s(getParam<Real>("f0s")),
      40        5418 :     _wGB(getParam<Real>("wGB")),
      41        5418 :     _length_scale(getParam<Real>("length_scale")),
      42        5418 :     _time_scale(getParam<Real>("time_scale")),
      43        5418 :     _GBmob0(getParam<Real>("GBmob0")),
      44        5418 :     _Q(getParam<Real>("Q")),
      45        5418 :     _GBMobility(getParam<Real>("GBMobility")),
      46        5418 :     _molar_vol(getParam<Real>("molar_volume")),
      47        2709 :     _T(coupledValue("T")),
      48        5418 :     _sigma(declareGenericProperty<Real, is_ad>("sigma")),
      49        5418 :     _M_GB(declareGenericProperty<Real, is_ad>("M_GB")),
      50        5418 :     _kappa(declareGenericProperty<Real, is_ad>("kappa_op")),
      51        5418 :     _gamma(declareGenericProperty<Real, is_ad>("gamma_asymm")),
      52        5418 :     _L(declareGenericProperty<Real, is_ad>("L")),
      53        2709 :     _dLdT(parameters.hasDefaultCoupledValue("T")
      54        2709 :               ? nullptr
      55        3069 :               : &declarePropertyDerivative<Real>("L", coupledName("T", 0))),
      56        5418 :     _l_GB(declareGenericProperty<Real, is_ad>("l_GB")),
      57        5418 :     _mu(declareGenericProperty<Real, is_ad>("mu")),
      58        5418 :     _entropy_diff(declareGenericProperty<Real, is_ad>("entropy_diff")),
      59        5418 :     _molar_volume(declareGenericProperty<Real, is_ad>("molar_volume")),
      60        5418 :     _act_wGB(declareGenericProperty<Real, is_ad>("act_wGB")),
      61        2709 :     _kb(8.617343e-5),     // Boltzmann constant in eV/K
      62        2709 :     _JtoeV(6.24150974e18) // Joule to eV conversion
      63             : {
      64        2709 :   if (_GBMobility == -1 && _GBmob0 == 0)
      65           0 :     mooseError("Either a value for GBMobility or for GBmob0 and Q must be provided");
      66        2709 : }
      67             : 
      68             : template <bool is_ad>
      69             : void
      70   118526288 : GBEvolutionBaseTempl<is_ad>::computeQpProperties()
      71             : {
      72   118526288 :   const Real length_scale4 = _length_scale * _length_scale * _length_scale * _length_scale;
      73             : 
      74             :   // GB mobility Derivative
      75             :   Real dM_GBdT;
      76             : 
      77   118526288 :   if (_GBMobility < 0)
      78             :   {
      79             :     // Convert to lengthscale^4/(eV*timescale);
      80   117147088 :     const Real M0 = _GBmob0 * _time_scale / (_JtoeV * length_scale4);
      81             : 
      82   117147088 :     _M_GB[_qp] = M0 * std::exp(-_Q / (_kb * _T[_qp]));
      83   119196688 :     dM_GBdT = MetaPhysicL::raw_value(_M_GB[_qp] * _Q / (_kb * _T[_qp] * _T[_qp]));
      84             :   }
      85             :   else
      86             :   {
      87             :     // Convert to lengthscale^4/(eV*timescale)
      88     1379200 :     _M_GB[_qp] = _GBMobility * _time_scale / (_JtoeV * length_scale4);
      89             :     dM_GBdT = 0.0;
      90             :   }
      91             : 
      92             :   // in the length scale of the system
      93   118526288 :   _l_GB[_qp] = _wGB;
      94             : 
      95   120575888 :   _L[_qp] = 4.0 / 3.0 * _M_GB[_qp] / _l_GB[_qp];
      96   118526288 :   if (_dLdT)
      97     3040000 :     (*_dLdT)[_qp] = MetaPhysicL::raw_value(4.0 / 3.0 * dM_GBdT / _l_GB[_qp]);
      98   120575888 :   _kappa[_qp] = 3.0 / 4.0 * _sigma[_qp] * _l_GB[_qp];
      99   118526288 :   _gamma[_qp] = 1.5;
     100   120575888 :   _mu[_qp] = 3.0 / 4.0 * 1.0 / _f0s * _sigma[_qp] / _l_GB[_qp];
     101             : 
     102             :   // J/(K mol) converted to eV(K mol)
     103   118526288 :   _entropy_diff[_qp] = 8.0e3 * _JtoeV;
     104             : 
     105             :   // m^3/mol converted to ls^3/mol
     106   118526288 :   _molar_volume[_qp] = _molar_vol / (_length_scale * _length_scale * _length_scale);
     107   118526288 :   _act_wGB[_qp] = 0.5e-9 / _length_scale;
     108   118526288 : }
     109             : 
     110             : template class GBEvolutionBaseTempl<false>;
     111             : template class GBEvolutionBaseTempl<true>;

Generated by: LCOV version 1.14