LCOV - code coverage report
Current view: top level - src/userobjects - CrystalPlasticityStateVarRateComponentVoce.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 95 112 84.8 %
Date: 2025-07-25 05:00:39 Functions: 7 7 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 "CrystalPlasticityStateVarRateComponentVoce.h"
      11             : #include "MooseError.h"
      12             : 
      13             : registerMooseObject("SolidMechanicsApp", CrystalPlasticityStateVarRateComponentVoce);
      14             : 
      15             : InputParameters
      16          12 : CrystalPlasticityStateVarRateComponentVoce::validParams()
      17             : {
      18             : 
      19          12 :   InputParameters params = CrystalPlasticityStateVarRateComponent::validParams();
      20          24 :   params.addParam<std::string>(
      21             :       "uo_slip_rate_name",
      22             :       "Name of slip rate property: Same as slip rate user object specified in input file.");
      23          24 :   params.addParam<std::string>("uo_state_var_name",
      24             :                                "Name of state variable property: Same as "
      25             :                                "state variable user object specified in input "
      26             :                                "file.");
      27          24 :   params.addParam<MooseEnum>(
      28             :       "crystal_lattice_type",
      29          24 :       CrystalPlasticityStateVarRateComponentVoce::crystalLatticeTypeOptions(),
      30             :       "Type of crystal lattyce structure output");
      31          24 :   params.addParam<std::vector<unsigned int>>("groups",
      32             :                                              {},
      33             :                                              "To group the initial values on different "
      34             :                                              "slip systems 'format: [start end)', i.e.'0 "
      35             :                                              "12 24 48' groups 0-11, 12-23 and 24-48 ");
      36          24 :   params.addParam<std::vector<Real>>("h0_group_values",
      37             :                                      "h0 hardening constant for each group "
      38             :                                      " i.e. '0.0 1.0 2.0' means 0-11 = 0.0, "
      39             :                                      "12-23 = 1.0 and 24-48 = 2.0 ");
      40          24 :   params.addParam<std::vector<Real>>("tau0_group_values",
      41             :                                      "The initial critical resolved shear stress"
      42             :                                      "corresponding to each group"
      43             :                                      " i.e. '100.0 110.0 120.0' means 0-11 = 100.0, "
      44             :                                      "12-23 = 110.0 and 24-48 = 120.0 ");
      45          24 :   params.addParam<std::vector<Real>>("tauSat_group_values",
      46             :                                      "The saturation resolved shear stress"
      47             :                                      "corresponding to each group"
      48             :                                      " i.e. '150.0 170.0 180.0' means 0-11 = 150.0, "
      49             :                                      "12-23 = 170.0 and 24-48 = 180.0 ");
      50          24 :   params.addParam<std::vector<Real>>("hardeningExponent_group_values",
      51             :                                      "The hardening exponent m"
      52             :                                      "corresponding to each group"
      53             :                                      " i.e. '1.0 2.0 3.0' means 0-11 = 1.0, "
      54             :                                      "12-23 = 2.0 and 24-48 = 3.0 ");
      55          24 :   params.addParam<std::vector<Real>>("selfHardening_group_values",
      56             :                                      "The self hardening coefficient q_aa"
      57             :                                      "corresponding to each group"
      58             :                                      " i.e. '1.0 2.0 3.0' means 0-11 = 1.0, "
      59             :                                      "12-23 = 2.0 and 24-48 = 3.0 "
      60             :                                      " usually these are all 1.");
      61          24 :   params.addParam<std::vector<Real>>("coplanarHardening_group_values",
      62             :                                      "The coplanar latent hardening coefficient q_ab"
      63             :                                      "corresponding to each group"
      64             :                                      " i.e. '1.0 2.0 3.0' means 0-11 = 1.0, "
      65             :                                      "12-23 = 2.0 and 24-48 = 3.0 ");
      66          24 :   params.addParam<std::vector<Real>>("GroupGroup_Hardening_group_values",
      67             :                                      "The group-to-group latent hardening coefficient q_ab"
      68             :                                      "This is a NxN vector"
      69             :                                      " i.e. '1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0' "
      70             :                                      "means non-coplanar slip systems in gr_11,22,33= "
      71             :                                      "1.0, 5.0 and 9.0 respectively."
      72             :                                      "latent hardening between for gr_12,13 = 2.0 3.0"
      73             :                                      " respectively");
      74          12 :   params.addClassDescription("Phenomenological Voce constitutive model state variable evolution "
      75             :                              "rate component base class.");
      76          12 :   return params;
      77           0 : }
      78             : 
      79           6 : CrystalPlasticityStateVarRateComponentVoce::CrystalPlasticityStateVarRateComponentVoce(
      80           6 :     const InputParameters & parameters)
      81             :   : CrystalPlasticityStateVarRateComponent(parameters),
      82           6 :     _mat_prop_slip_rate(
      83           6 :         getMaterialProperty<std::vector<Real>>(parameters.get<std::string>("uo_slip_rate_name"))),
      84           6 :     _mat_prop_state_var(
      85           6 :         getMaterialProperty<std::vector<Real>>(parameters.get<std::string>("uo_state_var_name"))),
      86          12 :     _crystal_lattice_type(getParam<MooseEnum>("crystal_lattice_type")),
      87          12 :     _groups(getParam<std::vector<unsigned int>>("groups")),
      88          12 :     _h0_group_values(getParam<std::vector<Real>>("h0_group_values")),
      89          12 :     _tau0_group_values(getParam<std::vector<Real>>("tau0_group_values")),
      90          12 :     _tauSat_group_values(getParam<std::vector<Real>>("tauSat_group_values")),
      91          12 :     _hardeningExponent_group_values(getParam<std::vector<Real>>("hardeningExponent_group_values")),
      92          12 :     _selfHardening_group_values(getParam<std::vector<Real>>("selfHardening_group_values")),
      93          12 :     _coplanarHardening_group_values(getParam<std::vector<Real>>("coplanarHardening_group_values")),
      94          18 :     _GroupGroup_Hardening_group_values(
      95             :         getParam<std::vector<Real>>("GroupGroup_Hardening_group_values")),
      96          12 :     _n_groups(_groups.size())
      97             : {
      98             :   // perform input checks
      99           6 :   if (_n_groups < 2)
     100           0 :     paramError("groups",
     101             :                "the number of slip system groups provided is not "
     102             :                "correct. At least two values are expected");
     103             : 
     104             :   // check the size of all the user provided parameters
     105           6 :   if (_h0_group_values.size() != _n_groups - 1)
     106           0 :     paramError("h0_group_values",
     107             :                "the number of supplied parameters does not"
     108             :                " match the number of ip system groups");
     109             : 
     110           6 :   if (_tau0_group_values.size() != _n_groups - 1)
     111           0 :     paramError("tau0_group_values",
     112             :                "the number of supplied parameters does "
     113             :                "not match the number of slip system groups");
     114             : 
     115           6 :   if (_tauSat_group_values.size() != _n_groups - 1)
     116           0 :     paramError("tauSat_group_values",
     117             :                "the number of supplied parameters does "
     118             :                "not match the number of slip system groups");
     119             : 
     120           6 :   if (_hardeningExponent_group_values.size() != _n_groups - 1)
     121           0 :     paramError("hardeningExponent_group_values",
     122             :                "the number of supplied "
     123             :                "parameters does not match the number of slip system groups");
     124             : 
     125           6 :   if (_selfHardening_group_values.size() != _n_groups - 1)
     126           0 :     paramError("selfHardening_group_values",
     127             :                "the number of supplied parameters "
     128             :                "does not match the number of slip system groups");
     129             : 
     130           6 :   if (_coplanarHardening_group_values.size() != _n_groups - 1)
     131           0 :     paramError("coplanarHardening_group_values",
     132             :                "the number of supplied "
     133             :                "parameters does not match the number of slip system groups");
     134             : 
     135           6 :   if (_GroupGroup_Hardening_group_values.size() != (_n_groups - 1) * (_n_groups - 1))
     136           0 :     paramError("GroupGroup_Hardening_group_values",
     137             :                "the number of supplied "
     138             :                "parameters does not match the number of slip system groups");
     139             : 
     140             :   // initialize useful variables;
     141           6 :   initSlipSystemPlaneID(_slipSystem_PlaneID);
     142           6 :   initSlipSystemGroupID(_slipSystem_GroupID);
     143           6 : }
     144             : 
     145             : bool
     146       15744 : CrystalPlasticityStateVarRateComponentVoce::calcStateVariableEvolutionRateComponent(
     147             :     unsigned int qp, std::vector<Real> & val) const
     148             : {
     149       15744 :   val.assign(_variable_size, 0.0);
     150             : 
     151             :   unsigned int group_i;
     152             :   Real h0;
     153             :   Real tau_0;
     154             :   Real tau_sat;
     155             :   Real hardening_exponenet;
     156             :   Real delta_tau;
     157             : 
     158       15744 :   DenseVector<Real> hb(_variable_size);
     159             : 
     160      771456 :   for (unsigned int i = 0; i < _variable_size; ++i)
     161             :   {
     162      755712 :     group_i = _slipSystem_GroupID[i];
     163      755712 :     h0 = _h0_group_values[group_i];
     164      755712 :     tau_0 = _tau0_group_values[group_i];
     165      755712 :     tau_sat = _tauSat_group_values[group_i];
     166      755712 :     hardening_exponenet = _hardeningExponent_group_values[group_i];
     167             : 
     168      755712 :     delta_tau = tau_sat - tau_0;
     169             : 
     170      755712 :     hb(i) = h0 *
     171      755712 :             std::pow(std::abs(1.0 - (_mat_prop_state_var[qp][i] - tau_0) / delta_tau),
     172      755712 :                      hardening_exponenet) *
     173      755712 :             std::copysign(1.0, 1.0 - (_mat_prop_state_var[qp][i] - tau_0) / delta_tau);
     174             :   }
     175             : 
     176      771456 :   for (unsigned int i = 0; i < _variable_size; ++i)
     177    37029888 :     for (unsigned int j = 0; j < _variable_size; ++j)
     178             :     {
     179    36274176 :       const Real q_ab = getHardeningCoefficient(i, j);
     180    36274176 :       val[i] += std::abs(_mat_prop_slip_rate[qp][j]) * q_ab * hb(j);
     181             :     }
     182             : 
     183       15744 :   return true;
     184             : }
     185             : 
     186             : MooseEnum
     187          12 : CrystalPlasticityStateVarRateComponentVoce::crystalLatticeTypeOptions()
     188             : {
     189          24 :   return MooseEnum("FCC BCC", "FCC");
     190             : }
     191             : 
     192             : void
     193           6 : CrystalPlasticityStateVarRateComponentVoce::initSlipSystemPlaneID(
     194             :     std::vector<unsigned int> & _slipSystem_PlaneID) const
     195             : {
     196           6 :   _slipSystem_PlaneID.assign(_variable_size, 0);
     197             : 
     198         294 :   for (unsigned int slipSystemIndex = 0; slipSystemIndex < _variable_size; ++slipSystemIndex)
     199         288 :     switch (_crystal_lattice_type)
     200             :     {
     201           0 :       case 0: // FCC
     202           0 :         if (slipSystemIndex < 12)
     203           0 :           _slipSystem_PlaneID[slipSystemIndex] = slipSystemIndex / 3;
     204             :         else
     205           0 :           mooseError("FCC with more than 12 slip planes is not implemented ");
     206             : 
     207           0 :         break;
     208             : 
     209         288 :       case 1: // BCC
     210         288 :         if (slipSystemIndex < 12)
     211          72 :           _slipSystem_PlaneID[slipSystemIndex] = slipSystemIndex / 2;
     212             : 
     213         216 :         else if (slipSystemIndex >= 12 && slipSystemIndex < 48)
     214         216 :           _slipSystem_PlaneID[slipSystemIndex] = (slipSystemIndex - 6);
     215             : 
     216             :         else
     217           0 :           mooseError("BCC with more than 48 slip systems is not implemented ");
     218             : 
     219             :         break;
     220             : 
     221           0 :       default:
     222           0 :         mooseError("VoceHardeningError: Pass valid crustal_structure_type ");
     223             :     }
     224           6 : }
     225             : 
     226             : void
     227           6 : CrystalPlasticityStateVarRateComponentVoce::initSlipSystemGroupID(
     228             :     std::vector<unsigned int> & _slipSystem_GroupID) const
     229             : {
     230           6 :   _slipSystem_GroupID.assign(_variable_size, 0);
     231             : 
     232         294 :   for (unsigned int slipSystemIndex = 0; slipSystemIndex < _variable_size; ++slipSystemIndex)
     233         648 :     for (unsigned int i = 0; i < _n_groups - 1; ++i)
     234         648 :       if (slipSystemIndex >= _groups[i] && slipSystemIndex < _groups[i + 1])
     235             :       {
     236         288 :         _slipSystem_GroupID[slipSystemIndex] = i;
     237         288 :         break;
     238             :       }
     239           6 : }
     240             : 
     241             : Real
     242    36274176 : CrystalPlasticityStateVarRateComponentVoce::getHardeningCoefficient(
     243             :     unsigned int slipSystemIndex_i, unsigned int slipSystemIndex_j) const
     244             : {
     245             :   // collect slip system plane and group
     246    36274176 :   const unsigned int group_i = _slipSystem_GroupID[slipSystemIndex_i];
     247    36274176 :   const unsigned int group_j = _slipSystem_GroupID[slipSystemIndex_j];
     248    36274176 :   const unsigned int plane_i = _slipSystem_PlaneID[slipSystemIndex_i];
     249    36274176 :   const unsigned int plane_j = _slipSystem_PlaneID[slipSystemIndex_j];
     250             : 
     251             :   // create check for clarity
     252             :   const bool same_slipSystem = slipSystemIndex_i == slipSystemIndex_j;
     253             :   const bool same_group = group_i == group_j;
     254             :   const bool same_plane = plane_i == plane_j;
     255             : 
     256             :   // retrieve appropriate coefficient
     257             :   Real q_ab;
     258    36274176 :   if (same_slipSystem)
     259      755712 :     q_ab = _selfHardening_group_values[group_i];
     260    35518464 :   else if (same_plane)
     261      188928 :     q_ab = _coplanarHardening_group_values[group_i];
     262    35329536 :   else if (same_group) // here for debugging purposes this if could be removed
     263    12658176 :     q_ab = _GroupGroup_Hardening_group_values[group_i * (_n_groups - 1) + group_i];
     264             :   else if (!same_group)
     265    22671360 :     q_ab = _GroupGroup_Hardening_group_values[group_i * (_n_groups - 1) + group_j];
     266             :   else // here for debugging purposes
     267             :     mooseError("VoceHardeningError:getHardeningCoefficient: case not listed, abort ");
     268             : 
     269    36274176 :   return q_ab;
     270             : }

Generated by: LCOV version 1.14