LCOV - code coverage report
Current view: top level - models/solid_mechanics/crystal_plasticity - VoceSingleSlipHardeningRule.cxx (source / functions) Coverage Total Hit
Test: coverage.info Lines: 96.4 % 28 27
Test Date: 2025-10-02 16:03:03 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/crystal_plasticity/VoceSingleSlipHardeningRule.h"
      26              : #include "neml2/tensors/Scalar.h"
      27              : 
      28              : namespace neml2
      29              : {
      30              : register_NEML2_object(VoceSingleSlipHardeningRule);
      31              : 
      32              : OptionSet
      33            2 : VoceSingleSlipHardeningRule::expected_options()
      34              : {
      35            2 :   OptionSet options = SingleSlipHardeningRule::expected_options();
      36            2 :   options.doc() = "Voce hardening for a SingleSlipStrength type model defined by \\f$ \\dot{\\tau} "
      37              :                   "= \\theta_0 \\left( 1 - \\frac{\\tau}{\\tau_f} \\right) "
      38              :                   "\\sum_{i=1}^{n_{slip}} \\left| \\dot{\\gamma}_i \\right| \\f$ where \\f$ "
      39              :                   "\\theta_0 \\f$ is the initial rate of work hardening, \\f$ \\tau_f \\f$ is the "
      40              :                   "saturated, maximum value of the slip system strength, and \\f$ \\dot{\\gamma}_i "
      41            2 :                   "\\f$ is the slip rate on each system.";
      42              : 
      43            4 :   options.set_parameter<TensorName<Scalar>>("initial_slope");
      44            4 :   options.set("initial_slope").doc() = "The initial rate of hardening";
      45            4 :   options.set_parameter<TensorName<Scalar>>("saturated_hardening");
      46            4 :   options.set("saturated_hardening").doc() =
      47            2 :       "The final, saturated value of the slip system strength";
      48            2 :   return options;
      49            0 : }
      50              : 
      51            3 : VoceSingleSlipHardeningRule::VoceSingleSlipHardeningRule(const OptionSet & options)
      52              :   : SingleSlipHardeningRule(options),
      53            9 :     _theta_0(declare_parameter<Scalar>("initial_slope", "initial_slope", true)),
      54           15 :     _tau_f(declare_parameter<Scalar>("saturated_hardening", "saturated_hardening", true))
      55              : {
      56            3 : }
      57              : 
      58              : void
      59            6 : VoceSingleSlipHardeningRule::set_value(bool out, bool dout_din, bool /*d2out_din2*/)
      60              : {
      61            6 :   if (out)
      62            5 :     _tau_dot = _theta_0 * (1 - _tau / _tau_f) * _gamma_dot_sum;
      63              : 
      64            6 :   if (dout_din)
      65              :   {
      66            3 :     if (_tau.is_dependent())
      67            3 :       _tau_dot.d(_tau) = -_theta_0 / _tau_f * _gamma_dot_sum;
      68              : 
      69            3 :     if (_gamma_dot_sum.is_dependent())
      70            3 :       _tau_dot.d(_gamma_dot_sum) = _theta_0 * (1 - _tau / _tau_f);
      71              : 
      72            9 :     if (const auto * const theta_0 = nl_param("initial_slope"))
      73            1 :       _tau_dot.d(*theta_0) = (1 - _tau / _tau_f) * _gamma_dot_sum;
      74              : 
      75            9 :     if (const auto * const tau_f = nl_param("saturated_hardening"))
      76            1 :       _tau_dot.d(*tau_f) = _theta_0 * _tau / (_tau_f * _tau_f) * _gamma_dot_sum;
      77              :   }
      78            6 : }
      79              : } // namespace neml2
        

Generated by: LCOV version 2.0-1