LCOV - code coverage report
Current view: top level - src/materials - PowerLawCreepStressUpdate.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #32971 (54bef8) with base c6cf66 Lines: 52 54 96.3 %
Date: 2026-05-29 20:40:07 Functions: 18 20 90.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 "PowerLawCreepStressUpdate.h"
      11             : 
      12             : registerMooseObject("SolidMechanicsApp", PowerLawCreepStressUpdate);
      13             : registerMooseObject("SolidMechanicsApp", ADPowerLawCreepStressUpdate);
      14             : 
      15             : template <bool is_ad>
      16             : InputParameters
      17        1852 : PowerLawCreepStressUpdateTempl<is_ad>::validParams()
      18             : {
      19        1852 :   InputParameters params = RadialReturnCreepStressUpdateBaseTempl<is_ad>::validParams();
      20        1852 :   params.addClassDescription(
      21             :       "This class uses the stress update material in a radial return isotropic power law creep "
      22             :       "model. This class can be used in conjunction with other creep and plasticity materials "
      23             :       "for more complex simulations.");
      24             : 
      25             :   // Linear strain hardening parameters
      26        3704 :   params.addCoupledVar("temperature", "Coupled temperature");
      27        3704 :   params.addRequiredParam<Real>("coefficient", "Leading coefficient in power-law equation");
      28        3704 :   params.addRequiredParam<Real>("n_exponent", "Exponent on effective stress in power-law equation");
      29        3704 :   params.addParam<Real>("m_exponent", 0.0, "Exponent on time in power-law equation");
      30        3704 :   params.addRequiredParam<Real>("activation_energy", "Activation energy");
      31        3704 :   params.addParam<Real>("gas_constant", 8.3143, "Universal gas constant");
      32        3704 :   params.addParam<Real>("start_time", 0.0, "Start time (if not zero)");
      33        1852 :   return params;
      34           0 : }
      35             : 
      36             : template <bool is_ad>
      37        1389 : PowerLawCreepStressUpdateTempl<is_ad>::PowerLawCreepStressUpdateTempl(
      38             :     const InputParameters & parameters)
      39             :   : RadialReturnCreepStressUpdateBaseTempl<is_ad>(parameters),
      40        4167 :     _temperature(this->isParamValid("temperature")
      41        1635 :                      ? &this->template coupledGenericValue<is_ad>("temperature")
      42             :                      : nullptr),
      43        2778 :     _coefficient(this->template getParam<Real>("coefficient")),
      44        2778 :     _n_exponent(this->template getParam<Real>("n_exponent")),
      45        2778 :     _m_exponent(this->template getParam<Real>("m_exponent")),
      46        2778 :     _activation_energy(this->template getParam<Real>("activation_energy")),
      47        2778 :     _gas_constant(this->template getParam<Real>("gas_constant")),
      48        2778 :     _start_time(this->template getParam<Real>("start_time")),
      49        2031 :     _exponential(1.0)
      50             : {
      51        1389 :   if (_start_time < this->_app.getStartTime() && (std::trunc(_m_exponent) != _m_exponent))
      52           0 :     this->paramError("start_time",
      53             :                      "Start time must be equal to or greater than the Executioner start_time if a "
      54             :                      "non-integer m_exponent is used");
      55        1389 : }
      56             : 
      57             : template <bool is_ad>
      58             : void
      59    23833929 : PowerLawCreepStressUpdateTempl<is_ad>::computeStressInitialize(
      60             :     const GenericReal<is_ad> & effective_trial_stress,
      61             :     const GenericRankFourTensor<is_ad> & elasticity_tensor)
      62             : {
      63             :   using std::exp, std::pow;
      64             : 
      65    12758235 :   RadialReturnStressUpdateTempl<is_ad>::computeStressInitialize(effective_trial_stress,
      66             :                                                                 elasticity_tensor);
      67             : 
      68    23833929 :   if (_temperature)
      69     1189069 :     _exponential = exp(-_activation_energy / (_gas_constant * (*_temperature)[_qp]));
      70             : 
      71    23833929 :   _exp_time = pow(_t - _start_time, _m_exponent);
      72    23833929 : }
      73             : 
      74             : template <bool is_ad>
      75             : template <typename ScalarType>
      76             : ScalarType
      77   128499084 : PowerLawCreepStressUpdateTempl<is_ad>::computeResidualInternal(
      78             :     const GenericReal<is_ad> & effective_trial_stress, const ScalarType & scalar)
      79             : {
      80             :   using std::pow;
      81             : 
      82   128499084 :   const ScalarType stress_delta = effective_trial_stress - _three_shear_modulus * scalar;
      83   204611852 :   const ScalarType creep_rate =
      84   128499084 :       _coefficient * pow(stress_delta, _n_exponent) * _exponential * _exp_time;
      85   128499084 :   return creep_rate * _dt - scalar;
      86             : }
      87             : 
      88             : template <bool is_ad>
      89             : GenericReal<is_ad>
      90   128764246 : PowerLawCreepStressUpdateTempl<is_ad>::computeDerivative(
      91             :     const GenericReal<is_ad> & effective_trial_stress, const GenericReal<is_ad> & scalar)
      92             : {
      93             :   using std::pow;
      94             : 
      95   128764246 :   const GenericReal<is_ad> stress_delta = effective_trial_stress - _three_shear_modulus * scalar;
      96   280989782 :   const GenericReal<is_ad> creep_rate_derivative =
      97   128764246 :       -_coefficient * _three_shear_modulus * _n_exponent * pow(stress_delta, _n_exponent - 1.0) *
      98   128764246 :       _exponential * _exp_time;
      99   204877014 :   return creep_rate_derivative * _dt - 1.0;
     100             : }
     101             : 
     102             : template <bool is_ad>
     103             : Real
     104      210860 : PowerLawCreepStressUpdateTempl<is_ad>::computeStrainEnergyRateDensity(
     105             :     const GenericMaterialProperty<RankTwoTensor, is_ad> & stress,
     106             :     const GenericMaterialProperty<RankTwoTensor, is_ad> & strain_rate)
     107             : {
     108      210860 :   if (_n_exponent <= 1)
     109             :     return 0.0;
     110             : 
     111      210860 :   Real creep_factor = _n_exponent / (_n_exponent + 1);
     112             : 
     113      272464 :   return MetaPhysicL::raw_value(creep_factor * stress[_qp].doubleContraction((strain_rate)[_qp]));
     114             : }
     115             : 
     116             : template <bool is_ad>
     117             : void
     118    23960155 : PowerLawCreepStressUpdateTempl<is_ad>::computeStressFinalize(
     119             :     const GenericRankTwoTensor<is_ad> & plastic_strain_increment)
     120             : {
     121    23960155 :   _creep_strain[_qp] += plastic_strain_increment;
     122    23960155 : }
     123             : 
     124             : template <bool is_ad>
     125             : void
     126    23551962 : PowerLawCreepStressUpdateTempl<is_ad>::resetIncrementalMaterialProperties()
     127             : {
     128    23551962 :   _creep_strain[_qp] = _creep_strain_old[_qp];
     129    23551962 : }
     130             : 
     131             : template <bool is_ad>
     132             : bool
     133    23420149 : PowerLawCreepStressUpdateTempl<is_ad>::substeppingCapabilityEnabled()
     134             : {
     135    23420149 :   return this->_use_substepping != RadialReturnStressUpdateTempl<is_ad>::SubsteppingType::NONE;
     136             : }
     137             : 
     138             : template class PowerLawCreepStressUpdateTempl<false>;
     139             : template class PowerLawCreepStressUpdateTempl<true>;
     140             : template Real PowerLawCreepStressUpdateTempl<false>::computeResidualInternal<Real>(const Real &,
     141             :                                                                                    const Real &);
     142             : template ADReal
     143             : PowerLawCreepStressUpdateTempl<true>::computeResidualInternal<ADReal>(const ADReal &,
     144             :                                                                       const ADReal &);
     145             : template ChainedReal
     146             : PowerLawCreepStressUpdateTempl<false>::computeResidualInternal<ChainedReal>(const Real &,
     147             :                                                                             const ChainedReal &);
     148             : template ChainedADReal
     149             : PowerLawCreepStressUpdateTempl<true>::computeResidualInternal<ChainedADReal>(const ADReal &,
     150             :                                                                              const ChainedADReal &);

Generated by: LCOV version 1.14