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 "IsotropicPlasticityStressUpdate.h" 11 : 12 : #include "Function.h" 13 : #include "ElasticityTensorTools.h" 14 : 15 : registerMooseObject("SolidMechanicsApp", ADIsotropicPlasticityStressUpdate); 16 : registerMooseObject("SolidMechanicsApp", IsotropicPlasticityStressUpdate); 17 : 18 : template <bool is_ad> 19 : InputParameters 20 556 : IsotropicPlasticityStressUpdateTempl<is_ad>::validParams() 21 : { 22 556 : InputParameters params = RadialReturnStressUpdateTempl<is_ad>::validParams(); 23 556 : params.addClassDescription("This class uses the discrete material in a radial return isotropic " 24 : "plasticity model. This class is one of the basic radial return " 25 : "constitutive models, yet it can be used in conjunction with other " 26 : "creep and plasticity materials for more complex simulations."); 27 : // Linear strain hardening parameters 28 1112 : params.addParam<FunctionName>("yield_stress_function", 29 : "Yield stress as a function of temperature"); 30 1112 : params.addParam<Real>("yield_stress", "The point at which plastic strain begins accumulating"); 31 1112 : params.addParam<FunctionName>("hardening_function", 32 : "True stress as a function of plastic strain"); 33 1112 : params.addParam<Real>("hardening_constant", "Hardening slope"); 34 1112 : params.addCoupledVar("temperature", 0.0, "Coupled Temperature"); 35 1112 : params.addDeprecatedParam<std::string>( 36 : "plastic_prepend", 37 : "", 38 : "String that is prepended to the plastic_strain Material Property", 39 : "This has been replaced by the 'base_name' parameter"); 40 556 : params.set<std::string>("effective_inelastic_strain_name") = "effective_plastic_strain"; 41 : 42 556 : return params; 43 0 : } 44 : 45 : template <bool is_ad> 46 419 : IsotropicPlasticityStressUpdateTempl<is_ad>::IsotropicPlasticityStressUpdateTempl( 47 : const InputParameters & parameters) 48 : : RadialReturnStressUpdateTempl<is_ad>(parameters), 49 419 : _plastic_prepend(this->template getParam<std::string>("plastic_prepend")), 50 419 : _yield_stress_function(this->isParamValid("yield_stress_function") 51 419 : ? &this->getFunction("yield_stress_function") 52 : : nullptr), 53 1672 : _yield_stress(this->isParamValid("yield_stress") ? this->template getParam<Real>("yield_stress") 54 : : 0), 55 419 : _hardening_constant(this->isParamValid("hardening_constant") 56 1137 : ? this->template getParam<Real>("hardening_constant") 57 : : 0), 58 419 : _hardening_function(this->isParamValid("hardening_function") 59 479 : ? &this->getFunction("hardening_function") 60 : : nullptr), 61 419 : _yield_condition(-1.0), // set to a non-physical value to catch uninitalized yield condition 62 419 : _hardening_slope(0.0), 63 419 : _plastic_strain(this->template declareGenericProperty<RankTwoTensor, is_ad>( 64 419 : _base_name + _plastic_prepend + "plastic_strain")), 65 838 : _plastic_strain_old(this->template getMaterialPropertyOld<RankTwoTensor>( 66 : _base_name + _plastic_prepend + "plastic_strain")), 67 419 : _hardening_variable( 68 419 : this->template declareGenericProperty<Real, is_ad>(_base_name + "hardening_variable")), 69 419 : _hardening_variable_old( 70 419 : this->template getMaterialPropertyOld<Real>(_base_name + "hardening_variable")), 71 838 : _temperature(this->template coupledGenericValue<is_ad>("temperature")) 72 : { 73 838 : if (parameters.isParamSetByUser("yield_stress") && _yield_stress <= 0.0) 74 2 : mooseError("Yield stress must be greater than zero"); 75 : 76 : // Both of these parameters are given default values by derived classes, which makes them valid 77 1666 : if (_yield_stress_function == nullptr && !this->isParamValid("yield_stress")) 78 2 : mooseError("Either yield_stress or yield_stress_function must be given"); 79 581 : if (!parameters.isParamValid("hardening_constant") && !this->isParamValid("hardening_function")) 80 2 : mooseError("Either hardening_constant or hardening_function must be defined"); 81 : 82 1047 : if (parameters.isParamSetByUser("hardening_constant") && this->isParamValid("hardening_function")) 83 2 : mooseError( 84 : "Only the hardening_constant or only the hardening_function can be defined but not both"); 85 411 : } 86 : 87 : template <bool is_ad> 88 : void 89 2880 : IsotropicPlasticityStressUpdateTempl<is_ad>::initQpStatefulProperties() 90 : { 91 2880 : _hardening_variable[_qp] = 0.0; 92 2880 : _plastic_strain[_qp].zero(); 93 2880 : } 94 : 95 : template <bool is_ad> 96 : void 97 0 : IsotropicPlasticityStressUpdateTempl<is_ad>::propagateQpStatefulProperties() 98 : { 99 0 : _hardening_variable[_qp] = _hardening_variable_old[_qp]; 100 0 : _plastic_strain[_qp] = _plastic_strain_old[_qp]; 101 : 102 0 : RadialReturnStressUpdateTempl<is_ad>::propagateQpStatefulPropertiesRadialReturn(); 103 0 : } 104 : 105 : template <bool is_ad> 106 : void 107 8061085 : IsotropicPlasticityStressUpdateTempl<is_ad>::computeStressInitialize( 108 : const GenericReal<is_ad> & effective_trial_stress, 109 : const GenericRankFourTensor<is_ad> & elasticity_tensor) 110 : { 111 0 : RadialReturnStressUpdateTempl<is_ad>::computeStressInitialize(effective_trial_stress, 112 : elasticity_tensor); 113 : 114 8061085 : computeYieldStress(elasticity_tensor); 115 : 116 8061085 : _yield_condition = effective_trial_stress - _hardening_variable_old[_qp] - _yield_stress; 117 8061085 : _hardening_variable[_qp] = _hardening_variable_old[_qp]; 118 8061085 : _plastic_strain[_qp] = _plastic_strain_old[_qp]; 119 8061085 : } 120 : 121 : template <bool is_ad> 122 : GenericReal<is_ad> 123 14464228 : IsotropicPlasticityStressUpdateTempl<is_ad>::computeResidual( 124 : const GenericReal<is_ad> & effective_trial_stress, const GenericReal<is_ad> & scalar) 125 : { 126 : mooseAssert(_yield_condition != -1.0, 127 : "the yield stress was not updated by computeStressInitialize"); 128 : 129 14464228 : if (_yield_condition > 0.0) 130 : { 131 12550342 : _hardening_slope = computeHardeningDerivative(scalar); 132 12550342 : _hardening_variable[_qp] = computeHardeningValue(scalar); 133 : 134 12550342 : return (effective_trial_stress - _hardening_variable[_qp] - _yield_stress) / 135 12550342 : _three_shear_modulus - 136 12550342 : scalar; 137 : } 138 : 139 11710 : return 0.0; 140 : } 141 : 142 : template <bool is_ad> 143 : GenericReal<is_ad> 144 14363316 : IsotropicPlasticityStressUpdateTempl<is_ad>::computeDerivative( 145 : const GenericReal<is_ad> & /*effective_trial_stress*/, const GenericReal<is_ad> & /*scalar*/) 146 : { 147 14363316 : if (_yield_condition > 0.0) 148 12516606 : return -1.0 - _hardening_slope / _three_shear_modulus; 149 : 150 11710 : return 1.0; 151 : } 152 : 153 : template <bool is_ad> 154 : void 155 8051121 : IsotropicPlasticityStressUpdateTempl<is_ad>::iterationFinalize(const GenericReal<is_ad> & scalar) 156 : { 157 8051121 : if (_yield_condition > 0.0) 158 6137235 : _hardening_variable[_qp] = computeHardeningValue(scalar); 159 8051121 : } 160 : 161 : template <bool is_ad> 162 : void 163 8349089 : IsotropicPlasticityStressUpdateTempl<is_ad>::computeStressFinalize( 164 : const GenericRankTwoTensor<is_ad> & plastic_strain_increment) 165 : { 166 8349089 : _plastic_strain[_qp] += plastic_strain_increment; 167 8349089 : } 168 : 169 : template <bool is_ad> 170 : GenericReal<is_ad> 171 18511699 : IsotropicPlasticityStressUpdateTempl<is_ad>::computeHardeningValue( 172 : const GenericReal<is_ad> & scalar) 173 : { 174 18511699 : if (_hardening_function) 175 : { 176 128824 : const Real strain_old = this->_effective_inelastic_strain_old[_qp]; 177 128824 : return _hardening_function->value(strain_old + scalar) - _yield_stress; 178 : } 179 : 180 18382875 : return _hardening_variable_old[_qp] + _hardening_slope * scalar; 181 : } 182 : 183 : template <bool is_ad> 184 : GenericReal<is_ad> 185 12433090 : IsotropicPlasticityStressUpdateTempl<is_ad>::computeHardeningDerivative( 186 : const GenericReal<is_ad> & /*scalar*/) 187 : { 188 12433090 : if (_hardening_function) 189 : { 190 84816 : const Real strain_old = this->_effective_inelastic_strain_old[_qp]; 191 84816 : return _hardening_function->timeDerivative(strain_old); 192 : } 193 : 194 12348274 : return _hardening_constant; 195 : } 196 : 197 : template <bool is_ad> 198 : void 199 8061085 : IsotropicPlasticityStressUpdateTempl<is_ad>::computeYieldStress( 200 : const GenericRankFourTensor<is_ad> & /*elasticity_tensor*/) 201 : { 202 8061085 : if (_yield_stress_function) 203 : { 204 0 : static const Moose::GenericType<Point, is_ad> p; 205 0 : _yield_stress = _yield_stress_function->value(_temperature[_qp], p); 206 : 207 0 : if (_yield_stress <= 0.0) 208 0 : mooseError("In ", 209 0 : this->_name, 210 : ": The calculated yield stress (", 211 0 : _yield_stress, 212 : ") is less than zero"); 213 : } 214 8061085 : } 215 : 216 : template class IsotropicPlasticityStressUpdateTempl<false>; 217 : template class IsotropicPlasticityStressUpdateTempl<true>;