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/porous_flow/AdvectiveStress.h"
26 : #include "neml2/tensors/Scalar.h"
27 : #include "neml2/tensors/R2.h"
28 : #include "neml2/tensors/functions/pow.h"
29 :
30 : namespace neml2
31 : {
32 : register_NEML2_object(AdvectiveStress);
33 : OptionSet
34 2 : AdvectiveStress::expected_options()
35 : {
36 2 : OptionSet options = Model::expected_options();
37 2 : options.doc() =
38 : "Calculate the advective stress, \\f$ p_s \\f$, taking the form of \\f$ p_s = \\frac{c}{3J} "
39 : "P_{ij}F_{ij} \\f$. Here, \\f$ J, P, F \\f$ are the the deformation gradient Jacobian, the "
40 : "1st Piola-Kirchhoff stress and the defomration gradient. \\f$ c \\f$ is the volume change "
41 2 : "coefficient.";
42 :
43 4 : options.set_parameter<TensorName<Scalar>>("coefficient");
44 4 : options.set("coefficient").doc() = "Coefficient c";
45 :
46 4 : options.set_input("js");
47 6 : options.set("js").doc() =
48 2 : "The Jacobian of the deformation gradient associated with the swelling and phase change";
49 :
50 4 : options.set_input("jt");
51 4 : options.set("jt").doc() =
52 2 : "The Jacobian of the deformation gradient associated with the thermal and volume expansion";
53 :
54 6 : options.set_input("deformation_gradient") = VariableName(FORCES, "F");
55 2 : options.set("deformation_gradient").doc() = "The deformation gradient";
56 :
57 6 : options.set_input("pk1_stress") = VariableName(STATE, "P");
58 2 : options.set("pk1_stress").doc() = "1st Piola-Kirchhoff stress";
59 :
60 6 : options.set_output("advective_stress") = VariableName(STATE, "advective_stress");
61 2 : options.set("advective_stress").doc() = "The average advective stress";
62 :
63 2 : return options;
64 0 : }
65 :
66 1 : AdvectiveStress::AdvectiveStress(const OptionSet & options)
67 : : Model(options),
68 4 : _coeff(declare_parameter<Scalar>("coeff", "coefficient")),
69 2 : _Js(options.get("js").user_specified() ? &declare_input_variable<Scalar>("js") : nullptr),
70 1 : _Jt(options.get("jt").user_specified() ? &declare_input_variable<Scalar>("jt") : nullptr),
71 1 : _P(declare_input_variable<R2>("pk1_stress")),
72 1 : _F(declare_input_variable<R2>("deformation_gradient")),
73 2 : _ps(declare_output_variable<Scalar>("advective_stress"))
74 : {
75 1 : }
76 :
77 : void
78 2 : AdvectiveStress::set_value(bool out, bool dout_din, bool /*d2out_din2*/)
79 : {
80 2 : Scalar Js = _Js ? _Js->value() : Scalar::full(1.0, _P.options());
81 2 : Scalar Jt = _Jt ? _Jt->value() : Scalar::full(1.0, _P.options());
82 :
83 2 : if (out)
84 : {
85 2 : _ps = -_coeff / 3.0 * pow(Js, -5.0 / 3.0) * pow(Jt, -2.0 / 3.0) * R2(_P).inner(R2(_F));
86 : }
87 :
88 2 : if (dout_din)
89 : {
90 1 : const auto I = R2::identity(_P.options());
91 :
92 1 : if (_Js && _Js->is_dependent())
93 4 : _ps.d(*_Js) = 5.0 / 3.0 * _coeff / 3.0 * pow(Js, -8.0 / 3.0) * pow(Jt, -2.0 / 3.0) *
94 5 : R2(_P).inner(R2(_F));
95 :
96 1 : if (_Jt && _Jt->is_dependent())
97 4 : _ps.d(*_Jt) = 2.0 / 3.0 * _coeff / 3.0 * pow(Js, -5.0 / 3.0) * pow(Jt, -5.0 / 3.0) *
98 5 : R2(_P).inner(R2(_F));
99 :
100 1 : if (_P.is_dependent())
101 1 : _ps.d(_P) = -_coeff / 3.0 * pow(Js, -5.0 / 3.0) * pow(Jt, -2.0 / 3.0) * _F;
102 :
103 1 : if (_F.is_dependent())
104 1 : _ps.d(_F) = -_coeff / 3.0 * pow(Js, -5.0 / 3.0) * pow(Jt, -2.0 / 3.0) * _P;
105 1 : }
106 2 : }
107 : } // namespace neml2
|