Line data Source code
1 : // Copyright 2024, 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/elasticity/CubicElasticityConverter.h"
26 :
27 : namespace neml2
28 : {
29 : const CubicElasticityConverter::ConversionTableType CubicElasticityConverter::table = {
30 : {{ElasticConstant::SHEAR_MODULUS,
31 : ElasticConstant::YOUNGS_MODULUS,
32 : ElasticConstant::POISSONS_RATIO},
33 : {&CubicElasticityConverter::G_E_nu_to_C1,
34 : &CubicElasticityConverter::G_E_nu_to_C2,
35 : &CubicElasticityConverter::G_E_nu_to_C3}},
36 : };
37 :
38 : CubicElasticityConverter::ConversionType
39 4 : CubicElasticityConverter::G_E_nu_to_C1(const InputType & input, const DerivativeFlagType & deriv)
40 : {
41 4 : const auto & G = input[0];
42 4 : const auto & E = input[1];
43 4 : const auto & nu = input[2];
44 :
45 4 : const auto C1 = E / ((1 + nu) * (1 - 2 * nu)) * (1 - nu);
46 4 : const auto dC1_dG = deriv[0] ? Scalar::zeros(G.options()) : Scalar();
47 4 : const auto dC1_dE = deriv[1] ? C1 / E : Scalar();
48 12 : const auto dC1_dnu = deriv[2] ? (-2.0 * (nu - 2.0) * nu * E) /
49 8 : ((2.0 * nu * nu + nu - 1) * (2.0 * nu * nu + nu - 1))
50 12 : : Scalar();
51 :
52 8 : return {C1, {dC1_dG, dC1_dE, dC1_dnu}};
53 8 : }
54 :
55 : CubicElasticityConverter::ConversionType
56 4 : CubicElasticityConverter::G_E_nu_to_C2(const InputType & input, const DerivativeFlagType & deriv)
57 : {
58 4 : const auto & G = input[0];
59 4 : const auto & E = input[1];
60 4 : const auto & nu = input[2];
61 :
62 4 : const auto C2 = E / ((1 + nu) * (1 - 2 * nu)) * nu;
63 4 : const auto dC2_dG = deriv[0] ? Scalar::zeros(G.options()) : Scalar();
64 4 : const auto dC2_dE = deriv[1] ? C2 / E : Scalar();
65 : const auto dC2_dnu =
66 16 : deriv[2] ? (2 * nu * nu * E + E) / ((2.0 * nu * nu + nu - 1) * (2.0 * nu * nu + nu - 1))
67 12 : : Scalar();
68 :
69 8 : return {C2, {dC2_dG, dC2_dE, dC2_dnu}};
70 8 : }
71 :
72 : CubicElasticityConverter::ConversionType
73 4 : CubicElasticityConverter::G_E_nu_to_C3(const InputType & input, const DerivativeFlagType & deriv)
74 : {
75 4 : const auto & G = input[0];
76 4 : const auto & E = input[1];
77 4 : const auto & nu = input[2];
78 :
79 4 : const auto C3 = 2.0 * G;
80 4 : const auto dC3_dG = deriv[0] ? Scalar::full(2.0, G.options()) : Scalar();
81 4 : const auto dC3_dE = deriv[1] ? Scalar::zeros(E.options()) : Scalar();
82 4 : const auto dC3_dnu = deriv[2] ? Scalar::zeros(nu.options()) : Scalar();
83 :
84 8 : return {C3, {dC3_dG, dC3_dE, dC3_dnu}};
85 8 : }
86 :
87 : } // namespace neml2
|