www.mooseframework.org
IsotropicPlasticityStressUpdate.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
11 
12 #include "Function.h"
13 #include "ElasticityTensorTools.h"
14 
17 
18 template <bool is_ad>
21 {
23  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  params.addParam<FunctionName>("yield_stress_function",
29  "Yield stress as a function of temperature");
30  params.addParam<Real>("yield_stress", "The point at which plastic strain begins accumulating");
31  params.addParam<FunctionName>("hardening_function",
32  "True stress as a function of plastic strain");
33  params.addParam<Real>("hardening_constant", "Hardening slope");
34  params.addCoupledVar("temperature", 0.0, "Coupled Temperature");
35  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  params.set<std::string>("effective_inelastic_strain_name") = "effective_plastic_strain";
41 
42  return params;
43 }
44 
45 template <bool is_ad>
47  const InputParameters & parameters)
48  : RadialReturnStressUpdateTempl<is_ad>(parameters),
49  _plastic_prepend(this->template getParam<std::string>("plastic_prepend")),
50  _yield_stress_function(this->isParamValid("yield_stress_function")
51  ? &this->getFunction("yield_stress_function")
52  : nullptr),
53  _yield_stress(this->isParamValid("yield_stress") ? this->template getParam<Real>("yield_stress")
54  : 0),
55  _hardening_constant(this->isParamValid("hardening_constant")
56  ? this->template getParam<Real>("hardening_constant")
57  : 0),
58  _hardening_function(this->isParamValid("hardening_function")
59  ? &this->getFunction("hardening_function")
60  : nullptr),
61  _yield_condition(-1.0), // set to a non-physical value to catch uninitalized yield condition
62  _hardening_slope(0.0),
63  _plastic_strain(this->template declareGenericProperty<RankTwoTensor, is_ad>(
64  _base_name + _plastic_prepend + "plastic_strain")),
65  _plastic_strain_old(this->template getMaterialPropertyOld<RankTwoTensor>(
66  _base_name + _plastic_prepend + "plastic_strain")),
67  _hardening_variable(
68  this->template declareGenericProperty<Real, is_ad>(_base_name + "hardening_variable")),
69  _hardening_variable_old(
70  this->template getMaterialPropertyOld<Real>(_base_name + "hardening_variable")),
71  _temperature(this->template coupledGenericValue<is_ad>("temperature"))
72 {
73  if (parameters.isParamSetByUser("yield_stress") && _yield_stress <= 0.0)
74  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  if (_yield_stress_function == nullptr && !this->isParamValid("yield_stress"))
78  mooseError("Either yield_stress or yield_stress_function must be given");
79  if (!parameters.isParamValid("hardening_constant") && !this->isParamValid("hardening_function"))
80  mooseError("Either hardening_constant or hardening_function must be defined");
81 
82  if (parameters.isParamSetByUser("hardening_constant") && this->isParamValid("hardening_function"))
83  mooseError(
84  "Only the hardening_constant or only the hardening_function can be defined but not both");
85 }
86 
87 template <bool is_ad>
88 void
90 {
91  _hardening_variable[_qp] = 0.0;
92  _plastic_strain[_qp].zero();
93 }
94 
95 template <bool is_ad>
96 void
98 {
99  _hardening_variable[_qp] = _hardening_variable_old[_qp];
100  _plastic_strain[_qp] = _plastic_strain_old[_qp];
101 
103 }
104 
105 template <bool is_ad>
106 void
108  const GenericReal<is_ad> & effective_trial_stress,
109  const GenericRankFourTensor<is_ad> & elasticity_tensor)
110 {
113 
114  computeYieldStress(elasticity_tensor);
115 
116  _yield_condition = effective_trial_stress - _hardening_variable_old[_qp] - _yield_stress;
117  _hardening_variable[_qp] = _hardening_variable_old[_qp];
118  _plastic_strain[_qp] = _plastic_strain_old[_qp];
119 }
120 
121 template <bool is_ad>
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  if (_yield_condition > 0.0)
130  {
131  _hardening_slope = computeHardeningDerivative(scalar);
132  _hardening_variable[_qp] = computeHardeningValue(scalar);
133 
134  return (effective_trial_stress - _hardening_variable[_qp] - _yield_stress) /
135  _three_shear_modulus -
136  scalar;
137  }
138 
139  return 0.0;
140 }
141 
142 template <bool is_ad>
145  const GenericReal<is_ad> & /*effective_trial_stress*/, const GenericReal<is_ad> & /*scalar*/)
146 {
147  if (_yield_condition > 0.0)
148  return -1.0 - _hardening_slope / _three_shear_modulus;
149 
150  return 1.0;
151 }
152 
153 template <bool is_ad>
154 void
156 {
157  if (_yield_condition > 0.0)
158  _hardening_variable[_qp] = computeHardeningValue(scalar);
159 }
160 
161 template <bool is_ad>
162 void
164  const GenericRankTwoTensor<is_ad> & plastic_strain_increment)
165 {
166  _plastic_strain[_qp] += plastic_strain_increment;
167 }
168 
169 template <bool is_ad>
172  const GenericReal<is_ad> & scalar)
173 {
174  if (_hardening_function)
175  {
176  const Real strain_old = this->_effective_inelastic_strain_old[_qp];
177  return _hardening_function->value(strain_old + scalar) - _yield_stress;
178  }
179 
180  return _hardening_variable_old[_qp] + _hardening_slope * scalar;
181 }
182 
183 template <bool is_ad>
186  const GenericReal<is_ad> & /*scalar*/)
187 {
188  if (_hardening_function)
189  {
190  const Real strain_old = this->_effective_inelastic_strain_old[_qp];
191  return _hardening_function->timeDerivative(strain_old);
192  }
193 
194  return _hardening_constant;
195 }
196 
197 template <bool is_ad>
198 void
200  const GenericRankFourTensor<is_ad> & /*elasticity_tensor*/)
201 {
202  if (_yield_stress_function)
203  {
204  static const MooseADWrapper<Point, is_ad> p;
205  _yield_stress = _yield_stress_function->value(_temperature[_qp], p);
206 
207  if (_yield_stress <= 0.0)
208  mooseError("In ",
209  this->_name,
210  ": The calculated yield stress (",
211  _yield_stress,
212  ") is less than zero");
213  }
214 }
215 
typename Moose::GenericType< RankFourTensor, is_ad > GenericRankFourTensor
virtual void computeYieldStress(const GenericRankFourTensor< is_ad > &elasticity_tensor)
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
virtual void computeStressFinalize(const GenericRankTwoTensor< is_ad > &plastic_strain_increment) override
Perform any necessary steps to finalize state after return mapping iterations.
static InputParameters validParams()
This class uses the Discrete material in a radial return isotropic plasticity model.
virtual void iterationFinalize(const GenericReal< is_ad > &scalar) override
Finalize internal state variables for a model for a given iteration.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void mooseError(Args &&... args)
virtual void computeStressInitialize(const GenericReal< is_ad > &effective_trial_stress, const GenericRankFourTensor< is_ad > &elasticity_tensor)
Perform any necessary initialization before return mapping iterations.
virtual void computeStressInitialize(const GenericReal< is_ad > &effective_trial_stress, const GenericRankFourTensor< is_ad > &elasticity_tensor) override
Perform any necessary initialization before return mapping iterations.
T & set(const std::string &name, bool quiet_mode=false)
virtual GenericReal< is_ad > computeDerivative(const GenericReal< is_ad > &effective_trial_stress, const GenericReal< is_ad > &scalar) override
Compute the derivative of the residual as a function of the scalar variable.
RadialReturnStressUpdate computes the radial return stress increment for an isotropic elastic-viscopl...
virtual void propagateQpStatefulProperties() override
If updateState is not called during a timestep, this will be.
bool isParamValid(const std::string &name) const
Real elasticity_tensor(unsigned int i, unsigned int j, unsigned int k, unsigned int l)
void addCoupledVar(const std::string &name, const std::string &doc_string)
IsotropicPlasticityStressUpdateTempl(const InputParameters &parameters)
bool isParamSetByUser(const std::string &name) const
typename MooseADWrapperStruct< T, is_ad >::type MooseADWrapper
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual GenericReal< is_ad > computeHardeningValue(const GenericReal< is_ad > &scalar)
void propagateQpStatefulPropertiesRadialReturn()
Propagate the properties pertaining to this intermediate class.
virtual GenericReal< is_ad > computeResidual(const GenericReal< is_ad > &effective_trial_stress, const GenericReal< is_ad > &scalar) override
Compute the residual for a predicted value of the scalar.
void mooseError(Args &&... args) const
typename Moose::GenericType< RankTwoTensor, is_ad > GenericRankTwoTensor
void addClassDescription(const std::string &doc_string)
const InputParameters & parameters() const
typename Moose::GenericType< Real, is_ad > GenericReal
registerMooseObject("SolidMechanicsApp", ADIsotropicPlasticityStressUpdate)
virtual GenericReal< is_ad > computeHardeningDerivative(const GenericReal< is_ad > &scalar)
bool isParamValid(const std::string &name) const