LCOV - code coverage report
Current view: top level - src/materials/crystal_plasticity - CrystalPlasticityKalidindiUpdate.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 99 104 95.2 %
Date: 2025-07-25 05:00:39 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         814 : CrystalPlasticityKalidindiUpdate::validParams()
      17             : {
      18         814 :   InputParameters params = CrystalPlasticityStressUpdateBase::validParams();
      19         814 :   params.addClassDescription("Kalidindi version of homogeneous crystal plasticity.");
      20        1628 :   params.addParam<Real>("r", 1.0, "Latent hardening coefficient");
      21        1628 :   params.addParam<Real>("h", 541.5, "hardening constants");
      22        1628 :   params.addParam<Real>("t_sat", 109.8, "saturated slip system strength");
      23        1628 :   params.addParam<Real>("gss_a", 2.5, "coefficient for hardening");
      24        1628 :   params.addParam<Real>("ao", 0.001, "slip rate coefficient");
      25        1628 :   params.addParam<Real>("xm", 0.1, "exponent for slip rate");
      26        1628 :   params.addParam<Real>("gss_initial", 60.8, "initial lattice friction strength of the material");
      27             : 
      28        1628 :   params.addParam<MaterialPropertyName>(
      29             :       "total_twin_volume_fraction",
      30             :       "Total twin volume fraction, if twinning is considered in the simulation");
      31             : 
      32         814 :   return params;
      33           0 : }
      34             : 
      35         606 : CrystalPlasticityKalidindiUpdate::CrystalPlasticityKalidindiUpdate(
      36         606 :     const InputParameters & parameters)
      37             :   : CrystalPlasticityStressUpdateBase(parameters),
      38             :     // Constitutive values
      39         606 :     _r(getParam<Real>("r")),
      40        1212 :     _h(getParam<Real>("h")),
      41        1212 :     _tau_sat(getParam<Real>("t_sat")),
      42        1212 :     _gss_a(getParam<Real>("gss_a")),
      43        1212 :     _ao(getParam<Real>("ao")),
      44        1212 :     _xm(getParam<Real>("xm")),
      45        1212 :     _gss_initial(getParam<Real>("gss_initial")),
      46             : 
      47             :     // resize vectors used in the consititutive slip hardening
      48         606 :     _hb(_number_slip_systems, 0.0),
      49         606 :     _slip_resistance_increment(_number_slip_systems, 0.0),
      50             : 
      51             :     // resize local caching vectors used for substepping
      52         606 :     _previous_substep_slip_resistance(_number_slip_systems, 0.0),
      53         606 :     _slip_resistance_before_update(_number_slip_systems, 0.0),
      54             : 
      55             :     // Twinning contributions, if used
      56         606 :     _include_twinning_in_Lp(parameters.isParamValid("total_twin_volume_fraction")),
      57        1212 :     _twin_volume_fraction_total(_include_twinning_in_Lp
      58         696 :                                     ? &getMaterialPropertyOld<Real>("total_twin_volume_fraction")
      59         606 :                                     : nullptr)
      60             : {
      61         606 : }
      62             : 
      63             : void
      64       28288 : CrystalPlasticityKalidindiUpdate::initQpStatefulProperties()
      65             : {
      66       28288 :   CrystalPlasticityStressUpdateBase::initQpStatefulProperties();
      67      367744 :   for (const auto i : make_range(_number_slip_systems))
      68             :   {
      69      339456 :     _slip_resistance[_qp][i] = _gss_initial;
      70      339456 :     _slip_increment[_qp][i] = 0.0;
      71             :   }
      72       28288 : }
      73             : 
      74             : void
      75     1258886 : CrystalPlasticityKalidindiUpdate::setInitialConstitutiveVariableValues()
      76             : {
      77             :   // Would also set old dislocation densities here if included in this model
      78     1258886 :   _slip_resistance[_qp] = _slip_resistance_old[_qp];
      79     1258886 :   _previous_substep_slip_resistance = _slip_resistance_old[_qp];
      80     1258886 : }
      81             : 
      82             : void
      83     1294322 : CrystalPlasticityKalidindiUpdate::setSubstepConstitutiveVariableValues()
      84             : {
      85             :   // Would also set substepped dislocation densities here if included in this model
      86     1294322 :   _slip_resistance[_qp] = _previous_substep_slip_resistance;
      87     1294322 : }
      88             : 
      89             : bool
      90     5989780 : CrystalPlasticityKalidindiUpdate::calculateSlipRate()
      91             : {
      92    77534876 :   for (const auto i : make_range(_number_slip_systems))
      93             :   {
      94    71573318 :     _slip_increment[_qp][i] =
      95    71573318 :         _ao * std::pow(std::abs(_tau[_qp][i] / _slip_resistance[_qp][i]), 1.0 / _xm);
      96    71573318 :     if (_tau[_qp][i] < 0.0)
      97    30045198 :       _slip_increment[_qp][i] *= -1.0;
      98             : 
      99    71573318 :     if (std::abs(_slip_increment[_qp][i]) * _substep_dt > _slip_incr_tol)
     100             :     {
     101       28222 :       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     5961558 : CrystalPlasticityKalidindiUpdate::calculateEquivalentSlipIncrement(
     113             :     RankTwoTensor & equivalent_slip_increment)
     114             : {
     115     5961558 :   if (_include_twinning_in_Lp)
     116             :   {
     117    20324148 :     for (const auto i : make_range(_number_slip_systems))
     118    18760752 :       equivalent_slip_increment += (1.0 - (*_twin_volume_fraction_total)[_qp]) *
     119    18760752 :                                    _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     4398162 :     CrystalPlasticityStressUpdateBase::calculateEquivalentSlipIncrement(equivalent_slip_increment);
     123     5961558 : }
     124             : 
     125             : void
     126     5909718 : CrystalPlasticityKalidindiUpdate::calculateConstitutiveSlipDerivative(
     127             :     std::vector<Real> & dslip_dtau)
     128             : {
     129    76826334 :   for (const auto i : make_range(_number_slip_systems))
     130             :   {
     131    70916616 :     if (MooseUtils::absoluteFuzzyEqual(_tau[_qp][i], 0.0))
     132     3769182 :       dslip_dtau[i] = 0.0;
     133             :     else
     134    67147434 :       dslip_dtau[i] = _ao / _xm *
     135    67147434 :                       std::pow(std::abs(_tau[_qp][i] / _slip_resistance[_qp][i]), 1.0 / _xm - 1.0) /
     136             :                       _slip_resistance[_qp][i];
     137             :   }
     138     5909718 : }
     139             : 
     140             : bool
     141     1272916 : CrystalPlasticityKalidindiUpdate::areConstitutiveStateVariablesConverged()
     142             : {
     143     1272916 :   return isConstitutiveStateVariableConverged(_slip_resistance[_qp],
     144     1272916 :                                               _slip_resistance_before_update,
     145     1272916 :                                               _previous_substep_slip_resistance,
     146     1272916 :                                               _resistance_tol);
     147             : }
     148             : 
     149             : void
     150     1266100 : CrystalPlasticityKalidindiUpdate::updateSubstepConstitutiveVariableValues()
     151             : {
     152             :   // Would also set substepped dislocation densities here if included in this model
     153     1266100 :   _previous_substep_slip_resistance = _slip_resistance[_qp];
     154     1266100 : }
     155             : 
     156             : void
     157     1450936 : CrystalPlasticityKalidindiUpdate::cacheStateVariablesBeforeUpdate()
     158             : {
     159     1450936 :   _slip_resistance_before_update = _slip_resistance[_qp];
     160     1450936 : }
     161             : 
     162             : void
     163     1450936 : CrystalPlasticityKalidindiUpdate::calculateStateVariableEvolutionRateComponent()
     164             : {
     165    18862168 :   for (const auto i : make_range(_number_slip_systems))
     166             :   {
     167             :     // Clear out increment from the previous iteration
     168    17411232 :     _slip_resistance_increment[i] = 0.0;
     169             : 
     170    17411232 :     _hb[i] = _h * std::pow(std::abs(1.0 - _slip_resistance[_qp][i] / _tau_sat), _gss_a);
     171    17411232 :     const Real hsign = 1.0 - _slip_resistance[_qp][i] / _tau_sat;
     172    17411232 :     if (hsign < 0.0)
     173           0 :       _hb[i] *= -1.0;
     174             :   }
     175             : 
     176    18862168 :   for (const auto i : make_range(_number_slip_systems))
     177             :   {
     178   226346016 :     for (const auto j : make_range(_number_slip_systems))
     179             :     {
     180             :       unsigned int iplane, jplane;
     181   208934784 :       iplane = i / 3;
     182   208934784 :       jplane = j / 3;
     183             : 
     184   208934784 :       if (iplane == jplane) // self vs. latent hardening
     185    52233696 :         _slip_resistance_increment[i] +=
     186    52233696 :             std::abs(_slip_increment[_qp][j]) * _hb[j]; // q_{ab} = 1.0 for self hardening
     187             :       else
     188   156701088 :         _slip_resistance_increment[i] +=
     189   156701088 :             std::abs(_slip_increment[_qp][j]) * _r * _hb[j]; // latent hardenign
     190             :     }
     191             :   }
     192     1450936 : }
     193             : 
     194             : bool
     195     1450936 : CrystalPlasticityKalidindiUpdate::updateStateVariables()
     196             : {
     197             :   // Now perform the check to see if the slip system should be updated
     198    18862168 :   for (const auto i : make_range(_number_slip_systems))
     199             :   {
     200    17411232 :     _slip_resistance_increment[i] *= _substep_dt;
     201    17411232 :     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    17411232 :       _slip_resistance[_qp][i] =
     205    17411232 :           _previous_substep_slip_resistance[i] + _slip_resistance_increment[i];
     206             : 
     207    17411232 :     if (_slip_resistance[_qp][i] < 0.0)
     208             :       return false;
     209             :   }
     210             :   return true;
     211             : }

Generated by: LCOV version 1.14