LCOV - code coverage report
Current view: top level - src/materials/large_deformation_models - LargeDeformationJ2Plasticity.C (source / functions) Hit Total Coverage
Test: coverage.info Lines: 55 56 98.2 %
Date: 2025-02-21 01:06:12 Functions: 6 6 100.0 %

          Line data    Source code
       1             : //* This file is part of the RACCOON application
       2             : //* being developed at Dolbow lab at Duke University
       3             : //* http://dolbow.pratt.duke.edu
       4             : 
       5             : #include "LargeDeformationJ2Plasticity.h"
       6             : #include "RaccoonUtils.h"
       7             : 
       8             : registerMooseObject("raccoonApp", LargeDeformationJ2Plasticity);
       9             : 
      10             : InputParameters
      11         328 : LargeDeformationJ2Plasticity::validParams()
      12             : {
      13         328 :   InputParameters params = LargeDeformationPlasticityModel::validParams();
      14         328 :   params.addClassDescription("Large deformation $J_2$ plasticity. The exponential constitutive "
      15             :                              "update is used to update the plastic deformation.");
      16         328 :   return params;
      17           0 : }
      18             : 
      19          39 : LargeDeformationJ2Plasticity::LargeDeformationJ2Plasticity(const InputParameters & parameters)
      20          39 :   : LargeDeformationPlasticityModel(parameters)
      21             : {
      22          39 :   _check_range = true;
      23          39 : }
      24             : 
      25             : void
      26      234024 : LargeDeformationJ2Plasticity::updateState(ADRankTwoTensor & stress, ADRankTwoTensor & Fe)
      27             : {
      28             :   // First assume no plastic increment
      29      234024 :   ADReal delta_ep = 0;
      30      234024 :   Fe = Fe * _Fp_old[_qp].inverse();
      31      234024 :   stress = _elasticity_model->computeMandelStress(Fe);
      32             : 
      33             :   // Compute the flow direction following the Prandtl-Reuss flow rule.
      34             :   // We guard against zero denominator.
      35      234024 :   ADRankTwoTensor stress_dev = stress.deviatoric();
      36      234024 :   ADReal stress_dev_norm = stress_dev.doubleContraction(stress_dev);
      37      234024 :   if (MooseUtils::absoluteFuzzyEqual(stress_dev_norm, 0))
      38       32840 :     stress_dev_norm.value() = libMesh::TOLERANCE * libMesh::TOLERANCE;
      39      468048 :   stress_dev_norm = std::sqrt(1.5 * stress_dev_norm);
      40      468048 :   _Np[_qp] = 1.5 * stress_dev / stress_dev_norm;
      41             :   // Return mapping
      42      234024 :   ADReal phi = computeResidual(stress_dev_norm, delta_ep);
      43      234024 :   if (phi > 0)
      44       96845 :     returnMappingSolve(stress_dev_norm, delta_ep, _console);
      45             : 
      46      468048 :   _ep[_qp] = _ep_old[_qp] + delta_ep;
      47             : 
      48             :   // Avoiding /0 issues for rate dependent models
      49      234024 :   _ep[_qp] = (_ep[_qp] == 0) ? 1e-20 : _ep[_qp];
      50             : 
      51      468048 :   ADRankTwoTensor delta_Fp = RaccoonUtils::exp(delta_ep * _Np[_qp]);
      52      234024 :   _Fp[_qp] = delta_Fp * _Fp_old[_qp];
      53             : 
      54             :   // Update stress and energy
      55      234024 :   Fe = Fe * delta_Fp.inverse();
      56      234024 :   stress = _elasticity_model->computeCauchyStress(Fe);
      57             : 
      58      234024 :   _hardening_model->plasticEnergy(_ep[_qp]);
      59      234024 :   _hardening_model->plasticDissipation(delta_ep, _ep[_qp], 0);
      60             : 
      61             :   // Avoiding NaN issues for rate depedent models
      62      234024 :   if (_t_step > 0)
      63             :   {
      64      451712 :     _heat[_qp] = _hardening_model->plasticDissipation(delta_ep, _ep[_qp], 1) * delta_ep / _dt;
      65             : 
      66      451712 :     _heat[_qp] += _hardening_model->thermalConjugate(_ep[_qp]) * delta_ep / _dt;
      67             :   }
      68             :   else
      69        8168 :     _heat[_qp] = 0;
      70      234024 : }
      71             : 
      72             : Real
      73      296823 : LargeDeformationJ2Plasticity::computeReferenceResidual(const ADReal & effective_trial_stress,
      74             :                                                        const ADReal & delta_ep)
      75             : {
      76      593646 :   return raw_value(effective_trial_stress - _elasticity_model
      77      593646 :                                                 ->computeMandelStress(delta_ep * _Np[_qp],
      78             :                                                                       /*plasticity_update = */ true)
      79      593646 :                                                 .doubleContraction(_Np[_qp]));
      80             : }
      81             : 
      82             : ADReal
      83      523479 : LargeDeformationJ2Plasticity::computeResidual(const ADReal & effective_trial_stress,
      84             :                                               const ADReal & delta_ep)
      85             : {
      86      523479 :   ADReal ep = _ep_old[_qp] + delta_ep;
      87             : 
      88             :   // Avoiding /0 errors for rate depedent models
      89      523479 :   ep = (ep == 0) ? 1e-20 : ep;
      90             : 
      91      523479 :   return effective_trial_stress -
      92      523479 :          _elasticity_model
      93     1046958 :              ->computeMandelStress(delta_ep * _Np[_qp],
      94             :                                    /*plasticity_update = */ true)
      95      523479 :              .doubleContraction(_Np[_qp]) -
      96      523479 :          _hardening_model->plasticEnergy(ep, 1) -
      97     1046958 :          _hardening_model->plasticDissipation(delta_ep, ep, 1);
      98             : }
      99             : 
     100             : ADReal
     101      291223 : LargeDeformationJ2Plasticity::computeDerivative(const ADReal & /*effective_trial_stress*/,
     102             :                                                 const ADReal & delta_ep)
     103             : {
     104      291223 :   ADReal ep = _ep_old[_qp] + delta_ep;
     105      291223 :   if (ep == 0)
     106             :   {
     107         970 :     ep = 1e-20;
     108             :   }
     109      582446 :   return -_elasticity_model->computeMandelStress(_Np[_qp], /*plasticity_update = */ true)
     110      291223 :               .doubleContraction(_Np[_qp]) -
     111      291223 :          _hardening_model->plasticEnergy(ep, 2) -
     112      582446 :          _hardening_model->plasticDissipation(delta_ep, ep, 2);
     113             : }

Generated by: LCOV version 1.16