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/SlopeSaturationVoceIsotropicHardening.h"
26 : #include "neml2/tensors/Scalar.h"
27 : #include "neml2/tensors/functions/sign.h"
28 :
29 : namespace neml2
30 : {
31 : register_NEML2_object(SlopeSaturationVoceIsotropicHardening);
32 :
33 : OptionSet
34 2 : SlopeSaturationVoceIsotropicHardening::expected_options()
35 : {
36 2 : OptionSet options = FlowRule::expected_options();
37 2 : options.doc() = "SlopeSaturationVoce isotropic hardening model, \\f$ \\dot{h} = \\theta_0 "
38 : "\\left(1 - \\frac{h}{R} \\right) \\varepsilon_p \\f$, where \\f$ R \\f$ is the "
39 : "isotropic hardening upon saturation, "
40 : "and \\f$ \\theta_0 \\f$ is the initial hardening rate. "
41 : "In addition to the reparameterization, this model differences from the "
42 : "`VoceIsotropicHardening` model in that it defines the hardening rate in a "
43 : "non-assocative manner. This is sometimes handy, for example in supplementing "
44 2 : "the model with static recovery.";
45 :
46 6 : options.set_input("isotropic_hardening") = VariableName(STATE, "internal", "k");
47 4 : options.set("isotropic_hardening").doc() = "Isotropic hardening variable";
48 :
49 4 : options.set_input("isotropic_hardening_rate");
50 6 : options.set("isotropic_hardening_rate").doc() =
51 2 : "Rate of isotropic hardening, defaults to isotropic_hardening + _rate";
52 :
53 4 : options.set_parameter<TensorName<Scalar>>("saturated_hardening");
54 4 : options.set("saturated_hardening").doc() = "Saturated isotropic hardening";
55 4 : options.set_parameter<TensorName<Scalar>>("initial_hardening_rate");
56 2 : options.set("initial_hardening_rate").doc() = "Initial hardening rate";
57 :
58 2 : return options;
59 0 : }
60 :
61 4 : SlopeSaturationVoceIsotropicHardening::SlopeSaturationVoceIsotropicHardening(
62 4 : const OptionSet & options)
63 : : FlowRule(options),
64 4 : _h(declare_input_variable<Scalar>("isotropic_hardening")),
65 8 : _h_dot(declare_output_variable<Scalar>(
66 8 : options.get<VariableName>("isotropic_hardening_rate").empty()
67 16 : ? _h.name().with_suffix("_rate")
68 : : options.get<VariableName>("isotropic_hardening_rate"))),
69 16 : _R(declare_parameter<Scalar>("R", "saturated_hardening", true)),
70 20 : _theta0(declare_parameter<Scalar>("theta0", "initial_hardening_rate", true))
71 : {
72 4 : }
73 :
74 : void
75 8 : SlopeSaturationVoceIsotropicHardening::set_value(bool out, bool dout_din, bool /*d2out_din2*/)
76 : {
77 8 : if (out)
78 6 : _h_dot = sign(_R) * _theta0 * (1.0 - _h / _R) * _gamma_dot;
79 :
80 8 : if (dout_din)
81 : {
82 4 : if (_gamma_dot.is_dependent())
83 4 : _h_dot.d(_gamma_dot) = sign(_R) * _theta0 * (1.0 - _h / _R);
84 :
85 4 : if (_h.is_dependent())
86 4 : _h_dot.d(_h) = -sign(_R) * _theta0 / _R * _gamma_dot;
87 :
88 16 : if (const auto * const R = nl_param("R"))
89 2 : _h_dot.d(*R) = _gamma_dot * _h * sign(_R) * _theta0 / (_R * _R);
90 :
91 12 : if (const auto * const theta0 = nl_param("theta0"))
92 2 : _h_dot.d(*theta0) = sign(_R) * (1.0 - _h / _R) * _gamma_dot;
93 : }
94 8 : }
95 : } // namespace neml2
|