25#include "neml2/models/SR2Invariant.h"
26#include "neml2/tensors/SSR4.h"
36 options.doc() =
"Calculate the invariant of a symmetric second order tensor (of type SR2).";
39 options.set(
"tensor").doc() =
"SR2 which is used to calculate the invariant of";
42 options.set(
"invariant").doc() =
"Invariant";
44 options.set<std::string>(
"invariant_type");
45 options.set(
"invariant_type").doc() =
"Type of invariant. Options are I1, I2, and VONMISES.";
52 _type(options.get<std::
string>(
"invariant_type")),
53 _A(declare_input_variable<
SR2>(
"tensor")),
54 _invariant(declare_output_variable<
Scalar>(
"invariant"))
74 else if (
_type ==
"I2")
77 _invariant = (A.tr() * A.tr() - A.inner(A)) / 2.0;
91 else if (
_type ==
"VONMISES")
94 Scalar vm = std::sqrt(3.0 / 2.0) *
S.norm(NEML2_EPS);
111 else if (
_type ==
"EFFECTIVE_STRAIN")
113 Scalar r = std::sqrt(2.0 / 3.0) * A.norm(NEML2_EPS);
120 auto d = 2.0 / 3.0 * A /
r;
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
Definition SR2Invariant.h:32
SR2Invariant(const OptionSet &options)
Definition SR2Invariant.cxx:50
const Variable< SR2 > & _A
Input second order tensor.
Definition SR2Invariant.h:44
const std::string _type
Definition SR2Invariant.h:41
Variable< Scalar > & _invariant
Invariant of the input tensor.
Definition SR2Invariant.h:47
static OptionSet expected_options()
Definition SR2Invariant.cxx:33
void set_value(bool out, bool dout_din, bool d2out_din2) override
The map between input -> output, and optionally its derivatives.
Definition SR2Invariant.cxx:59
The (logical) symmetric second order tensor.
Definition SR2.h:46
static SR2 identity(const torch::TensorOptions &options=default_tensor_options())
Identity.
Definition SR2.cxx:110
static SSR4 identity_dev(const torch::TensorOptions &options=default_tensor_options())
Create the deviatoric identity tensor .
Definition SSR4.cxx:70
static SSR4 identity(const torch::TensorOptions &options=default_tensor_options())
Create the identity tensor .
Definition SSR4.cxx:45
static SSR4 identity_sym(const torch::TensorOptions &options=default_tensor_options())
Create the symmetric identity tensor .
Definition SSR4.cxx:58
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