LCOV - code coverage report
Current view: top level - src/materials - PowerLawCreepStressUpdate.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 52 54 96.3 %
Date: 2025-07-25 05:00:39 Functions: 19 20 95.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        3152 : PowerLawCreepStressUpdateTempl<is_ad>::validParams()
      18             : {
      19        3152 :   InputParameters params = RadialReturnCreepStressUpdateBaseTempl<is_ad>::validParams();
      20        3152 :   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        6304 :   params.addCoupledVar("temperature", "Coupled temperature");
      27        6304 :   params.addRequiredParam<Real>("coefficient", "Leading coefficient in power-law equation");
      28        6304 :   params.addRequiredParam<Real>("n_exponent", "Exponent on effective stress in power-law equation");
      29        6304 :   params.addParam<Real>("m_exponent", 0.0, "Exponent on time in power-law equation");
      30        6304 :   params.addRequiredParam<Real>("activation_energy", "Activation energy");
      31        6304 :   params.addParam<Real>("gas_constant", 8.3143, "Universal gas constant");
      32        6304 :   params.addParam<Real>("start_time", 0.0, "Start time (if not zero)");
      33        3152 :   return params;
      34           0 : }
      35             : 
      36             : template <bool is_ad>
      37        2364 : PowerLawCreepStressUpdateTempl<is_ad>::PowerLawCreepStressUpdateTempl(
      38             :     const InputParameters & parameters)
      39             :   : RadialReturnCreepStressUpdateBaseTempl<is_ad>(parameters),
      40        7092 :     _temperature(this->isParamValid("temperature")
      41        2778 :                      ? &this->template coupledGenericValue<is_ad>("temperature")
      42             :                      : nullptr),
      43        4728 :     _coefficient(this->template getParam<Real>("coefficient")),
      44        4728 :     _n_exponent(this->template getParam<Real>("n_exponent")),
      45        4728 :     _m_exponent(this->template getParam<Real>("m_exponent")),
      46        4728 :     _activation_energy(this->template getParam<Real>("activation_energy")),
      47        4728 :     _gas_constant(this->template getParam<Real>("gas_constant")),
      48        4728 :     _start_time(this->template getParam<Real>("start_time")),
      49        3474 :     _exponential(1.0)
      50             : {
      51        2364 :   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        2364 : }
      56             : 
      57             : template <bool is_ad>
      58             : void
      59    43294624 : PowerLawCreepStressUpdateTempl<is_ad>::computeStressInitialize(
      60             :     const GenericReal<is_ad> & effective_trial_stress,
      61             :     const GenericRankFourTensor<is_ad> & elasticity_tensor)
      62             : {
      63    22672018 :   RadialReturnStressUpdateTempl<is_ad>::computeStressInitialize(effective_trial_stress,
      64             :                                                                 elasticity_tensor);
      65             : 
      66    43294624 :   if (_temperature)
      67     2025752 :     _exponential = std::exp(-_activation_energy / (_gas_constant * (*_temperature)[_qp]));
      68             : 
      69    43294624 :   _exp_time = std::pow(_t - _start_time, _m_exponent);
      70    43294624 : }
      71             : 
      72             : template <bool is_ad>
      73             : template <typename ScalarType>
      74             : ScalarType
      75   224582728 : PowerLawCreepStressUpdateTempl<is_ad>::computeResidualInternal(
      76             :     const GenericReal<is_ad> & effective_trial_stress, const ScalarType & scalar)
      77             : {
      78   224582728 :   const ScalarType stress_delta = effective_trial_stress - _three_shear_modulus * scalar;
      79   357330372 :   const ScalarType creep_rate =
      80   224582728 :       _coefficient * std::pow(stress_delta, _n_exponent) * _exponential * _exp_time;
      81   224582728 :   return creep_rate * _dt - scalar;
      82             : }
      83             : 
      84             : template <bool is_ad>
      85             : GenericReal<is_ad>
      86   218430488 : PowerLawCreepStressUpdateTempl<is_ad>::computeDerivative(
      87             :     const GenericReal<is_ad> & effective_trial_stress, const GenericReal<is_ad> & scalar)
      88             : {
      89   218430488 :   const GenericReal<is_ad> stress_delta = effective_trial_stress - _three_shear_modulus * scalar;
      90   471004864 :   const GenericReal<is_ad> creep_rate_derivative =
      91   218430488 :       -_coefficient * _three_shear_modulus * _n_exponent *
      92   218430488 :       std::pow(stress_delta, _n_exponent - 1.0) * _exponential * _exp_time;
      93   344717676 :   return creep_rate_derivative * _dt - 1.0;
      94             : }
      95             : 
      96             : template <bool is_ad>
      97             : Real
      98      293624 : PowerLawCreepStressUpdateTempl<is_ad>::computeStrainEnergyRateDensity(
      99             :     const GenericMaterialProperty<RankTwoTensor, is_ad> & stress,
     100             :     const GenericMaterialProperty<RankTwoTensor, is_ad> & strain_rate)
     101             : {
     102      293624 :   if (_n_exponent <= 1)
     103             :     return 0.0;
     104             : 
     105      293624 :   Real creep_factor = _n_exponent / (_n_exponent + 1);
     106             : 
     107      373936 :   return MetaPhysicL::raw_value(creep_factor * stress[_qp].doubleContraction((strain_rate)[_qp]));
     108             : }
     109             : 
     110             : template <bool is_ad>
     111             : void
     112    43533284 : PowerLawCreepStressUpdateTempl<is_ad>::computeStressFinalize(
     113             :     const GenericRankTwoTensor<is_ad> & plastic_strain_increment)
     114             : {
     115    43533284 :   _creep_strain[_qp] += plastic_strain_increment;
     116    43533284 : }
     117             : 
     118             : template <bool is_ad>
     119             : void
     120    42971280 : PowerLawCreepStressUpdateTempl<is_ad>::resetIncrementalMaterialProperties()
     121             : {
     122    42971280 :   _creep_strain[_qp] = _creep_strain_old[_qp];
     123    42971280 : }
     124             : 
     125             : template <bool is_ad>
     126             : bool
     127    42725408 : PowerLawCreepStressUpdateTempl<is_ad>::substeppingCapabilityEnabled()
     128             : {
     129    42725408 :   return this->_use_substepping != RadialReturnStressUpdateTempl<is_ad>::SubsteppingType::NONE;
     130             : }
     131             : 
     132             : template class PowerLawCreepStressUpdateTempl<false>;
     133             : template class PowerLawCreepStressUpdateTempl<true>;
     134             : template Real PowerLawCreepStressUpdateTempl<false>::computeResidualInternal<Real>(const Real &,
     135             :                                                                                    const Real &);
     136             : template ADReal
     137             : PowerLawCreepStressUpdateTempl<true>::computeResidualInternal<ADReal>(const ADReal &,
     138             :                                                                       const ADReal &);
     139             : template ChainedReal
     140             : PowerLawCreepStressUpdateTempl<false>::computeResidualInternal<ChainedReal>(const Real &,
     141             :                                                                             const ChainedReal &);
     142             : template ChainedADReal
     143             : PowerLawCreepStressUpdateTempl<true>::computeResidualInternal<ChainedADReal>(const ADReal &,
     144             :                                                                              const ChainedADReal &);

Generated by: LCOV version 1.14