LCOV - code coverage report
Current view: top level - src/materials/crystal_plasticity - ComputeCrystalPlasticityVolumetricEigenstrain.C (source / functions) Hit Total Coverage
Test: idaholab/moose tensor_mechanics: d6b47a Lines: 32 33 97.0 %
Date: 2024-02-27 11:53:14 Functions: 4 4 100.0 %
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             : #include "ComputeCrystalPlasticityVolumetricEigenstrain.h"
      11             : 
      12             : registerMooseObject("TensorMechanicsApp", ComputeCrystalPlasticityVolumetricEigenstrain);
      13             : 
      14             : InputParameters
      15          44 : ComputeCrystalPlasticityVolumetricEigenstrain::validParams()
      16             : {
      17          44 :   InputParameters params = ComputeCrystalPlasticityEigenstrainBase::validParams();
      18          44 :   params.addClassDescription("Computes the deformation gradient from the volumetric eigenstrain "
      19             :                              "due to spherical voids in a crystal plasticity simulation");
      20          88 :   params.addRequiredParam<MaterialPropertyName>(
      21             :       "spherical_void_number_density",
      22             :       "The material property name of the number density of the spherical voids, in 1/mm^3.");
      23          88 :   params.addRequiredParam<MaterialPropertyName>(
      24             :       "mean_spherical_void_radius",
      25             :       "The material property name for the mean radius value, in mm, for the spherical voids");
      26             : 
      27          44 :   return params;
      28           0 : }
      29             : 
      30          33 : ComputeCrystalPlasticityVolumetricEigenstrain::ComputeCrystalPlasticityVolumetricEigenstrain(
      31          33 :     const InputParameters & parameters)
      32             :   : DerivativeMaterialInterface<ComputeCrystalPlasticityEigenstrainBase>(parameters),
      33          33 :     _void_density(getMaterialProperty<Real>("spherical_void_number_density")),
      34          66 :     _void_density_old(getMaterialPropertyOld<Real>("spherical_void_number_density")),
      35          66 :     _void_radius(getMaterialProperty<Real>("mean_spherical_void_radius")),
      36          66 :     _void_radius_old(getMaterialPropertyOld<Real>("mean_spherical_void_radius")),
      37          66 :     _equivalent_linear_change(declareProperty<Real>("equivalent_linear_change"))
      38             : {
      39          33 : }
      40             : 
      41             : void
      42      133530 : ComputeCrystalPlasticityVolumetricEigenstrain::computeQpDeformationGradient()
      43             : {
      44             :   // check that the values of the radius and the density are both positive
      45      133530 :   if (_void_radius[_qp] < 0.0)
      46           5 :     mooseException("A negative mean spherical void radius value, ",
      47             :                    _void_radius[_qp],
      48             :                    ", has been provided; this value is "
      49             :                    "non-physical and violates the assumptions of this eigenstrain class");
      50      133525 :   if (_void_density[_qp] < 0.0)
      51           5 :     mooseException(
      52             :         "A negative, non-physical spherical void number density has been provided: ",
      53             :         _void_density[_qp],
      54             :         ". This value is non-physical and violates the assumptions of this eigenstrain class");
      55             : 
      56             :   // compute the linear commponent of the current and old volume due to the voids
      57      133520 :   _equivalent_linear_change[_qp] =
      58      133520 :       computeLinearComponentVolume(_void_radius[_qp], _void_density[_qp]);
      59             :   Real previous_linear =
      60      133520 :       computeLinearComponentVolume(_void_radius_old[_qp], _void_density_old[_qp]);
      61             : 
      62      133520 :   const Real linear_increment = _equivalent_linear_change[_qp] - previous_linear;
      63             : 
      64             :   // scale by the ratio of the substep to full time step for consistency
      65             :   // in cases where substepping is used
      66      133520 :   RankTwoTensor eigenstrain = RankTwoTensor::Identity() * linear_increment * _substep_dt / _dt;
      67             : 
      68             :   // Rotate the eigenstrain for the crystal deformation gradient with Euler angles
      69             :   RankTwoTensor residual_equivalent_volumetric_expansion_increment =
      70      267040 :       RankTwoTensor::Identity() - eigenstrain.rotated(_crysrot[_qp]);
      71             : 
      72      133520 :   _deformation_gradient[_qp] =
      73      133520 :       residual_equivalent_volumetric_expansion_increment.inverse() * _deformation_gradient_old[_qp];
      74      133520 : }
      75             : 
      76             : Real
      77      267040 : ComputeCrystalPlasticityVolumetricEigenstrain::computeLinearComponentVolume(const Real & radius,
      78             :                                                                             const Real & density)
      79             : {
      80             :   const Real cb_radius = Utility::pow<3>(radius);
      81      267040 :   const Real volume = 4.0 * (libMesh::pi)*cb_radius * density / 3.0;
      82      267040 :   const Real linear_component = std::cbrt(volume);
      83             : 
      84      267040 :   return linear_component;
      85             : }

Generated by: LCOV version 1.14