https://mooseframework.inl.gov
Loading...
Searching...
No Matches
TwoParameterPlasticityStressUpdate.C
Go to the documentation of this file.
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
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 _dsp_scratch(_num_pq),
37 _dsp_trial_scratch(_num_pq),
38 _d2sp_scratch(_num_pq)
39{
40}
41
42void
43TwoParameterPlasticityStressUpdate::yieldFunctionValuesV(const std::vector<Real> & stress_params,
44 const std::vector<Real> & intnl,
45 std::vector<Real> & yf) const
46{
47 const Real p = stress_params[0];
48 const Real q = stress_params[1];
49 yieldFunctionValues(p, q, intnl, yf);
50}
51
52void
54{
55 setEppEqq(Eijkl, _Epp, _Eqq);
56 _Eij[0][0] = _Epp;
57 _Eij[1][0] = _Eij[0][1] = 0.0;
58 _Eij[1][1] = _Eqq;
59 _En = _Epp;
60 _Cij[0][0] = 1.0 / _Epp;
61 _Cij[1][0] = _Cij[0][1] = 0.0;
62 _Cij[1][1] = 1.0 / _Eqq;
63}
64
65void
66TwoParameterPlasticityStressUpdate::preReturnMapV(const std::vector<Real> & trial_stress_params,
67 const RankTwoTensor & stress_trial,
68 const std::vector<Real> & intnl_old,
69 const std::vector<Real> & yf,
70 const RankFourTensor & Eijkl)
71{
72 const Real p_trial = trial_stress_params[0];
73 const Real q_trial = trial_stress_params[1];
74 preReturnMap(p_trial, q_trial, stress_trial, intnl_old, yf, Eijkl);
75}
76
77void
79 Real /*q_trial*/,
80 const RankTwoTensor & /*stress_trial*/,
81 const std::vector<Real> & /*intnl_old*/,
82 const std::vector<Real> & /*yf*/,
83 const RankFourTensor & /*Eijkl*/)
84{
85 return;
86}
87
88void
90 Real q_trial,
91 const std::vector<Real> & intnl_old,
92 Real & p,
93 Real & q,
94 Real & gaE,
95 std::vector<Real> & intnl) const
96{
97 p = p_trial;
98 q = q_trial;
99 gaE = 0.0;
100 std::copy(intnl_old.begin(), intnl_old.end(), intnl.begin());
101}
102
103void
104TwoParameterPlasticityStressUpdate::computeAllQV(const std::vector<Real> & stress_params,
105 const std::vector<Real> & intnl,
106 std::vector<yieldAndFlow> & all_q) const
107{
108 const Real p = stress_params[0];
109 const Real q = stress_params[1];
110 computeAllQ(p, q, intnl, all_q);
111}
112
113void
114TwoParameterPlasticityStressUpdate::initializeVarsV(const std::vector<Real> & trial_stress_params,
115 const std::vector<Real> & intnl_old,
116 std::vector<Real> & stress_params,
117 Real & gaE,
118 std::vector<Real> & intnl) const
119{
120 const Real p_trial = trial_stress_params[0];
121 const Real q_trial = trial_stress_params[1];
122 Real p;
123 Real q;
124 initializeVars(p_trial, q_trial, intnl_old, p, q, gaE, intnl);
125 stress_params[0] = p;
126 stress_params[1] = q;
127}
128
129void
130TwoParameterPlasticityStressUpdate::setIntnlValuesV(const std::vector<Real> & trial_stress_params,
131 const std::vector<Real> & current_stress_params,
132 const std::vector<Real> & intnl_old,
133 std::vector<Real> & intnl) const
134{
135 const Real p_trial = trial_stress_params[0];
136 const Real q_trial = trial_stress_params[1];
137 const Real p = current_stress_params[0];
138 const Real q = current_stress_params[1];
139 setIntnlValues(p_trial, q_trial, p, q, intnl_old, intnl);
140}
141
142void
144 const std::vector<Real> & trial_stress_params,
145 const std::vector<Real> & current_stress_params,
146 const std::vector<Real> & intnl_old,
147 std::vector<std::vector<Real>> & dintnl) const
148{
149 const Real p_trial = trial_stress_params[0];
150 const Real q_trial = trial_stress_params[1];
151 const Real p = current_stress_params[0];
152 const Real q = current_stress_params[1];
153 setIntnlDerivatives(p_trial, q_trial, p, q, intnl_old, dintnl);
154}
155
156void
158 std::vector<Real> & stress_params) const
159{
160 Real p;
161 Real q;
162 computePQ(stress, p, q);
163 stress_params[0] = p;
164 stress_params[1] = q;
165}
166
167void
169 const RankTwoTensor & stress_trial,
170 const std::vector<Real> & trial_stress_params,
171 const RankTwoTensor & stress,
172 const std::vector<Real> & stress_params,
173 Real gaE,
174 const yieldAndFlow & smoothed_q,
175 const RankFourTensor & Eijkl,
176 bool compute_full_tangent_operator,
177 const std::vector<std::vector<Real>> & dvar_dtrial,
178 RankFourTensor & cto)
179{
180 const Real p_trial = trial_stress_params[0];
181 const Real q_trial = trial_stress_params[1];
182 const Real p = stress_params[0];
183 const Real q = stress_params[1];
184 _dp_dpt = dvar_dtrial[0][0];
185 _dp_dqt = dvar_dtrial[0][1];
186 _dq_dpt = dvar_dtrial[1][0];
187 _dq_dqt = dvar_dtrial[1][1];
188 _dgaE_dpt = dvar_dtrial[2][0];
189 _dgaE_dqt = dvar_dtrial[2][1];
190 consistentTangentOperator(stress_trial,
191 p_trial,
192 q_trial,
193 stress,
194 p,
195 q,
196 gaE,
197 smoothed_q,
198 Eijkl,
199 compute_full_tangent_operator,
200 cto);
201}
202
203void
205 const RankTwoTensor & stress_trial,
206 Real /*p_trial*/,
207 Real /*q_trial*/,
208 const RankTwoTensor & stress,
209 Real /*p*/,
210 Real /*q*/,
211 Real gaE,
212 const yieldAndFlow & smoothed_q,
213 const RankFourTensor & elasticity_tensor,
214 bool compute_full_tangent_operator,
215 RankFourTensor & cto) const
216{
217 cto = elasticity_tensor;
218 if (!compute_full_tangent_operator)
219 return;
220
223
224 const RankTwoTensor s1 = elasticity_tensor * ((1.0 / _Epp) * (1.0 - _dp_dpt) * _dsp_scratch[0] +
225 (1.0 / _Eqq) * (-_dq_dpt) * _dsp_scratch[1]);
226 const RankTwoTensor s2 = elasticity_tensor * ((1.0 / _Epp) * (-_dp_dqt) * _dsp_scratch[0] +
227 (1.0 / _Eqq) * (1.0 - _dq_dqt) * _dsp_scratch[1]);
230
231 for (unsigned i = 0; i < _tensor_dimensionality; ++i)
232 for (unsigned j = 0; j < _tensor_dimensionality; ++j)
233 for (unsigned k = 0; k < _tensor_dimensionality; ++k)
234 for (unsigned l = 0; l < _tensor_dimensionality; ++l)
235 cto(i, j, k, l) -= s1(i, j) * t1(k, l) + s2(i, j) * t2(k, l);
236
238
239 const RankFourTensor Tijab =
240 elasticity_tensor * (gaE / _Epp) *
241 (smoothed_q.dg[0] * _d2sp_scratch[0] + smoothed_q.dg[1] * _d2sp_scratch[1]);
242
244 try
245 {
246 inv = inv.transposeMajor().invSymm();
247 }
248 catch (const MooseException & e)
249 {
250 // Cannot form the inverse, so probably at some degenerate place in stress space.
251 // Just return with the "best estimate" of the cto.
252 mooseWarning("TwoParameterPlasticityStressUpdate: Cannot invert 1+T in consistent tangent "
253 "operator computation at quadpoint ",
254 _qp,
255 " of element ",
256 _current_elem->id());
257 return;
258 }
259
260 cto = (cto.transposeMajor() * inv).transposeMajor();
261}
262
263void
265 const std::vector<Real> & stress_params,
266 Real gaE,
267 const std::vector<Real> & intnl,
268 const yieldAndFlow & smoothed_q,
269 const RankFourTensor & Eijkl,
270 RankTwoTensor & stress) const
271{
272 const Real p_ok = stress_params[0];
273 const Real q_ok = stress_params[1];
274 setStressAfterReturn(stress_trial, p_ok, q_ok, gaE, intnl, smoothed_q, Eijkl, stress);
275}
276
277void
279 const RankTwoTensor & /*stress_trial*/,
280 Real gaE,
281 const yieldAndFlow & smoothed_q,
282 const RankFourTensor & /*elasticity_tensor*/,
283 const RankTwoTensor & returned_stress,
284 RankTwoTensor & inelastic_strain_increment)
285{
286 inelastic_strain_increment = (gaE / _Epp) * (smoothed_q.dg[0] * dpdstress(returned_stress) +
287 smoothed_q.dg[1] * dqdstress(returned_stress));
288}
289
290void
292 std::vector<RankTwoTensor> & dsp) const
293{
294 // _num_pq = _num_sp
295 mooseAssert(dsp.size() == _num_pq,
296 "TwoParameterPlasticityStressUpdate: dsp incorrectly sized in dstressparam_dstress");
297 dsp[0] = dpdstress(stress);
298 dsp[1] = dqdstress(stress);
299}
300
301void
303 std::vector<RankFourTensor> & d2sp) const
304{
305 // _num_pq = _num_sp
306 mooseAssert(
307 d2sp.size() == _num_pq,
308 "TwoParameterPlasticityStressUpdate: d2sp incorrectly sized in d2stressparam_dstress");
309 d2sp[0] = d2pdstress2(stress);
310 d2sp[1] = d2qdstress2(stress);
311}
const Real p
void addClassDescription(const std::string &doc_string)
void mooseWarning(Args &&... args) const
MultiParameterPlasticityStressUpdate performs the return-map algorithm and associated stress updates ...
std::vector< std::vector< Real > > _Eij
E[i, j] in the system of equations to be solved.
std::vector< std::vector< Real > > _Cij
_Cij[i, j] * _Eij[j, k] = 1 iff j == k
static constexpr unsigned _tensor_dimensionality
Internal dimensionality of tensors (currently this is 3 throughout solid mechanics)
RankFourTensorTempl< T > transposeMajor() const
const Elem *const & _current_elem
std::vector< RankTwoTensor > _dsp_trial_scratch
d(stress_param[:])/d(stress_trial) used in dstressparam_dstress to avoid repeatedly allocating/deallo...
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 setEffectiveElasticity(const RankFourTensor &Eijkl) override
Sets _Eij and _En and _Cij.
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,...
std::vector< RankTwoTensor > _dsp_scratch
d(stress_param[:])/d(stress) used in dstressparam_dstress to avoid repeatedly allocating/deallocating...
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,...
Real _dq_dpt
derivative of Variable with respect to trial variable (used in consistent-tangent-operator calculatio...
void setInelasticStrainIncrementAfterReturn(const RankTwoTensor &stress_trial, Real gaE, const yieldAndFlow &smoothed_q, const RankFourTensor &elasticity_tensor, const RankTwoTensor &returned_stress, RankTwoTensor &inelastic_strain_increment) override
Sets inelastic strain increment from the returned configuration This is called after the return-map p...
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,...
virtual RankTwoTensor dpdstress(const RankTwoTensor &stress) const =0
d(p)/d(stress) Derived classes must override this
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 RankFourTensor d2pdstress2(const RankTwoTensor &stress) const =0
d2(p)/d(stress)/d(stress) Derived classes must override this
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,...
virtual void d2stressparam_dstress(const RankTwoTensor &stress, std::vector< RankFourTensor > &d2sp) const override
d2(stress_param[i])/d(stress)/d(stress) at given stress.
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.
virtual void computeStressParams(const RankTwoTensor &stress, std::vector< Real > &stress_params) const override
Computes stress_params, given stress.
static constexpr int _num_pq
Number of variables = 2 = (p, q)
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 _dp_dqt
derivative of Variable with respect to trial variable (used in consistent-tangent-operator calculatio...
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...
std::vector< RankFourTensor > _d2sp_scratch
d2(stress_param[:])/d(stress)/d(stress) used in d2stressparam_dstress to avoid repeatedly allocating/...
virtual void computePQ(const RankTwoTensor &stress, Real &p, Real &q) const =0
Computes p and q, given stress.
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 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 RankFourTensor d2qdstress2(const RankTwoTensor &stress) const =0
d2(q)/d(stress)/d(stress) Derived classes must override this
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...
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 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 dstressparam_dstress(const RankTwoTensor &stress, std::vector< RankTwoTensor > &dsp) const override
d(stress_param[i])/d(stress) at given stress.
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.
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.
virtual RankTwoTensor dqdstress(const RankTwoTensor &stress) const =0
d(q)/d(stress) Derived classes must override this
Real _dp_dpt
derivative of Variable with respect to trial variable (used in consistent-tangent-operator calculatio...
TwoParameterPlasticityStressUpdate(const InputParameters &parameters, unsigned num_yf, unsigned num_intnl)
Real _dgaE_dpt
derivative of Variable with respect to trial variable (used in consistent-tangent-operator calculatio...
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.
Real elasticity_tensor(unsigned int i, unsigned int j, unsigned int k, unsigned int l)
Struct designed to hold info about a single yield function and its derivatives, as well as the flow d...