https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FiniteStrainCPSlipRateRes.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#include "libmesh/utility.h"
12
13registerMooseObjectDeprecated("SolidMechanicsApp", FiniteStrainCPSlipRateRes, "11/15/2024 12:00");
14
17{
19 params.addClassDescription("Deprecated class: please use CrystalPlasticityKalidindiUpdate and "
20 "ComputeMultipleCrystalPlasticityStress instead.");
21 return params;
22}
23
26 _resid(_nss),
27 _slip_rate(_nss),
28 _dsliprate_dgss(_nss),
29 _jacob(_nss, _nss),
30 _dsliprate_dsliprate(_nss, _nss)
31{
32}
33
34void
43
44void
50
51void
53{
54 Real rnorm, rnorm0, rnorm_prev;
55 unsigned int iter = 0;
56
57#ifdef DEBUG
58 std::vector<Real> rnormst(_maxiter + 1), slipratest(_maxiter + 1); // Use for Debugging
59#endif
60
62 if (_err_tol)
63 return;
64 rnorm = calcResidNorm();
65 rnorm0 = rnorm;
66
67#ifdef DEBUG
68 rnormst[iter] = rnorm;
69 Real slipratemax = 0.0;
70 for (unsigned int i = 0; i < _nss; ++i)
71 if (std::abs(_slip_rate(i)) > slipratemax)
72 slipratemax = std::abs(_slip_rate(i));
73 slipratest[iter] = slipratemax;
74#endif
75
76 while (rnorm > _rtol * rnorm0 && rnorm0 > _abs_tol && iter < _maxiter)
77 {
78 calcUpdate();
79
80 DenseVector<Real> update = _resid;
81
82 _slip_rate -= update;
83
85 if (_err_tol)
86 return;
87 rnorm_prev = rnorm;
88 rnorm = calcResidNorm();
89
90 if (_use_line_search && rnorm > rnorm_prev && !lineSearchUpdateSlipRate(rnorm_prev, update))
91 {
92#ifdef DEBUG
93 mooseWarning("FiniteStrainCrystalPLasticity: Failed with line search");
94#endif
95 _err_tol = true;
96 return;
97 }
98
100
102 rnorm = calcResidNorm();
103 iter++;
104
105#ifdef DEBUG
106 slipratemax = 0.0;
107 for (unsigned int i = 0; i < _nss; ++i)
108 if (std::abs(_slip_rate(i)) > slipratemax)
109 slipratemax = std::abs(_slip_rate(i));
110 rnormst[iter] = rnorm;
111 slipratest[iter] = slipratemax;
112#endif
113 }
114
115 if (iter == _maxiter)
116 {
117#ifdef DEBUG
118 mooseWarning("FiniteStrainCPSlipRateRes: NR exceeds maximum iteration ", iter, " ", rnorm);
119#endif
120 _err_tol = true;
121 return;
122 }
123}
124
125void
133
134void
136{
137 RankTwoTensor eqv_slip_incr, ce, ee;
139
141 _slip_incr *= _dt;
142
143 for (unsigned int i = 0; i < _nss; ++i)
144 eqv_slip_incr += _s0[i] * _slip_incr(i);
145
146 eqv_slip_incr = iden - eqv_slip_incr;
147
148 _fp_inv = _fp_old_inv * eqv_slip_incr;
150
151 ce = _fe.transpose() * _fe;
152 ee = ce - iden;
153 ee *= 0.5;
154
155 _pk2_tmp = _elasticity_tensor[_qp] * ee;
156
157 for (unsigned int i = 0; i < _nss; ++i)
159
162
163 if (_err_tol)
164 return;
165
166 for (unsigned int i = 0; i < _nss; ++i)
167 _resid(i) = _slip_rate(i) - _slip_incr(i) / _dt;
168}
169
170void
172{
173 //_dsliprate_dsliprate not reinitialized to zero, hence order is important
176
177 for (unsigned int i = 0; i < _nss; ++i)
178 for (unsigned int j = 0; j < _nss; ++j)
179 {
180 _jacob(i, j) = 0.0;
181 if (i == j)
182 _jacob(i, j) += 1.0;
183 _jacob(i, j) -= _dsliprate_dsliprate(i, j);
184 }
185}
186
187void
189{
190 RankFourTensor dfedfpinv, deedfe, dfpinvdpk2;
191 std::vector<RankTwoTensor> dtaudpk2(_nss), dfpinvdsliprate(_nss);
192
193 for (unsigned int i = 0; i < _nss; ++i)
194 {
195 dtaudpk2[i] = _s0[i];
196 dfpinvdsliprate[i] = -_fp_old_inv * _s0[i] * _dt;
197 }
198
199 for (const auto i : make_range(Moose::dim))
200 for (const auto j : make_range(Moose::dim))
201 for (const auto k : make_range(Moose::dim))
202 dfedfpinv(i, j, k, j) = _dfgrd_tmp(i, k);
203
204 for (const auto i : make_range(Moose::dim))
205 for (const auto j : make_range(Moose::dim))
206 for (const auto k : make_range(Moose::dim))
207 {
208 deedfe(i, j, k, i) = deedfe(i, j, k, i) + _fe(k, j) * 0.5;
209 deedfe(i, j, k, j) = deedfe(i, j, k, j) + _fe(k, i) * 0.5;
210 }
211
212 RankFourTensor dpk2dfpinv;
213
214 dpk2dfpinv = _elasticity_tensor[_qp] * deedfe * dfedfpinv;
215
216 for (unsigned int i = 0; i < _nss; ++i)
217 for (unsigned int j = 0; j < _nss; ++j)
219 _dslipdtau(i) * dtaudpk2[i].doubleContraction(dpk2dfpinv * dfpinvdsliprate[j]);
220}
221
222void
224{
225 for (unsigned int i = 0; i < _nss; ++i)
226 for (unsigned int j = 0; j < _nss; ++j)
228}
229
230void
232{
234
235 if (_err_tol)
236 return;
237
238 _dslipdtau *= 1.0 / _dt;
239
240 for (unsigned int i = 0; i < _nss; ++i)
241 _dsliprate_dgss(i) = -_a0(i) / _xm(i) *
242 std::pow(std::abs(_tau(i) / _gss_tmp[i]), 1.0 / _xm(i) - 1.0) * _tau(i) /
243 std::pow(_gss_tmp[i], 2.0);
244}
245
246void
248{
249 DenseMatrix<Real> A = _jacob;
250 DenseVector<Real> r(_nss);
251 DenseVector<Real> x(_nss);
252
253 r = _resid;
254
255 A.lu_solve(r, x);
256
257 _resid = x;
258}
259
260Real
262{
263 Real rnorm = 0.0;
264 for (unsigned int i = 0; i < _nss; ++i)
265 rnorm += Utility::pow<2>(_resid(i));
266 rnorm = std::sqrt(rnorm) / _nss;
267
268 return rnorm;
269}
270
271bool
273 const DenseVector<Real> & update)
274{
275 if (_lsrch_method == "CUT_HALF")
276 {
277 Real rnorm;
278 Real step = 1.0;
279 do
280 {
281 for (unsigned int i = 0; i < update.size(); ++i)
282 _slip_rate(i) += step * update(i);
283
284 step /= 2.0;
285
286 for (unsigned int i = 0; i < update.size(); ++i)
287 _slip_rate(i) -= step * update(i);
288
290 if (_err_tol)
291 return false;
292 rnorm = calcResidNorm();
293 } while (rnorm > rnorm_prev && step > _min_lsrch_step);
294
295 if (rnorm > rnorm_prev && step <= _min_lsrch_step)
296 return false;
297
298 return true;
299 }
300 else if (_lsrch_method == "BISECTION")
301 {
302 unsigned int count = 0;
303 Real step_a = 0.0;
304 Real step_b = 1.0;
305 Real step = 1.0;
306 Real s_m = 1000.0;
307 Real rnorm = 1000.0;
308
309 Real s_b = calcResidDotProdUpdate(update);
310 Real rnorm1 = calcResidNorm();
311
312 for (unsigned int i = 0; i < update.size(); ++i)
313 _slip_rate(i) += update(i);
314
316 Real s_a = calcResidDotProdUpdate(update);
317 Real rnorm0 = calcResidNorm();
318
319 for (unsigned int i = 0; i < update.size(); ++i)
320 _slip_rate(i) -= update(i);
321
322 if ((rnorm1 / rnorm0) < _lsrch_tol || s_a * s_b > 0)
323 {
325 return true;
326 }
327
328 while ((rnorm / rnorm0) > _lsrch_tol && count < _lsrch_max_iter)
329 {
330
331 for (unsigned int i = 0; i < update.size(); ++i)
332 _slip_rate(i) += step * update(i);
333
334 step = 0.5 * (step_a + step_b);
335
336 for (unsigned int i = 0; i < update.size(); ++i)
337 _slip_rate(i) -= step * update(i);
338
340 s_m = calcResidDotProdUpdate(update);
341 rnorm = calcResidNorm();
342
343 if (s_m * s_a < 0.0)
344 {
345 step_b = step;
346 s_b = s_m;
347 }
348 if (s_m * s_b < 0.0)
349 {
350 step_a = step;
351 s_a = s_m;
352 }
353 count++;
354 }
355
356 if ((rnorm / rnorm0) < _lsrch_tol && count < _lsrch_max_iter)
357 return true;
358
359 return false;
360 }
361 else
362 {
363 mooseError("Line search meothod is not provided.");
364 return false;
365 }
366}
367
368Real
370{
371 Real dotprod = 0.0;
372 for (unsigned int i = 0; i < _nss; ++i)
373 dotprod += _resid(i) * update(i);
374 return dotprod;
375}
const std::vector< double > x
registerMooseObjectDeprecated("SolidMechanicsApp", FiniteStrainCPSlipRateRes, "11/15/2024 12:00")
void mooseWarning(Args &&... args)
void mooseError(Args &&... args)
unsigned int count
FiniteStrainCPSlipRateRes(const InputParameters &parameters)
virtual void calcResidualSlipRate()
This function calculates residual of slip rate.
virtual void getSlipIncrements()
This function updates the slip system resistances.
virtual void solveStress()
This function solves for stress, updates plastic deformation gradient.
virtual void calcDgssDsliprate()
This function calculates partial derivative of slip system resistances with respect to split rate.
virtual void calcDtauDsliprate()
This function calculates partial derivative of resolved shear stress with respect to split rate.
virtual void calcJacobianSlipRate()
This function calculates jacobian of slip rate.
virtual void calcResidJacobSlipRate()
This function calculates residual and jacobian of slip rate.
static InputParameters validParams()
void calcUpdate()
This function calculates and updates the residual of slip rate.
virtual Real calcResidNorm()
This function calculates the residual norm.
virtual void solveStatevar()
This function solves internal variables.
bool lineSearchUpdateSlipRate(const Real, const DenseVector< Real > &)
This function performs the line search update.
Real calcResidDotProdUpdate(const DenseVector< Real > &)
This function calculates the dot product of residual and update.
virtual void preSolveStress()
This function sets variable for internal variable solve.
FiniteStrainCrystalPlasticity uses the multiplicative decomposition of deformation gradient and solve...
Real _rtol
Stress residual equation relative tolerance.
const MaterialProperty< RankFourTensor > & _elasticity_tensor
Elasticity tensor material property.
const unsigned int _nss
Number of slip system resistance.
virtual void update_slip_system_resistance()
This function updates the slip system resistances.
unsigned int _lsrch_max_iter
Line search bisection method maximum iteration number.
Real _lsrch_tol
Line search bisection method tolerance.
unsigned int _maxiter
Maximum number of iterations for stress update.
Real _min_lsrch_step
Minimum line search step size.
virtual void preSolveStress()
This function set variables for stress solve.
virtual void getSlipIncrements()
This function updates the slip increments.
Real _abs_tol
Stress residual equation absolute tolerance.
virtual void postSolveStress()
This function update stress and plastic deformation gradient after solve.
bool _use_line_search
Flag to activate line serach.
void addClassDescription(const std::string &doc_string)
T doubleContraction(const RankTwoTensorTempl< T > &a) const
RankTwoTensorTempl< T > transpose() const
static constexpr std::size_t dim