Line data Source code
1 : // Copyright 2024, UChicago Argonne, LLC
2 : // All Rights Reserved
3 : // Software Name: NEML2 -- the New Engineering material Model Library, version 2
4 : // By: Argonne National Laboratory
5 : // OPEN SOURCE LICENSE (MIT)
6 : //
7 : // Permission is hereby granted, free of charge, to any person obtaining a copy
8 : // of this software and associated documentation files (the "Software"), to deal
9 : // in the Software without restriction, including without limitation the rights
10 : // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 : // copies of the Software, and to permit persons to whom the Software is
12 : // furnished to do so, subject to the following conditions:
13 : //
14 : // The above copyright notice and this permission notice shall be included in
15 : // all copies or substantial portions of the Software.
16 : //
17 : // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 : // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 : // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 : // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 : // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 : // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 : // THE SOFTWARE.
24 :
25 : #include "neml2/models/solid_mechanics/crystal_plasticity/PowerLawSlipRule.h"
26 : #include "neml2/models/solid_mechanics/crystal_plasticity/SlipRule.h"
27 : #include "neml2/tensors/Scalar.h"
28 : #include "neml2/tensors/functions/pow.h"
29 : #include "neml2/tensors/functions/abs.h"
30 : #include "neml2/tensors/functions/diag_embed.h"
31 :
32 : namespace neml2
33 : {
34 : register_NEML2_object(PowerLawSlipRule);
35 :
36 : OptionSet
37 2 : PowerLawSlipRule::expected_options()
38 : {
39 2 : OptionSet options = SlipRule::expected_options();
40 2 : options.doc() =
41 : "Power law slip rule defined as \\f$ \\dot{\\gamma}_i = \\dot{\\gamma}_0 \\left| "
42 : "\\frac{\\tau_i}{\\hat{\\tau}_i} \\right|^{n-1} \\frac{\\tau_i}{\\hat{\\tau}_i} \\f$ with "
43 : "\\f$ \\dot{\\gamma}_i \\f$ the slip rate on system \\f$ i \\f$, \\f$ \\tau_i \\f$ the "
44 : "resolved shear, \\f$ \\hat{\\tau}_i \\f$ the slip system strength, \\f$ n \\f$ the rate "
45 2 : "senstivity, and \\f$ \\dot{\\gamma}_0 \\f$ a reference slip rate.";
46 :
47 4 : options.set_parameter<TensorName<Scalar>>("gamma0");
48 4 : options.set("gamma0").doc() = "Reference slip rate";
49 :
50 4 : options.set_parameter<TensorName<Scalar>>("n");
51 2 : options.set("n").doc() = "Rate sensitivity exponent";
52 :
53 2 : return options;
54 0 : }
55 :
56 2 : PowerLawSlipRule::PowerLawSlipRule(const OptionSet & options)
57 : : SlipRule(options),
58 6 : _gamma0(declare_parameter<Scalar>("gamma0", "gamma0")),
59 10 : _n(declare_parameter<Scalar>("n", "n"))
60 : {
61 2 : }
62 :
63 : void
64 4 : PowerLawSlipRule::set_value(bool out, bool dout_din, bool /*d2out_din2*/)
65 : {
66 4 : const auto D = utils::broadcast_batch_dim(_rss, _tau, _gamma0, _n);
67 :
68 4 : if (out)
69 3 : _g = _gamma0 * pow(abs(_rss / _tau), _n - 1.0) * _rss / _tau;
70 :
71 4 : if (dout_din)
72 : {
73 2 : if (_rss.is_dependent())
74 4 : _g.d(_rss) =
75 6 : Tensor(batch_diag_embed(_gamma0 * _n * pow(abs(_rss / _tau), _n - 1.0) / _tau), D);
76 :
77 2 : if (_tau.is_dependent())
78 4 : _g.d(_tau) = Tensor(batch_diag_embed(-_n * _gamma0 * _rss * pow(abs(_rss.value()), _n - 1.0) /
79 4 : pow(Scalar(_tau), _n + 1)),
80 2 : D);
81 : }
82 4 : }
83 : } // namespace neml2
|