LCOV - code coverage report
Current view: top level - models/solid_mechanics - ChabochePlasticHardening.cxx (source / functions) Coverage Total Hit
Test: coverage.info Lines: 97.5 % 40 39
Test Date: 2025-06-29 01:25:44 Functions: 100.0 % 3 3

            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/ChabochePlasticHardening.h"
      26              : #include "neml2/tensors/Scalar.h"
      27              : #include "neml2/tensors/SR2.h"
      28              : #include "neml2/tensors/SSR4.h"
      29              : #include "neml2/tensors/functions/pow.h"
      30              : #include "neml2/tensors/functions/log.h"
      31              : 
      32              : namespace neml2
      33              : {
      34              : register_NEML2_object(ChabochePlasticHardening);
      35              : 
      36              : OptionSet
      37            2 : ChabochePlasticHardening::expected_options()
      38              : {
      39            2 :   OptionSet options = FredrickArmstrongPlasticHardening::expected_options();
      40            2 :   options.doc() +=
      41              :       " The complete Chaboche model adds static recovery terms \\f$ - A \\lVert \\boldsymbol{X} "
      42              :       "\\rVert^{a - 1} \\boldsymbol{X} \\f$, so the model includes kinematic hardening, dynamic "
      43              :       "recovery, and static recovery.  \\f$ A \\f$ and \\f$ a \\f$ are additional material "
      44            2 :       "parameters.";
      45              : 
      46            4 :   options.set_parameter<TensorName<Scalar>>("A");
      47            4 :   options.set("A").doc() = "Static recovery prefactor";
      48              : 
      49            4 :   options.set_parameter<TensorName<Scalar>>("a");
      50            2 :   options.set("a").doc() = "Static recovery exponent";
      51              : 
      52            2 :   return options;
      53            0 : }
      54              : 
      55            4 : ChabochePlasticHardening::ChabochePlasticHardening(const OptionSet & options)
      56              :   : FredrickArmstrongPlasticHardening(options),
      57           12 :     _A(declare_parameter<Scalar>("A", "A", true)),
      58           20 :     _a(declare_parameter<Scalar>("a", "a", true))
      59              : {
      60            4 : }
      61              : 
      62              : void
      63            8 : ChabochePlasticHardening::set_value(bool out, bool dout_din, bool /*d2out_din2*/)
      64              : {
      65            8 :   auto eps = machine_precision(_X.scalar_type());
      66              :   // The effective stress
      67            8 :   auto s = SR2(_X).norm(eps);
      68              :   // The part that's proportional to the plastic strain rate
      69            8 :   auto g_term = 2.0 / 3.0 * _C * _NM - _g * _X;
      70              :   // The static recovery term
      71            8 :   auto s_term = -_A * pow(s, _a - 1) * _X;
      72              : 
      73            8 :   if (out)
      74            7 :     _X_dot = g_term * _gamma_dot + s_term;
      75              : 
      76            8 :   if (dout_din)
      77              :   {
      78            4 :     auto I = SR2::identity_map(_X.options());
      79              : 
      80            4 :     if (_gamma_dot.is_dependent())
      81            4 :       _X_dot.d(_gamma_dot) = g_term;
      82              : 
      83            4 :     if (_NM.is_dependent())
      84            4 :       _X_dot.d(_NM) = 2.0 / 3.0 * _C * _gamma_dot * I;
      85              : 
      86            4 :     if (_X.is_dependent())
      87           16 :       _X_dot.d(_X) = -_g * _gamma_dot * I -
      88           20 :                      _A * pow(s, _a - 3) * ((_a - 1) * SR2(_X).outer(SR2(_X)) + s * s * I);
      89              : 
      90           12 :     if (const auto * const C = nl_param("C"))
      91            1 :       _X_dot.d(*C) = 2.0 / 3.0 * _NM * _gamma_dot;
      92              : 
      93           12 :     if (const auto * const g = nl_param("g"))
      94            1 :       _X_dot.d(*g) = -_X * _gamma_dot;
      95              : 
      96           12 :     if (const auto * const A = nl_param("A"))
      97            1 :       _X_dot.d(*A) = -pow(s, _a - 1) * _X;
      98              : 
      99           12 :     if (const auto * const a = nl_param("a"))
     100            1 :       _X_dot.d(*a) = -_A * _X * pow(s, _a - 1) * log(s);
     101            4 :   }
     102            8 : }
     103              : 
     104              : } // namespace neml2
        

Generated by: LCOV version 2.0-1