LCOV - code coverage report
Current view: top level - src/materials - IsotropicPowerLawHardeningStressUpdate.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 0 45 0.0 %
Date: 2025-07-25 05:00:39 Functions: 0 12 0.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 "IsotropicPowerLawHardeningStressUpdate.h"
      11             : #include "ElasticityTensorTools.h"
      12             : 
      13             : registerMooseObject("SolidMechanicsApp", IsotropicPowerLawHardeningStressUpdate);
      14             : registerMooseObject("SolidMechanicsApp", ADIsotropicPowerLawHardeningStressUpdate);
      15             : 
      16             : template <bool is_ad>
      17             : InputParameters
      18           0 : IsotropicPowerLawHardeningStressUpdateTempl<is_ad>::validParams()
      19             : {
      20           0 :   InputParameters params = IsotropicPlasticityStressUpdateTempl<is_ad>::validParams();
      21           0 :   params.addClassDescription("This class uses the discrete material in a radial return isotropic "
      22             :                              "plasticity power law hardening model, solving for the yield stress "
      23             :                              "as the intersection of the power law relation curve and Hooke's law. "
      24             :                              " This class can be used in conjunction with other creep and "
      25             :                              "plasticity materials for more complex simulations.");
      26             : 
      27             :   // Set and Suppress parameters to enable calculation of the yield stress
      28           0 :   params.set<Real>("yield_stress") = 1.0;
      29           0 :   params.set<Real>("hardening_constant") = 1.0;
      30           0 :   params.suppressParameter<Real>("yield_stress");
      31           0 :   params.suppressParameter<Real>("hardening_constant");
      32             : 
      33             :   // Power law hardening specific parameters
      34           0 :   params.addRequiredParam<Real>("strength_coefficient",
      35             :                                 "The strength coefficient (K) for power law hardening");
      36           0 :   params.addRequiredRangeCheckedParam<Real>(
      37             :       "strain_hardening_exponent",
      38             :       "strain_hardening_exponent>=0.0 & strain_hardening_exponent <=1.0",
      39             :       "The strain hardening exponent (n) for power law hardening");
      40             : 
      41           0 :   return params;
      42           0 : }
      43             : 
      44             : template <bool is_ad>
      45           0 : IsotropicPowerLawHardeningStressUpdateTempl<is_ad>::IsotropicPowerLawHardeningStressUpdateTempl(
      46             :     const InputParameters & parameters)
      47             :   : IsotropicPlasticityStressUpdateTempl<is_ad>(parameters),
      48           0 :     _K(parameters.get<Real>("strength_coefficient")),
      49           0 :     _strain_hardening_exponent(parameters.get<Real>("strain_hardening_exponent"))
      50             : {
      51           0 : }
      52             : 
      53             : template <bool is_ad>
      54             : void
      55           0 : IsotropicPowerLawHardeningStressUpdateTempl<is_ad>::computeStressInitialize(
      56             :     const GenericReal<is_ad> & effective_trial_stress,
      57             :     const GenericRankFourTensor<is_ad> & elasticity_tensor)
      58             : {
      59           0 :   RadialReturnStressUpdateTempl<is_ad>::computeStressInitialize(effective_trial_stress,
      60             :                                                                 elasticity_tensor);
      61             : 
      62           0 :   computeYieldStress(elasticity_tensor);
      63             : 
      64           0 :   _effective_trial_stress = effective_trial_stress;
      65           0 :   this->_yield_condition =
      66           0 :       effective_trial_stress - this->_hardening_variable_old[_qp] - this->_yield_stress;
      67             : 
      68           0 :   this->_hardening_variable[_qp] = this->_hardening_variable_old[_qp];
      69           0 :   this->_plastic_strain[_qp] = this->_plastic_strain_old[_qp];
      70           0 : }
      71             : 
      72             : template <bool is_ad>
      73             : GenericReal<is_ad>
      74           0 : IsotropicPowerLawHardeningStressUpdateTempl<is_ad>::computeHardeningDerivative(
      75             :     const GenericReal<is_ad> & scalar)
      76             : {
      77           0 :   const GenericReal<is_ad> stress_delta = _effective_trial_stress - _three_shear_modulus * scalar;
      78           0 :   GenericReal<is_ad> slope = std::pow(stress_delta, (1.0 / _strain_hardening_exponent - 1.0)) /
      79           0 :                              _strain_hardening_exponent * 1.0 /
      80           0 :                              std::pow(_K, 1.0 / _strain_hardening_exponent);
      81           0 :   slope -= 1.0 / _youngs_modulus;
      82             : 
      83           0 :   return 1.0 / slope;
      84             : }
      85             : 
      86             : template <bool is_ad>
      87             : void
      88           0 : IsotropicPowerLawHardeningStressUpdateTempl<is_ad>::computeYieldStress(
      89             :     const GenericRankFourTensor<is_ad> & elasticity_tensor)
      90             : {
      91             :   // Pull in the Lam\`{e} lambda, and caculate E
      92           0 :   const GenericReal<is_ad> lambda = getIsotropicLameLambda(elasticity_tensor);
      93           0 :   const GenericReal<is_ad> shear_modulus = _three_shear_modulus / 3.0;
      94             : 
      95           0 :   _youngs_modulus = shear_modulus * (3.0 * lambda + 2 * shear_modulus) / (lambda + shear_modulus);
      96             : 
      97             :   // Then solve for yield stress using equation from the header file
      98           0 :   this->_yield_stress = std::pow(_K / std::pow(_youngs_modulus, _strain_hardening_exponent),
      99           0 :                                  1.0 / (1.0 - _strain_hardening_exponent));
     100           0 :   if (this->_yield_stress <= 0.0)
     101           0 :     mooseError("The yield stress must be greater than zero, but during the simulation your yield "
     102             :                "stress became less than zero.");
     103           0 : }
     104             : 
     105             : template <bool is_ad>
     106             : GenericReal<is_ad>
     107           0 : IsotropicPowerLawHardeningStressUpdateTempl<is_ad>::getIsotropicLameLambda(
     108             :     const GenericRankFourTensor<is_ad> & elasticity_tensor)
     109             : {
     110           0 :   const GenericReal<is_ad> lame_lambda = elasticity_tensor(0, 0, 1, 1);
     111             : 
     112           0 :   if (this->_mesh.dimension() == 3 &&
     113             :       MetaPhysicL::raw_value(lame_lambda) != MetaPhysicL::raw_value(elasticity_tensor(1, 1, 2, 2)))
     114           0 :     mooseError(
     115             :         "Check to ensure that your Elasticity Tensor is truly Isotropic: different lambda values");
     116           0 :   return lame_lambda;
     117             : }
     118             : 
     119             : template class IsotropicPowerLawHardeningStressUpdateTempl<false>;
     120             : template class IsotropicPowerLawHardeningStressUpdateTempl<true>;

Generated by: LCOV version 1.14