LCOV - code coverage report
Current view: top level - src/materials/crystal_plasticity - CrystalPlasticityKalidindiUpdate.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #31405 (292dce) with base fef103 Lines: 99 104 95.2 %
Date: 2025-09-04 07:57:23 Functions: 13 13 100.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 "CrystalPlasticityKalidindiUpdate.h"
      11             : #include "libmesh/int_range.h"
      12             : 
      13             : registerMooseObject("SolidMechanicsApp", CrystalPlasticityKalidindiUpdate);
      14             : 
      15             : InputParameters
      16         938 : CrystalPlasticityKalidindiUpdate::validParams()
      17             : {
      18         938 :   InputParameters params = CrystalPlasticityStressUpdateBase::validParams();
      19         938 :   params.addClassDescription("Kalidindi version of homogeneous crystal plasticity.");
      20        1876 :   params.addParam<Real>("r", 1.0, "Latent hardening coefficient");
      21        1876 :   params.addParam<Real>("h", 541.5, "hardening constants");
      22        1876 :   params.addParam<Real>("t_sat", 109.8, "saturated slip system strength");
      23        1876 :   params.addParam<Real>("gss_a", 2.5, "coefficient for hardening");
      24        1876 :   params.addParam<Real>("ao", 0.001, "slip rate coefficient");
      25        1876 :   params.addParam<Real>("xm", 0.1, "exponent for slip rate");
      26        1876 :   params.addParam<Real>("gss_initial", 60.8, "initial lattice friction strength of the material");
      27             : 
      28        1876 :   params.addParam<MaterialPropertyName>(
      29             :       "total_twin_volume_fraction",
      30             :       "Total twin volume fraction, if twinning is considered in the simulation");
      31             : 
      32         938 :   return params;
      33           0 : }
      34             : 
      35         699 : CrystalPlasticityKalidindiUpdate::CrystalPlasticityKalidindiUpdate(
      36         699 :     const InputParameters & parameters)
      37             :   : CrystalPlasticityStressUpdateBase(parameters),
      38             :     // Constitutive values
      39         699 :     _r(getParam<Real>("r")),
      40        1398 :     _h(getParam<Real>("h")),
      41        1398 :     _tau_sat(getParam<Real>("t_sat")),
      42        1398 :     _gss_a(getParam<Real>("gss_a")),
      43        1398 :     _ao(getParam<Real>("ao")),
      44        1398 :     _xm(getParam<Real>("xm")),
      45        1398 :     _gss_initial(getParam<Real>("gss_initial")),
      46             : 
      47             :     // resize vectors used in the consititutive slip hardening
      48         699 :     _hb(_number_slip_systems, 0.0),
      49         699 :     _slip_resistance_increment(_number_slip_systems, 0.0),
      50             : 
      51             :     // resize local caching vectors used for substepping
      52         699 :     _previous_substep_slip_resistance(_number_slip_systems, 0.0),
      53         699 :     _slip_resistance_before_update(_number_slip_systems, 0.0),
      54             : 
      55             :     // Twinning contributions, if used
      56         699 :     _include_twinning_in_Lp(parameters.isParamValid("total_twin_volume_fraction")),
      57        1398 :     _twin_volume_fraction_total(_include_twinning_in_Lp
      58         804 :                                     ? &getMaterialPropertyOld<Real>("total_twin_volume_fraction")
      59         699 :                                     : nullptr)
      60             : {
      61         699 : }
      62             : 
      63             : void
      64       34496 : CrystalPlasticityKalidindiUpdate::initQpStatefulProperties()
      65             : {
      66       34496 :   CrystalPlasticityStressUpdateBase::initQpStatefulProperties();
      67      448448 :   for (const auto i : make_range(_number_slip_systems))
      68             :   {
      69      413952 :     _slip_resistance[_qp][i] = _gss_initial;
      70      413952 :     _slip_increment[_qp][i] = 0.0;
      71             :   }
      72       34496 : }
      73             : 
      74             : void
      75     1570742 : CrystalPlasticityKalidindiUpdate::setInitialConstitutiveVariableValues()
      76             : {
      77             :   // Would also set old dislocation densities here if included in this model
      78     1570742 :   _slip_resistance[_qp] = _slip_resistance_old[_qp];
      79     1570742 :   _previous_substep_slip_resistance = _slip_resistance_old[_qp];
      80     1570742 : }
      81             : 
      82             : void
      83     1615042 : CrystalPlasticityKalidindiUpdate::setSubstepConstitutiveVariableValues()
      84             : {
      85             :   // Would also set substepped dislocation densities here if included in this model
      86     1615042 :   _slip_resistance[_qp] = _previous_substep_slip_resistance;
      87     1615042 : }
      88             : 
      89             : bool
      90     7509436 : CrystalPlasticityKalidindiUpdate::calculateSlipRate()
      91             : {
      92    97207344 :   for (const auto i : make_range(_number_slip_systems))
      93             :   {
      94    89733185 :     _slip_increment[_qp][i] =
      95    89733185 :         _ao * std::pow(std::abs(_tau[_qp][i] / _slip_resistance[_qp][i]), 1.0 / _xm);
      96    89733185 :     if (_tau[_qp][i] < 0.0)
      97    37834132 :       _slip_increment[_qp][i] *= -1.0;
      98             : 
      99    89733185 :     if (std::abs(_slip_increment[_qp][i]) * _substep_dt > _slip_incr_tol)
     100             :     {
     101       35277 :       if (_print_convergence_message)
     102           0 :         mooseWarning("Maximum allowable slip increment exceeded ",
     103           0 :                      std::abs(_slip_increment[_qp][i]) * _substep_dt);
     104             : 
     105             :       return false;
     106             :     }
     107             :   }
     108             :   return true;
     109             : }
     110             : 
     111             : void
     112     7474159 : CrystalPlasticityKalidindiUpdate::calculateEquivalentSlipIncrement(
     113             :     RankTwoTensor & equivalent_slip_increment)
     114             : {
     115     7474159 :   if (_include_twinning_in_Lp)
     116             :   {
     117    25957815 :     for (const auto i : make_range(_number_slip_systems))
     118    23961060 :       equivalent_slip_increment += (1.0 - (*_twin_volume_fraction_total)[_qp]) *
     119    23961060 :                                    _flow_direction[_qp][i] * _slip_increment[_qp][i] * _substep_dt;
     120             :   }
     121             :   else // if no twinning volume fraction material property supplied, use base class
     122     5477404 :     CrystalPlasticityStressUpdateBase::calculateEquivalentSlipIncrement(equivalent_slip_increment);
     123     7474159 : }
     124             : 
     125             : void
     126     7409359 : CrystalPlasticityKalidindiUpdate::calculateConstitutiveSlipDerivative(
     127             :     std::vector<Real> & dslip_dtau)
     128             : {
     129    96321667 :   for (const auto i : make_range(_number_slip_systems))
     130             :   {
     131    88912308 :     if (MooseUtils::absoluteFuzzyEqual(_tau[_qp][i], 0.0))
     132     4743400 :       dslip_dtau[i] = 0.0;
     133             :     else
     134    84168908 :       dslip_dtau[i] = _ao / _xm *
     135    84168908 :                       std::pow(std::abs(_tau[_qp][i] / _slip_resistance[_qp][i]), 1.0 / _xm - 1.0) /
     136             :                       _slip_resistance[_qp][i];
     137             :   }
     138     7409359 : }
     139             : 
     140             : bool
     141     1588501 : CrystalPlasticityKalidindiUpdate::areConstitutiveStateVariablesConverged()
     142             : {
     143     1588501 :   return isConstitutiveStateVariableConverged(_slip_resistance[_qp],
     144     1588501 :                                               _slip_resistance_before_update,
     145     1588501 :                                               _previous_substep_slip_resistance,
     146     1588501 :                                               _resistance_tol);
     147             : }
     148             : 
     149             : void
     150     1579765 : CrystalPlasticityKalidindiUpdate::updateSubstepConstitutiveVariableValues()
     151             : {
     152             :   // Would also set substepped dislocation densities here if included in this model
     153     1579765 :   _previous_substep_slip_resistance = _slip_resistance[_qp];
     154     1579765 : }
     155             : 
     156             : void
     157     1815422 : CrystalPlasticityKalidindiUpdate::cacheStateVariablesBeforeUpdate()
     158             : {
     159     1815422 :   _slip_resistance_before_update = _slip_resistance[_qp];
     160     1815422 : }
     161             : 
     162             : void
     163     1815422 : CrystalPlasticityKalidindiUpdate::calculateStateVariableEvolutionRateComponent()
     164             : {
     165    23600486 :   for (const auto i : make_range(_number_slip_systems))
     166             :   {
     167             :     // Clear out increment from the previous iteration
     168    21785064 :     _slip_resistance_increment[i] = 0.0;
     169             : 
     170    21785064 :     _hb[i] = _h * std::pow(std::abs(1.0 - _slip_resistance[_qp][i] / _tau_sat), _gss_a);
     171    21785064 :     const Real hsign = 1.0 - _slip_resistance[_qp][i] / _tau_sat;
     172    21785064 :     if (hsign < 0.0)
     173           0 :       _hb[i] *= -1.0;
     174             :   }
     175             : 
     176    23600486 :   for (const auto i : make_range(_number_slip_systems))
     177             :   {
     178   283205832 :     for (const auto j : make_range(_number_slip_systems))
     179             :     {
     180             :       unsigned int iplane, jplane;
     181   261420768 :       iplane = i / 3;
     182   261420768 :       jplane = j / 3;
     183             : 
     184   261420768 :       if (iplane == jplane) // self vs. latent hardening
     185    65355192 :         _slip_resistance_increment[i] +=
     186    65355192 :             std::abs(_slip_increment[_qp][j]) * _hb[j]; // q_{ab} = 1.0 for self hardening
     187             :       else
     188   196065576 :         _slip_resistance_increment[i] +=
     189   196065576 :             std::abs(_slip_increment[_qp][j]) * _r * _hb[j]; // latent hardenign
     190             :     }
     191             :   }
     192     1815422 : }
     193             : 
     194             : bool
     195     1815422 : CrystalPlasticityKalidindiUpdate::updateStateVariables()
     196             : {
     197             :   // Now perform the check to see if the slip system should be updated
     198    23600486 :   for (const auto i : make_range(_number_slip_systems))
     199             :   {
     200    21785064 :     _slip_resistance_increment[i] *= _substep_dt;
     201    21785064 :     if (_previous_substep_slip_resistance[i] < _zero_tol && _slip_resistance_increment[i] < 0.0)
     202           0 :       _slip_resistance[_qp][i] = _previous_substep_slip_resistance[i];
     203             :     else
     204    21785064 :       _slip_resistance[_qp][i] =
     205    21785064 :           _previous_substep_slip_resistance[i] + _slip_resistance_increment[i];
     206             : 
     207    21785064 :     if (_slip_resistance[_qp][i] < 0.0)
     208             :       return false;
     209             :   }
     210             :   return true;
     211             : }

Generated by: LCOV version 1.14