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/SwellingAndPhaseChangeDeformationJacobian.h"
26 : #include "neml2/tensors/Scalar.h"
27 :
28 : namespace neml2
29 : {
30 : register_NEML2_object(SwellingAndPhaseChangeDeformationJacobian);
31 :
32 : OptionSet
33 2 : SwellingAndPhaseChangeDeformationJacobian::expected_options()
34 : {
35 2 : OptionSet options = Model::expected_options();
36 2 : options.doc() =
37 : "Define the linear isotropic phase change deformation Jacobian for a freezing liquid or a "
38 : "melting solid, i.e. \\f$ J = \\left( 1 + \\alpha c \\phi^f + (1-c) \\phi^f \\Delta \\Omega "
39 : "\\right) \\f$, where \\f$ \\alpha \\f$ is the coefficient of swelling, \\f$ \\Delta \\Omega "
40 : "\\f$ is relative difference of the reference volume between the two phases, \\f$ \\phi^f "
41 : "\\f$ "
42 2 : "is the fluid fraction associated with swelling, and \\f$ c \\f$ is the phase fraction.";
43 :
44 6 : options.set_input("fluid_fraction") = VariableName(STATE, "phi_f");
45 4 : options.set("fluid_fraction").doc() = "Volume fraction of the fluid phase.";
46 :
47 4 : options.set_parameter<TensorName<Scalar>>("phase_fraction");
48 6 : options.set("phase_fraction").doc() =
49 2 : "Phase fraction during the phase change. 0 means all solid, 1 means all liquid.";
50 :
51 4 : options.set_parameter<TensorName<Scalar>>("swelling_coefficient");
52 4 : options.set("swelling_coefficient").doc() = "Coefficient of phase expansion";
53 :
54 4 : options.set_parameter<TensorName<Scalar>>("reference_volume_difference");
55 4 : options.set("reference_volume_difference").doc() =
56 2 : "Relative difference between the reference volumes of the two phases.";
57 :
58 6 : options.set<VariableName>("jacobian") = VariableName(STATE, "J");
59 2 : options.set("jacobian").doc() = "Phase change deformation Jacobian";
60 :
61 2 : return options;
62 0 : }
63 :
64 1 : SwellingAndPhaseChangeDeformationJacobian::SwellingAndPhaseChangeDeformationJacobian(
65 1 : const OptionSet & options)
66 : : Model(options),
67 1 : _vf(declare_input_variable<Scalar>("fluid_fraction")),
68 4 : _c(declare_parameter<Scalar>("c", "phase_fraction", /*allow_nonlinear=*/true)),
69 4 : _alpha(declare_parameter<Scalar>("alpha", "swelling_coefficient")),
70 4 : _dOmega(declare_parameter<Scalar>("dOmega", "reference_volume_difference")),
71 2 : _J(declare_output_variable<Scalar>("jacobian"))
72 : {
73 1 : }
74 :
75 : void
76 2 : SwellingAndPhaseChangeDeformationJacobian::set_value(bool out, bool dout_din, bool /*d2out_din2*/)
77 : {
78 2 : if (out)
79 2 : _J = (1.0 + _alpha * _c * _vf + (1 - _c) * _vf * _dOmega);
80 :
81 2 : if (dout_din)
82 : {
83 1 : if (_vf.is_dependent())
84 1 : _J.d(_vf) = (_alpha * _c + (1 - _c) * _dOmega);
85 :
86 3 : if (const auto * const c = nl_param("c"))
87 1 : _J.d(*c) = (_alpha * _vf - _vf * _dOmega);
88 : }
89 2 : }
90 : } // namespace neml2
|