NEML2 1.4.0
Loading...
Searching...
No Matches
KocksMeckingRateSensitivity.cxx
1// Copyright 2023, 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/KocksMeckingRateSensitivity.h"
26
27namespace neml2
28{
29register_NEML2_object(KocksMeckingRateSensitivity);
30
33{
35 options.doc() =
36 "Calculates the temperature-dependent rate sensitivity for a Perzyna-type model using the "
37 "Kocks-Mecking model. The value is \\f$ n = \\frac{\\mu b^3}{k T A} \\f$ with \\f$ \\mu "
38 "\\f$ the shear modulus, \\f$ b \\f$ the Burgers vector, \\f$ k\\f$ the Boltzmann constant, "
39 "\\f$ T \\f$ absolute temperature, and \\f$ A \\f$ the Kocks-Mecking slope parameter.";
40
41 options.set<CrossRef<Scalar>>("A");
42 options.set("A").doc() = "The Kocks-Mecking slope parameter";
43 options.set<CrossRef<Scalar>>("shear_modulus");
44 options.set("shear_modulus").doc() = "The shear modulus";
45
46 options.set<Real>("k");
47 options.set("k").doc() = "Boltzmann constant";
48 options.set<Real>("b");
49 options.set("b").doc() = "The Burgers vector";
50
51 options.set<VariableName>("temperature") = VariableName("forces", "T");
52 options.set("temperature").doc() = "Absolute temperature";
53 return options;
54}
55
57 : NonlinearParameter<Scalar>(options),
58 _A(declare_parameter<Scalar>("A", "A")),
59 _mu(declare_parameter<Scalar>("shear_modulus", "shear_modulus")),
60 _k(options.get<Real>("k")),
61 _b3(options.get<Real>("b") * options.get<Real>("b") * options.get<Real>("b")),
62 _T(declare_input_variable<Scalar>("temperature"))
63{
64}
65
66void
68{
69 if (out)
70 _p = -_mu * _b3 / (_k * _T * _A);
71
72 if (dout_din)
73 {
74 _p.d(_T) = _b3 * _mu / (_A * _k * _T * _T);
75 if (const auto mu = nl_param("shear_modulus"))
76 _p.d(*mu) = -_b3 / (_A * _k * _T);
77 if (const auto A = nl_param("A"))
78 _p.d(*A) = -_b3 * _mu / (_A * _A * _k * _T);
79 }
80
81 if (d2out_din2)
82 {
83 // T, T
84 _p.d(_T, _T) = -2.0 * _b3 * _mu / (_A * _k * _T * _T * _T);
85 if (const auto A = nl_param("A"))
86 {
87 // A, A
88 _p.d(*A, *A) = -2.0 * _b3 * _mu / (_A * _A * _A * _k * _T);
89 // A, T and T, A
90 auto AT = -_b3 * _mu / (_A * _A * _k * _T * _T);
91 _p.d(*A, _T) = AT;
92 _p.d(_T, *A) = AT;
93 }
94 if (const auto mu = nl_param("mu"))
95 {
96 // mu, T and T, mu
97 auto MT = _b3 / (_A * _k * _T * _T);
98 _p.d(*mu, _T) = MT;
99 _p.d(_T, *mu) = MT;
100
101 if (const auto A = nl_param("A"))
102 {
103 // mu, A and A, mu
104 auto MA = _b3 / (_A * _A * _k * _T);
105 _p.d(*mu, *A) = MA;
106 _p.d(*A, *mu) = MA;
107 }
108 }
109 }
110}
111} // namespace neml2
The wrapper (decorator) for cross-referencing unresolved values at parse time.
Definition CrossRef.h:52
A scalar-valued parameter defined by (mu0 - D/(exp(T0/T)-1)) * exp(_C)
Definition KocksMeckingRateSensitivity.h:35
const Real _k
The Boltzmann constant.
Definition KocksMeckingRateSensitivity.h:51
KocksMeckingRateSensitivity(const OptionSet &options)
Definition KocksMeckingRateSensitivity.cxx:56
const Scalar & _mu
The shear modulus.
Definition KocksMeckingRateSensitivity.h:48
const Variable< Scalar > & _T
The temperature.
Definition KocksMeckingRateSensitivity.h:57
const Scalar & _A
The Kocks-Mecking slope.
Definition KocksMeckingRateSensitivity.h:45
static OptionSet expected_options()
Definition KocksMeckingRateSensitivity.cxx:32
const Real _b3
Burgers vector cubed.
Definition KocksMeckingRateSensitivity.h:54
void set_value(bool out, bool dout_din, bool d2out_din2) override
The map between input -> output, and optionally its derivatives.
Definition KocksMeckingRateSensitivity.cxx:67
The accessor containing all the information needed to access an item in a LabeledAxis.
Definition LabeledAxisAccessor.h:44
const torch::TensorOptions & options() const
This model's tensor options.
Definition Model.h:116
The base class for nonlinear parameters.
Definition NonlinearParameter.h:51
Variable< Scalar > & _p
The nonlinear parameter.
Definition NonlinearParameter.h:62
static OptionSet expected_options()
Definition NonlinearParameter.cxx:31
A custom map-like data structure. The keys are strings, and the values can be nonhomogeneously typed.
Definition OptionSet.h:59
const VariableBase * nl_param(const std::string &) const
Query the existence of a nonlinear parameter.
Definition ParameterStore.cxx:56
The (logical) scalar.
Definition Scalar.h:38
Derivative d(const VariableBase &x)
Create a wrapper representing the derivative dy/dx.
Definition Variable.cxx:102
Definition CrossRef.cxx:32
double Real
Definition types.h:33
LabeledAxisAccessor VariableName
Definition Variable.h:35