DAMASK_EICMD/src/homogenization_mechanical.f90

248 lines
11 KiB
Fortran
Raw Normal View History

2020-12-16 15:51:24 +05:30
!--------------------------------------------------------------------------------------------------
!> @author Martin Diehl, KU Leuven
!> @brief Partition F and homogenize P/dPdF
!--------------------------------------------------------------------------------------------------
2021-02-13 23:27:41 +05:30
submodule(homogenization) mechanical
2020-12-16 15:51:24 +05:30
2020-12-23 18:33:15 +05:30
2020-12-16 15:51:24 +05:30
interface
2021-02-09 03:51:53 +05:30
module subroutine mechanical_pass_init
end subroutine mechanical_pass_init
2020-12-16 15:51:24 +05:30
2021-02-09 03:51:53 +05:30
module subroutine mechanical_isostrain_init
end subroutine mechanical_isostrain_init
2020-12-16 15:51:24 +05:30
2021-02-09 03:51:53 +05:30
module subroutine mechanical_RGC_init(num_homogMech)
2020-12-16 15:51:24 +05:30
class(tNode), pointer, intent(in) :: &
num_homogMech !< pointer to mechanical homogenization numerics data
2021-02-09 03:51:53 +05:30
end subroutine mechanical_RGC_init
2020-12-16 15:51:24 +05:30
2021-02-09 03:51:53 +05:30
module subroutine mechanical_isostrain_partitionDeformation(F,avgF)
2020-12-16 15:51:24 +05:30
real(pReal), dimension (:,:,:), intent(out) :: F !< partitioned deformation gradient
real(pReal), dimension (3,3), intent(in) :: avgF !< average deformation gradient at material point
2021-02-09 03:51:53 +05:30
end subroutine mechanical_isostrain_partitionDeformation
2020-12-16 15:51:24 +05:30
2021-02-15 23:13:51 +05:30
module subroutine mechanical_RGC_partitionDeformation(F,avgF,ce)
2020-12-16 15:51:24 +05:30
real(pReal), dimension (:,:,:), intent(out) :: F !< partitioned deformation gradient
real(pReal), dimension (3,3), intent(in) :: avgF !< average deformation gradient at material point
integer, intent(in) :: &
2021-02-15 23:13:51 +05:30
ce
2021-02-09 03:51:53 +05:30
end subroutine mechanical_RGC_partitionDeformation
2020-12-16 15:51:24 +05:30
module subroutine mechanical_isostrain_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,ho)
2020-12-16 15:51:24 +05:30
real(pReal), dimension (3,3), intent(out) :: avgP !< average stress at material point
real(pReal), dimension (3,3,3,3), intent(out) :: dAvgPdAvgF !< average stiffness at material point
real(pReal), dimension (:,:,:), intent(in) :: P !< partitioned stresses
real(pReal), dimension (:,:,:,:,:), intent(in) :: dPdF !< partitioned stiffnesses
integer, intent(in) :: ho
2021-02-09 03:51:53 +05:30
end subroutine mechanical_isostrain_averageStressAndItsTangent
2020-12-16 15:51:24 +05:30
module subroutine mechanical_RGC_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,ho)
2020-12-16 15:51:24 +05:30
real(pReal), dimension (3,3), intent(out) :: avgP !< average stress at material point
real(pReal), dimension (3,3,3,3), intent(out) :: dAvgPdAvgF !< average stiffness at material point
real(pReal), dimension (:,:,:), intent(in) :: P !< partitioned stresses
real(pReal), dimension (:,:,:,:,:), intent(in) :: dPdF !< partitioned stiffnesses
integer, intent(in) :: ho
2021-02-09 03:51:53 +05:30
end subroutine mechanical_RGC_averageStressAndItsTangent
2020-12-16 15:51:24 +05:30
2021-02-22 20:47:32 +05:30
module function mechanical_RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHappy)
2020-12-28 14:25:54 +05:30
logical, dimension(2) :: doneAndHappy
real(pReal), dimension(:,:,:), intent(in) :: &
P,& !< partitioned stresses
F !< partitioned deformation gradients
2020-12-28 14:25:54 +05:30
real(pReal), dimension(:,:,:,:,:), intent(in) :: dPdF !< partitioned stiffnesses
real(pReal), dimension(3,3), intent(in) :: avgF !< average F
real(pReal), intent(in) :: dt !< time increment
integer, intent(in) :: &
2021-02-22 20:47:32 +05:30
ce !< cell
2021-02-09 03:51:53 +05:30
end function mechanical_RGC_updateState
2020-12-28 14:25:54 +05:30
module subroutine mechanical_RGC_results(ho,group)
integer, intent(in) :: ho !< homogenization type
2020-12-16 15:51:24 +05:30
character(len=*), intent(in) :: group !< group name in HDF5 file
2021-02-09 03:51:53 +05:30
end subroutine mechanical_RGC_results
2020-12-16 15:51:24 +05:30
end interface
contains
!--------------------------------------------------------------------------------------------------
!> @brief Allocate variables and set parameters.
!--------------------------------------------------------------------------------------------------
2021-02-09 03:51:53 +05:30
module subroutine mechanical_init(num_homog)
2020-12-16 15:51:24 +05:30
class(tNode), pointer, intent(in) :: &
num_homog
class(tNode), pointer :: &
num_homogMech
2021-02-13 23:27:41 +05:30
print'(/,a)', ' <<<+- homogenization:mechanical init -+>>>'
2020-12-16 15:51:24 +05:30
allocate(homogenization_dPdF(3,3,3,3,discretization_nIPs*discretization_Nelems), source=0.0_pReal)
homogenization_F0 = spread(math_I3,3,discretization_nIPs*discretization_Nelems) ! initialize to identity
homogenization_F = homogenization_F0 ! initialize to identity
allocate(homogenization_P(3,3,discretization_nIPs*discretization_Nelems), source=0.0_pReal)
2020-12-16 15:51:24 +05:30
num_homogMech => num_homog%get('mech',defaultVal=emptyDict)
2021-02-09 03:51:53 +05:30
if (any(homogenization_type == HOMOGENIZATION_NONE_ID)) call mechanical_pass_init
if (any(homogenization_type == HOMOGENIZATION_ISOSTRAIN_ID)) call mechanical_isostrain_init
if (any(homogenization_type == HOMOGENIZATION_RGC_ID)) call mechanical_RGC_init(num_homogMech)
2020-12-16 15:51:24 +05:30
2021-02-09 03:51:53 +05:30
end subroutine mechanical_init
2020-12-16 15:51:24 +05:30
!--------------------------------------------------------------------------------------------------
!> @brief Partition F onto the individual constituents.
!--------------------------------------------------------------------------------------------------
2021-02-15 23:13:51 +05:30
module subroutine mechanical_partition(subF,ce)
2020-12-16 15:51:24 +05:30
real(pReal), intent(in), dimension(3,3) :: &
subF
integer, intent(in) :: &
2021-02-15 23:13:51 +05:30
ce
2020-12-30 15:33:13 +05:30
2020-12-29 16:55:03 +05:30
integer :: co
2021-02-15 23:13:51 +05:30
real(pReal), dimension (3,3,homogenization_Nconstituents(material_homogenizationAt2(ce))) :: Fs
2020-12-29 16:55:03 +05:30
2020-12-16 15:51:24 +05:30
2021-02-15 23:13:51 +05:30
chosenHomogenization: select case(homogenization_type(material_homogenizationAt2(ce)))
2020-12-16 15:51:24 +05:30
case (HOMOGENIZATION_NONE_ID) chosenHomogenization
2020-12-31 12:16:26 +05:30
Fs(1:3,1:3,1) = subF
2020-12-16 15:51:24 +05:30
case (HOMOGENIZATION_ISOSTRAIN_ID) chosenHomogenization
2021-02-09 03:51:53 +05:30
call mechanical_isostrain_partitionDeformation(Fs,subF)
2020-12-16 15:51:24 +05:30
case (HOMOGENIZATION_RGC_ID) chosenHomogenization
2021-02-15 23:13:51 +05:30
call mechanical_RGC_partitionDeformation(Fs,subF,ce)
2020-12-16 15:51:24 +05:30
end select chosenHomogenization
2021-02-15 23:13:51 +05:30
do co = 1,homogenization_Nconstituents(material_homogenizationAt2(ce))
call phase_mechanical_setF(Fs(1:3,1:3,co),co,ce)
2020-12-29 16:55:03 +05:30
enddo
2021-02-09 03:51:53 +05:30
end subroutine mechanical_partition
2020-12-16 15:51:24 +05:30
!--------------------------------------------------------------------------------------------------
!> @brief Average P and dPdF from the individual constituents.
!--------------------------------------------------------------------------------------------------
2021-02-26 02:12:40 +05:30
module subroutine mechanical_homogenize(dt,ce)
2020-12-16 15:51:24 +05:30
real(pReal), intent(in) :: dt
2021-02-26 02:12:40 +05:30
integer, intent(in) :: ce
2021-02-26 02:12:40 +05:30
integer :: co
real(pReal) :: dPdFs(3,3,3,3,homogenization_Nconstituents(material_homogenizationAt2(ce)))
real(pReal) :: Ps(3,3,homogenization_Nconstituents(material_homogenizationAt2(ce)))
2020-12-16 15:51:24 +05:30
2021-02-26 02:12:40 +05:30
chosenHomogenization: select case(homogenization_type(material_homogenizationAt2(ce)))
2020-12-16 15:51:24 +05:30
case (HOMOGENIZATION_NONE_ID) chosenHomogenization
homogenization_P(1:3,1:3,ce) = phase_mechanical_getP(1,ce)
homogenization_dPdF(1:3,1:3,1:3,1:3,ce) = phase_mechanical_dPdF(dt,1,ce)
2020-12-16 15:51:24 +05:30
case (HOMOGENIZATION_ISOSTRAIN_ID) chosenHomogenization
2021-02-26 02:12:40 +05:30
do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce))
dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(dt,co,ce)
Ps(:,:,co) = phase_mechanical_getP(co,ce)
2020-12-16 15:51:24 +05:30
enddo
2021-02-09 03:51:53 +05:30
call mechanical_isostrain_averageStressAndItsTangent(&
2020-12-27 14:17:20 +05:30
homogenization_P(1:3,1:3,ce), &
homogenization_dPdF(1:3,1:3,1:3,1:3,ce),&
2020-12-30 15:33:13 +05:30
Ps,dPdFs, &
2021-02-26 02:12:40 +05:30
material_homogenizationAt2(ce))
2020-12-16 15:51:24 +05:30
case (HOMOGENIZATION_RGC_ID) chosenHomogenization
2021-02-26 02:12:40 +05:30
do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce))
dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(dt,co,ce)
Ps(:,:,co) = phase_mechanical_getP(co,ce)
2020-12-16 15:51:24 +05:30
enddo
2021-02-09 03:51:53 +05:30
call mechanical_RGC_averageStressAndItsTangent(&
2020-12-27 14:17:20 +05:30
homogenization_P(1:3,1:3,ce), &
homogenization_dPdF(1:3,1:3,1:3,1:3,ce),&
2020-12-30 15:33:13 +05:30
Ps,dPdFs, &
2021-02-26 02:12:40 +05:30
material_homogenizationAt2(ce))
2020-12-16 15:51:24 +05:30
end select chosenHomogenization
2021-02-09 03:51:53 +05:30
end subroutine mechanical_homogenize
2020-12-16 15:51:24 +05:30
2020-12-28 14:25:54 +05:30
!--------------------------------------------------------------------------------------------------
!> @brief update the internal state of the homogenization scheme and tell whether "done" and
!> "happy" with result
!--------------------------------------------------------------------------------------------------
module function mechanical_updateState(subdt,subF,ce) result(doneAndHappy)
2020-12-28 14:25:54 +05:30
real(pReal), intent(in) :: &
subdt !< current time step
real(pReal), intent(in), dimension(3,3) :: &
subF
integer, intent(in) :: &
ce
2020-12-28 14:25:54 +05:30
logical, dimension(2) :: doneAndHappy
integer :: co
2021-02-22 20:47:32 +05:30
real(pReal) :: dPdFs(3,3,3,3,homogenization_Nconstituents(material_homogenizationAt2(ce)))
real(pReal) :: Fs(3,3,homogenization_Nconstituents(material_homogenizationAt2(ce)))
real(pReal) :: Ps(3,3,homogenization_Nconstituents(material_homogenizationAt2(ce)))
2020-12-28 14:25:54 +05:30
2021-02-22 20:47:32 +05:30
if (homogenization_type(material_homogenizationAt2(ce)) == HOMOGENIZATION_RGC_ID) then
do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce))
dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(subdt,co,ce)
Fs(:,:,co) = phase_mechanical_getF(co,ce)
Ps(:,:,co) = phase_mechanical_getP(co,ce)
2020-12-28 14:25:54 +05:30
enddo
2021-02-22 20:47:32 +05:30
doneAndHappy = mechanical_RGC_updateState(Ps,Fs,subF,subdt,dPdFs,ce)
2020-12-28 14:25:54 +05:30
else
doneAndHappy = .true.
endif
2021-02-09 03:51:53 +05:30
end function mechanical_updateState
2020-12-28 14:25:54 +05:30
2020-12-16 15:51:24 +05:30
!--------------------------------------------------------------------------------------------------
!> @brief Write results to file.
!--------------------------------------------------------------------------------------------------
module subroutine mechanical_results(group_base,ho)
2020-12-16 15:51:24 +05:30
character(len=*), intent(in) :: group_base
integer, intent(in) :: ho
2020-12-16 15:51:24 +05:30
character(len=:), allocatable :: group
2021-03-25 23:52:59 +05:30
group = trim(group_base)//'/mechanical'
2020-12-16 15:51:24 +05:30
call results_closeGroup(results_addGroup(group))
select case(homogenization_type(ho))
2020-12-16 15:51:24 +05:30
case(HOMOGENIZATION_rgc_ID)
call mechanical_RGC_results(ho,group)
2020-12-16 15:51:24 +05:30
end select
!temp = reshape(homogenization_F,[3,3,discretization_nIPs*discretization_Nelems])
!call results_writeDataset(group,temp,'F',&
! 'deformation gradient','1')
!temp = reshape(homogenization_P,[3,3,discretization_nIPs*discretization_Nelems])
!call results_writeDataset(group,temp,'P',&
! '1st Piola-Kirchhoff stress','Pa')
2021-02-09 03:51:53 +05:30
end subroutine mechanical_results
2020-12-16 15:51:24 +05:30
2021-02-13 23:27:41 +05:30
end submodule mechanical