NEML2 1.4.0
Loading...
Searching...
No Matches
YieldFunction.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/YieldFunction.h"
26
27namespace neml2
28{
29register_NEML2_object(YieldFunction);
30
33{
35 options.doc() =
36 "Classical macroscale plasticity yield function, \\f$ f = \\bar{\\sigma} - \\sigma_y - h "
37 "\\f$, where \\f$ \\bar{\\sigma} \\f$ is the effective stress, \\f$ \\sigma_y \\f$ is the "
38 "yield stress, and \\f$ h \\f$ is the isotropic hardening.";
39
40 options.set<CrossRef<Scalar>>("yield_stress");
41 options.set("yield_stress").doc() = "Yield stress";
42
43 options.set<VariableName>("effective_stress") = VariableName("state", "internal", "s");
44 options.set("effective_stress").doc() = "Effective stress";
45
46 options.set<VariableName>("isotropic_hardening");
47 options.set("isotropic_hardening").doc() = "Isotropic hardening";
48
49 options.set<VariableName>("yield_function") = VariableName("state", "internal", "fp");
50 options.set("yield_function").doc() = "Yield function";
51
52 return options;
53}
54
56 : Model(options),
57 _s(declare_input_variable<Scalar>("effective_stress")),
58 _h(options.get<VariableName>("isotropic_hardening").empty()
59 ? nullptr
60 : &declare_input_variable<Scalar>("isotropic_hardening")),
61 _f(declare_output_variable<Scalar>("yield_function")),
62 _sy(declare_parameter<Scalar>("sy", "yield_stress"))
63{
64}
65
66void
68{
69 if (out)
70 {
71 if (_h)
72 _f = std::sqrt(2.0 / 3.0) * (_s - _sy - (*_h));
73 else
74 _f = std::sqrt(2.0 / 3.0) * (_s - _sy);
75 }
76
77 if (dout_din)
78 {
80
81 _f.d(_s) = std::sqrt(2.0 / 3.0) * I;
82
83 if (_h)
84 _f.d(*_h) = -std::sqrt(2.0 / 3.0) * I;
85
86 if (const auto sy = nl_param("sy"))
87 _f.d(*sy) = -std::sqrt(2.0 / 3.0) * I;
88 }
89
90 if (d2out_din2)
91 {
92 // zero
93 }
94}
95} // namespace neml2
The wrapper (decorator) for cross-referencing unresolved values at parse time.
Definition CrossRef.h:52
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:33
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
static Scalar identity_map(const torch::TensorOptions &options=default_tensor_options())
The derivative of a Scalar with respect to itself.
Definition Scalar.cxx:35
Derivative d(const VariableBase &x)
Create a wrapper representing the derivative dy/dx.
Definition Variable.cxx:102
Definition YieldFunction.h:32
Variable< Scalar > & _f
Yield function.
Definition YieldFunction.h:49
const Scalar & _sy
Yield stress.
Definition YieldFunction.h:52
const Variable< Scalar > * _h
(Optional) Isotropic hardening
Definition YieldFunction.h:46
YieldFunction(const OptionSet &options)
Definition YieldFunction.cxx:55
const Variable< Scalar > & _s
Effective stress.
Definition YieldFunction.h:43
static OptionSet expected_options()
Definition YieldFunction.cxx:32
void set_value(bool out, bool dout_din, bool d2out_din2) override
The value of the yield function.
Definition YieldFunction.cxx:67
Definition CrossRef.cxx:32
LabeledAxisAccessor VariableName
Definition Variable.h:35