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/AssociativePlasticFlow.h"
26 : #include "neml2/tensors/Scalar.h"
27 : #include "neml2/tensors/SR2.h"
28 : #include "neml2/tensors/SSR4.h"
29 :
30 : namespace neml2
31 : {
32 : register_NEML2_object(AssociativePlasticFlow);
33 :
34 : OptionSet
35 2 : AssociativePlasticFlow::expected_options()
36 : {
37 2 : OptionSet options = FlowRule::expected_options();
38 2 : options.doc() +=
39 : " This object calculates the rate of plastic strain following associative flow rule, i.e. "
40 : "\\f$ \\dot{\\boldsymbol{\\varepsilon}}_p = - \\dot{\\gamma} \\frac{\\partial f}{\\partial "
41 : "\\boldsymbol{M}} \\f$, where \\f$ \\dot{\\boldsymbol{\\varepsilon}}_p \\f$ is the plastic "
42 : "strain, \\f$ \\dot{\\gamma} \\f$ is the flow rate, \\f$ f \\f$ is the yield function, and "
43 2 : "\\f$ \\boldsymbol{M} \\f$ is the Mandel stress.";
44 :
45 6 : options.set_input("flow_direction") = VariableName(STATE, "internal", "NM");
46 2 : options.set("flow_direction").doc() = "Flow direction which can be calculated using Normality";
47 :
48 6 : options.set_output("plastic_strain_rate") = VariableName(STATE, "internal", "Ep_rate");
49 2 : options.set("plastic_strain_rate").doc() = "Rate of plastic strain";
50 :
51 2 : return options;
52 0 : }
53 :
54 4 : AssociativePlasticFlow::AssociativePlasticFlow(const OptionSet & options)
55 : : FlowRule(options),
56 4 : _NM(declare_input_variable<SR2>("flow_direction")),
57 8 : _Ep_dot(declare_output_variable<SR2>("plastic_strain_rate"))
58 : {
59 4 : }
60 :
61 : void
62 8 : AssociativePlasticFlow::set_value(bool out, bool dout_din, bool /*d2out_din2*/)
63 : {
64 : // For associative flow,
65 : // Ep_dot = gamma_dot * NM
66 : // NM = df/dM
67 :
68 8 : if (out)
69 7 : _Ep_dot = _gamma_dot * _NM;
70 :
71 8 : if (dout_din)
72 : {
73 4 : auto I = SR2::identity_map(_gamma_dot.options());
74 :
75 4 : if (_gamma_dot.is_dependent())
76 4 : _Ep_dot.d(_gamma_dot) = _NM;
77 :
78 4 : if (_NM.is_dependent())
79 4 : _Ep_dot.d(_NM) = _gamma_dot * I;
80 4 : }
81 8 : }
82 : } // namespace neml2
|