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/KocksMeckingActivationEnergy.h"
26 : #include "neml2/tensors/Scalar.h"
27 : #include "neml2/tensors/functions/log.h"
28 :
29 : namespace neml2
30 : {
31 : register_NEML2_object(KocksMeckingActivationEnergy);
32 :
33 : OptionSet
34 2 : KocksMeckingActivationEnergy::expected_options()
35 : {
36 2 : OptionSet options = Model::expected_options();
37 2 : options.doc() =
38 : "Calculates the Kocks-Mecking normalized activation as \\f$g = \\frac{kT}{\\mu "
39 : "b^3} \\log \\frac{\\dot{\\varepsilon}_0}{\\dot{\\varepsilon}} \\f$ with \\f$ "
40 : "\\mu \\f$ the shear modulus, \\f$ k \\f$ the Boltzmann constant, \\f$ T \\f$ the absolute "
41 : "temperature, \\f$ b \\f$ the Burgers vector length, \\f$ \\dot{\\varepsilon}_0 \\f$ a "
42 2 : "reference strain rate, and \\f$ \\dot{\\varepsilon} \\f$ the current strain rate.";
43 :
44 4 : options.set_parameter<TensorName<Scalar>>("shear_modulus");
45 4 : options.set("shear_modulus").doc() = "The shear modulus";
46 :
47 4 : options.set<double>("eps0");
48 4 : options.set("eps0").doc() = "Reference strain rate";
49 :
50 4 : options.set<double>("k");
51 4 : options.set("k").doc() = "The Boltzmann constant";
52 4 : options.set<double>("b");
53 2 : options.set("b").doc() = "Magnitude of the Burgers vector";
54 :
55 6 : options.set_input("temperature") = VariableName(FORCES, "T");
56 2 : options.set("temperature").doc() = "Absolute temperature";
57 :
58 6 : options.set_input("strain_rate") = VariableName(FORCES, "effective_strain_rate");
59 2 : options.set("strain_rate").doc() = "Name of the effective strain rate";
60 :
61 6 : options.set_output("activation_energy") = VariableName(FORCES, "g");
62 2 : options.set("activation_energy").doc() = "Output name of the activation energy";
63 2 : return options;
64 0 : }
65 :
66 2 : KocksMeckingActivationEnergy::KocksMeckingActivationEnergy(const OptionSet & options)
67 : : Model(options),
68 8 : _mu(declare_parameter<Scalar>("mu", "shear_modulus", /*allow_nonlinear=*/true)),
69 4 : _eps0(options.get<double>("eps0")),
70 4 : _k(options.get<double>("k")),
71 10 : _b3(options.get<double>("b") * options.get<double>("b") * options.get<double>("b")),
72 2 : _T(declare_input_variable<Scalar>("temperature")),
73 2 : _eps_dot(declare_input_variable<Scalar>("strain_rate")),
74 4 : _g(declare_output_variable<Scalar>("activation_energy"))
75 : {
76 2 : }
77 :
78 : void
79 4 : KocksMeckingActivationEnergy::set_value(bool out, bool dout_din, bool /*d2out_din2*/)
80 : {
81 4 : if (out)
82 3 : _g = _k * _T / (_mu * _b3) * log(_eps0 / _eps_dot);
83 :
84 4 : if (dout_din)
85 : {
86 2 : if (_T.is_dependent())
87 2 : _g.d(_T) = _k / (_mu * _b3) * log(_eps0 / _eps_dot);
88 :
89 2 : if (_eps_dot.is_dependent())
90 2 : _g.d(_eps_dot) = -_k * _T / (_mu * _b3 * _eps_dot);
91 :
92 6 : if (const auto * const mu = nl_param("mu"))
93 1 : _g.d(*mu) = -_k * _T / (_b3 * _mu * _mu) * log(_eps0 / _eps_dot);
94 : }
95 4 : }
96 : } // namespace neml2
|