www.mooseframework.org
TwoParameterPlasticityStressUpdate.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 "Conversion.h" // for stringify
13 #include "libmesh/utility.h" // for Utility::pow
14 
17 {
19  params.addClassDescription("Return-map and Jacobian algorithms for (P, Q) plastic models");
20  return params;
21 }
22 
24  const InputParameters & parameters, unsigned num_yf, unsigned num_intnl)
25  : MultiParameterPlasticityStressUpdate(parameters, _num_pq, num_yf, num_intnl),
26  _p_trial(0.0),
27  _q_trial(0.0),
28  _Epp(0.0),
29  _Eqq(0.0),
30  _dgaE_dpt(0.0),
31  _dgaE_dqt(0.0),
32  _dp_dpt(0.0),
33  _dq_dpt(0.0),
34  _dp_dqt(0.0),
35  _dq_dqt(0.0)
36 {
37 }
38 
39 void
40 TwoParameterPlasticityStressUpdate::yieldFunctionValuesV(const std::vector<Real> & stress_params,
41  const std::vector<Real> & intnl,
42  std::vector<Real> & yf) const
43 {
44  const Real p = stress_params[0];
45  const Real q = stress_params[1];
46  yieldFunctionValues(p, q, intnl, yf);
47 }
48 
49 void
51 {
52  setEppEqq(Eijkl, _Epp, _Eqq);
53  _Eij[0][0] = _Epp;
54  _Eij[1][0] = _Eij[0][1] = 0.0;
55  _Eij[1][1] = _Eqq;
56  _En = _Epp;
57  _Cij[0][0] = 1.0 / _Epp;
58  _Cij[1][0] = _Cij[0][1] = 0.0;
59  _Cij[1][1] = 1.0 / _Eqq;
60 }
61 
62 void
63 TwoParameterPlasticityStressUpdate::preReturnMapV(const std::vector<Real> & trial_stress_params,
64  const RankTwoTensor & stress_trial,
65  const std::vector<Real> & intnl_old,
66  const std::vector<Real> & yf,
67  const RankFourTensor & Eijkl)
68 {
69  const Real p_trial = trial_stress_params[0];
70  const Real q_trial = trial_stress_params[1];
71  preReturnMap(p_trial, q_trial, stress_trial, intnl_old, yf, Eijkl);
72 }
73 
74 void
76  Real /*q_trial*/,
77  const RankTwoTensor & /*stress_trial*/,
78  const std::vector<Real> & /*intnl_old*/,
79  const std::vector<Real> & /*yf*/,
80  const RankFourTensor & /*Eijkl*/)
81 {
82  return;
83 }
84 
85 void
87  Real q_trial,
88  const std::vector<Real> & intnl_old,
89  Real & p,
90  Real & q,
91  Real & gaE,
92  std::vector<Real> & intnl) const
93 {
94  p = p_trial;
95  q = q_trial;
96  gaE = 0.0;
97  std::copy(intnl_old.begin(), intnl_old.end(), intnl.begin());
98 }
99 
100 void
101 TwoParameterPlasticityStressUpdate::computeAllQV(const std::vector<Real> & stress_params,
102  const std::vector<Real> & intnl,
103  std::vector<yieldAndFlow> & all_q) const
104 {
105  const Real p = stress_params[0];
106  const Real q = stress_params[1];
107  computeAllQ(p, q, intnl, all_q);
108 }
109 
110 void
111 TwoParameterPlasticityStressUpdate::initializeVarsV(const std::vector<Real> & trial_stress_params,
112  const std::vector<Real> & intnl_old,
113  std::vector<Real> & stress_params,
114  Real & gaE,
115  std::vector<Real> & intnl) const
116 {
117  const Real p_trial = trial_stress_params[0];
118  const Real q_trial = trial_stress_params[1];
119  Real p;
120  Real q;
121  initializeVars(p_trial, q_trial, intnl_old, p, q, gaE, intnl);
122  stress_params[0] = p;
123  stress_params[1] = q;
124 }
125 
126 void
127 TwoParameterPlasticityStressUpdate::setIntnlValuesV(const std::vector<Real> & trial_stress_params,
128  const std::vector<Real> & current_stress_params,
129  const std::vector<Real> & intnl_old,
130  std::vector<Real> & intnl) const
131 {
132  const Real p_trial = trial_stress_params[0];
133  const Real q_trial = trial_stress_params[1];
134  const Real p = current_stress_params[0];
135  const Real q = current_stress_params[1];
136  setIntnlValues(p_trial, q_trial, p, q, intnl_old, intnl);
137 }
138 
139 void
141  const std::vector<Real> & trial_stress_params,
142  const std::vector<Real> & current_stress_params,
143  const std::vector<Real> & intnl_old,
144  std::vector<std::vector<Real>> & dintnl) const
145 {
146  const Real p_trial = trial_stress_params[0];
147  const Real q_trial = trial_stress_params[1];
148  const Real p = current_stress_params[0];
149  const Real q = current_stress_params[1];
150  setIntnlDerivatives(p_trial, q_trial, p, q, intnl_old, dintnl);
151 }
152 
153 void
155  std::vector<Real> & stress_params) const
156 {
157  Real p;
158  Real q;
159  computePQ(stress, p, q);
160  stress_params[0] = p;
161  stress_params[1] = q;
162 }
163 
164 void
166  const RankTwoTensor & stress_trial,
167  const std::vector<Real> & trial_stress_params,
168  const RankTwoTensor & stress,
169  const std::vector<Real> & stress_params,
170  Real gaE,
171  const yieldAndFlow & smoothed_q,
172  const RankFourTensor & Eijkl,
173  bool compute_full_tangent_operator,
174  const std::vector<std::vector<Real>> & dvar_dtrial,
175  RankFourTensor & cto)
176 {
177  const Real p_trial = trial_stress_params[0];
178  const Real q_trial = trial_stress_params[1];
179  const Real p = stress_params[0];
180  const Real q = stress_params[1];
181  _dp_dpt = dvar_dtrial[0][0];
182  _dp_dqt = dvar_dtrial[0][1];
183  _dq_dpt = dvar_dtrial[1][0];
184  _dq_dqt = dvar_dtrial[1][1];
185  _dgaE_dpt = dvar_dtrial[2][0];
186  _dgaE_dqt = dvar_dtrial[2][1];
187  consistentTangentOperator(stress_trial,
188  p_trial,
189  q_trial,
190  stress,
191  p,
192  q,
193  gaE,
194  smoothed_q,
195  Eijkl,
196  compute_full_tangent_operator,
197  cto);
198 }
199 
200 void
202  const RankTwoTensor & stress_trial,
203  Real /*p_trial*/,
204  Real /*q_trial*/,
205  const RankTwoTensor & stress,
206  Real /*p*/,
207  Real /*q*/,
208  Real gaE,
209  const yieldAndFlow & smoothed_q,
210  const RankFourTensor & elasticity_tensor,
211  bool compute_full_tangent_operator,
212  RankFourTensor & cto) const
213 {
214  cto = elasticity_tensor;
215  if (!compute_full_tangent_operator)
216  return;
217 
218  const RankTwoTensor dpdsig = dpdstress(stress);
219  const RankTwoTensor dpdsig_trial = dpdstress(stress_trial);
220  const RankTwoTensor dqdsig = dqdstress(stress);
221  const RankTwoTensor dqdsig_trial = dqdstress(stress_trial);
222 
223  const RankTwoTensor s1 = elasticity_tensor * ((1.0 / _Epp) * (1.0 - _dp_dpt) * dpdsig +
224  (1.0 / _Eqq) * (-_dq_dpt) * dqdsig);
225  const RankTwoTensor s2 = elasticity_tensor * ((1.0 / _Epp) * (-_dp_dqt) * dpdsig +
226  (1.0 / _Eqq) * (1.0 - _dq_dqt) * dqdsig);
227  const RankTwoTensor t1 = elasticity_tensor * dpdsig_trial;
228  const RankTwoTensor t2 = elasticity_tensor * dqdsig_trial;
229 
230  for (unsigned i = 0; i < _tensor_dimensionality; ++i)
231  for (unsigned j = 0; j < _tensor_dimensionality; ++j)
232  for (unsigned k = 0; k < _tensor_dimensionality; ++k)
233  for (unsigned l = 0; l < _tensor_dimensionality; ++l)
234  cto(i, j, k, l) -= s1(i, j) * t1(k, l) + s2(i, j) * t2(k, l);
235 
236  const RankFourTensor d2pdsig2 = d2pdstress2(stress);
237  const RankFourTensor d2qdsig2 = d2qdstress2(stress);
238 
239  const RankFourTensor Tijab = elasticity_tensor * (gaE / _Epp) *
240  (smoothed_q.dg[0] * d2pdsig2 + smoothed_q.dg[1] * d2qdsig2);
241 
243  try
244  {
245  inv = inv.transposeMajor().invSymm();
246  }
247  catch (const MooseException & e)
248  {
249  // Cannot form the inverse, so probably at some degenerate place in stress space.
250  // Just return with the "best estimate" of the cto.
251  mooseWarning("TwoParameterPlasticityStressUpdate: Cannot invert 1+T in consistent tangent "
252  "operator computation at quadpoint ",
253  _qp,
254  " of element ",
255  _current_elem->id());
256  return;
257  }
258 
259  cto = (cto.transposeMajor() * inv).transposeMajor();
260 }
261 
262 void
264  const std::vector<Real> & stress_params,
265  Real gaE,
266  const std::vector<Real> & intnl,
267  const yieldAndFlow & smoothed_q,
268  const RankFourTensor & Eijkl,
269  RankTwoTensor & stress) const
270 {
271  const Real p_ok = stress_params[0];
272  const Real q_ok = stress_params[1];
273  setStressAfterReturn(stress_trial, p_ok, q_ok, gaE, intnl, smoothed_q, Eijkl, stress);
274 }
275 
276 void
278  const RankTwoTensor & /*stress_trial*/,
279  Real gaE,
280  const yieldAndFlow & smoothed_q,
281  const RankFourTensor & /*elasticity_tensor*/,
282  const RankTwoTensor & returned_stress,
283  RankTwoTensor & inelastic_strain_increment) const
284 {
285  inelastic_strain_increment = (gaE / _Epp) * (smoothed_q.dg[0] * dpdstress(returned_stress) +
286  smoothed_q.dg[1] * dqdstress(returned_stress));
287 }
288 
289 std::vector<RankTwoTensor>
291 {
292  std::vector<RankTwoTensor> dsp(_num_pq, RankTwoTensor());
293  dsp[0] = dpdstress(stress);
294  dsp[1] = dqdstress(stress);
295  return dsp;
296 }
297 
298 std::vector<RankFourTensor>
300 {
301  std::vector<RankFourTensor> d2(_num_pq, RankFourTensor());
302  d2[0] = d2pdstress2(stress);
303  d2[1] = d2qdstress2(stress);
304  return d2;
305 }
virtual RankFourTensor d2pdstress2(const RankTwoTensor &stress) const =0
d2(p)/d(stress)/d(stress) Derived classes must override this
virtual std::vector< RankFourTensor > d2stress_param_dstress(const RankTwoTensor &stress) const override
d2(stress_param[i])/d(stress)/d(stress) at given stress
virtual void setStressAfterReturn(const RankTwoTensor &stress_trial, Real p_ok, Real q_ok, Real gaE, const std::vector< Real > &intnl, const yieldAndFlow &smoothed_q, const RankFourTensor &Eijkl, RankTwoTensor &stress) const =0
Sets stress from the admissible parameters.
static constexpr int _num_pq
Number of variables = 2 = (p, q)
virtual void setEppEqq(const RankFourTensor &Eijkl, Real &Epp, Real &Eqq) const =0
Set Epp and Eqq based on the elasticity tensor Derived classes must override this.
Real _dp_dpt
derivative of Variable with respect to trial variable (used in consistent-tangent-operator calculatio...
Real _dq_dpt
derivative of Variable with respect to trial variable (used in consistent-tangent-operator calculatio...
virtual void consistentTangentOperator(const RankTwoTensor &stress_trial, Real p_trial, Real q_trial, const RankTwoTensor &stress, Real p, Real q, Real gaE, const yieldAndFlow &smoothed_q, const RankFourTensor &Eijkl, bool compute_full_tangent_operator, RankFourTensor &cto) const
Calculates the consistent tangent operator.
virtual void setEffectiveElasticity(const RankFourTensor &Eijkl) override
Sets _Eij and _En and _Cij.
virtual void setIntnlValues(Real p_trial, Real q_trial, Real p, Real q, const std::vector< Real > &intnl_old, std::vector< Real > &intnl) const =0
Sets the internal parameters based on the trial values of p and q, their current values, and the old values of the internal parameters.
Struct designed to hold info about a single yield function and its derivatives, as well as the flow d...
void setIntnlValuesV(const std::vector< Real > &trial_stress_params, const std::vector< Real > &current_stress_params, const std::vector< Real > &intnl_old, std::vector< Real > &intnl) const override
Sets the internal parameters based on the trial values of stress_params, their current values...
std::vector< std::vector< Real > > _Cij
_Cij[i, j] * _Eij[j, k] = 1 iff j == k
virtual void computeAllQ(Real p, Real q, const std::vector< Real > &intnl, std::vector< yieldAndFlow > &all_q) const =0
Completely fills all_q with correct values.
Real _dgaE_dqt
derivative of Variable with respect to trial variable (used in consistent-tangent-operator calculatio...
Real _dgaE_dpt
derivative of Variable with respect to trial variable (used in consistent-tangent-operator calculatio...
void mooseWarning(Args &&... args) const
Real elasticity_tensor(unsigned int i, unsigned int j, unsigned int k, unsigned int l)
unsigned int _qp
virtual void initializeVars(Real p_trial, Real q_trial, const std::vector< Real > &intnl_old, Real &p, Real &q, Real &gaE, std::vector< Real > &intnl) const
Sets (p, q, gaE, intnl) at "good guesses" of the solution to the Return-Map algorithm.
TwoParameterPlasticityStressUpdate(const InputParameters &parameters, unsigned num_yf, unsigned num_intnl)
std::vector< std::vector< Real > > _Eij
E[i, j] in the system of equations to be solved.
virtual void yieldFunctionValues(Real p, Real q, const std::vector< Real > &intnl, std::vector< Real > &yf) const =0
Computes the values of the yield functions, given p, q and intnl parameters.
virtual void setIntnlDerivativesV(const std::vector< Real > &trial_stress_params, const std::vector< Real > &current_stress_params, const std::vector< Real > &intnl, std::vector< std::vector< Real >> &dintnl) const override
Sets the derivatives of internal parameters, based on the trial values of stress_params, their current values, and the current values of the internal parameters.
void initializeVarsV(const std::vector< Real > &trial_stress_params, const std::vector< Real > &intnl_old, std::vector< Real > &stress_params, Real &gaE, std::vector< Real > &intnl) const override
Sets (stress_params, intnl) at "good guesses" of the solution to the Return-Map algorithm.
Real _dq_dqt
derivative of Variable with respect to trial variable (used in consistent-tangent-operator calculatio...
void computeAllQV(const std::vector< Real > &stress_params, const std::vector< Real > &intnl, std::vector< yieldAndFlow > &all_q) const override
Completely fills all_q with correct values.
virtual void computePQ(const RankTwoTensor &stress, Real &p, Real &q) const =0
Computes p and q, given stress.
virtual std::vector< RankTwoTensor > dstress_param_dstress(const RankTwoTensor &stress) const override
d(stress_param[i])/d(stress) at given stress
RankFourTensorTempl< T > transposeMajor() const
void consistentTangentOperatorV(const RankTwoTensor &stress_trial, const std::vector< Real > &trial_stress_params, const RankTwoTensor &stress, const std::vector< Real > &stress_params, Real gaE, const yieldAndFlow &smoothed_q, const RankFourTensor &Eijkl, bool compute_full_tangent_operator, const std::vector< std::vector< Real >> &dvar_dtrial, RankFourTensor &cto) override
Calculates the consistent tangent operator.
void yieldFunctionValuesV(const std::vector< Real > &stress_params, const std::vector< Real > &intnl, std::vector< Real > &yf) const override
Computes the values of the yield functions, given stress_params and intnl parameters.
Real _Epp
elasticity tensor in p direction
void setStressAfterReturnV(const RankTwoTensor &stress_trial, const std::vector< Real > &stress_params, Real gaE, const std::vector< Real > &intnl, const yieldAndFlow &smoothed_q, const RankFourTensor &Eijkl, RankTwoTensor &stress) const override
Sets stress from the admissible parameters.
virtual void computeStressParams(const RankTwoTensor &stress, std::vector< Real > &stress_params) const override
Computes stress_params, given stress.
virtual RankTwoTensor dqdstress(const RankTwoTensor &stress) const =0
d(q)/d(stress) Derived classes must override this
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real _Eqq
elasticity tensor in q direction
MultiParameterPlasticityStressUpdate performs the return-map algorithm and associated stress updates ...
void preReturnMapV(const std::vector< Real > &trial_stress_params, const RankTwoTensor &stress_trial, const std::vector< Real > &intnl_old, const std::vector< Real > &yf, const RankFourTensor &Eijkl) override
Derived classes may employ this function to record stuff or do other computations prior to the return...
virtual void preReturnMap(Real p_trial, Real q_trial, const RankTwoTensor &stress_trial, const std::vector< Real > &intnl_old, const std::vector< Real > &yf, const RankFourTensor &Eijkl)
Derived classes may employ this function to record stuff or do other computations prior to the return...
virtual void setIntnlDerivatives(Real p_trial, Real q_trial, Real p, Real q, const std::vector< Real > &intnl, std::vector< std::vector< Real >> &dintnl) const =0
Sets the derivatives of internal parameters, based on the trial values of p and q, their current values, and the old values of the internal parameters.
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
void setInelasticStrainIncrementAfterReturn(const RankTwoTensor &stress_trial, Real gaE, const yieldAndFlow &smoothed_q, const RankFourTensor &elasticity_tensor, const RankTwoTensor &returned_stress, RankTwoTensor &inelastic_strain_increment) const override
Sets inelastic strain increment from the returned configuration This is called after the return-map p...
Real _dp_dqt
derivative of Variable with respect to trial variable (used in consistent-tangent-operator calculatio...
RankFourTensorTempl< T > invSymm() const
virtual RankFourTensor d2qdstress2(const RankTwoTensor &stress) const =0
d2(q)/d(stress)/d(stress) Derived classes must override this
static constexpr unsigned _tensor_dimensionality
Internal dimensionality of tensors (currently this is 3 throughout tensor_mechanics) ...
static const std::string k
Definition: NS.h:124
const Elem *const & _current_elem
virtual RankTwoTensor dpdstress(const RankTwoTensor &stress) const =0
d(p)/d(stress) Derived classes must override this