https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ArrheniusMaterialProperty.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
12#include "PhysicalConstants.h"
13
14#include "libmesh/utility.h"
15
18
19template <bool is_ad>
22{
24
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 params.addRequiredParam<std::string>("property_name",
31 "Specify the name of this material property");
32 params.addRequiredCoupledVar("temperature", "Coupled temperature");
33 params.addRequiredParam<std::vector<Real>>("frequency_factor",
34 "List of Arrhenius pre-exponential coefficients");
35 params.addRequiredParam<std::vector<Real>>("activation_energy", "List of activation energies");
36 params.addRangeCheckedParam<Real>("gas_constant",
38 "gas_constant>0",
39 "Gas constant for Arrhenius function");
40 params.addRangeCheckedParam<Real>(
41 "initial_temperature",
42 1.0,
43 "initial_temperature > 0",
44 "Initial temperature utilized for initialization of stateful properties");
45
46 return params;
47}
48
49template <bool is_ad>
51 const InputParameters & parameters)
52 : Material(parameters),
53 _diffusivity(
54 this->template declareGenericProperty<Real, is_ad>(getParam<std::string>("property_name"))),
55 _diffusivity_dT(this->template declareGenericProperty<Real, is_ad>(
56 getParam<std::string>("property_name") + "_dT")),
57 _temperature(this->template coupledGenericValue<is_ad>("temperature")),
58 _D_0(getParam<std::vector<Real>>("frequency_factor")),
59 _Q(getParam<std::vector<Real>>("activation_energy")),
60 _R(getParam<Real>("gas_constant")),
61 _number(_D_0.size()),
62 _initial_temperature(this->template getParam<Real>("initial_temperature"))
63{
64 if (_number != _Q.size())
65 paramError("frequency_factor",
66 "frequency_factor and activation_energy must have the same number of entries");
67 if (_number == 0)
68 paramError("frequency_factor",
69 "At least one frequency_factor and activation_energy parameter must be given");
70}
71
72template <bool is_ad>
73void
75{
76 _diffusivity[_qp] = 0.0;
77 _diffusivity_dT[_qp] = 0.0;
78
79 for (unsigned int i = 0; i < _number; ++i)
80 {
81 _diffusivity[_qp] += _D_0[i] * std::exp(-_Q[i] / _R / _initial_temperature);
82 _diffusivity_dT[_qp] -= _D_0[i] * std::exp(-_Q[i] / _R / _initial_temperature) * _Q[i];
83 }
84
85 _diffusivity_dT[_qp] /= _R * Utility::pow<2>(_initial_temperature);
86}
87
88template <bool is_ad>
89void
91{
92 using std::max, std::exp;
93
94 const GenericReal<is_ad> temp = max(_temperature[_qp], 1e-30);
95
96 _diffusivity[_qp] = 0.0;
97 _diffusivity_dT[_qp] = 0.0;
98
99 for (unsigned int i = 0; i < _number; ++i)
100 {
101 _diffusivity[_qp] += _D_0[i] * exp(-_Q[i] / _R / temp);
102 _diffusivity_dT[_qp] += _D_0[i] * exp(-_Q[i] / _R / temp) * _Q[i];
103 }
104
105 _diffusivity_dT[_qp] /= (_R * Utility::pow<2>(temp));
106}
registerMooseObject("MiscApp", ArrheniusMaterialProperty)
Moose::GenericType< Real, is_ad > GenericReal
const unsigned int _number
Number of _D_0 and _Q parameters.
const std::vector< Real > _Q
Vector of activation energies.
ArrheniusMaterialPropertyTempl(const InputParameters &parameters)
virtual void computeQpProperties() override
virtual void initQpStatefulProperties() override
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
static InputParameters validParams()
void paramError(const std::string &param, Args... args) const
const auto ideal_gas_constant