LCOV - code coverage report
Current view: top level - src/materials/crystal_plasticity - ComputeCrystalPlasticityVolumetricEigenstrain.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 32 33 97.0 %
Date: 2025-07-25 05:00:39 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://mooseframework.inl.gov
       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("SolidMechanicsApp", ComputeCrystalPlasticityVolumetricEigenstrain);
      13             : 
      14             : InputParameters
      15         112 : ComputeCrystalPlasticityVolumetricEigenstrain::validParams()
      16             : {
      17         112 :   InputParameters params = ComputeCrystalPlasticityEigenstrainBase::validParams();
      18         112 :   params.addClassDescription("Computes the deformation gradient from the volumetric eigenstrain "
      19             :                              "due to spherical voids in a crystal plasticity simulation");
      20         224 :   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         224 :   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         112 :   return params;
      28           0 : }
      29             : 
      30          84 : ComputeCrystalPlasticityVolumetricEigenstrain::ComputeCrystalPlasticityVolumetricEigenstrain(
      31          84 :     const InputParameters & parameters)
      32             :   : DerivativeMaterialInterface<ComputeCrystalPlasticityEigenstrainBase>(parameters),
      33          84 :     _void_density(getMaterialProperty<Real>("spherical_void_number_density")),
      34         168 :     _void_density_old(getMaterialPropertyOld<Real>("spherical_void_number_density")),
      35         168 :     _void_radius(getMaterialProperty<Real>("mean_spherical_void_radius")),
      36         168 :     _void_radius_old(getMaterialPropertyOld<Real>("mean_spherical_void_radius")),
      37         168 :     _equivalent_linear_change(declareProperty<Real>("equivalent_linear_change"))
      38             : {
      39          84 : }
      40             : 
      41             : void
      42      285844 : ComputeCrystalPlasticityVolumetricEigenstrain::computeQpDeformationGradient()
      43             : {
      44             :   // check that the values of the radius and the density are both positive
      45      285844 :   if (_void_radius[_qp] < 0.0)
      46          10 :     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      285834 :   if (_void_density[_qp] < 0.0)
      51          10 :     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      285824 :   _equivalent_linear_change[_qp] =
      58      285824 :       computeLinearComponentVolume(_void_radius[_qp], _void_density[_qp]);
      59             :   Real previous_linear =
      60      285824 :       computeLinearComponentVolume(_void_radius_old[_qp], _void_density_old[_qp]);
      61             : 
      62      285824 :   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      285824 :   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      571648 :       RankTwoTensor::Identity() - eigenstrain.rotated(_crysrot[_qp]);
      71             : 
      72      285824 :   _deformation_gradient[_qp] =
      73      285824 :       residual_equivalent_volumetric_expansion_increment.inverse() * _deformation_gradient_old[_qp];
      74      285824 : }
      75             : 
      76             : Real
      77      571648 : ComputeCrystalPlasticityVolumetricEigenstrain::computeLinearComponentVolume(const Real & radius,
      78             :                                                                             const Real & density)
      79             : {
      80             :   const Real cb_radius = Utility::pow<3>(radius);
      81      571648 :   const Real volume = 4.0 * (libMesh::pi)*cb_radius * density / 3.0;
      82      571648 :   const Real linear_component = std::cbrt(volume);
      83             : 
      84      571648 :   return linear_component;
      85             : }

Generated by: LCOV version 1.14