NEML2 1.4.0
Loading...
Searching...
No Matches
WR2ExplicitExponentialTimeIntegration.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/WR2ExplicitExponentialTimeIntegration.h"
26#include "neml2/tensors/tensors.h"
27
28namespace neml2
29{
31
34{
36 options.doc() = "Perform explicit discrete exponential time integration of a rotation. The "
37 "update can be written as \\f$ s = \\exp\\left[ (t-t_n)\\dot{s}\\right] \\circ "
38 "s_n \\f$, where \\f$ \\circ \\f$ denotes the rotation operator.";
39
40 options.set<VariableName>("variable");
41 options.set("variable").doc() = "Variable being integrated";
42
43 options.set<VariableName>("time") = VariableName("t");
44 options.set("time").doc() = "Time";
45
46 return options;
47}
48
50 const OptionSet & options)
51 : Model(options),
52 _var_name(options.get<VariableName>("variable")),
53 _var_rate_name(_var_name.with_suffix("_rate")),
54 _s(declare_output_variable<Rot>(_var_name.on("state"))),
55 _s_dot(declare_input_variable<WR2>(_var_rate_name.on("state"))),
56 _sn(declare_input_variable<Rot>(_var_name.on("old_state"))),
57 _t(declare_input_variable<Scalar>(options.get<VariableName>("time").on("forces"))),
58 _tn(declare_input_variable<Scalar>(options.get<VariableName>("time").on("old_forces")))
59{
60}
61
62void
64{
65 neml_assert_dbg(!d2out_din2, "Second derivative not implemented.");
66
67 const auto dt = _t - _tn;
68
69 // Incremental rotation
70 const auto inc = (_s_dot * dt).exp();
71
72 if (out)
73 _s = Rot(_sn).rotate(inc);
74
75 if (dout_din)
76 {
77 const auto de = (_s_dot * dt).dexp();
78 _s.d(_s_dot) = Rot(_sn).drotate(inc) * de * dt;
80 {
82 _s.d(_t) = Rot(_sn).drotate(inc) * de * Vec(_s_dot.value());
83 _s.d(_tn) = -Rot(_sn).drotate(inc) * de * Vec(_s_dot.value());
84 }
85 }
86}
87
88} // 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
@ UPDATING
Definition Model.h:188
static OptionSet expected_options()
Definition Model.cxx:33
static enum neml2::Model::Stage stage
Definition Model.cxx:30
A custom map-like data structure. The keys are strings, and the values can be nonhomogeneously typed.
Definition OptionSet.h:59
Rotation stored as modified Rodrigues parameters.
Definition Rot.h:49
Rot rotate(const Rot &r) const
Rotate.
Definition Rot.cxx:81
R2 drotate_self(const Rot &r) const
Derivative of the rotated Rodrigues vector w.r.t. this vector.
Definition Rot.cxx:103
R2 drotate(const Rot &r) const
Derivative of the rotated Rodrigues vector w.r.t. the other Rodrigues vector.
Definition Rot.cxx:87
The (logical) scalar.
Definition Scalar.h:38
The (logical) vector.
Definition Vec.h:42
Explicit exponential time integration for rotations.
Definition WR2ExplicitExponentialTimeIntegration.h:34
const Variable< WR2 > & _s_dot
Current variable spin rate.
Definition WR2ExplicitExponentialTimeIntegration.h:55
Variable< Rot > & _s
Current value.
Definition WR2ExplicitExponentialTimeIntegration.h:52
const Variable< Scalar > & _t
Current time.
Definition WR2ExplicitExponentialTimeIntegration.h:61
WR2ExplicitExponentialTimeIntegration(const OptionSet &options)
Definition WR2ExplicitExponentialTimeIntegration.cxx:49
const Variable< Scalar > & _tn
Previous time.
Definition WR2ExplicitExponentialTimeIntegration.h:64
static OptionSet expected_options()
Definition WR2ExplicitExponentialTimeIntegration.cxx:33
const Variable< Rot > & _sn
Previous value.
Definition WR2ExplicitExponentialTimeIntegration.h:58
void set_value(bool out, bool dout_din, bool d2out_din2) override
Perform the time integration to update the variable value.
Definition WR2ExplicitExponentialTimeIntegration.cxx:63
A skew rank 2, represented as an axial vector.
Definition WR2.h:43
Definition CrossRef.cxx:32
void neml_assert_dbg(bool assertion, Args &&... args)
Definition error.h:85
LabeledAxisAccessor VariableName
Definition Variable.h:35