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 480 : IsotropicPlasticityStressUpdateTempl<is_ad>::validParams() 21 : { 22 480 : InputParameters params = RadialReturnStressUpdateTempl<is_ad>::validParams(); 23 480 : 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 960 : params.addParam<FunctionName>("yield_stress_function", 29 : "Yield stress as a function of temperature"); 30 960 : params.addParam<Real>("yield_stress", "The point at which plastic strain begins accumulating"); 31 960 : params.addParam<FunctionName>("hardening_function", 32 : "True stress as a function of plastic strain"); 33 960 : params.addParam<Real>("hardening_constant", "Hardening slope"); 34 960 : params.addCoupledVar("temperature", 0.0, "Coupled Temperature"); 35 960 : 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 480 : params.set<std::string>("effective_inelastic_strain_name") = "effective_plastic_strain"; 41 : 42 480 : return params; 43 0 : } 44 : 45 : template <bool is_ad> 46 362 : IsotropicPlasticityStressUpdateTempl<is_ad>::IsotropicPlasticityStressUpdateTempl( 47 : const InputParameters & parameters) 48 : : RadialReturnStressUpdateTempl<is_ad>(parameters), 49 362 : _plastic_prepend(this->template getParam<std::string>("plastic_prepend")), 50 362 : _yield_stress_function(this->isParamValid("yield_stress_function") 51 362 : ? &this->getFunction("yield_stress_function") 52 : : nullptr), 53 1444 : _yield_stress(this->isParamValid("yield_stress") ? this->template getParam<Real>("yield_stress") 54 : : 0), 55 362 : _hardening_constant(this->isParamValid("hardening_constant") 56 978 : ? this->template getParam<Real>("hardening_constant") 57 : : 0), 58 362 : _hardening_function(this->isParamValid("hardening_function") 59 416 : ? &this->getFunction("hardening_function") 60 : : nullptr), 61 362 : _yield_condition(-1.0), // set to a non-physical value to catch uninitalized yield condition 62 362 : _hardening_slope(0.0), 63 362 : _plastic_strain(this->template declareGenericProperty<RankTwoTensor, is_ad>( 64 362 : _base_name + _plastic_prepend + "plastic_strain")), 65 724 : _plastic_strain_old(this->template getMaterialPropertyOld<RankTwoTensor>( 66 : _base_name + _plastic_prepend + "plastic_strain")), 67 362 : _hardening_variable( 68 362 : this->template declareGenericProperty<Real, is_ad>(_base_name + "hardening_variable")), 69 362 : _hardening_variable_old( 70 362 : this->template getMaterialPropertyOld<Real>(_base_name + "hardening_variable")), 71 724 : _temperature(this->template coupledGenericValue<is_ad>("temperature")) 72 : { 73 724 : 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 1438 : if (_yield_stress_function == nullptr && !this->isParamValid("yield_stress")) 78 2 : mooseError("Either yield_stress or yield_stress_function must be given"); 79 506 : if (!parameters.isParamValid("hardening_constant") && !this->isParamValid("hardening_function")) 80 2 : mooseError("Either hardening_constant or hardening_function must be defined"); 81 : 82 900 : 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 354 : } 86 : 87 : template <bool is_ad> 88 : void 89 2304 : IsotropicPlasticityStressUpdateTempl<is_ad>::initQpStatefulProperties() 90 : { 91 2304 : _hardening_variable[_qp] = 0.0; 92 2304 : _plastic_strain[_qp].zero(); 93 2304 : } 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 6460852 : 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 6460852 : computeYieldStress(elasticity_tensor); 115 : 116 6460852 : _yield_condition = effective_trial_stress - _hardening_variable_old[_qp] - _yield_stress; 117 6460852 : _hardening_variable[_qp] = _hardening_variable_old[_qp]; 118 6460852 : _plastic_strain[_qp] = _plastic_strain_old[_qp]; 119 6460852 : } 120 : 121 : template <bool is_ad> 122 : GenericReal<is_ad> 123 11569984 : 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 11569984 : if (_yield_condition > 0.0) 130 : { 131 10014024 : _hardening_slope = computeHardeningDerivative(scalar); 132 10014024 : _hardening_variable[_qp] = computeHardeningValue(scalar); 133 : 134 10014024 : return (effective_trial_stress - _hardening_variable[_qp] - _yield_stress) / 135 10014024 : _three_shear_modulus - 136 10014024 : scalar; 137 : } 138 : 139 9368 : return 0.0; 140 : } 141 : 142 : template <bool is_ad> 143 : GenericReal<is_ad> 144 11489424 : IsotropicPlasticityStressUpdateTempl<is_ad>::computeDerivative( 145 : const GenericReal<is_ad> & /*effective_trial_stress*/, const GenericReal<is_ad> & /*scalar*/) 146 : { 147 11489424 : if (_yield_condition > 0.0) 148 9987000 : return -1.0 - _hardening_slope / _three_shear_modulus; 149 : 150 9368 : return 1.0; 151 : } 152 : 153 : template <bool is_ad> 154 : void 155 6452852 : IsotropicPlasticityStressUpdateTempl<is_ad>::iterationFinalize(const GenericReal<is_ad> & scalar) 156 : { 157 6452852 : if (_yield_condition > 0.0) 158 4896892 : _hardening_variable[_qp] = computeHardeningValue(scalar); 159 6452852 : } 160 : 161 : template <bool is_ad> 162 : void 163 6690660 : IsotropicPlasticityStressUpdateTempl<is_ad>::computeStressFinalize( 164 : const GenericRankTwoTensor<is_ad> & plastic_strain_increment) 165 : { 166 6690660 : _plastic_strain[_qp] += plastic_strain_increment; 167 6690660 : } 168 : 169 : template <bool is_ad> 170 : GenericReal<is_ad> 171 14770828 : IsotropicPlasticityStressUpdateTempl<is_ad>::computeHardeningValue( 172 : const GenericReal<is_ad> & scalar) 173 : { 174 14770828 : if (_hardening_function) 175 : { 176 102752 : const Real strain_old = this->_effective_inelastic_strain_old[_qp]; 177 102752 : return _hardening_function->value(strain_old + scalar) - _yield_stress; 178 : } 179 : 180 14668076 : return _hardening_variable_old[_qp] + _hardening_slope * scalar; 181 : } 182 : 183 : template <bool is_ad> 184 : GenericReal<is_ad> 185 9920632 : IsotropicPlasticityStressUpdateTempl<is_ad>::computeHardeningDerivative( 186 : const GenericReal<is_ad> & /*scalar*/) 187 : { 188 9920632 : if (_hardening_function) 189 : { 190 67648 : const Real strain_old = this->_effective_inelastic_strain_old[_qp]; 191 67648 : return _hardening_function->timeDerivative(strain_old); 192 : } 193 : 194 9852984 : return _hardening_constant; 195 : } 196 : 197 : template <bool is_ad> 198 : void 199 6460852 : IsotropicPlasticityStressUpdateTempl<is_ad>::computeYieldStress( 200 : const GenericRankFourTensor<is_ad> & /*elasticity_tensor*/) 201 : { 202 6460852 : 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 6460852 : } 215 : 216 : template class IsotropicPlasticityStressUpdateTempl<false>; 217 : template class IsotropicPlasticityStressUpdateTempl<true>;