DAMASK_EICMD/src/homogenization_mechanical.f90

250 lines
10 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
module subroutine pass_init
end subroutine pass_init
2020-12-16 15:51:24 +05:30
module subroutine isostrain_init
end subroutine isostrain_init
2020-12-16 15:51:24 +05:30
module subroutine 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
end subroutine RGC_init
2020-12-16 15:51:24 +05:30
module subroutine 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
end subroutine isostrain_partitionDeformation
2020-12-16 15:51:24 +05:30
module subroutine 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
end subroutine RGC_partitionDeformation
2020-12-16 15:51:24 +05:30
module function 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
end function RGC_updateState
2020-12-28 14:25:54 +05:30
module subroutine 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
end subroutine RGC_results
2020-12-16 15:51:24 +05:30
end interface
2021-04-08 00:09:11 +05:30
integer(kind(HOMOGENIZATION_undefined_ID)), dimension(:), allocatable :: &
homogenization_type !< type of each homogenization
2020-12-16 15:51:24 +05:30
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
2021-04-07 15:18:04 +05:30
call material_parseHomogenization2()
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)
if (any(homogenization_type == HOMOGENIZATION_NONE_ID)) call pass_init
if (any(homogenization_type == HOMOGENIZATION_ISOSTRAIN_ID)) call isostrain_init
if (any(homogenization_type == HOMOGENIZATION_RGC_ID)) call 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-04-06 15:08:44 +05:30
real(pReal), dimension (3,3,homogenization_Nconstituents(material_homogenizationID(ce))) :: Fs
2020-12-29 16:55:03 +05:30
2020-12-16 15:51:24 +05:30
2021-04-06 15:08:44 +05:30
chosenHomogenization: select case(homogenization_type(material_homogenizationID(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
call isostrain_partitionDeformation(Fs,subF)
2020-12-16 15:51:24 +05:30
case (HOMOGENIZATION_RGC_ID) chosenHomogenization
call RGC_partitionDeformation(Fs,subF,ce)
2020-12-16 15:51:24 +05:30
end select chosenHomogenization
2021-04-06 15:08:44 +05:30
do co = 1,homogenization_Nconstituents(material_homogenizationID(ce))
2021-04-08 00:36:29 +05:30
call phase_set_F(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-07-17 15:20:21 +05:30
module subroutine mechanical_homogenize(Delta_t,ce)
2020-12-16 15:51:24 +05:30
2021-07-17 15:20:21 +05:30
real(pReal), intent(in) :: Delta_t
2021-02-26 02:12:40 +05:30
integer, intent(in) :: ce
2021-02-26 02:12:40 +05:30
integer :: co
2020-12-16 15:51:24 +05:30
2021-04-11 15:48:26 +05:30
homogenization_P(1:3,1:3,ce) = phase_P(1,ce)
2021-07-17 15:20:21 +05:30
homogenization_dPdF(1:3,1:3,1:3,1:3,ce) = phase_mechanical_dPdF(Delta_t,1,ce)
2021-04-11 15:48:26 +05:30
do co = 2, homogenization_Nconstituents(material_homogenizationID(ce))
homogenization_P(1:3,1:3,ce) = homogenization_P(1:3,1:3,ce) &
+ phase_P(co,ce)
homogenization_dPdF(1:3,1:3,1:3,1:3,ce) = homogenization_dPdF(1:3,1:3,1:3,1:3,ce) &
2021-07-17 15:20:21 +05:30
+ phase_mechanical_dPdF(Delta_t,co,ce)
2021-04-11 15:48:26 +05:30
enddo
2020-12-16 15:51:24 +05:30
2021-04-11 15:48:26 +05:30
homogenization_P(1:3,1:3,ce) = homogenization_P(1:3,1:3,ce) &
/ real(homogenization_Nconstituents(material_homogenizationID(ce)),pReal)
homogenization_dPdF(1:3,1:3,1:3,1:3,ce) = homogenization_dPdF(1:3,1:3,1:3,1:3,ce) &
/ real(homogenization_Nconstituents(material_homogenizationID(ce)),pReal)
2020-12-16 15:51:24 +05:30
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-04-06 15:08:44 +05:30
real(pReal) :: dPdFs(3,3,3,3,homogenization_Nconstituents(material_homogenizationID(ce)))
real(pReal) :: Fs(3,3,homogenization_Nconstituents(material_homogenizationID(ce)))
real(pReal) :: Ps(3,3,homogenization_Nconstituents(material_homogenizationID(ce)))
2020-12-28 14:25:54 +05:30
2021-04-06 15:08:44 +05:30
if (homogenization_type(material_homogenizationID(ce)) == HOMOGENIZATION_RGC_ID) then
do co = 1, homogenization_Nconstituents(material_homogenizationID(ce))
dPdFs(:,:,:,:,co) = phase_mechanical_dPdF(subdt,co,ce)
2021-04-08 00:36:29 +05:30
Fs(:,:,co) = phase_F(co,ce)
Ps(:,:,co) = phase_P(co,ce)
2020-12-28 14:25:54 +05:30
enddo
doneAndHappy = 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 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-04-07 15:18:04 +05:30
!--------------------------------------------------------------------------------------------------
!> @brief parses the homogenization part from the material configuration
!--------------------------------------------------------------------------------------------------
subroutine material_parseHomogenization2()
class(tNode), pointer :: &
material_homogenization, &
homog, &
homogMech
integer :: h
material_homogenization => config_material%get('homogenization')
allocate(homogenization_type(size(material_name_homogenization)), source=HOMOGENIZATION_undefined_ID)
do h=1, size(material_name_homogenization)
homog => material_homogenization%get(h)
homogMech => homog%get('mechanical')
select case (homogMech%get_asString('type'))
case('pass')
homogenization_type(h) = HOMOGENIZATION_NONE_ID
case('isostrain')
homogenization_type(h) = HOMOGENIZATION_ISOSTRAIN_ID
case('RGC')
homogenization_type(h) = HOMOGENIZATION_RGC_ID
case default
call IO_error(500,ext_msg=homogMech%get_asString('type'))
end select
enddo
end subroutine material_parseHomogenization2
2021-02-13 23:27:41 +05:30
end submodule mechanical