NEML2 1.4.0
Loading...
Searching...
No Matches
LinearIsotropicElasticity.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/LinearIsotropicElasticity.h"
26#include "neml2/tensors/SSR4.h"
27
28namespace neml2
29{
30register_NEML2_object(LinearIsotropicElasticity);
31
34{
36 options.doc() += " for linear isotropic material. \\f$ \\boldsymbol{\\sigma} = K \\tr "
37 "\\boldsymbol{\\varepsilon}_e + 2 G \\text{dev} \\boldsymbol{\\varepsilon}_e "
38 "\\f$, where \\f$ K \\f$ and \\f$ G \\f$ are bulk and shear moduli, "
39 "respectively. For convenience, this object only requests Young's modulus and "
40 "Poisson's ratio, and handles the Lame parameter conversion behind the scenes.";
41
42 options.set<CrossRef<Scalar>>("youngs_modulus");
43 options.set("youngs_modulus").doc() = "Young's modulus";
44
45 options.set<CrossRef<Scalar>>("poisson_ratio");
46 options.set("poisson_ratio").doc() = "Poisson's ratio";
47
48 return options;
49}
50
52 : Elasticity(options),
53 _E(declare_parameter<Scalar>("E", "youngs_modulus")),
54 _nu(declare_parameter<Scalar>("nu", "poisson_ratio"))
55{
56}
57
58void
59LinearIsotropicElasticity::set_value(bool out, bool dout_din, bool /*d2out_din2*/)
60{
61 // We need to work with the bulk modulus K and the shear modulus G so that the expression for
62 // stiffness and compliance can be unified:
63 const auto K = _E / 3 / (1 - 2 * _nu);
64 const auto G = _E / 2 / (1 + _nu);
65 const auto vf = _compliance ? 1 / (3 * K) : 3 * K;
66 const auto df = _compliance ? 1 / (2 * G) : 2 * G;
67
68 if (out)
69 _to = vf * SR2(_from).vol() + df * SR2(_from).dev();
70
71 if (dout_din)
72 {
73 const auto I = SSR4::identity_vol(options());
74 const auto J = SSR4::identity_dev(options());
75 _to.d(_from) = vf * I + df * J;
76 }
77}
78} // namespace neml2
The wrapper (decorator) for cross-referencing unresolved values at parse time.
Definition CrossRef.h:52
Definition Elasticity.h:33
const bool _compliance
Definition Elasticity.h:44
const Variable< SR2 > & _from
Definition Elasticity.h:59
Variable< SR2 > & _to
Definition Elasticity.h:65
static OptionSet expected_options()
Definition Elasticity.cxx:30
Definition LinearIsotropicElasticity.h:32
const Scalar & _nu
Poisson's ratio.
Definition LinearIsotropicElasticity.h:45
const Scalar & _E
Young's modulus.
Definition LinearIsotropicElasticity.h:42
static OptionSet expected_options()
Definition LinearIsotropicElasticity.cxx:33
LinearIsotropicElasticity(const OptionSet &options)
Definition LinearIsotropicElasticity.cxx:51
void set_value(bool out, bool dout_din, bool d2out_din2) override
The map between input -> output, and optionally its derivatives.
Definition LinearIsotropicElasticity.cxx:59
const torch::TensorOptions & options() const
This model's tensor options.
Definition Model.h:116
A custom map-like data structure. The keys are strings, and the values can be nonhomogeneously typed.
Definition OptionSet.h:59
The (logical) symmetric second order tensor.
Definition SR2.h:46
SR2 dev() const
Deviatoric part of the tensor.
Definition SR2.cxx:167
SR2 vol() const
Volumetric part of the tensor.
Definition SR2.cxx:161
static SSR4 identity_dev(const torch::TensorOptions &options=default_tensor_options())
Create the deviatoric identity tensor .
Definition SSR4.cxx:70
static SSR4 identity_vol(const torch::TensorOptions &options=default_tensor_options())
Create the volumetric identity tensor .
Definition SSR4.cxx:64
The (logical) scalar.
Definition Scalar.h:38
Definition CrossRef.cxx:32