NEML2 1.4.0
Loading...
Searching...
No Matches
KocksMeckingActivationEnergy.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/KocksMeckingActivationEnergy.h"
26
27namespace neml2
28{
29register_NEML2_object(KocksMeckingActivationEnergy);
30
33{
35 options.doc() =
36 "Calculates the Kocks-Mecking normalized activation as \\f$g = \\frac{kT}{\\mu "
37 "b^3} \\log \\frac{\\dot{\\varepsilon}_0}{\\dot{\\varepsilon}} \\f$ with \\f$ "
38 "\\mu \\f$ the shear modulus, \\f$ k \\f$ the Boltzmann constant, \\f$ T \\f$ the absolute "
39 "temperature, \\f$ b \\f$ the Burgers vector length, \\f$ \\dot{\\varepsilon}_0 \\f$ a "
40 "reference strain rate, and \\f$ \\dot{\\varepsilon} \\f$ the current strain rate.";
41
42 options.set<CrossRef<Scalar>>("shear_modulus");
43 options.set("shear_modulus").doc() = "The shear modulus";
44
45 options.set<Real>("eps0");
46 options.set("eps0").doc() = "Reference strain rate";
47
48 options.set<Real>("k");
49 options.set("k").doc() = "The Boltzmann constant";
50 options.set<Real>("b");
51 options.set("b").doc() = "Magnitude of the Burgers vector";
52
53 options.set<VariableName>("temperature") = VariableName("forces", "T");
54 options.set("temperature").doc() = "Absolute temperature";
55
56 options.set<VariableName>("strain_rate") = VariableName("forces", "effective_strain_rate");
57 options.set("strain_rate").doc() = "Name of the effective strain rate";
58
59 options.set<VariableName>("activation_energy") = VariableName("forces", "g");
60 options.set("activation_energy").doc() = "Output name of the activation energy";
61 return options;
62}
63
65 : Model(options),
66 _mu(declare_parameter<Scalar>("shear_modulus", "shear_modulus")),
67 _eps0(options.get<Real>("eps0")),
68 _k(options.get<Real>("k")),
69 _b3(options.get<Real>("b") * options.get<Real>("b") * options.get<Real>("b")),
70 _T(declare_input_variable<Scalar>("temperature")),
71 _eps_dot(declare_input_variable<Scalar>("strain_rate")),
72 _g(declare_output_variable<Scalar>("activation_energy"))
73{
74}
75
76void
78{
79 neml_assert(!d2out_din2, "Second derivatives not implemented");
80
81 if (out)
82 _g = _k * _T / (_mu * _b3) * math::log(_eps0 / _eps_dot);
83
84 if (dout_din)
85 {
86 _g.d(_T) = _k / (_mu * _b3) * math::log(_eps0 / _eps_dot);
87 _g.d(_eps_dot) = -_k * _T / (_mu * _b3 * _eps_dot);
88 if (const auto mu = nl_param("shear_modulus"))
89 _g.d(*mu) = -_k * _T / (_b3 * _mu * _mu) * math::log(_eps0 / _eps_dot);
90 }
91}
92} // namespace neml2
The wrapper (decorator) for cross-referencing unresolved values at parse time.
Definition CrossRef.h:52
Definition KocksMeckingActivationEnergy.h:32
const Variable< Scalar > & _eps_dot
The strain rate.
Definition KocksMeckingActivationEnergy.h:57
Variable< Scalar > & _g
The activation energy.
Definition KocksMeckingActivationEnergy.h:60
const Real _k
The Boltzmann constant.
Definition KocksMeckingActivationEnergy.h:48
KocksMeckingActivationEnergy(const OptionSet &options)
Definition KocksMeckingActivationEnergy.cxx:64
const Scalar & _mu
The shear modulus.
Definition KocksMeckingActivationEnergy.h:42
const Variable< Scalar > & _T
The temperature.
Definition KocksMeckingActivationEnergy.h:54
static OptionSet expected_options()
Definition KocksMeckingActivationEnergy.cxx:32
const Real _b3
Burgers vector cubed.
Definition KocksMeckingActivationEnergy.h:51
void set_value(bool out, bool dout_din, bool d2out_din2) override
The map between input -> output, and optionally its derivatives.
Definition KocksMeckingActivationEnergy.cxx:77
const Real _eps0
The reference strain rate.
Definition KocksMeckingActivationEnergy.h:45
The accessor containing all the information needed to access an item in a LabeledAxis.
Definition LabeledAxisAccessor.h:44
The base class for all constitutive models.
Definition Model.h:53
const torch::TensorOptions & options() const
This model's tensor options.
Definition Model.h:116
static OptionSet expected_options()
Definition Model.cxx:32
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
Derived log(const Derived &a)
Definition BatchTensorBase.h:486
Definition CrossRef.cxx:32
double Real
Definition types.h:31
LabeledAxisAccessor VariableName
Definition Variable.h:35
void neml_assert(bool assertion, Args &&... args)
Definition error.h:73