LCOV - code coverage report
Current view: top level - src/materials - ArrheniusMaterialProperty.C (source / functions) Hit Total Coverage
Test: idaholab/moose misc: #32971 (54bef8) with base c6cf66 Lines: 33 44 75.0 %
Date: 2026-05-29 20:37:18 Functions: 6 8 75.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 "ArrheniusMaterialProperty.h"
      11             : 
      12             : #include "PhysicalConstants.h"
      13             : 
      14             : #include "libmesh/utility.h"
      15             : 
      16             : registerMooseObject("MiscApp", ArrheniusMaterialProperty);
      17             : registerMooseObject("MiscApp", ADArrheniusMaterialProperty);
      18             : 
      19             : template <bool is_ad>
      20             : InputParameters
      21          68 : ArrheniusMaterialPropertyTempl<is_ad>::validParams()
      22             : {
      23          68 :   InputParameters params = Material::validParams();
      24             : 
      25          68 :   params.addClassDescription(
      26             :       "Arbitrary material property of the sum of an arbitary number ($i$) of "
      27             :       "Arrhenius functions $A_i * \\exp{-Q_i / (RT)}$, where $A_i$ is the frequency "
      28             :       "factor, $Q_i$ is the activation energy, and $R$ is the gas constant.");
      29             : 
      30         136 :   params.addRequiredParam<std::string>("property_name",
      31             :                                        "Specify the name of this material property");
      32         136 :   params.addRequiredCoupledVar("temperature", "Coupled temperature");
      33         136 :   params.addRequiredParam<std::vector<Real>>("frequency_factor",
      34             :                                              "List of Arrhenius pre-exponential coefficients");
      35         136 :   params.addRequiredParam<std::vector<Real>>("activation_energy", "List of activation energies");
      36         136 :   params.addRangeCheckedParam<Real>("gas_constant",
      37             :                                     PhysicalConstants::ideal_gas_constant,
      38             :                                     "gas_constant>0",
      39             :                                     "Gas constant for Arrhenius function");
      40         204 :   params.addRangeCheckedParam<Real>(
      41             :       "initial_temperature",
      42         136 :       1.0,
      43             :       "initial_temperature > 0",
      44             :       "Initial temperature utilized for initialization of stateful properties");
      45             : 
      46          68 :   return params;
      47           0 : }
      48             : 
      49             : template <bool is_ad>
      50          51 : ArrheniusMaterialPropertyTempl<is_ad>::ArrheniusMaterialPropertyTempl(
      51             :     const InputParameters & parameters)
      52             :   : Material(parameters),
      53          51 :     _diffusivity(
      54         102 :         this->template declareGenericProperty<Real, is_ad>(getParam<std::string>("property_name"))),
      55         153 :     _diffusivity_dT(this->template declareGenericProperty<Real, is_ad>(
      56             :         getParam<std::string>("property_name") + "_dT")),
      57          51 :     _temperature(this->template coupledGenericValue<is_ad>("temperature")),
      58         102 :     _D_0(getParam<std::vector<Real>>("frequency_factor")),
      59         102 :     _Q(getParam<std::vector<Real>>("activation_energy")),
      60         102 :     _R(getParam<Real>("gas_constant")),
      61          51 :     _number(_D_0.size()),
      62         153 :     _initial_temperature(this->template getParam<Real>("initial_temperature"))
      63             : {
      64          51 :   if (_number != _Q.size())
      65           0 :     paramError("frequency_factor",
      66             :                "frequency_factor and activation_energy must have the same number of entries");
      67          51 :   if (_number == 0)
      68           0 :     paramError("frequency_factor",
      69             :                "At least one frequency_factor and activation_energy parameter must be given");
      70          51 : }
      71             : 
      72             : template <bool is_ad>
      73             : void
      74           0 : ArrheniusMaterialPropertyTempl<is_ad>::initQpStatefulProperties()
      75             : {
      76           0 :   _diffusivity[_qp] = 0.0;
      77           0 :   _diffusivity_dT[_qp] = 0.0;
      78             : 
      79           0 :   for (unsigned int i = 0; i < _number; ++i)
      80             :   {
      81           0 :     _diffusivity[_qp] += _D_0[i] * std::exp(-_Q[i] / _R / _initial_temperature);
      82           0 :     _diffusivity_dT[_qp] -= _D_0[i] * std::exp(-_Q[i] / _R / _initial_temperature) * _Q[i];
      83             :   }
      84             : 
      85           0 :   _diffusivity_dT[_qp] /= _R * Utility::pow<2>(_initial_temperature);
      86           0 : }
      87             : 
      88             : template <bool is_ad>
      89             : void
      90         226 : ArrheniusMaterialPropertyTempl<is_ad>::computeQpProperties()
      91             : {
      92             :   using std::max, std::exp;
      93             : 
      94         226 :   const GenericReal<is_ad> temp = max(_temperature[_qp], 1e-30);
      95             : 
      96         226 :   _diffusivity[_qp] = 0.0;
      97         226 :   _diffusivity_dT[_qp] = 0.0;
      98             : 
      99         678 :   for (unsigned int i = 0; i < _number; ++i)
     100             :   {
     101         908 :     _diffusivity[_qp] += _D_0[i] * exp(-_Q[i] / _R / temp);
     102         908 :     _diffusivity_dT[_qp] += _D_0[i] * exp(-_Q[i] / _R / temp) * _Q[i];
     103             :   }
     104             : 
     105         340 :   _diffusivity_dT[_qp] /= (_R * Utility::pow<2>(temp));
     106         226 : }

Generated by: LCOV version 1.14