LCOV - code coverage report
Current view: top level - include/materials/crystal_plasticity - CrystalPlasticityStressUpdateBase.h (source / functions) Hit Total Coverage
Test: idaholab/moose tensor_mechanics: d6b47a Lines: 2 9 22.2 %
Date: 2024-02-27 11:53:14 Functions: 2 9 22.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://www.mooseframework.org
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #pragma once
      11             : 
      12             : #include "Material.h"
      13             : #include "RankTwoTensor.h"
      14             : #include "RankFourTensor.h"
      15             : #include "DelimitedFileReader.h"
      16             : 
      17             : class CrystalPlasticityStressUpdateBase : public Material
      18             : {
      19             : public:
      20             :   static InputParameters validParams();
      21             : 
      22             :   CrystalPlasticityStressUpdateBase(const InputParameters & parameters);
      23             : 
      24             :   /// Sets the value of the global variable _qp for inheriting classes
      25             :   void setQp(const unsigned int & qp);
      26             : 
      27             :   /// Sets the value of the _substep_dt for inheriting classes
      28             :   void setSubstepDt(const Real & substep_dt);
      29             : 
      30             :   ///@{ Retained as empty methods to avoid a warning from Material.C in framework. These methods are unused in all inheriting classes and should not be overwritten.
      31           0 :   virtual void resetQpProperties() final {}
      32      112974 :   virtual void resetProperties() final {}
      33             :   ///@}
      34             : 
      35             :   /**
      36             :    * initializes the stateful properties such as PK2 stress, resolved shear
      37             :    * stress, plastic deformation gradient, slip system resistances, etc.
      38             :    * This class is often overwritten by inherting classes.
      39             :    */
      40             :   virtual void initQpStatefulProperties() override;
      41             : 
      42             :   /**
      43             :    * A helper method to read in plane normal and direction vectors from a file
      44             :    * and to normalize the vectors. This method is abstracted to allow for reuse
      45             :    * in inheriting classes with multiple plane normal and direction vector pairs.
      46             :    */
      47             :   virtual void getSlipSystems();
      48             : 
      49             :   /**
      50             :    * A helper method to transform the Miller-Bravais 4-index notation for HCP
      51             :    * crystals into a a 3-index Cartesian representation, using the convention
      52             :    * a$_1$ = x of axis alignment in the basal plane
      53             :    */
      54             :   void transformHexagonalMillerBravaisSlipSystems(const MooseUtils::DelimitedFileReader & reader);
      55             : 
      56             :   /**
      57             :    * Computes the Schmid tensor (m x n) for the original (reference) crystal
      58             :    * lattice orientation for each glide slip system
      59             :    */
      60             :   void calculateFlowDirection(const RankTwoTensor & crysrot);
      61             : 
      62             :   /**
      63             :    * Computes the shear stess for each slip system
      64             :    */
      65             :   void calculateShearStress(const RankTwoTensor & pk2,
      66             :                             const RankTwoTensor & inverse_eigenstrain_deformation_grad,
      67             :                             const unsigned int & num_eigenstrains);
      68             : 
      69             :   /**
      70             :    * Calculates the total value of $\frac{d\mathbf{F}^P^{-1}}{d\mathbf{PK2}}$ and
      71             :    * is intended to be an overwritten helper method for inheriting classes with
      72             :    * multiple constitutive dislocation slip mechanisms, e.g. glide and twinning,
      73             :    * $\sum_i \frac{d\mathbf{F}^P^{-1}}{d\mathbf{PK2}_i}$
      74             :    */
      75             :   virtual void calculateTotalPlasticDeformationGradientDerivative(
      76             :       RankFourTensor & dfpinvdpk2,
      77             :       const RankTwoTensor & inverse_plastic_deformation_grad_old,
      78             :       const RankTwoTensor & inverse_eigenstrain_deformation_grad_old,
      79             :       const unsigned int & num_eigenstrains);
      80             : 
      81             :   /**
      82             :    * A helper method to rotate the a direction and plane normal system set into
      83             :    * the local crystal llatice orientation as defined by the crystal rotation
      84             :    * tensor from the Elasticity tensor class.
      85             :    */
      86             :   void calculateSchmidTensor(const unsigned int & number_dislocation_systems,
      87             :                              const std::vector<RealVectorValue> & plane_normal_vector,
      88             :                              const std::vector<RealVectorValue> & direction_vector,
      89             :                              std::vector<RankTwoTensor> & schmid_tensor,
      90             :                              const RankTwoTensor & crysrot);
      91             : 
      92             :   /**
      93             :    * A helper method to sort the slip systems of a crystal into cross slip families based
      94             :    * on common slip directions.  This method determines if slip directions are parallel,
      95             :    * and stores the index of the slip systems from getSlipSystems (the same index is used
      96             :    * for the applied shear stress and the internal state variables) in a vector of vectors,
      97             :    * where the outer vector separates the individual slip system families and the inner vector
      98             :    * stories the indices of the slip systems within a single family.  This vector of vectors
      99             :    * can then be used in the inheriting classes to calculate cross slip interactions.
     100             :    * The values of number_cross_slip_directions and number_cross_slip_planes must be set to
     101             :    * use this sorting method.
     102             :    */
     103             :   void sortCrossSlipFamilies();
     104             : 
     105             :   /**
     106             :    * A helper method for inherting classes to identify to which cross slip family vector
     107             :    * a particular slip system index belongs after the slip systems have been sorted. Returns
     108             :    * the integer value of the identified cross slip system family for the outer vector
     109             :    * created in sortCrossSlipFamilies.
     110             :    */
     111             :   unsigned int identifyCrossSlipFamily(const unsigned int index);
     112             : 
     113             :   /**
     114             :    * This virtual method is called to set the constitutive internal state variables
     115             :    * current value and the previous substep value to the old property value for
     116             :    * the start of the stress convergence while loop.
     117             :    */
     118           0 :   virtual void setInitialConstitutiveVariableValues() {}
     119             : 
     120             :   /**
     121             :    * This virtual method is called to set the current constitutive internal state
     122             :    * variable value to that of the previous substep at the beginning of the next
     123             :    * substep increment. In cases where only one substep is taken (or when the first)
     124             :    * substep is taken, this method sets the current constitutive internal state
     125             :    * variable value to the old value.
     126             :    */
     127           0 :   virtual void setSubstepConstitutiveVariableValues() {}
     128             : 
     129             :   /**
     130             :    * Stores the current value of the constitutive internal state variables into
     131             :    * a separate material property in case substepping is required, once the
     132             :    * constitutive variables have passed convergence tolerances. This separate
     133             :    * material property is used as the previous substep value in the associated
     134             :    * setSubstepConstitutiveVariableValues method in the next substep (if taken).
     135             :    */
     136           0 :   virtual void updateSubstepConstitutiveVariableValues() {}
     137             : 
     138             :   /**
     139             :    * This virtual method is called to calculate the slip system slip
     140             :    * increment based on the constitutive model defined in the child class.
     141             :    * This method must be overwritten in the child class.
     142             :    */
     143             :   virtual bool calculateSlipRate() = 0;
     144             : 
     145             :   virtual void calculateEquivalentSlipIncrement(RankTwoTensor & /*equivalent_slip_increment*/);
     146             : 
     147             :   /**
     148             :    * This virtual method is called to find the derivative of the slip increment
     149             :    * with respect to the applied shear stress on the slip system based on the
     150             :    * constiutive model defined in the child class.  This method must be overwritten
     151             :    * in the child class.
     152             :    */
     153             :   virtual void calculateConstitutiveSlipDerivative(std::vector<Real> & /*dslip_dtau*/) = 0;
     154             : 
     155             :   /**
     156             :    * Finalizes the values of the state variables and slip system resistance
     157             :    * for the current timestep after convergence has been reached.
     158             :    */
     159             : 
     160           0 :   virtual void cacheStateVariablesBeforeUpdate() {}
     161             : 
     162           0 :   virtual void calculateStateVariableEvolutionRateComponent() {}
     163             : 
     164             :   /**
     165             :    * Finalizes the values of the state variables and slip system resistance
     166             :    * for the current timestep after convergence has been reached.
     167             :    */
     168             :   virtual bool updateStateVariables() = 0;
     169             : 
     170     1907107 :   virtual void calculateSlipResistance() {}
     171             : 
     172             :   /**
     173             :    * Determines if all the state variables have converged
     174             :    */
     175           0 :   virtual bool areConstitutiveStateVariablesConverged() { return true; }
     176             : 
     177             :   /**
     178             :    * Check if a typical state variable, e.g. defect density, has converged
     179             :    * by comparing the change in the values over the iteration period.
     180             :    */
     181             :   virtual bool isConstitutiveStateVariableConverged(const std::vector<Real> & current_var,
     182             :                                                     const std::vector<Real> & var_before_update,
     183             :                                                     const std::vector<Real> & previous_substep_var,
     184             :                                                     const Real & tolerance);
     185             : 
     186             : protected:
     187             :   /// Base name prepended to all material property names to allow for
     188             :   /// multi-material systems
     189             :   const std::string _base_name;
     190             : 
     191             :   const enum class CrystalLatticeType { BCC, FCC, HCP } _crystal_lattice_type;
     192             : 
     193             :   const std::vector<Real> _unit_cell_dimension;
     194             : 
     195             :   ///Maximum number of active slip systems for the crystalline material being modeled
     196             :   const unsigned int _number_slip_systems;
     197             : 
     198             :   /// File should contain slip plane normal and direction.
     199             :   std::string _slip_sys_file_name;
     200             : 
     201             :   /// @{Parameters to characterize the cross slip behavior of the crystal
     202             :   const Real _number_cross_slip_directions;
     203             :   const Real _number_cross_slip_planes;
     204             :   ///@}
     205             : 
     206             :   /// Internal variable update equation tolerance
     207             :   Real _rel_state_var_tol;
     208             :   /// Slip increment tolerance
     209             :   Real _slip_incr_tol;
     210             :   /// Tolerance for change in slip system resistance over an increment
     211             :   Real _resistance_tol;
     212             :   /// Residual tolerance when variable value is zero. Default 1e-12.
     213             :   Real _zero_tol;
     214             : 
     215             :   ///@{Slip system resistance
     216             :   MaterialProperty<std::vector<Real>> & _slip_resistance;
     217             :   const MaterialProperty<std::vector<Real>> & _slip_resistance_old;
     218             :   ///@}
     219             : 
     220             :   /// Current slip increment material property
     221             :   MaterialProperty<std::vector<Real>> & _slip_increment;
     222             : 
     223             :   ///@{Slip system direction and normal and associated Schmid tensors
     224             :   std::vector<RealVectorValue> _slip_direction;
     225             :   std::vector<RealVectorValue> _slip_plane_normal;
     226             :   MaterialProperty<std::vector<RankTwoTensor>> & _flow_direction;
     227             :   ///@}
     228             : 
     229             :   /// Resolved shear stress on each slip system
     230             :   MaterialProperty<std::vector<Real>> & _tau;
     231             : 
     232             :   /// Flag to print to console warning messages on stress, constitutive model convergence
     233             :   const bool _print_convergence_message;
     234             : 
     235             :   /// Substepping time step value used within the inheriting constitutive models
     236             :   Real _substep_dt;
     237             : 
     238             :   /// Sorted slip system indices into cross slip family groups
     239             :   std::vector<std::vector<unsigned int>> _cross_slip_familes;
     240             : 
     241             :   /// Flag to run the cross slip calculations if cross slip numbers are specified
     242             :   bool _calculate_cross_slip;
     243             : };

Generated by: LCOV version 1.14