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/PerzynaPlasticFlowRate.h"
26 : #include "neml2/tensors/Scalar.h"
27 : #include "neml2/tensors/functions/heaviside.h"
28 : #include "neml2/tensors/functions/abs.h"
29 : #include "neml2/tensors/functions/pow.h"
30 : #include "neml2/tensors/functions/log.h"
31 :
32 : namespace neml2
33 : {
34 : register_NEML2_object(PerzynaPlasticFlowRate);
35 :
36 : OptionSet
37 2 : PerzynaPlasticFlowRate::expected_options()
38 : {
39 2 : OptionSet options = PlasticFlowRate::expected_options();
40 2 : options.doc() =
41 : "Perzyna's viscous approximation of the consistent yield envelope (with a power "
42 : "law), i.e. \\f$ \\dot{\\gamma} = \\left( \\frac{\\left< f \\right>}{\\eta} \\right)^n \\f$, "
43 : "where \\f$ f \\f$ is the yield function, \\f$ \\eta \\f$ is the reference stress, and \\f$ "
44 2 : "n \\f$ is the power-law exponent.";
45 :
46 4 : options.set_parameter<TensorName<Scalar>>("reference_stress");
47 4 : options.set("reference_stress").doc() = "Reference stress";
48 :
49 4 : options.set_parameter<TensorName<Scalar>>("exponent");
50 2 : options.set("exponent").doc() = "Power-law exponent";
51 :
52 2 : return options;
53 0 : }
54 :
55 5 : PerzynaPlasticFlowRate::PerzynaPlasticFlowRate(const OptionSet & options)
56 : : PlasticFlowRate(options),
57 15 : _eta(declare_parameter<Scalar>("eta", "reference_stress", /*allow_nonlinear=*/true)),
58 25 : _n(declare_parameter<Scalar>("n", "exponent", /*allow_nonlinear=*/true))
59 : {
60 5 : }
61 :
62 : void
63 10 : PerzynaPlasticFlowRate::set_value(bool out, bool dout_din, bool /*d2out_din2*/)
64 : {
65 : // Compute the Perzyna approximation of the yield surface
66 10 : auto Hf = heaviside(Scalar(_f));
67 10 : auto f_abs = abs(Scalar(_f));
68 10 : auto gamma_dot_m = pow(f_abs / _eta, _n);
69 10 : auto gamma_dot = gamma_dot_m * Hf;
70 :
71 10 : if (out)
72 9 : _gamma_dot = gamma_dot;
73 :
74 10 : if (dout_din)
75 : {
76 5 : auto dgamma_dot_df = _n / f_abs * gamma_dot;
77 :
78 5 : if (_f.is_dependent())
79 5 : _gamma_dot.d(_f) = dgamma_dot_df;
80 :
81 15 : if (const auto * const eta = nl_param("eta"))
82 1 : _gamma_dot.d(*eta) = -_n * gamma_dot / _eta;
83 :
84 15 : if (const auto * const n = nl_param("n"))
85 1 : _gamma_dot.d(*n) = gamma_dot * log(f_abs / _eta);
86 5 : }
87 10 : }
88 : } // namespace neml2
|