removed now obsolete files from former structure
This commit is contained in:
parent
122760601c
commit
ca1b9787b6
|
@ -1,996 +0,0 @@
|
|||
!##############################################################
|
||||
MODULE CPFEM
|
||||
!##############################################################
|
||||
! *** CPFEM engine ***
|
||||
!
|
||||
use prec, only: pReal,pInt
|
||||
implicit none
|
||||
!
|
||||
! ****************************************************************
|
||||
! *** General variables for the material behaviour calculation ***
|
||||
! ****************************************************************
|
||||
real(pReal), dimension (:,:), allocatable :: CPFEM_Temperature
|
||||
real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_ffn_bar !average FFN per IP
|
||||
real(pReal), dimension (:,:,:,:,:), allocatable :: CPFEM_ffn !individual FFN per grain
|
||||
real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_ffn1_bar !average FFN1 per IP
|
||||
real(pReal), dimension (:,:,:,:,:), allocatable :: CPFEM_ffn1 !individual FFN1 per grain
|
||||
real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_PK1_bar !average PK1 per IP
|
||||
real(pReal), dimension (:,:,:,:,:), allocatable :: CPFEM_PK1 !individual PK1 per grain
|
||||
real(pReal), dimension (:,:,:,:,:,:), allocatable :: CPFEM_dPdF_bar !average dPdF per IP
|
||||
real(pReal), dimension (:,:,:,:,:,:), allocatable :: CPFEM_dPdF_bar_old !old average dPdF per IP
|
||||
real(pReal), dimension (:,:,:,:,:,:,:),allocatable :: CPFEM_dPdF !individual dPdF per grain
|
||||
real(pReal), dimension (:,:,:), allocatable :: CPFEM_stress_bar
|
||||
real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_jaco_bar
|
||||
real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_jaco_knownGood
|
||||
real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_results
|
||||
real(pReal), dimension (:,:,:,:,:), allocatable :: CPFEM_Lp_old
|
||||
real(pReal), dimension (:,:,:,:,:), allocatable :: CPFEM_Lp_new
|
||||
real(pReal), dimension (:,:,:,:,:), allocatable :: CPFEM_Fp_old
|
||||
real(pReal), dimension (:,:,:,:,:), allocatable :: CPFEM_Fp_new
|
||||
real(pReal), dimension (:,:,:,:,:), allocatable :: CPFEM_Fe1
|
||||
real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_Tstar_v
|
||||
real(pReal), parameter :: CPFEM_odd_stress = 1e15_pReal, CPFEM_odd_jacobian = 1e50_pReal
|
||||
integer(pInt) :: CPFEM_Nresults = 4_pInt ! three Euler angles plus volume fraction
|
||||
logical :: CPFEM_init_done = .false. ! remember whether init has been done already
|
||||
logical :: CPFEM_calc_done = .false. ! remember whether first IP has already calced the results
|
||||
!
|
||||
! *** Solution at single crystallite level ***
|
||||
!
|
||||
logical, dimension (:,:,:),allocatable :: crystallite_converged !individual covergence flag per grain
|
||||
!
|
||||
CONTAINS
|
||||
!
|
||||
!*********************************************************
|
||||
!*** allocate the arrays defined in module CPFEM ***
|
||||
!*** and initialize them ***
|
||||
!*********************************************************
|
||||
SUBROUTINE CPFEM_init(Temperature)
|
||||
!
|
||||
use prec
|
||||
use math, only: math_EulertoR, math_I3, math_identity2nd
|
||||
use mesh
|
||||
use constitutive
|
||||
!
|
||||
implicit none
|
||||
!
|
||||
real(pReal) Temperature
|
||||
integer(pInt) e,i,g
|
||||
!
|
||||
! *** mpie.marc parameters ***
|
||||
allocate(CPFEM_Temperature(mesh_maxNips,mesh_NcpElems)) ; CPFEM_Temperature = Temperature
|
||||
allocate(CPFEM_ffn_bar(3,3,mesh_maxNips,mesh_NcpElems))
|
||||
forall(e=1:mesh_NcpElems,i=1:mesh_maxNips) CPFEM_ffn_bar(:,:,i,e) = math_I3
|
||||
allocate(CPFEM_ffn(3,3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems))
|
||||
forall(g=1:constitutive_maxNgrains,e=1:mesh_NcpElems,i=1:mesh_maxNips) CPFEM_ffn(:,:,g,i,e) = math_I3
|
||||
allocate(CPFEM_ffn1_bar(3,3,mesh_maxNips,mesh_NcpElems)) ; CPFEM_ffn1_bar = CPFEM_ffn_bar
|
||||
allocate(CPFEM_ffn1(3,3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; CPFEM_ffn1 = CPFEM_ffn
|
||||
allocate(CPFEM_PK1_bar(3,3,mesh_maxNips,mesh_NcpElems)) ; CPFEM_PK1_bar = 0.0_pReal
|
||||
allocate(CPFEM_PK1(3,3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; CPFEM_PK1 = 0.0_pReal
|
||||
allocate(CPFEM_dPdF_bar(3,3,3,3,mesh_maxNips,mesh_NcpElems)) ; CPFEM_dPdF_bar = 0.0_pReal
|
||||
allocate(CPFEM_dPdF_bar_old(3,3,3,3,mesh_maxNips,mesh_NcpElems)) ; CPFEM_dPdF_bar_old = 0.0_pReal
|
||||
allocate(CPFEM_dPdF(3,3,3,3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; CPFEM_dPdF = 0.0_pReal
|
||||
allocate(CPFEM_stress_bar(6,mesh_maxNips,mesh_NcpElems)) ; CPFEM_stress_bar = 0.0_pReal
|
||||
allocate(CPFEM_jaco_bar(6,6,mesh_maxNips,mesh_NcpElems)) ; CPFEM_jaco_bar = 0.0_pReal
|
||||
allocate(CPFEM_jaco_knownGood(6,6,mesh_maxNips,mesh_NcpElems)) ; CPFEM_jaco_knownGood = 0.0_pReal
|
||||
!
|
||||
! *** User defined results !!! MISSING incorporate consti_Nresults ***
|
||||
allocate(CPFEM_results(CPFEM_Nresults+constitutive_maxNresults,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems))
|
||||
CPFEM_results = 0.0_pReal
|
||||
!
|
||||
! *** Plastic velocity gradient ***
|
||||
allocate(CPFEM_Lp_old(3,3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; CPFEM_Lp_old = 0.0_pReal
|
||||
allocate(CPFEM_Lp_new(3,3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; CPFEM_Lp_new = 0.0_pReal
|
||||
|
||||
! *** Plastic deformation gradient at (t=t0) and (t=t1) ***
|
||||
allocate(CPFEM_Fp_new(3,3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; CPFEM_Fp_new = 0.0_pReal
|
||||
allocate(CPFEM_Fp_old(3,3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems))
|
||||
forall (e=1:mesh_NcpElems,i=1:mesh_maxNips,g=1:constitutive_maxNgrains) &
|
||||
CPFEM_Fp_old(:,:,g,i,e) = math_EulerToR(constitutive_EulerAngles(:,g,i,e)) ! plastic def gradient reflects init orientation
|
||||
! *** Elastic deformation gradient at (t=t1) ***
|
||||
allocate(CPFEM_Fe1(3,3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; CPFEM_Fe1 = 0.0_pReal
|
||||
! *** Stress vector at (t=t1) ***
|
||||
allocate(CPFEM_Tstar_v(6,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; CPFEM_Tstar_v = 0.0_pReal
|
||||
!
|
||||
! *** Output to MARC output file ***
|
||||
!$OMP CRITICAL (write2out)
|
||||
write(6,*)
|
||||
write(6,*) 'CPFEM Initialization'
|
||||
write(6,*)
|
||||
write(6,*) 'CPFEM_Temperature: ', shape(CPFEM_Temperature)
|
||||
write(6,*) 'CPFEM_ffn_bar: ', shape(CPFEM_ffn_bar)
|
||||
write(6,*) 'CPFEM_ffn: ', shape(CPFEM_ffn)
|
||||
write(6,*) 'CPFEM_ffn1_bar: ', shape(CPFEM_ffn1_bar)
|
||||
write(6,*) 'CPFEM_ffn1: ', shape(CPFEM_ffn1)
|
||||
write(6,*) 'CPFEM_PK1_bar: ', shape(CPFEM_PK1_bar)
|
||||
write(6,*) 'CPFEM_PK1: ', shape(CPFEM_PK1)
|
||||
write(6,*) 'CPFEM_dPdF_bar: ', shape(CPFEM_dPdF_bar)
|
||||
write(6,*) 'CPFEM_dPdF_bar_old: ', shape(CPFEM_dPdF_bar_old)
|
||||
write(6,*) 'CPFEM_dPdF: ', shape(CPFEM_dPdF)
|
||||
write(6,*) 'CPFEM_stress_bar: ', shape(CPFEM_stress_bar)
|
||||
write(6,*) 'CPFEM_jaco_bar: ', shape(CPFEM_jaco_bar)
|
||||
write(6,*) 'CPFEM_jaco_knownGood: ', shape(CPFEM_jaco_knownGood)
|
||||
write(6,*) 'CPFEM_results: ', shape(CPFEM_results)
|
||||
write(6,*) 'CPFEM_Lp_old: ', shape(CPFEM_Lp_old)
|
||||
write(6,*) 'CPFEM_Lp_new: ', shape(CPFEM_Lp_new)
|
||||
write(6,*) 'CPFEM_Fp_old: ', shape(CPFEM_Fp_old)
|
||||
write(6,*) 'CPFEM_Fp_new: ', shape(CPFEM_Fp_new)
|
||||
write(6,*) 'CPFEM_Fe1: ', shape(CPFEM_Fe1)
|
||||
write(6,*) 'CPFEM_Tstar_v: ', shape(CPFEM_Tstar_v)
|
||||
write(6,*)
|
||||
call flush(6)
|
||||
!$OMP END CRITICAL (write2out)
|
||||
return
|
||||
!
|
||||
END SUBROUTINE
|
||||
!
|
||||
!
|
||||
!***********************************************************************
|
||||
!*** perform initialization at first call, update variables and ***
|
||||
!*** call the actual material model ***
|
||||
!
|
||||
! CPFEM_mode computation mode (regular, collection, recycle)
|
||||
! ffn deformation gradient for t=t0
|
||||
! ffn1 deformation gradient for t=t1
|
||||
! Temperature temperature
|
||||
! CPFEM_dt time increment
|
||||
! CPFEM_en element number
|
||||
! CPFEM_in intergration point number
|
||||
! CPFEM_stress stress vector in Mandel notation
|
||||
! CPFEM_updateJaco flag to initiate computation of Jacobian
|
||||
! CPFEM_jaco jacobian in Mandel notation
|
||||
! CPFEM_ngens size of stress strain law
|
||||
!***********************************************************************
|
||||
SUBROUTINE CPFEM_general(CPFEM_mode, ffn, ffn1, Temperature, CPFEM_dt,&
|
||||
CPFEM_en, CPFEM_in, CPFEM_stress, CPFEM_updateJaco, CPFEM_jaco, CPFEM_ngens)
|
||||
! note: CPFEM_stress = Cauchy stress cs(6) and CPFEM_jaco = Consistent tangent dcs/de
|
||||
!
|
||||
use prec, only: pReal,pInt
|
||||
use FEsolving
|
||||
use debug
|
||||
use math
|
||||
use mesh, only: mesh_init,mesh_FEasCP, mesh_NcpElems, FE_Nips, FE_mapElemtype, mesh_element
|
||||
use lattice, only: lattice_init
|
||||
use constitutive, only: constitutive_init,constitutive_state_old,constitutive_state_new,material_Cslip_66
|
||||
implicit none
|
||||
!
|
||||
integer(pInt) CPFEM_en, CPFEM_in, cp_en, CPFEM_ngens, i,j,k,l,m,n
|
||||
real(pReal), dimension (3,3) :: ffn,ffn1,Kirchhoff_bar
|
||||
real(pReal), dimension (3,3,3,3) :: H_bar, H_bar_sym
|
||||
real(pReal), dimension(CPFEM_ngens) :: CPFEM_stress
|
||||
real(pReal), dimension(CPFEM_ngens,CPFEM_ngens) :: CPFEM_jaco, odd_jaco
|
||||
real(pReal) Temperature,CPFEM_dt,J_inverse
|
||||
integer(pInt) CPFEM_mode ! 1: regular computation with aged results&
|
||||
! 2: regular computation&
|
||||
! 3: collection of FEM data&
|
||||
! 4: recycling of former results (MARC speciality)&
|
||||
! 5: record tangent from former converged inc&
|
||||
! 6: restore tangent from former converged inc
|
||||
logical CPFEM_updateJaco
|
||||
!
|
||||
if (.not. CPFEM_init_done) then ! initialization step (three dimensional stress state check missing?)
|
||||
call math_init()
|
||||
call mesh_init()
|
||||
call lattice_init()
|
||||
call constitutive_init()
|
||||
call crystallite_init()
|
||||
call CPFEM_init(Temperature)
|
||||
CPFEM_init_done = .true.
|
||||
endif
|
||||
!
|
||||
cp_en = mesh_FEasCP('elem',CPFEM_en)
|
||||
if (cp_en == 1 .and. CPFEM_in == 1) then
|
||||
!$OMP CRITICAL (write2out)
|
||||
write(6,'(a10,1x,f8.4,1x,a10,1x,i4,1x,a10,1x,i3,1x,a10,1x,i2,x,a10,1x,i2)') &
|
||||
'theTime',theTime,'theInc',theInc,'theCycle',theCycle,'theLovl',theLovl,&
|
||||
'mode',CPFEM_mode
|
||||
!$OMP END CRITICAL (write2out)
|
||||
endif
|
||||
!
|
||||
select case (CPFEM_mode)
|
||||
case (2,1) ! regular computation (with aging of results)
|
||||
if (any(abs(ffn1 - CPFEM_ffn1_bar(:,:,CPFEM_in,cp_en)) > relevantStrain)) then
|
||||
CPFEM_stress_bar(1:CPFEM_ngens,:,:) = CPFEM_odd_stress
|
||||
odd_jaco = CPFEM_odd_jacobian*math_identity2nd(CPFEM_ngens)
|
||||
forall (i=1:mesh_NcpElems, j=1:FE_Nips(mesh_element(2,cp_en))) &
|
||||
CPFEM_jaco_bar(1:CPFEM_ngens,1:CPFEM_ngens,j,i) = odd_jaco
|
||||
outdatedFFN1 = .true.
|
||||
if (.not. CPFEM_calc_done .AND.CPFEM_mode == 1) then
|
||||
CPFEM_Lp_old = CPFEM_Lp_new
|
||||
CPFEM_Fp_old = CPFEM_Fp_new
|
||||
constitutive_state_old = constitutive_state_new
|
||||
endif
|
||||
!$OMP CRITICAL (write2out)
|
||||
write(6,*) 'WARNING: FFN1 changed for ip', CPFEM_in, 'of element', cp_en
|
||||
!$OMP END CRITICAL (write2out)
|
||||
return
|
||||
else
|
||||
if (.not. CPFEM_calc_done) then ! puuh, me needs doing all the work...
|
||||
if (CPFEM_mode == 1) then ! age results at start of new increment
|
||||
CPFEM_Lp_old = CPFEM_Lp_new
|
||||
CPFEM_Fp_old = CPFEM_Fp_new
|
||||
constitutive_state_old = constitutive_state_new
|
||||
endif
|
||||
debug_cutbackDistribution = 0_pInt ! initialize debugging data
|
||||
debug_InnerLoopDistribution = 0_pInt
|
||||
debug_OuterLoopDistribution = 0_pInt
|
||||
!
|
||||
!******************************************************************************************************
|
||||
! parallelization moved down to material point and single crystallite
|
||||
!******************************************************************************************************
|
||||
!!$OMP PARALLEL DO
|
||||
! do e=1,mesh_NcpElems ! ## this shall be done in a parallel loop in the future ##
|
||||
! do i=1,FE_Nips(mesh_element(2,e)) ! iterate over all IPs of this element's type
|
||||
! debugger = (e==1 .and. i==1) ! switch on debugging for first IP in first element
|
||||
call CPFEM_MaterialPoint(CPFEM_updateJaco, CPFEM_dt, 0, 0)
|
||||
! enddo
|
||||
! enddo
|
||||
!!$OMP END PARALLEL DO
|
||||
call debug_info() ! output of debugging/performance statistics
|
||||
CPFEM_calc_done = .true. ! now calc is done
|
||||
endif
|
||||
! translate from P and dP/dF to CS and dCS/dE
|
||||
!!$OMP CRITICAL (evilmatmul)
|
||||
Kirchhoff_bar = math_mul33x33(CPFEM_PK1_bar(:,:,CPFEM_in, cp_en),transpose(CPFEM_ffn1_bar(:,:,CPFEM_in, cp_en)))
|
||||
!!$OMP END CRITICAL (evilmatmul)
|
||||
J_inverse = 1.0_pReal/math_det3x3(CPFEM_ffn1_bar(:,:,CPFEM_in, cp_en))
|
||||
CPFEM_stress_bar(1:CPFEM_ngens,CPFEM_in,cp_en) = math_Mandel33to6(J_inverse*Kirchhoff_bar)
|
||||
!
|
||||
H_bar = 0.0_pReal
|
||||
forall(i=1:3,j=1:3,k=1:3,l=1:3,m=1:3,n=1:3) &
|
||||
H_bar(i,j,k,l) = H_bar(i,j,k,l) + &
|
||||
CPFEM_ffn1_bar(j,m,CPFEM_in,cp_en) * &
|
||||
CPFEM_ffn1_bar(l,n,CPFEM_in,cp_en) * &
|
||||
CPFEM_dPdF_bar(i,m,k,n,CPFEM_in,cp_en) - &
|
||||
math_I3(j,l)*CPFEM_ffn1_bar(i,m,CPFEM_in,cp_en)*CPFEM_PK1_bar(k,m,CPFEM_in,cp_en) + &
|
||||
0.5_pReal*(math_I3(i,k)*Kirchhoff_bar(j,l) + math_I3(j,l)*Kirchhoff_bar(i,k) + &
|
||||
math_I3(i,l)*Kirchhoff_bar(j,k) + math_I3(j,k)*Kirchhoff_bar(i,l))
|
||||
forall(i=1:3,j=1:3,k=1:3,l=1:3) &
|
||||
H_bar_sym(i,j,k,l)= 0.25_pReal*(H_bar(i,j,k,l) +H_bar(j,i,k,l) +H_bar(i,j,l,k) +H_bar(j,i,l,k))
|
||||
CPFEM_jaco_bar(1:CPFEM_ngens,1:CPFEM_ngens,CPFEM_in,cp_en) = math_Mandel3333to66(J_inverse*H_bar)
|
||||
! if (CPFEM_in==8 .and. cp_en==80) then
|
||||
! do e=1,80
|
||||
! do i=1,8
|
||||
! write(6,*)
|
||||
! write(6,*) e, i
|
||||
! write(6,*) CPFEM_stress_bar(1:CPFEM_ngens,i,e)
|
||||
! write(6,*)
|
||||
! write(6,*) CPFEM_jaco_bar(1:CPFEM_ngens,1:CPFEM_ngens,i,e)
|
||||
! enddo
|
||||
! enddo
|
||||
! endif
|
||||
!
|
||||
endif
|
||||
case (3) ! collect and return odd result
|
||||
CPFEM_Temperature(CPFEM_in,cp_en) = Temperature
|
||||
CPFEM_ffn_bar(:,:,CPFEM_in,cp_en) = ffn
|
||||
CPFEM_ffn1_bar(:,:,CPFEM_in,cp_en) = ffn1
|
||||
CPFEM_stress_bar(1:CPFEM_ngens,CPFEM_in,cp_en) = CPFEM_odd_stress
|
||||
CPFEM_jaco_bar(1:CPFEM_ngens,1:CPFEM_ngens,CPFEM_in,cp_en) = CPFEM_odd_jacobian*math_identity2nd(CPFEM_ngens)
|
||||
CPFEM_calc_done = .false.
|
||||
! if (CPFEM_in==8 .and. cp_en==80) then
|
||||
! do e=1,80
|
||||
! do i=1,8
|
||||
! write(6,*)
|
||||
! write(6,*) e, i
|
||||
! write(6,*) ffn1
|
||||
! enddo
|
||||
! enddo
|
||||
! endif
|
||||
|
||||
case (4) ! do nothing since we can recycle the former results (MARC specialty)
|
||||
case (5) ! record consistent tangent at beginning of new increment
|
||||
CPFEM_jaco_knownGood = CPFEM_jaco_bar
|
||||
case (6) ! restore consistent tangent after cutback
|
||||
CPFEM_jaco_bar = CPFEM_jaco_knownGood
|
||||
end select
|
||||
!
|
||||
! return the local stress and the jacobian from storage
|
||||
CPFEM_stress(1:CPFEM_ngens) = CPFEM_stress_bar(1:CPFEM_ngens,CPFEM_in,cp_en)
|
||||
CPFEM_jaco(1:CPFEM_ngens,1:CPFEM_ngens) = CPFEM_jaco_bar(1:CPFEM_ngens,1:CPFEM_ngens,CPFEM_in,cp_en)
|
||||
!
|
||||
return
|
||||
!
|
||||
END SUBROUTINE
|
||||
!
|
||||
!
|
||||
!**********************************************************
|
||||
!*** calculate the material point behaviour ***
|
||||
!**********************************************************
|
||||
SUBROUTINE CPFEM_MaterialPoint(&
|
||||
updateJaco,& ! flag to initiate Jacobian updating
|
||||
CPFEM_dt,& ! Time increment (dt)
|
||||
CPFEM_in,& ! Integration point number
|
||||
cp_en) ! Element number
|
||||
!
|
||||
use prec
|
||||
use FEsolving, only: theCycle
|
||||
use debug
|
||||
use math, only: math_pDecomposition,math_RtoEuler,inDeg,math_I3,math_invert3x3,math_permut,math_invert,math_delta
|
||||
use IO, only: IO_error
|
||||
use mesh, only: mesh_element, mesh_NcpElems, FE_Nips
|
||||
! use crystallite
|
||||
use constitutive
|
||||
implicit none
|
||||
!
|
||||
integer(pInt) cp_en,CPFEM_in,g,i,e
|
||||
integer(pInt) el_start, el_end, ip_start, ip_end
|
||||
logical updateJaco,error
|
||||
real(pReal) CPFEM_dt,volfrac
|
||||
real(pReal), dimension(3,3) :: U,R !,Fe1
|
||||
! real(pReal), dimension(3,3) :: PK1
|
||||
! real(pReal), dimension(3,3,3,3) :: dPdF,dPdF_bar_old
|
||||
!
|
||||
CPFEM_PK1_bar = 0.0_pReal ! zero out average first PK stress
|
||||
!initialize element loop
|
||||
if (cp_en /= 0_pInt) then
|
||||
el_start = cp_en
|
||||
el_end = cp_en
|
||||
else
|
||||
el_start = 1_pInt
|
||||
el_end = mesh_NcpElems
|
||||
endif
|
||||
! prescribe FFN and FFN1 depending on homogenization scheme
|
||||
!$OMP PARALLEL DO
|
||||
do e=el_start,el_end
|
||||
if(CPFEM_in /= 0_pInt) then
|
||||
ip_start = CPFEM_in
|
||||
ip_end = CPFEM_in
|
||||
else
|
||||
ip_start = 1
|
||||
ip_end = FE_Nips(mesh_element(2,e)) ! iterate over all IPs of this element's type
|
||||
endif
|
||||
do i=ip_start,ip_end
|
||||
do g=1,texture_Ngrains(mesh_element(4,e))
|
||||
CPFEM_ffn(:,:,g,i,e) = CPFEM_ffn_bar(:,:,i,e) !Taylor homogenization
|
||||
CPFEM_ffn1(:,:,g,i,e) = CPFEM_ffn1_bar(:,:,i,e) !Taylor homogenization
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
!$OMP END PARALLEL DO
|
||||
! calculate stress, update state and update jacobian in case needed for all or one ip
|
||||
if (updateJaco) then
|
||||
CPFEM_dPdF_bar_old = CPFEM_dPdF_bar ! remember former average consistent tangent
|
||||
CPFEM_dPdF_bar = 0.0_pReal ! zero out avg consistent tangent for later assembly
|
||||
endif
|
||||
call SingleCrystallite(updateJaco,CPFEM_dt,el_start,el_end,CPFEM_in)
|
||||
!******************************************************************************************************
|
||||
! check convergence of homogenization in case needed
|
||||
!******************************************************************************************************
|
||||
! calculate average quantities per ip and post results
|
||||
!$OMP PARALLEL DO
|
||||
do e=el_start,el_end
|
||||
if(CPFEM_in /= 0_pInt) then
|
||||
ip_start = CPFEM_in
|
||||
ip_end = CPFEM_in
|
||||
else
|
||||
ip_start = 1
|
||||
ip_end = FE_Nips(mesh_element(2,e)) ! iterate over all IPs of this element's type
|
||||
endif
|
||||
do i=ip_start,ip_end
|
||||
do g=1,texture_Ngrains(mesh_element(4,e))
|
||||
volfrac = constitutive_matVolFrac(g,i,e)*constitutive_texVolFrac(g,i,e)
|
||||
CPFEM_PK1_bar(:,:,i,e) = CPFEM_PK1_bar(:,:,i,e) + volfrac * CPFEM_PK1(:,:,g,i,e)
|
||||
if (updateJaco) CPFEM_dPdF_bar(:,:,:,:,i,e) = &
|
||||
CPFEM_dPdF_bar(:,:,:,:,i,e) + volfrac * CPFEM_dPdF(:,:,:,:,g,i,e) ! add up crystallite stiffnesses
|
||||
! (may have "holes" corresponding
|
||||
! to former avg tangent)
|
||||
! update results plotted in MENTAT
|
||||
call math_pDecomposition(CPFEM_Fe1(:,:,g,i,e),U,R,error) ! polar decomposition
|
||||
if (error) then
|
||||
!$OMP CRITICAL (write2out)
|
||||
write(6,*) 'polar decomposition of', CPFEM_Fe1(:,:,g,i,e)
|
||||
write(6,*) 'Grain: ',g
|
||||
write(6,*) 'Integration point: ',i
|
||||
write(6,*) 'Element: ',mesh_element(1,e)
|
||||
!$OMP END CRITICAL (write2out)
|
||||
call IO_error(650)
|
||||
return
|
||||
endif
|
||||
CPFEM_results(1:3,g,i,e) = math_RtoEuler(transpose(R))*inDeg ! orientation
|
||||
CPFEM_results(4 ,g,i,e) = volfrac ! volume fraction of orientation
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
!$OMP END PARALLEL DO
|
||||
!
|
||||
return
|
||||
!
|
||||
END SUBROUTINE
|
||||
!
|
||||
!
|
||||
!********************************************************************
|
||||
! Initialize crystallite
|
||||
!********************************************************************
|
||||
subroutine crystallite_init()
|
||||
use mesh, only: mesh_maxNips,mesh_NcpElems
|
||||
use constitutive, only: constitutive_maxNgrains
|
||||
|
||||
implicit none
|
||||
|
||||
allocate(crystallite_converged(constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)); crystallite_converged = .false.
|
||||
!
|
||||
! *** Output to MARC output file ***
|
||||
!$OMP CRITICAL (write2out)
|
||||
write(6,*)
|
||||
write(6,*) 'crystallite Initialization'
|
||||
write(6,*)
|
||||
write(6,*) 'crystallite_converged: ', shape(crystallite_converged)
|
||||
write(6,*)
|
||||
call flush(6)
|
||||
!$OMP END CRITICAL (write2out)
|
||||
return
|
||||
!
|
||||
end subroutine
|
||||
!
|
||||
!
|
||||
!********************************************************************
|
||||
! Calculates the stress and jacobi (if wanted) for all or a single component
|
||||
!********************************************************************
|
||||
subroutine SingleCrystallite(&
|
||||
updateJaco,& ! update of Jacobian required
|
||||
dt,& ! time increment
|
||||
el_start,& ! first element in element loop
|
||||
el_end,& ! last element in element loop
|
||||
CPFEM_in) ! IP number
|
||||
!
|
||||
use prec, only: pReal,pInt,pert_Fg,subStepMin, nCutback
|
||||
use debug
|
||||
use constitutive
|
||||
use mesh, only: mesh_element, FE_Nips
|
||||
use math
|
||||
use IO, only: IO_error
|
||||
! use CPFEM
|
||||
|
||||
implicit none
|
||||
!
|
||||
logical updateJaco, JacoOK
|
||||
real(preal) dt
|
||||
real(pReal), dimension(3,3) :: Fg_pert,Lp_pert, P_pert, Fp_pert, Fe_pert
|
||||
real(pReal), dimension(6) :: Tstar_v
|
||||
real(pReal), dimension(constitutive_maxNstatevars) :: state_pert
|
||||
integer(pInt) el_start, el_end, CPFEM_in, ip_start, ip_end, g, i, e, k, l, iOuter
|
||||
!
|
||||
crystallite_converged=.true.
|
||||
!$OMP PARALLEL DO
|
||||
do e=el_start,el_end
|
||||
if(CPFEM_in /= 0_pInt) then
|
||||
ip_start = CPFEM_in
|
||||
ip_end = CPFEM_in
|
||||
else
|
||||
ip_start = 1
|
||||
ip_end = FE_Nips(mesh_element(2,e)) ! iterate over all IPs of this element's type
|
||||
endif
|
||||
do i=ip_start,ip_end
|
||||
do g=1,texture_Ngrains(mesh_element(4,e))
|
||||
crystallite_converged(g,i,e)=.false.
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
!$OMP END PARALLEL DO
|
||||
constitutive_state_new=constitutive_state_old
|
||||
CPFEM_Lp_new = CPFEM_Lp_old
|
||||
iOuter = 0_pInt
|
||||
do while(any(crystallite_converged(:,:,el_start:el_end))==.false.)
|
||||
!$OMP PARALLEL DO
|
||||
do e=el_start,el_end
|
||||
if(CPFEM_in /= 0_pInt) then
|
||||
ip_start = CPFEM_in
|
||||
ip_end = CPFEM_in
|
||||
else
|
||||
ip_start = 1
|
||||
ip_end = FE_Nips(mesh_element(2,e)) ! iterate over all IPs of this element's type
|
||||
endif
|
||||
do i=ip_start,ip_end
|
||||
do g=1,texture_Ngrains(mesh_element(4,e))
|
||||
if(.not.crystallite_converged(g,i,e))&
|
||||
call IntegrateStress(CPFEM_Tstar_v(:,g,i,e), CPFEM_PK1(:,:,g,i,e), CPFEM_ffn1(:,:,g,i,e),&
|
||||
CPFEM_Fp_new(:,:,g,i,e), CPFEM_Fe1(:,:,g,i,e), CPFEM_Lp_new(:,:,g,i,e),&
|
||||
constitutive_state_new(:,g,i,e), dt, g, i, e)
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
!$OMP END PARALLEL DO
|
||||
!$OMP PARALLEL DO
|
||||
do e=el_start,el_end
|
||||
if(CPFEM_in /= 0_pInt) then
|
||||
ip_start = CPFEM_in
|
||||
ip_end = CPFEM_in
|
||||
else
|
||||
ip_start = 1
|
||||
ip_end = FE_Nips(mesh_element(2,e)) ! iterate over all IPs of this element's type
|
||||
endif
|
||||
do i=ip_start,ip_end
|
||||
do g=1,texture_Ngrains(mesh_element(4,e))
|
||||
if(.not.crystallite_converged(g,i,e))&
|
||||
call UpdateState(CPFEM_Tstar_v(:,g,i,e),constitutive_state_new(:,g,i,e),dt,g,i,e)
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
!$OMP END PARALLEL DO
|
||||
iOuter = iOuter + 1_pInt
|
||||
if (iOuter==Nouter) then
|
||||
!$OMP CRITICAL (write2out)
|
||||
write (6,*) 'Terminated outer loop at el,ip,grain',e,i,g
|
||||
!$OMP CRITICAL (out)
|
||||
debug_OuterLoopDistribution(iOuter) = debug_OuterLoopDistribution(iOuter)+1
|
||||
!$OMP END CRITICAL (out)
|
||||
call IO_error(600)
|
||||
!$OMP END CRITICAL (write2out)
|
||||
endif
|
||||
end do
|
||||
!$OMP CRITICAL (out)
|
||||
debug_OuterLoopDistribution(iOuter) = debug_OuterLoopDistribution(iOuter)+1
|
||||
!$OMP END CRITICAL (out)
|
||||
|
||||
if (wantsConstitutiveResults) then ! get the post_results upon request
|
||||
!$OMP PARALLEL DO
|
||||
do e=el_start,el_end
|
||||
if(CPFEM_in /= 0_pInt) then
|
||||
ip_start = CPFEM_in
|
||||
ip_end = CPFEM_in
|
||||
else
|
||||
ip_start = 1
|
||||
ip_end = FE_Nips(mesh_element(2,e)) ! iterate over all IPs of this element's type
|
||||
endif
|
||||
do i=ip_start,ip_end
|
||||
do g=1,texture_Ngrains(mesh_element(4,e))
|
||||
CPFEM_results(CPFEM_Nresults+1:CPFEM_Nresults+constitutive_Nresults(g,i,e),g,i,e) =&
|
||||
constitutive_post_results(CPFEM_Tstar_v(:,g,i,e),constitutive_state_new(:,g,i,e),&
|
||||
CPFEM_Temperature(i,e),dt,g,i,e)
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
!$OMP END PARALLEL DO
|
||||
endif
|
||||
!
|
||||
!***** Calculate Jacobian *****
|
||||
if(updateJaco) then
|
||||
if (debugger) then
|
||||
!$OMP CRITICAL (write2out)
|
||||
write (6,*) 'Jacobian calc'
|
||||
!$OMP END CRITICAL (write2out)
|
||||
endif
|
||||
! crystallite_converged=.false.
|
||||
!$OMP PARALLEL DO
|
||||
do e=el_start,el_end
|
||||
if(CPFEM_in /= 0_pInt) then
|
||||
ip_start = CPFEM_in
|
||||
ip_end = CPFEM_in
|
||||
else
|
||||
ip_start = 1
|
||||
ip_end = FE_Nips(mesh_element(2,e)) ! iterate over all IPs of this element's type
|
||||
endif
|
||||
do i=ip_start,ip_end
|
||||
do g=1,texture_Ngrains(mesh_element(4,e))
|
||||
do k=1,3
|
||||
do l=1,3
|
||||
crystallite_converged(g,i,e)=.false.
|
||||
JacoOK=.true.
|
||||
Fg_pert = CPFEM_ffn1(:,:,g,i,e) ! initialize perturbed Fg
|
||||
Fg_pert(k,l) = Fg_pert(k,l) + pert_Fg ! perturb single component
|
||||
Lp_pert = CPFEM_Lp_new(:,:,g,i,e) ! initialize Lp
|
||||
Fp_pert = CPFEM_Fp_new(:,:,g,i,e) ! initialize Fp
|
||||
state_pert = constitutive_state_new(:,g,i,e) ! initial guess from end of time step
|
||||
iOuter=0_pInt
|
||||
do while(.not.crystallite_converged(g,i,e))
|
||||
call IntegrateStress(Tstar_v, P_pert, Fg_pert, Fp_pert, Fe_pert, Lp_pert, state_pert, dt, g, i, e)
|
||||
call UpdateState(Tstar_v,state_pert,dt,g,i,e)
|
||||
iOuter = iOuter + 1_pInt
|
||||
if (iOuter==Nouter) then
|
||||
JacoOK=.false.
|
||||
exit
|
||||
endif
|
||||
end do
|
||||
!$OMP CRITICAL (out)
|
||||
debug_OuterLoopDistribution(iOuter) = debug_OuterLoopDistribution(iOuter)+1
|
||||
!$OMP END CRITICAL (out)
|
||||
if (JacoOK) &
|
||||
CPFEM_dPdF(:,:,k,l,g,i,e) = (P_pert-CPFEM_PK1(:,:,g,i,e))/pert_Fg ! constructing tangent dP_ij/dFg_kl only if valid forward difference
|
||||
! otherwise leave component unchanged
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
!$OMP END PARALLEL DO
|
||||
endif
|
||||
!
|
||||
return
|
||||
!
|
||||
end subroutine
|
||||
!
|
||||
!********************************************************************
|
||||
! Update the state for a single component
|
||||
!********************************************************************
|
||||
subroutine UpdateState(&
|
||||
Tstar_v,& ! stress
|
||||
state,& ! state
|
||||
dt,& ! time increment
|
||||
g,& ! grain number
|
||||
i,& ! integration point number
|
||||
e& ! element number
|
||||
)
|
||||
use prec, only: pReal,pInt,reltol_Outer
|
||||
use constitutive, only: constitutive_dotState, constitutive_state_old, constitutive_Nstatevars
|
||||
! use CPFEM, only: CPFEM_Temperature
|
||||
!
|
||||
integer(pInt) g, i, e
|
||||
real(pReal), dimension(6) :: Tstar_v
|
||||
real(pReal), dimension(constitutive_Nstatevars(g, i, e)) :: state, ROuter
|
||||
real(pReal) dt
|
||||
!
|
||||
ROuter = state - constitutive_state_old(:,g,i,e) - &
|
||||
dt*constitutive_dotState(Tstar_v,state,CPFEM_Temperature(i,e),&
|
||||
g,i,e) ! residuum from evolution of microstructure
|
||||
state = state - ROuter ! update of microstructure
|
||||
if (maxval(abs(ROuter/state),state /= 0.0_pReal) < reltol_Outer) crystallite_converged(g,i,e) = .true.
|
||||
!
|
||||
return
|
||||
!
|
||||
end subroutine
|
||||
!
|
||||
!
|
||||
!********************************************************************
|
||||
! Calculates the stress for a single component
|
||||
!********************************************************************
|
||||
!***********************************************************************
|
||||
!*** calculation of stress (P), stiffness (dPdF), ***
|
||||
!*** and announcment of any ***
|
||||
!*** acceleration of the Newton-Raphson correction ***
|
||||
!***********************************************************************
|
||||
subroutine IntegrateStress(&
|
||||
Tstar_v,& ! Stress vector
|
||||
P,& ! first PK stress
|
||||
Fg_new,& ! new global deformation gradient
|
||||
Fp_new,& ! new plastic deformation gradient
|
||||
Fe_new,& ! new "elastic" deformation gradient
|
||||
Lp,& ! plastic velocity gradient
|
||||
state_new,& ! new state variable array
|
||||
dt,& ! time increment
|
||||
g,& ! grain number
|
||||
i,& ! integration point number
|
||||
e) ! element number
|
||||
|
||||
! post_results,& ! plot results from constitutive model
|
||||
! Fp_new,& ! new plastic deformation gradient
|
||||
! updateJaco,& ! update of Jacobian required
|
||||
! Temperature,& ! temperature of crystallite
|
||||
! Fg_old,& ! old global deformation gradient
|
||||
! Fp_old,& ! old plastic deformation gradient
|
||||
! state_old) ! old state variable array
|
||||
!
|
||||
use prec, only: pReal,pInt,pert_Fg,subStepMin, nCutback
|
||||
use debug
|
||||
use constitutive, only: constitutive_Nstatevars,constitutive_Nresults,constitutive_state_old
|
||||
use math
|
||||
! use CPFEM
|
||||
!
|
||||
implicit none
|
||||
!
|
||||
character(len=128) msg
|
||||
logical error,success
|
||||
integer(pInt) e,i,g, nCutbacks, maxCutbacks
|
||||
real(pReal) Temperature
|
||||
real(pReal) dt,dt_aim,subFrac,subStep,det
|
||||
real(pReal), dimension(3,3) :: Lp,Lp_interpolated,inv
|
||||
real(pReal), dimension(3,3) :: Fg_current,Fg_new,Fg_aim,deltaFg
|
||||
real(pReal), dimension(3,3) :: Fp_current,Fp_new
|
||||
real(pReal), dimension(3,3) :: Fe_current,Fe_new
|
||||
real(pReal), dimension(3,3) :: P
|
||||
real(pReal), dimension(6) :: Tstar_v
|
||||
real(pReal), dimension(constitutive_Nstatevars(g,i,e)) :: state_new
|
||||
! real(pReal), dimension(constitutive_Nstatevars(g,i,e)) :: state_current
|
||||
!
|
||||
! debugger= e==1.and.i==1
|
||||
deltaFg = Fg_new - CPFEM_ffn(:,:,g,i,e)
|
||||
subFrac = 0.0_pReal
|
||||
subStep = 1.0_pReal
|
||||
nCutbacks = 0_pInt
|
||||
maxCutbacks = 0_pInt
|
||||
Fg_current = CPFEM_ffn(:,:,g,i,e) ! initialize to start of inc
|
||||
Fp_current = CPFEM_Fp_old(:,:,g,i,e)
|
||||
call math_invert3x3(Fp_current,inv,det,error)
|
||||
Fe_current = math_mul33x33(Fg_current,inv)
|
||||
! state_current = state_new
|
||||
success = .false. ! pretend cutback
|
||||
dt_aim = 0.0_pReal ! prevent initial Lp interpolation
|
||||
Temperature=CPFEM_Temperature(i,e)
|
||||
!
|
||||
! begin the cutback loop
|
||||
do while (subStep > subStepMin) ! continue until finished or too much cut backing
|
||||
if (success) then ! wind forward
|
||||
Fg_current = Fg_aim
|
||||
Fe_current = Fe_new
|
||||
Fp_current = Fp_new
|
||||
! state_current = state_new
|
||||
elseif (dt_aim > 0.0_pReal) then
|
||||
call math_invert3x3(Fg_aim,inv,det,error) ! inv of Fg_aim
|
||||
Lp_interpolated = 0.5_pReal*Lp + &
|
||||
0.5_pReal*(math_I3 - math_mul33x33(Fp_current,&
|
||||
math_mul33x33(inv,Fe_current)))/dt_aim ! interpolate Lp and L
|
||||
if (debugger) then
|
||||
!$OMP CRITICAL (write2out)
|
||||
write (6,*) 'Lp interpolation'
|
||||
write (6,'(a,/,3(3(f12.7,x)/))') 'from',Lp(1:3,:)
|
||||
write (6,'(a,/,3(3(f12.7,x)/))') 'to',Lp_interpolated(1:3,:)
|
||||
!$OMP END CRITICAL (write2out)
|
||||
endif
|
||||
Lp = Lp_interpolated
|
||||
endif
|
||||
!
|
||||
Fg_aim = Fg_current + subStep*deltaFg ! aim for Fg
|
||||
dt_aim = subStep*dt ! aim for dt
|
||||
if (debugger) then
|
||||
!$OMP CRITICAL (write2out)
|
||||
write (6,*) 'using these values'
|
||||
! write (6,'(a,/,3(4(f9.3,x)/))') 'state current / MPa',state_current/1e6_pReal
|
||||
write (6,'(a,/,3(4(f9.3,x)/))') 'state new / MPa',state_new/1e6_pReal
|
||||
write (6,'(a,/,3(3(f12.7,x)/))') 'Fe current',Fe_current(1:3,:)
|
||||
write (6,'(a,/,3(3(f12.7,x)/))') 'Fp current',Fp_current(1:3,:)
|
||||
write (6,'(a,/,3(3(f12.7,x)/))') 'Lp (old=new guess)',Lp(1:3,:)
|
||||
write (6,'(a20,f,x,a2,x,f)') 'integrating from ',subFrac,'to',(subFrac+subStep)
|
||||
!$OMP END CRITICAL (write2out)
|
||||
endif
|
||||
!
|
||||
call TimeIntegration(msg,Lp,Fp_new,Fe_new,Tstar_v,P,state_new,dt_aim,e,i,g,Temperature,Fg_aim,Fp_current)
|
||||
!
|
||||
|
||||
if (msg == 'ok') then
|
||||
subFrac = subFrac + subStep
|
||||
subStep = min(1.0_pReal-subFrac, subStep*2.0_pReal) ! accelerate
|
||||
nCutbacks = 0_pInt ! reset cutback counter
|
||||
success = .true. ! keep current Lp
|
||||
else
|
||||
nCutbacks = nCutbacks + 1 ! record additional cutback
|
||||
maxCutbacks = max(nCutbacks,maxCutbacks)! remember maximum number of cutbacks
|
||||
subStep = subStep / 2.0_pReal ! cut time step in half
|
||||
success = .false. ! force Lp interpolation
|
||||
! if (debugger) then
|
||||
!$OMP CRITICAL (write2out)
|
||||
write (6,*) '>>>>>>>>>>>>>>>>>>>> cutback <<<<<<<<<<<<<<<<<<<<<<'
|
||||
write (6,*) 'Element, Ip:', e, i
|
||||
write (6,*) msg
|
||||
!$OMP END CRITICAL (write2out)
|
||||
! endif
|
||||
!
|
||||
endif
|
||||
enddo ! potential substepping
|
||||
!
|
||||
!$OMP CRITICAL (cutback)
|
||||
debug_cutbackDistribution(min(nCutback,maxCutbacks)+1) = debug_cutbackDistribution(min(nCutback,maxCutbacks)+1)+1
|
||||
!$OMP END CRITICAL (cutback)
|
||||
!
|
||||
! debugger = .false.
|
||||
return
|
||||
end subroutine
|
||||
|
||||
!
|
||||
!***********************************************************************
|
||||
!*** fully-implicit two-level time integration ***
|
||||
!*** based on a residuum in Lp and intermediate ***
|
||||
!*** acceleration of the Newton-Raphson correction ***
|
||||
!***********************************************************************
|
||||
SUBROUTINE TimeIntegration(&
|
||||
msg,& ! return message
|
||||
Lpguess,& ! guess of plastic velocity gradient
|
||||
Fp_new,& ! new plastic deformation gradient
|
||||
Fe_new,& ! new "elastic" deformation gradient
|
||||
Tstar_v,& ! Stress vector
|
||||
P,& ! 1nd PK stress (taken as initial guess if /= 0)
|
||||
state,& ! current microstructure at end of time inc (taken as guess if /= 0)
|
||||
dt,& ! time increment
|
||||
cp_en,& ! element number
|
||||
ip,& ! integration point number
|
||||
grain,& ! grain number
|
||||
Temperature,& ! temperature
|
||||
Fg_new,& ! new total def gradient
|
||||
Fp_old) ! former plastic def gradient
|
||||
! state_current) ! former microstructure
|
||||
use prec
|
||||
use debug
|
||||
use mesh, only: mesh_element
|
||||
use constitutive, only: constitutive_Nstatevars,constitutive_Microstructure,&
|
||||
constitutive_homogenizedC,constitutive_LpAndItsTangent
|
||||
use math
|
||||
use IO
|
||||
implicit none
|
||||
!
|
||||
character(len=*) msg
|
||||
logical failed
|
||||
integer(pInt) cp_en, ip, grain
|
||||
integer(pInt) iInner,dummy, i,j,k,l,m,n
|
||||
real(pReal) dt, Temperature, det, p_hydro, leapfrog,maxleap
|
||||
real(pReal), dimension(6) :: Tstar_v
|
||||
real(pReal), dimension(9,9) :: dLp,dTdLp,dRdLp,invdRdLp,eye2
|
||||
real(pReal), dimension(6,6) :: C_66
|
||||
real(pReal), dimension(3,3) :: Fg_new,Fp_new,invFp_new,Fp_old,invFp_old,Fe_new
|
||||
real(pReal), dimension(3,3) :: P !,Tstar
|
||||
real(pReal), dimension(3,3) :: Lp,Lpguess,Lpguess_old,Rinner,Rinner_old,A,B,BT,AB,BTA
|
||||
real(pReal), dimension(3,3,3,3) :: C
|
||||
real(pReal), dimension(constitutive_Nstatevars(grain, ip, cp_en)) :: state
|
||||
!
|
||||
msg = 'ok' ! error-free so far
|
||||
eye2 = math_identity2nd(9)
|
||||
|
||||
call math_invert3x3(Fp_old,invFp_old,det,failed) ! inversion of Fp_old
|
||||
if (failed) then
|
||||
msg = 'inversion Fp_old'
|
||||
return
|
||||
endif
|
||||
|
||||
A = math_mul33x33(transpose(invFp_old), math_mul33x33(transpose(Fg_new),math_mul33x33(Fg_new,invFp_old)))
|
||||
!
|
||||
! if (all(state == 0.0_pReal)) state = state_current ! former state guessed, if none specified
|
||||
! iOuter = 0_pInt ! outer counter
|
||||
!
|
||||
if (debugger) then
|
||||
!$OMP CRITICAL (write2out)
|
||||
write (6,'(a,/,3(3(f12.7,x)/))') 'Fg to be calculated',Fg_new
|
||||
!$OMP END CRITICAL (write2out)
|
||||
endif
|
||||
!
|
||||
!Outer: do ! outer iteration: State
|
||||
! iOuter = iOuter+1
|
||||
! if (debugger) then
|
||||
!!$OMP CRITICAL (write2out)
|
||||
! write (6,'(a,i3)') '---outer ',iOuter
|
||||
! write (6,'(a,/,3(4(f9.3,x)/))') 'state old / MPa',state_old/1e6_pReal
|
||||
! write (6,'(a,/,3(4(f9.3,x)/))') 'state / MPa',state/1e6_pReal
|
||||
! write (6,'(a,/,3(3(f12.7,x)/))') 'Lpguess',Lpguess(1:3,:)
|
||||
!!$OMP END CRITICAL (write2out)
|
||||
! endif
|
||||
!
|
||||
! if (iOuter > nOuter) then
|
||||
! msg = 'limit Outer iteration'
|
||||
!!$OMP CRITICAL (out)
|
||||
! debug_OuterLoopDistribution(nOuter) = debug_OuterLoopDistribution(nOuter)+1
|
||||
!!$OMP END CRITICAL (out)
|
||||
! return
|
||||
! endif
|
||||
call constitutive_Microstructure(state,Temperature,grain,ip,cp_en)
|
||||
C_66 = constitutive_HomogenizedC(state, grain, ip, cp_en)
|
||||
C = math_Mandel66to3333(C_66) ! 4th rank elasticity tensor
|
||||
!
|
||||
iInner = 0_pInt
|
||||
leapfrog = 1.0_pReal ! correction as suggested by invdRdLp-step
|
||||
maxleap = 1024.0_pReal ! preassign maximum acceleration level
|
||||
!
|
||||
Lpguess_old = Lpguess ! consider present Lpguess good
|
||||
!
|
||||
Inner: do ! inner iteration: Lp
|
||||
iInner = iInner+1
|
||||
! if (debugger) then
|
||||
!!$OMP CRITICAL (write2out)
|
||||
! write (6,'(a,i3)') 'inner ',iInner
|
||||
! if (iInner < 3) then
|
||||
! write (6,'(a,/,3(3(f12.7,x)/))') 'Lpguess',Lpguess(1:3,:)
|
||||
! endif
|
||||
!!$OMP END CRITICAL (write2out)
|
||||
! endif
|
||||
if (iInner > nInner) then ! too many loops required
|
||||
Lpguess = Lpguess_old ! do not trust the last update but resort to former one
|
||||
msg = 'limit Inner iteration'
|
||||
!$OMP CRITICAL (in)
|
||||
debug_InnerLoopDistribution(nInner) = debug_InnerLoopDistribution(nInner)+1
|
||||
!$OMP END CRITICAL (in)
|
||||
return
|
||||
endif
|
||||
!
|
||||
B = math_i3 - dt*Lpguess
|
||||
BT = transpose(B)
|
||||
AB = math_mul33x33(A,B)
|
||||
BTA = math_mul33x33(BT,A)
|
||||
Tstar_v = 0.5_pReal*math_mul66x6(C_66,math_mandel33to6(math_mul33x33(BT,AB)-math_I3))
|
||||
! Tstar = math_Mandel6to33(Tstar_v)
|
||||
p_hydro=(Tstar_v(1)+Tstar_v(2)+Tstar_v(3))/3.0_pReal
|
||||
forall(i=1:3) Tstar_v(i) = Tstar_v(i)-p_hydro ! subtract hydrostatic pressure
|
||||
call constitutive_LpAndItsTangent(Lp,dLp, &
|
||||
Tstar_v,state,Temperature,grain,ip,cp_en)
|
||||
!
|
||||
Rinner = Lpguess - Lp ! update current residuum
|
||||
!
|
||||
if (.not.(any(Rinner/=Rinner)) .and. & ! exclude any NaN in residuum
|
||||
( (maxval(abs(Rinner)) < abstol_Inner) .or. & ! below abs tol .or.
|
||||
( any(abs(dt*Lpguess) > relevantStrain) .and. & ! worth checking? .and.
|
||||
maxval(abs(Rinner/Lpguess),abs(dt*Lpguess) > relevantStrain) < reltol_Inner & ! below rel tol
|
||||
) &
|
||||
) &
|
||||
) &
|
||||
exit Inner ! convergence
|
||||
!
|
||||
! check for acceleration/deceleration in Newton--Raphson correction
|
||||
!
|
||||
if (any(Rinner/=Rinner) .and. & ! NaN occured at regular speed
|
||||
leapfrog == 1.0) then
|
||||
Lpguess = Lpguess_old ! restore known good guess
|
||||
msg = 'NaN present' ! croak for cutback
|
||||
return
|
||||
|
||||
elseif (leapfrog > 1.0_pReal .and. & ! at fast pace ?
|
||||
(sum(Rinner*Rinner) > sum(Rinner_old*Rinner_old) .or. & ! worse residuum
|
||||
sum(Rinner*Rinner_old) < 0.0_pReal) .or. & ! residuum changed sign (overshoot)
|
||||
any(Rinner/=Rinner) ) then ! NaN
|
||||
maxleap = 0.5_pReal * leapfrog ! limit next acceleration
|
||||
leapfrog = 1.0_pReal ! grinding halt
|
||||
|
||||
else ! better residuum
|
||||
dTdLp = 0.0_pReal ! calc dT/dLp
|
||||
forall (i=1:3,j=1:3,k=1:3,l=1:3,m=1:3,n=1:3) &
|
||||
dTdLp(3*(i-1)+j,3*(k-1)+l) = dTdLp(3*(i-1)+j,3*(k-1)+l) + &
|
||||
C(i,j,l,n)*AB(k,n)+C(i,j,m,l)*BTA(m,k)
|
||||
dTdLp = -0.5_pReal*dt*dTdLp
|
||||
dRdLp = eye2 - math_mul99x99(dLp,dTdLp) ! calc dR/dLp
|
||||
invdRdLp = 0.0_pReal
|
||||
call math_invert(9,dRdLp,invdRdLp,dummy,failed) ! invert dR/dLp --> dLp/dR
|
||||
if (failed) then
|
||||
msg = 'inversion dR/dLp'
|
||||
if (debugger) then
|
||||
!$OMP CRITICAL (write2out)
|
||||
write (6,*) msg
|
||||
write (6,'(a,/,9(9(e9.3,x)/))') 'dRdLp', dRdLp(1:9,:)
|
||||
write (6,'(a,/,3(4(f9.3,x)/))') 'state / MPa',state/1e6_pReal
|
||||
write (6,'(a,/,3(3(f12.7,x)/))') 'Lpguess',Lpguess(1:3,:)
|
||||
write (6,'(a,/,3(3(e12.7,x)/))') 'Lp',Lp(1:3,:)
|
||||
write (6,'(a,/,6(f9.3,x))') 'Tstar / MPa',Tstar_v/1e6_pReal
|
||||
!$OMP END CRITICAL (write2out)
|
||||
endif
|
||||
return
|
||||
endif
|
||||
!
|
||||
Rinner_old = Rinner ! remember current residuum
|
||||
Lpguess_old = Lpguess ! remember current Lp guess
|
||||
if (iInner > 1 .and. leapfrog < maxleap) &
|
||||
leapfrog = 2.0_pReal * leapfrog ! accelerate if ok
|
||||
endif
|
||||
!
|
||||
Lpguess = Lpguess_old ! start from current guess
|
||||
Rinner = Rinner_old ! use current residuum
|
||||
forall (i=1:3,j=1:3,k=1:3,l=1:3) & ! leapfrog to updated Lpguess
|
||||
Lpguess(i,j) = Lpguess(i,j) - leapfrog*invdRdLp(3*(i-1)+j,3*(k-1)+l)*Rinner(k,l)
|
||||
enddo Inner
|
||||
!
|
||||
!$OMP CRITICAL (in)
|
||||
debug_InnerLoopDistribution(iInner) = debug_InnerLoopDistribution(iInner)+1
|
||||
!$OMP END CRITICAL (in)
|
||||
! ROuter = state - state_old - &
|
||||
! dt*constitutive_dotState(Tstar_v,state,Temperature,&
|
||||
! grain,ip,cp_en) ! residuum from evolution of microstructure
|
||||
! state = state - ROuter ! update of microstructure
|
||||
!
|
||||
! if (iOuter==nOuter) then
|
||||
!!$OMP CRITICAL (write2out)
|
||||
! write (6,*) 'Terminated outer loop at el,ip,grain',cp_en,ip,grain
|
||||
!!$OMP END CRITICAL (write2out)
|
||||
! exit Outer
|
||||
! endif
|
||||
! if (maxval(abs(Router/state),state /= 0.0_pReal) < reltol_Outer) exit Outer
|
||||
! enddo Outer
|
||||
!
|
||||
!!$OMP CRITICAL (out)
|
||||
! debug_OuterLoopDistribution(iOuter) = debug_OuterLoopDistribution(iOuter)+1
|
||||
!!$OMP END CRITICAL (out)
|
||||
invFp_new = math_mul33x33(invFp_old,B)
|
||||
call math_invert3x3(invFp_new,Fp_new,det,failed)
|
||||
if (failed) then
|
||||
msg = 'inversion Fp_new^-1'
|
||||
return
|
||||
endif
|
||||
!
|
||||
! if (wantsConstitutiveResults) then ! get the post_results upon request
|
||||
! results = 0.0_pReal
|
||||
! results = constitutive_post_results(Tstar_v,state,Temperature,dt,grain,ip,cp_en)
|
||||
! endif
|
||||
!
|
||||
Fp_new = Fp_new*det**(1.0_pReal/3.0_pReal) ! regularize Fp by det = det(InvFp_new) !!
|
||||
forall (i=1:3) Tstar_v(i) = Tstar_v(i)+p_hydro ! add hydrostatic component back
|
||||
Fe_new = math_mul33x33(Fg_new,invFp_new) ! calc resulting Fe
|
||||
! P = math_mul33x33(Fe_new,math_mul33x33(Tstar,transpose(invFp_new))) ! first PK stress
|
||||
P = math_mul33x33(Fe_new,math_mul33x33(math_Mandel6to33(Tstar_v),transpose(invFp_new))) ! first PK stress
|
||||
|
||||
return
|
||||
!
|
||||
END SUBROUTINE
|
||||
!
|
||||
END MODULE
|
||||
!##############################################################
|
||||
|
|
@ -1,950 +0,0 @@
|
|||
!##############################################################
|
||||
MODULE CPFEM
|
||||
!##############################################################
|
||||
! *** CPFEM engine ***
|
||||
!
|
||||
use prec, only: pReal,pInt
|
||||
implicit none
|
||||
!
|
||||
! ****************************************************************
|
||||
! *** General variables for the material behaviour calculation ***
|
||||
! ****************************************************************
|
||||
real(pReal), dimension (:,:), allocatable :: CPFEM_Temperature
|
||||
real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_ffn_bar !average FFN per IP
|
||||
real(pReal), dimension (:,:,:,:,:), allocatable :: CPFEM_ffn !individual FFN per grain
|
||||
real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_ffn1_bar !average FFN1 per IP
|
||||
real(pReal), dimension (:,:,:,:,:), allocatable :: CPFEM_ffn1 !individual FFN1 per grain
|
||||
real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_PK1_bar !average PK1 per IP
|
||||
real(pReal), dimension (:,:,:,:,:), allocatable :: CPFEM_PK1 !individual PK1 per grain
|
||||
real(pReal), dimension (:,:,:,:,:,:), allocatable :: CPFEM_dPdF_bar !average dPdF per IP
|
||||
real(pReal), dimension (:,:,:,:,:,:), allocatable :: CPFEM_dPdF_bar_old !old average dPdF per IP
|
||||
real(pReal), dimension (:,:,:,:,:,:,:),allocatable :: CPFEM_dPdF !individual dPdF per grain
|
||||
real(pReal), dimension (:,:,:), allocatable :: CPFEM_stress_bar
|
||||
real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_jaco_bar
|
||||
real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_jaco_knownGood
|
||||
real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_results
|
||||
real(pReal), dimension (:,:,:,:,:), allocatable :: CPFEM_Lp_old
|
||||
real(pReal), dimension (:,:,:,:,:), allocatable :: CPFEM_Lp_new
|
||||
real(pReal), dimension (:,:,:,:,:), allocatable :: CPFEM_Fp_old
|
||||
real(pReal), dimension (:,:,:,:,:), allocatable :: CPFEM_Fp_new
|
||||
real(pReal), dimension (:,:,:,:,:), allocatable :: CPFEM_Fe1
|
||||
real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_Tstar_v
|
||||
real(pReal), parameter :: CPFEM_odd_stress = 1e15_pReal, CPFEM_odd_jacobian = 1e50_pReal
|
||||
integer(pInt) :: CPFEM_Nresults = 4_pInt ! three Euler angles plus volume fraction
|
||||
logical :: CPFEM_init_done = .false. ! remember whether init has been done already
|
||||
logical :: CPFEM_calc_done = .false. ! remember whether first IP has already calced the results
|
||||
logical :: CPFEM_results_aged = .false. ! remember whether results have been aged at inc start
|
||||
! *** Solution at single crystallite level ***
|
||||
!
|
||||
logical, dimension (:,:,:),allocatable :: crystallite_converged !individual covergence flag per grain
|
||||
!
|
||||
CONTAINS
|
||||
!
|
||||
!*********************************************************
|
||||
!*** allocate the arrays defined in module CPFEM ***
|
||||
!*** and initialize them ***
|
||||
!*********************************************************
|
||||
SUBROUTINE CPFEM_init(Temperature)
|
||||
!
|
||||
use prec
|
||||
use math, only: math_EulertoR, math_I3, math_identity2nd
|
||||
use mesh
|
||||
use constitutive
|
||||
!
|
||||
implicit none
|
||||
!
|
||||
real(pReal) Temperature
|
||||
integer(pInt) e,i,g
|
||||
!
|
||||
! *** mpie.marc parameters ***
|
||||
allocate(CPFEM_Temperature(mesh_maxNips,mesh_NcpElems)) ; CPFEM_Temperature = Temperature
|
||||
allocate(CPFEM_ffn_bar(3,3,mesh_maxNips,mesh_NcpElems))
|
||||
forall(e=1:mesh_NcpElems,i=1:mesh_maxNips) CPFEM_ffn_bar(:,:,i,e) = math_I3
|
||||
allocate(CPFEM_ffn(3,3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems))
|
||||
forall(g=1:constitutive_maxNgrains,e=1:mesh_NcpElems,i=1:mesh_maxNips) CPFEM_ffn(:,:,g,i,e) = math_I3
|
||||
allocate(CPFEM_ffn1_bar(3,3,mesh_maxNips,mesh_NcpElems)) ; CPFEM_ffn1_bar = CPFEM_ffn_bar
|
||||
allocate(CPFEM_ffn1(3,3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; CPFEM_ffn1 = CPFEM_ffn
|
||||
allocate(CPFEM_PK1_bar(3,3,mesh_maxNips,mesh_NcpElems)) ; CPFEM_PK1_bar = 0.0_pReal
|
||||
allocate(CPFEM_PK1(3,3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; CPFEM_PK1 = 0.0_pReal
|
||||
allocate(CPFEM_dPdF_bar(3,3,3,3,mesh_maxNips,mesh_NcpElems)) ; CPFEM_dPdF_bar = 0.0_pReal
|
||||
allocate(CPFEM_dPdF_bar_old(3,3,3,3,mesh_maxNips,mesh_NcpElems)) ; CPFEM_dPdF_bar_old = 0.0_pReal
|
||||
allocate(CPFEM_dPdF(3,3,3,3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; CPFEM_dPdF = 0.0_pReal
|
||||
allocate(CPFEM_stress_bar(6,mesh_maxNips,mesh_NcpElems)) ; CPFEM_stress_bar = 0.0_pReal
|
||||
allocate(CPFEM_jaco_bar(6,6,mesh_maxNips,mesh_NcpElems)) ; CPFEM_jaco_bar = 0.0_pReal
|
||||
allocate(CPFEM_jaco_knownGood(6,6,mesh_maxNips,mesh_NcpElems)) ; CPFEM_jaco_knownGood = 0.0_pReal
|
||||
!
|
||||
! *** User defined results !!! MISSING incorporate consti_Nresults ***
|
||||
allocate(CPFEM_results(CPFEM_Nresults+constitutive_maxNresults,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems))
|
||||
CPFEM_results = 0.0_pReal
|
||||
!
|
||||
! *** Plastic velocity gradient ***
|
||||
allocate(CPFEM_Lp_old(3,3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; CPFEM_Lp_old = 0.0_pReal
|
||||
allocate(CPFEM_Lp_new(3,3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; CPFEM_Lp_new = 0.0_pReal
|
||||
|
||||
! *** Plastic deformation gradient at (t=t0) and (t=t1) ***
|
||||
allocate(CPFEM_Fp_new(3,3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; CPFEM_Fp_new = 0.0_pReal
|
||||
allocate(CPFEM_Fp_old(3,3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems))
|
||||
forall (e=1:mesh_NcpElems,i=1:mesh_maxNips,g=1:constitutive_maxNgrains) &
|
||||
CPFEM_Fp_old(:,:,g,i,e) = math_EulerToR(constitutive_EulerAngles(:,g,i,e)) ! plastic def gradient reflects init orientation
|
||||
! *** Elastic deformation gradient at (t=t1) ***
|
||||
allocate(CPFEM_Fe1(3,3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; CPFEM_Fe1 = 0.0_pReal
|
||||
! *** Stress vector at (t=t1) ***
|
||||
allocate(CPFEM_Tstar_v(6,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; CPFEM_Tstar_v = 0.0_pReal
|
||||
!
|
||||
! *** Output to MARC output file ***
|
||||
!$OMP CRITICAL (write2out)
|
||||
write(6,*)
|
||||
write(6,*) 'CPFEM Initialization'
|
||||
write(6,*)
|
||||
write(6,*) 'CPFEM_Temperature: ', shape(CPFEM_Temperature)
|
||||
write(6,*) 'CPFEM_ffn_bar: ', shape(CPFEM_ffn_bar)
|
||||
write(6,*) 'CPFEM_ffn: ', shape(CPFEM_ffn)
|
||||
write(6,*) 'CPFEM_ffn1_bar: ', shape(CPFEM_ffn1_bar)
|
||||
write(6,*) 'CPFEM_ffn1: ', shape(CPFEM_ffn1)
|
||||
write(6,*) 'CPFEM_PK1_bar: ', shape(CPFEM_PK1_bar)
|
||||
write(6,*) 'CPFEM_PK1: ', shape(CPFEM_PK1)
|
||||
write(6,*) 'CPFEM_dPdF_bar: ', shape(CPFEM_dPdF_bar)
|
||||
write(6,*) 'CPFEM_dPdF_bar_old: ', shape(CPFEM_dPdF_bar_old)
|
||||
write(6,*) 'CPFEM_dPdF: ', shape(CPFEM_dPdF)
|
||||
write(6,*) 'CPFEM_stress_bar: ', shape(CPFEM_stress_bar)
|
||||
write(6,*) 'CPFEM_jaco_bar: ', shape(CPFEM_jaco_bar)
|
||||
write(6,*) 'CPFEM_jaco_knownGood: ', shape(CPFEM_jaco_knownGood)
|
||||
write(6,*) 'CPFEM_results: ', shape(CPFEM_results)
|
||||
write(6,*) 'CPFEM_Lp_old: ', shape(CPFEM_Lp_old)
|
||||
write(6,*) 'CPFEM_Lp_new: ', shape(CPFEM_Lp_new)
|
||||
write(6,*) 'CPFEM_Fp_old: ', shape(CPFEM_Fp_old)
|
||||
write(6,*) 'CPFEM_Fp_new: ', shape(CPFEM_Fp_new)
|
||||
write(6,*) 'CPFEM_Fe1: ', shape(CPFEM_Fe1)
|
||||
write(6,*) 'CPFEM_Tstar_v: ', shape(CPFEM_Tstar_v)
|
||||
write(6,*)
|
||||
call flush(6)
|
||||
!$OMP END CRITICAL (write2out)
|
||||
return
|
||||
!
|
||||
END SUBROUTINE
|
||||
!
|
||||
!
|
||||
!***********************************************************************
|
||||
!*** perform initialization at first call, update variables and ***
|
||||
!*** call the actual material model ***
|
||||
!
|
||||
! CPFEM_mode computation mode (regular, collection, recycle)
|
||||
! ffn deformation gradient for t=t0
|
||||
! ffn1 deformation gradient for t=t1
|
||||
! Temperature temperature
|
||||
! CPFEM_dt time increment
|
||||
! CPFEM_en element number
|
||||
! CPFEM_in intergration point number
|
||||
! CPFEM_stress stress vector in Mandel notation
|
||||
! CPFEM_updateJaco flag to initiate computation of Jacobian
|
||||
! CPFEM_jaco jacobian in Mandel notation
|
||||
! CPFEM_ngens size of stress strain law
|
||||
!***********************************************************************
|
||||
SUBROUTINE CPFEM_general(CPFEM_mode, ffn, ffn1, Temperature, CPFEM_dt,&
|
||||
CPFEM_en, CPFEM_in, CPFEM_stress, CPFEM_updateJaco, CPFEM_jaco, CPFEM_ngens)
|
||||
! note: CPFEM_stress = Cauchy stress cs(6) and CPFEM_jaco = Consistent tangent dcs/de
|
||||
!
|
||||
use prec, only: pReal,pInt
|
||||
use FEsolving
|
||||
use debug
|
||||
use math
|
||||
use mesh, only: mesh_init,mesh_FEasCP, mesh_NcpElems, FE_Nips, FE_mapElemtype, mesh_element
|
||||
use lattice, only: lattice_init
|
||||
use constitutive, only: constitutive_init,constitutive_state_old,constitutive_state_new,material_Cslip_66
|
||||
implicit none
|
||||
!
|
||||
integer(pInt) CPFEM_en, CPFEM_in, cp_en, CPFEM_ngens, i,j,k,l,m,n, e
|
||||
real(pReal), dimension (3,3) :: ffn,ffn1,Kirchhoff_bar
|
||||
real(pReal), dimension (3,3,3,3) :: H_bar, H_bar_sym
|
||||
real(pReal), dimension(CPFEM_ngens) :: CPFEM_stress
|
||||
real(pReal), dimension(CPFEM_ngens,CPFEM_ngens) :: CPFEM_jaco, odd_jaco
|
||||
real(pReal) Temperature,CPFEM_dt,J_inverse
|
||||
integer(pInt) CPFEM_mode ! 1: regular computation with aged results&
|
||||
! 2: regular computation&
|
||||
! 3: collection of FEM data&
|
||||
! 4: recycling of former results (MARC speciality)&
|
||||
! 5: record tangent from former converged inc&
|
||||
! 6: restore tangent from former converged inc
|
||||
logical CPFEM_updateJaco
|
||||
!
|
||||
if (.not. CPFEM_init_done) then ! initialization step (three dimensional stress state check missing?)
|
||||
call math_init()
|
||||
call mesh_init()
|
||||
call lattice_init()
|
||||
call constitutive_init()
|
||||
call crystallite_init()
|
||||
call CPFEM_init(Temperature)
|
||||
CPFEM_init_done = .true.
|
||||
endif
|
||||
!
|
||||
cp_en = mesh_FEasCP('elem',CPFEM_en)
|
||||
if (cp_en == 1 .and. CPFEM_in == 1) &
|
||||
write(6,'(a10,1x,f8.4,1x,a10,1x,i4,1x,a10,1x,i3,1x,a10,1x,i2,x,a10,1x,i2)') &
|
||||
'theTime',theTime,'theInc',theInc,'theCycle',theCycle,'theLovl',theLovl,&
|
||||
'mode',CPFEM_mode
|
||||
|
||||
if (CPFEM_mode /= 1) CPFEM_results_aged = .false.
|
||||
|
||||
select case (CPFEM_mode)
|
||||
|
||||
case (2,1) ! *** regular computation (with aging of results) ***
|
||||
if (CPFEM_mode == 1 .and. &
|
||||
.not. CPFEM_results_aged) then ! age results at start of new increment
|
||||
CPFEM_Fp_old = CPFEM_Fp_new
|
||||
constitutive_state_old = constitutive_state_new
|
||||
CPFEM_results_aged = .true. ! aging is done
|
||||
write (6,*) ')))))))))))))) results aged (((((((((((((((',cp_en,CPFEM_in
|
||||
endif
|
||||
|
||||
CPFEM_Temperature(CPFEM_in,cp_en) = Temperature ! store temperature
|
||||
CPFEM_ffn_bar(:,:,CPFEM_in,cp_en) = ffn ! store def grad for start of inc
|
||||
CPFEM_ffn1_bar(:,:,CPFEM_in,cp_en) = ffn1 ! store def grad for end of inc
|
||||
debugger = (cp_en == 1160 .and. CPFEM_in == 6) ! switch on debugging
|
||||
call CPFEM_MaterialPoint(CPFEM_updateJaco, CPFEM_dt, CPFEM_in, cp_en) ! call for result at this IP
|
||||
|
||||
! translate from P and dP/dF to CS and dCS/dE
|
||||
|
||||
Kirchhoff_bar = math_mul33x33(CPFEM_PK1_bar(:,:,CPFEM_in, cp_en),transpose(CPFEM_ffn1_bar(:,:,CPFEM_in, cp_en)))
|
||||
J_inverse = 1.0_pReal/math_det3x3(CPFEM_ffn1_bar(:,:,CPFEM_in, cp_en))
|
||||
CPFEM_stress_bar(1:CPFEM_ngens,CPFEM_in,cp_en) = math_Mandel33to6(J_inverse*Kirchhoff_bar)
|
||||
|
||||
H_bar = 0.0_pReal
|
||||
forall(i=1:3,j=1:3,k=1:3,l=1:3,m=1:3,n=1:3) &
|
||||
H_bar(i,j,k,l) = H_bar(i,j,k,l) + &
|
||||
CPFEM_ffn1_bar(j,m,CPFEM_in,cp_en) * &
|
||||
CPFEM_ffn1_bar(l,n,CPFEM_in,cp_en) * &
|
||||
CPFEM_dPdF_bar(i,m,k,n,CPFEM_in,cp_en) - &
|
||||
math_I3(j,l)*CPFEM_ffn1_bar(i,m,CPFEM_in,cp_en)*CPFEM_PK1_bar(k,m,CPFEM_in,cp_en) + &
|
||||
0.5_pReal*(math_I3(i,k)*Kirchhoff_bar(j,l) + math_I3(j,l)*Kirchhoff_bar(i,k) + &
|
||||
math_I3(i,l)*Kirchhoff_bar(j,k) + math_I3(j,k)*Kirchhoff_bar(i,l))
|
||||
forall(i=1:3,j=1:3,k=1:3,l=1:3) &
|
||||
H_bar_sym(i,j,k,l)= 0.25_pReal*(H_bar(i,j,k,l) +H_bar(j,i,k,l) +H_bar(i,j,l,k) +H_bar(j,i,l,k))
|
||||
CPFEM_jaco_bar(1:CPFEM_ngens,1:CPFEM_ngens,CPFEM_in,cp_en) = math_Mandel3333to66(J_inverse*H_bar)
|
||||
|
||||
case (3) ! *** collect and return odd result ***
|
||||
CPFEM_Temperature(CPFEM_in,cp_en) = Temperature
|
||||
CPFEM_ffn_bar(:,:,CPFEM_in,cp_en) = ffn
|
||||
CPFEM_ffn1_bar(:,:,CPFEM_in,cp_en) = ffn1
|
||||
CPFEM_stress_bar(1:CPFEM_ngens,CPFEM_in,cp_en) = CPFEM_odd_stress
|
||||
CPFEM_jaco_bar(1:CPFEM_ngens,1:CPFEM_ngens,CPFEM_in,cp_en) = CPFEM_odd_jacobian*math_identity2nd(CPFEM_ngens)
|
||||
CPFEM_calc_done = .false.
|
||||
|
||||
case (4) ! *** do nothing since we can recycle the former results (MARC specialty) ***
|
||||
case (5) ! *** record consistent tangent at beginning of new increment ***
|
||||
CPFEM_jaco_knownGood = CPFEM_jaco_bar
|
||||
case (6) ! *** restore consistent tangent after cutback ***
|
||||
CPFEM_jaco_bar = CPFEM_jaco_knownGood
|
||||
end select
|
||||
!
|
||||
! return the local stress and the jacobian from storage
|
||||
CPFEM_stress(1:CPFEM_ngens) = CPFEM_stress_bar(1:CPFEM_ngens,CPFEM_in,cp_en)
|
||||
CPFEM_jaco(1:CPFEM_ngens,1:CPFEM_ngens) = CPFEM_jaco_bar(1:CPFEM_ngens,1:CPFEM_ngens,CPFEM_in,cp_en)
|
||||
if (debugger) write (6,'(a,/,6(6(f9.3,x)/))') 'stiffness / GPa',CPFEM_jaco(1:CPFEM_ngens,:)/1e9_pReal
|
||||
!
|
||||
return
|
||||
!
|
||||
END SUBROUTINE
|
||||
!
|
||||
!
|
||||
!**********************************************************
|
||||
!*** calculate the material point behaviour ***
|
||||
!**********************************************************
|
||||
SUBROUTINE CPFEM_MaterialPoint(&
|
||||
updateJaco,& ! flag to initiate Jacobian updating
|
||||
CPFEM_dt,& ! Time increment (dt)
|
||||
CPFEM_in,& ! Integration point number
|
||||
cp_en) ! Element number
|
||||
!
|
||||
use prec
|
||||
use FEsolving, only: theCycle
|
||||
use debug
|
||||
use math, only: math_pDecomposition,math_RtoEuler,inDeg,math_I3,math_invert3x3,math_permut,math_invert,math_delta
|
||||
use IO, only: IO_error
|
||||
use mesh, only: mesh_element, mesh_NcpElems, FE_Nips
|
||||
! use crystallite
|
||||
use constitutive
|
||||
implicit none
|
||||
|
||||
!
|
||||
integer(pInt) cp_en,CPFEM_in,g,i,e
|
||||
integer(pInt) el_start, el_end, ip_start, ip_end
|
||||
logical updateJaco,error
|
||||
real(pReal) CPFEM_dt,volfrac
|
||||
real(pReal), dimension(3,3) :: U,R !,Fe1
|
||||
! real(pReal), dimension(3,3) :: PK1
|
||||
! real(pReal), dimension(3,3,3,3) :: dPdF,dPdF_bar_old
|
||||
!
|
||||
CPFEM_PK1_bar = 0.0_pReal ! zero out average first PK stress
|
||||
!initialize element loop
|
||||
if (cp_en /= 0_pInt) then
|
||||
el_start = cp_en
|
||||
el_end = cp_en
|
||||
else
|
||||
el_start = 1_pInt
|
||||
el_end = mesh_NcpElems
|
||||
endif
|
||||
! prescribe FFN and FFN1 depending on homogenization scheme
|
||||
!$OMP PARALLEL DO
|
||||
do e=el_start,el_end
|
||||
if(CPFEM_in /= 0_pInt) then
|
||||
ip_start = CPFEM_in
|
||||
ip_end = CPFEM_in
|
||||
else
|
||||
ip_start = 1
|
||||
ip_end = FE_Nips(mesh_element(2,e)) ! iterate over all IPs of this element's type
|
||||
endif
|
||||
do i=ip_start,ip_end
|
||||
do g=1,texture_Ngrains(mesh_element(4,e))
|
||||
CPFEM_ffn(:,:,g,i,e) = CPFEM_ffn_bar(:,:,i,e) !Taylor homogenization
|
||||
CPFEM_ffn1(:,:,g,i,e) = CPFEM_ffn1_bar(:,:,i,e) !Taylor homogenization
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
!$OMP END PARALLEL DO
|
||||
! calculate stress, update state and update jacobian in case needed for all or one ip
|
||||
if (updateJaco) then
|
||||
CPFEM_dPdF_bar_old = CPFEM_dPdF_bar ! remember former average consistent tangent
|
||||
CPFEM_dPdF_bar = 0.0_pReal ! zero out avg consistent tangent for later assembly
|
||||
endif
|
||||
call SingleCrystallite(updateJaco,CPFEM_dt,el_start,el_end,CPFEM_in)
|
||||
!******************************************************************************************************
|
||||
! check convergence of homogenization in case needed
|
||||
!******************************************************************************************************
|
||||
! calculate average quantities per ip and post results
|
||||
!$OMP PARALLEL DO
|
||||
do e=el_start,el_end
|
||||
if(CPFEM_in /= 0_pInt) then
|
||||
ip_start = CPFEM_in
|
||||
ip_end = CPFEM_in
|
||||
else
|
||||
ip_start = 1
|
||||
ip_end = FE_Nips(mesh_element(2,e)) ! iterate over all IPs of this element's type
|
||||
endif
|
||||
do i=ip_start,ip_end
|
||||
do g=1,texture_Ngrains(mesh_element(4,e))
|
||||
volfrac = constitutive_matVolFrac(g,i,e)*constitutive_texVolFrac(g,i,e)
|
||||
CPFEM_PK1_bar(:,:,i,e) = CPFEM_PK1_bar(:,:,i,e) + volfrac * CPFEM_PK1(:,:,g,i,e)
|
||||
if (updateJaco) CPFEM_dPdF_bar(:,:,:,:,i,e) = &
|
||||
CPFEM_dPdF_bar(:,:,:,:,i,e) + volfrac * CPFEM_dPdF(:,:,:,:,g,i,e) ! add up crystallite stiffnesses
|
||||
! (may have "holes" corresponding
|
||||
! to former avg tangent)
|
||||
! update results plotted in MENTAT
|
||||
call math_pDecomposition(CPFEM_Fe1(:,:,g,i,e),U,R,error) ! polar decomposition
|
||||
if (error) then
|
||||
!$OMP CRITICAL (write2out)
|
||||
write(6,*) 'polar decomposition of', CPFEM_Fe1(:,:,g,i,e)
|
||||
write(6,*) 'Grain: ',g
|
||||
write(6,*) 'Integration point: ',i
|
||||
write(6,*) 'Element: ',mesh_element(1,e)
|
||||
!$OMP END CRITICAL (write2out)
|
||||
call IO_error(650)
|
||||
return
|
||||
endif
|
||||
CPFEM_results(1:3,g,i,e) = math_RtoEuler(transpose(R))*inDeg ! orientation
|
||||
CPFEM_results(4 ,g,i,e) = volfrac ! volume fraction of orientation
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
!$OMP END PARALLEL DO
|
||||
!
|
||||
return
|
||||
!
|
||||
END SUBROUTINE
|
||||
!
|
||||
!
|
||||
!********************************************************************
|
||||
! Initialize crystallite
|
||||
!********************************************************************
|
||||
subroutine crystallite_init()
|
||||
use mesh, only: mesh_maxNips,mesh_NcpElems
|
||||
use constitutive, only: constitutive_maxNgrains
|
||||
|
||||
implicit none
|
||||
|
||||
allocate(crystallite_converged(constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)); crystallite_converged = .false.
|
||||
!
|
||||
! *** Output to MARC output file ***
|
||||
!$OMP CRITICAL (write2out)
|
||||
write(6,*)
|
||||
write(6,*) 'crystallite Initialization'
|
||||
write(6,*)
|
||||
write(6,*) 'crystallite_converged: ', shape(crystallite_converged)
|
||||
write(6,*)
|
||||
call flush(6)
|
||||
!$OMP END CRITICAL (write2out)
|
||||
return
|
||||
!
|
||||
end subroutine
|
||||
!
|
||||
!
|
||||
!********************************************************************
|
||||
! Calculates the stress and jacobi (if wanted) for all or a single component
|
||||
!********************************************************************
|
||||
subroutine SingleCrystallite(&
|
||||
updateJaco,& ! update of Jacobian required
|
||||
dt,& ! time increment
|
||||
el_start,& ! first element in element loop
|
||||
el_end,& ! last element in element loop
|
||||
CPFEM_in) ! IP number
|
||||
!
|
||||
use prec, only: pReal,pInt,pert_Fg,subStepMin, nCutback
|
||||
use debug
|
||||
use constitutive
|
||||
use mesh, only: mesh_element, FE_Nips
|
||||
use math
|
||||
use IO, only: IO_error
|
||||
! use CPFEM
|
||||
|
||||
implicit none
|
||||
!
|
||||
logical updateJaco, JacoOK
|
||||
real(preal) dt
|
||||
real(pReal), dimension(3,3) :: Fg_pert,Lp_pert, P_pert, Fp_pert, Fe_pert
|
||||
real(pReal), dimension(6) :: Tstar_v
|
||||
real(pReal), dimension(constitutive_maxNstatevars) :: state_pert
|
||||
integer(pInt) el_start, el_end, CPFEM_in, ip_start, ip_end, g, i, e, k, l, iOuter
|
||||
!
|
||||
crystallite_converged=.true.
|
||||
!$OMP PARALLEL DO
|
||||
do e=el_start,el_end
|
||||
if(CPFEM_in /= 0_pInt) then
|
||||
ip_start = CPFEM_in
|
||||
ip_end = CPFEM_in
|
||||
else
|
||||
ip_start = 1
|
||||
ip_end = FE_Nips(mesh_element(2,e)) ! iterate over all IPs of this element's type
|
||||
endif
|
||||
do i=ip_start,ip_end
|
||||
do g=1,texture_Ngrains(mesh_element(4,e))
|
||||
crystallite_converged(g,i,e)=.false.
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
!$OMP END PARALLEL DO
|
||||
constitutive_state_new=constitutive_state_old
|
||||
CPFEM_Lp_new = CPFEM_Lp_old
|
||||
iOuter = 0_pInt
|
||||
do while(any(crystallite_converged(:,:,el_start:el_end))==.false.)
|
||||
!$OMP PARALLEL DO
|
||||
do e=el_start,el_end
|
||||
if(CPFEM_in /= 0_pInt) then
|
||||
ip_start = CPFEM_in
|
||||
ip_end = CPFEM_in
|
||||
else
|
||||
ip_start = 1
|
||||
ip_end = FE_Nips(mesh_element(2,e)) ! iterate over all IPs of this element's type
|
||||
endif
|
||||
do i=ip_start,ip_end
|
||||
do g=1,texture_Ngrains(mesh_element(4,e))
|
||||
if(.not.crystallite_converged(g,i,e))&
|
||||
call IntegrateStress(CPFEM_Tstar_v(:,g,i,e), CPFEM_PK1(:,:,g,i,e), CPFEM_ffn1(:,:,g,i,e),&
|
||||
CPFEM_Fp_new(:,:,g,i,e), CPFEM_Fe1(:,:,g,i,e), CPFEM_Lp_new(:,:,g,i,e),&
|
||||
constitutive_state_new(:,g,i,e), dt, g, i, e)
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
!$OMP END PARALLEL DO
|
||||
!$OMP PARALLEL DO
|
||||
do e=el_start,el_end
|
||||
if(CPFEM_in /= 0_pInt) then
|
||||
ip_start = CPFEM_in
|
||||
ip_end = CPFEM_in
|
||||
else
|
||||
ip_start = 1
|
||||
ip_end = FE_Nips(mesh_element(2,e)) ! iterate over all IPs of this element's type
|
||||
endif
|
||||
do i=ip_start,ip_end
|
||||
do g=1,texture_Ngrains(mesh_element(4,e))
|
||||
if(.not.crystallite_converged(g,i,e))&
|
||||
call UpdateState(CPFEM_Tstar_v(:,g,i,e),constitutive_state_new(:,g,i,e),dt,g,i,e)
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
!$OMP END PARALLEL DO
|
||||
iOuter = iOuter + 1_pInt
|
||||
if (iOuter==Nouter) then
|
||||
!$OMP CRITICAL (write2out)
|
||||
write (6,*) 'Terminated outer loop at el,ip,grain',e,i,g
|
||||
!$OMP CRITICAL (out)
|
||||
debug_OuterLoopDistribution(iOuter) = debug_OuterLoopDistribution(iOuter)+1
|
||||
!$OMP END CRITICAL (out)
|
||||
call IO_error(600)
|
||||
!$OMP END CRITICAL (write2out)
|
||||
endif
|
||||
end do
|
||||
!$OMP CRITICAL (out)
|
||||
debug_OuterLoopDistribution(iOuter) = debug_OuterLoopDistribution(iOuter)+1
|
||||
!$OMP END CRITICAL (out)
|
||||
|
||||
if (wantsConstitutiveResults) then ! get the post_results upon request
|
||||
!$OMP PARALLEL DO
|
||||
do e=el_start,el_end
|
||||
if(CPFEM_in /= 0_pInt) then
|
||||
ip_start = CPFEM_in
|
||||
ip_end = CPFEM_in
|
||||
else
|
||||
ip_start = 1
|
||||
ip_end = FE_Nips(mesh_element(2,e)) ! iterate over all IPs of this element's type
|
||||
endif
|
||||
do i=ip_start,ip_end
|
||||
do g=1,texture_Ngrains(mesh_element(4,e))
|
||||
CPFEM_results(CPFEM_Nresults+1:CPFEM_Nresults+constitutive_Nresults(g,i,e),g,i,e) =&
|
||||
constitutive_post_results(CPFEM_Tstar_v(:,g,i,e),constitutive_state_new(:,g,i,e),&
|
||||
CPFEM_Temperature(i,e),dt,g,i,e)
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
!$OMP END PARALLEL DO
|
||||
endif
|
||||
!
|
||||
!***** Calculate Jacobian *****
|
||||
if(updateJaco) then
|
||||
if (debugger) then
|
||||
!$OMP CRITICAL (write2out)
|
||||
write (6,*) 'Jacobian calc'
|
||||
!$OMP END CRITICAL (write2out)
|
||||
endif
|
||||
! crystallite_converged=.false.
|
||||
!$OMP PARALLEL DO
|
||||
do e=el_start,el_end
|
||||
if(CPFEM_in /= 0_pInt) then
|
||||
ip_start = CPFEM_in
|
||||
ip_end = CPFEM_in
|
||||
else
|
||||
ip_start = 1
|
||||
ip_end = FE_Nips(mesh_element(2,e)) ! iterate over all IPs of this element's type
|
||||
endif
|
||||
do i=ip_start,ip_end
|
||||
do g=1,texture_Ngrains(mesh_element(4,e))
|
||||
do k=1,3
|
||||
do l=1,3
|
||||
crystallite_converged(g,i,e)=.false.
|
||||
JacoOK=.true.
|
||||
Fg_pert = CPFEM_ffn1(:,:,g,i,e) ! initialize perturbed Fg
|
||||
Fg_pert(k,l) = Fg_pert(k,l) + pert_Fg ! perturb single component
|
||||
Lp_pert = CPFEM_Lp_new(:,:,g,i,e) ! initialize Lp
|
||||
Fp_pert = CPFEM_Fp_new(:,:,g,i,e) ! initialize Fp
|
||||
state_pert = constitutive_state_new(:,g,i,e) ! initial guess from end of time step
|
||||
iOuter=0_pInt
|
||||
do while(.not.crystallite_converged(g,i,e))
|
||||
call IntegrateStress(Tstar_v, P_pert, Fg_pert, Fp_pert, Fe_pert, Lp_pert, state_pert, dt, g, i, e)
|
||||
call UpdateState(Tstar_v,state_pert,dt,g,i,e)
|
||||
iOuter = iOuter + 1_pInt
|
||||
if (iOuter==Nouter) then
|
||||
JacoOK=.false.
|
||||
exit
|
||||
endif
|
||||
end do
|
||||
!$OMP CRITICAL (out)
|
||||
debug_OuterLoopDistribution(iOuter) = debug_OuterLoopDistribution(iOuter)+1
|
||||
!$OMP END CRITICAL (out)
|
||||
if (JacoOK) &
|
||||
CPFEM_dPdF(:,:,k,l,g,i,e) = (P_pert-CPFEM_PK1(:,:,g,i,e))/pert_Fg ! constructing tangent dP_ij/dFg_kl only if valid forward difference
|
||||
! otherwise leave component unchanged
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
!$OMP END PARALLEL DO
|
||||
endif
|
||||
!
|
||||
return
|
||||
!
|
||||
end subroutine
|
||||
!
|
||||
!********************************************************************
|
||||
! Update the state for a single component
|
||||
!********************************************************************
|
||||
subroutine UpdateState(&
|
||||
Tstar_v,& ! stress
|
||||
state,& ! state
|
||||
dt,& ! time increment
|
||||
g,& ! grain number
|
||||
i,& ! integration point number
|
||||
e& ! element number
|
||||
)
|
||||
use prec, only: pReal,pInt,reltol_Outer
|
||||
use constitutive, only: constitutive_dotState, constitutive_state_old, constitutive_Nstatevars
|
||||
! use CPFEM, only: CPFEM_Temperature
|
||||
!
|
||||
integer(pInt) g, i, e
|
||||
real(pReal), dimension(6) :: Tstar_v
|
||||
real(pReal), dimension(constitutive_Nstatevars(g, i, e)) :: state, ROuter
|
||||
real(pReal) dt
|
||||
!
|
||||
ROuter = state - constitutive_state_old(:,g,i,e) - &
|
||||
dt*constitutive_dotState(Tstar_v,state,CPFEM_Temperature(i,e),&
|
||||
g,i,e) ! residuum from evolution of microstructure
|
||||
state = state - ROuter ! update of microstructure
|
||||
if (maxval(abs(ROuter/state),state /= 0.0_pReal) < reltol_Outer) crystallite_converged(g,i,e) = .true.
|
||||
!
|
||||
return
|
||||
!
|
||||
end subroutine
|
||||
!
|
||||
!
|
||||
!********************************************************************
|
||||
! Calculates the stress for a single component
|
||||
!********************************************************************
|
||||
!***********************************************************************
|
||||
!*** calculation of stress (P), stiffness (dPdF), ***
|
||||
!*** and announcment of any ***
|
||||
!*** acceleration of the Newton-Raphson correction ***
|
||||
!***********************************************************************
|
||||
subroutine IntegrateStress(&
|
||||
Tstar_v,& ! Stress vector
|
||||
P,& ! first PK stress
|
||||
Fg_new,& ! new global deformation gradient
|
||||
Fp_new,& ! new plastic deformation gradient
|
||||
Fe_new,& ! new "elastic" deformation gradient
|
||||
Lp,& ! plastic velocity gradient
|
||||
state_new,& ! new state variable array
|
||||
dt,& ! time increment
|
||||
g,& ! grain number
|
||||
i,& ! integration point number
|
||||
e) ! element number
|
||||
|
||||
! post_results,& ! plot results from constitutive model
|
||||
! Fp_new,& ! new plastic deformation gradient
|
||||
! updateJaco,& ! update of Jacobian required
|
||||
! Temperature,& ! temperature of crystallite
|
||||
! Fg_old,& ! old global deformation gradient
|
||||
! Fp_old,& ! old plastic deformation gradient
|
||||
! state_old) ! old state variable array
|
||||
!
|
||||
use prec, only: pReal,pInt,pert_Fg,subStepMin, nCutback
|
||||
use debug
|
||||
use constitutive, only: constitutive_Nstatevars,constitutive_Nresults,constitutive_state_old
|
||||
use math
|
||||
! use CPFEM
|
||||
!
|
||||
implicit none
|
||||
!
|
||||
character(len=128) msg
|
||||
logical error,success
|
||||
integer(pInt) e,i,g, nCutbacks, maxCutbacks
|
||||
real(pReal) Temperature
|
||||
real(pReal) dt,dt_aim,subFrac,subStep,det
|
||||
real(pReal), dimension(3,3) :: Lp,Lp_interpolated,inv
|
||||
real(pReal), dimension(3,3) :: Fg_current,Fg_new,Fg_aim,deltaFg
|
||||
real(pReal), dimension(3,3) :: Fp_current,Fp_new
|
||||
real(pReal), dimension(3,3) :: Fe_current,Fe_new
|
||||
real(pReal), dimension(3,3) :: P
|
||||
real(pReal), dimension(6) :: Tstar_v
|
||||
real(pReal), dimension(constitutive_Nstatevars(g,i,e)) :: state_new
|
||||
! real(pReal), dimension(constitutive_Nstatevars(g,i,e)) :: state_current
|
||||
!
|
||||
! debugger= e==1.and.i==1
|
||||
deltaFg = Fg_new - CPFEM_ffn(:,:,g,i,e)
|
||||
subFrac = 0.0_pReal
|
||||
subStep = 1.0_pReal
|
||||
nCutbacks = 0_pInt
|
||||
maxCutbacks = 0_pInt
|
||||
Fg_current = CPFEM_ffn(:,:,g,i,e) ! initialize to start of inc
|
||||
Fp_current = CPFEM_Fp_old(:,:,g,i,e)
|
||||
call math_invert3x3(Fp_current,inv,det,error)
|
||||
Fe_current = math_mul33x33(Fg_current,inv)
|
||||
! state_current = state_new
|
||||
success = .false. ! pretend cutback
|
||||
dt_aim = 0.0_pReal ! prevent initial Lp interpolation
|
||||
Temperature=CPFEM_Temperature(i,e)
|
||||
!
|
||||
! begin the cutback loop
|
||||
do while (subStep > subStepMin) ! continue until finished or too much cut backing
|
||||
if (success) then ! wind forward
|
||||
Fg_current = Fg_aim
|
||||
Fe_current = Fe_new
|
||||
Fp_current = Fp_new
|
||||
! state_current = state_new
|
||||
elseif (dt_aim > 0.0_pReal) then
|
||||
call math_invert3x3(Fg_aim,inv,det,error) ! inv of Fg_aim
|
||||
Lp_interpolated = 0.5_pReal*Lp + &
|
||||
0.5_pReal*(math_I3 - math_mul33x33(Fp_current,&
|
||||
math_mul33x33(inv,Fe_current)))/dt_aim ! interpolate Lp and L
|
||||
if (debugger) then
|
||||
!$OMP CRITICAL (write2out)
|
||||
write (6,*) 'Lp interpolation'
|
||||
write (6,'(a,/,3(3(f12.7,x)/))') 'from',Lp(1:3,:)
|
||||
write (6,'(a,/,3(3(f12.7,x)/))') 'to',Lp_interpolated(1:3,:)
|
||||
!$OMP END CRITICAL (write2out)
|
||||
endif
|
||||
Lp = Lp_interpolated
|
||||
endif
|
||||
!
|
||||
Fg_aim = Fg_current + subStep*deltaFg ! aim for Fg
|
||||
dt_aim = subStep*dt ! aim for dt
|
||||
if (debugger) then
|
||||
!$OMP CRITICAL (write2out)
|
||||
write (6,*) 'using these values'
|
||||
! write (6,'(a,/,3(4(f9.3,x)/))') 'state current / MPa',state_current/1e6_pReal
|
||||
write (6,'(a,/,3(4(f9.3,x)/))') 'state new / MPa',state_new/1e6_pReal
|
||||
write (6,'(a,/,3(3(f12.7,x)/))') 'Fe current',Fe_current(1:3,:)
|
||||
write (6,'(a,/,3(3(f12.7,x)/))') 'Fp current',Fp_current(1:3,:)
|
||||
write (6,'(a,/,3(3(f12.7,x)/))') 'Lp (old=new guess)',Lp(1:3,:)
|
||||
write (6,'(a20,f,x,a2,x,f)') 'integrating from ',subFrac,'to',(subFrac+subStep)
|
||||
!$OMP END CRITICAL (write2out)
|
||||
endif
|
||||
!
|
||||
call TimeIntegration(msg,Lp,Fp_new,Fe_new,Tstar_v,P,state_new,dt_aim,e,i,g,Temperature,Fg_aim,Fp_current)
|
||||
!
|
||||
|
||||
if (msg == 'ok') then
|
||||
subFrac = subFrac + subStep
|
||||
subStep = min(1.0_pReal-subFrac, subStep*2.0_pReal) ! accelerate
|
||||
nCutbacks = 0_pInt ! reset cutback counter
|
||||
success = .true. ! keep current Lp
|
||||
else
|
||||
nCutbacks = nCutbacks + 1 ! record additional cutback
|
||||
maxCutbacks = max(nCutbacks,maxCutbacks)! remember maximum number of cutbacks
|
||||
subStep = subStep / 2.0_pReal ! cut time step in half
|
||||
success = .false. ! force Lp interpolation
|
||||
! if (debugger) then
|
||||
!$OMP CRITICAL (write2out)
|
||||
write (6,*) '>>>>>>>>>>>>>>>>>>>> cutback <<<<<<<<<<<<<<<<<<<<<<'
|
||||
write (6,*) 'Element, Ip:', e, i
|
||||
write (6,*) msg
|
||||
!$OMP END CRITICAL (write2out)
|
||||
! endif
|
||||
!
|
||||
endif
|
||||
enddo ! potential substepping
|
||||
!
|
||||
!$OMP CRITICAL (cutback)
|
||||
debug_cutbackDistribution(min(nCutback,maxCutbacks)+1) = debug_cutbackDistribution(min(nCutback,maxCutbacks)+1)+1
|
||||
!$OMP END CRITICAL (cutback)
|
||||
!
|
||||
! debugger = .false.
|
||||
return
|
||||
end subroutine
|
||||
|
||||
!
|
||||
!***********************************************************************
|
||||
!*** fully-implicit two-level time integration ***
|
||||
!*** based on a residuum in Lp and intermediate ***
|
||||
!*** acceleration of the Newton-Raphson correction ***
|
||||
!***********************************************************************
|
||||
SUBROUTINE TimeIntegration(&
|
||||
msg,& ! return message
|
||||
Lpguess,& ! guess of plastic velocity gradient
|
||||
Fp_new,& ! new plastic deformation gradient
|
||||
Fe_new,& ! new "elastic" deformation gradient
|
||||
Tstar_v,& ! Stress vector
|
||||
P,& ! 1nd PK stress (taken as initial guess if /= 0)
|
||||
state,& ! current microstructure at end of time inc (taken as guess if /= 0)
|
||||
dt,& ! time increment
|
||||
cp_en,& ! element number
|
||||
ip,& ! integration point number
|
||||
grain,& ! grain number
|
||||
Temperature,& ! temperature
|
||||
Fg_new,& ! new total def gradient
|
||||
Fp_old) ! former plastic def gradient
|
||||
! state_current) ! former microstructure
|
||||
use prec
|
||||
use debug
|
||||
use mesh, only: mesh_element
|
||||
use constitutive, only: constitutive_Nstatevars,constitutive_Microstructure,&
|
||||
constitutive_homogenizedC,constitutive_LpAndItsTangent
|
||||
use math
|
||||
use IO
|
||||
implicit none
|
||||
!
|
||||
character(len=*) msg
|
||||
logical failed
|
||||
integer(pInt) cp_en, ip, grain
|
||||
integer(pInt) iInner,dummy, i,j,k,l,m,n
|
||||
real(pReal) dt, Temperature, det, p_hydro, leapfrog,maxleap
|
||||
real(pReal), dimension(6) :: Tstar_v
|
||||
real(pReal), dimension(9,9) :: dLp,dTdLp,dRdLp,invdRdLp,eye2
|
||||
real(pReal), dimension(6,6) :: C_66
|
||||
real(pReal), dimension(3,3) :: Fg_new,Fp_new,invFp_new,Fp_old,invFp_old,Fe_new
|
||||
real(pReal), dimension(3,3) :: P !,Tstar
|
||||
real(pReal), dimension(3,3) :: Lp,Lpguess,Lpguess_old,Rinner,Rinner_old,A,B,BT,AB,BTA
|
||||
real(pReal), dimension(3,3,3,3) :: C
|
||||
real(pReal), dimension(constitutive_Nstatevars(grain, ip, cp_en)) :: state
|
||||
!
|
||||
msg = 'ok' ! error-free so far
|
||||
eye2 = math_identity2nd(9)
|
||||
|
||||
call math_invert3x3(Fp_old,invFp_old,det,failed) ! inversion of Fp_old
|
||||
if (failed) then
|
||||
msg = 'inversion Fp_old'
|
||||
return
|
||||
endif
|
||||
|
||||
A = math_mul33x33(transpose(invFp_old), math_mul33x33(transpose(Fg_new),math_mul33x33(Fg_new,invFp_old)))
|
||||
!
|
||||
! if (all(state == 0.0_pReal)) state = state_current ! former state guessed, if none specified
|
||||
! iOuter = 0_pInt ! outer counter
|
||||
!
|
||||
if (debugger) then
|
||||
!$OMP CRITICAL (write2out)
|
||||
write (6,'(a,/,3(3(f12.7,x)/))') 'Fg to be calculated',Fg_new
|
||||
!$OMP END CRITICAL (write2out)
|
||||
endif
|
||||
!
|
||||
!Outer: do ! outer iteration: State
|
||||
! iOuter = iOuter+1
|
||||
! if (debugger) then
|
||||
!!$OMP CRITICAL (write2out)
|
||||
! write (6,'(a,i3)') '---outer ',iOuter
|
||||
! write (6,'(a,/,3(4(f9.3,x)/))') 'state old / MPa',state_old/1e6_pReal
|
||||
! write (6,'(a,/,3(4(f9.3,x)/))') 'state / MPa',state/1e6_pReal
|
||||
! write (6,'(a,/,3(3(f12.7,x)/))') 'Lpguess',Lpguess(1:3,:)
|
||||
!!$OMP END CRITICAL (write2out)
|
||||
! endif
|
||||
!
|
||||
! if (iOuter > nOuter) then
|
||||
! msg = 'limit Outer iteration'
|
||||
!!$OMP CRITICAL (out)
|
||||
! debug_OuterLoopDistribution(nOuter) = debug_OuterLoopDistribution(nOuter)+1
|
||||
!!$OMP END CRITICAL (out)
|
||||
! return
|
||||
! endif
|
||||
call constitutive_Microstructure(state,Temperature,grain,ip,cp_en)
|
||||
C_66 = constitutive_HomogenizedC(state, grain, ip, cp_en)
|
||||
C = math_Mandel66to3333(C_66) ! 4th rank elasticity tensor
|
||||
!
|
||||
iInner = 0_pInt
|
||||
leapfrog = 1.0_pReal ! correction as suggested by invdRdLp-step
|
||||
maxleap = 1024.0_pReal ! preassign maximum acceleration level
|
||||
!
|
||||
Lpguess_old = Lpguess ! consider present Lpguess good
|
||||
!
|
||||
Inner: do ! inner iteration: Lp
|
||||
iInner = iInner+1
|
||||
! if (debugger) then
|
||||
!!$OMP CRITICAL (write2out)
|
||||
! write (6,'(a,i3)') 'inner ',iInner
|
||||
! if (iInner < 3) then
|
||||
! write (6,'(a,/,3(3(f12.7,x)/))') 'Lpguess',Lpguess(1:3,:)
|
||||
! endif
|
||||
!!$OMP END CRITICAL (write2out)
|
||||
! endif
|
||||
if (iInner > nInner) then ! too many loops required
|
||||
Lpguess = Lpguess_old ! do not trust the last update but resort to former one
|
||||
msg = 'limit Inner iteration'
|
||||
!$OMP CRITICAL (in)
|
||||
debug_InnerLoopDistribution(nInner) = debug_InnerLoopDistribution(nInner)+1
|
||||
!$OMP END CRITICAL (in)
|
||||
return
|
||||
endif
|
||||
!
|
||||
B = math_i3 - dt*Lpguess
|
||||
BT = transpose(B)
|
||||
AB = math_mul33x33(A,B)
|
||||
BTA = math_mul33x33(BT,A)
|
||||
Tstar_v = 0.5_pReal*math_mul66x6(C_66,math_mandel33to6(math_mul33x33(BT,AB)-math_I3))
|
||||
! Tstar = math_Mandel6to33(Tstar_v)
|
||||
p_hydro=(Tstar_v(1)+Tstar_v(2)+Tstar_v(3))/3.0_pReal
|
||||
forall(i=1:3) Tstar_v(i) = Tstar_v(i)-p_hydro ! subtract hydrostatic pressure
|
||||
call constitutive_LpAndItsTangent(Lp,dLp, &
|
||||
Tstar_v,state,Temperature,grain,ip,cp_en)
|
||||
!
|
||||
Rinner = Lpguess - Lp ! update current residuum
|
||||
!
|
||||
if (.not.(any(Rinner/=Rinner)) .and. & ! exclude any NaN in residuum
|
||||
( (maxval(abs(Rinner)) < abstol_Inner) .or. & ! below abs tol .or.
|
||||
( any(abs(dt*Lpguess) > relevantStrain) .and. & ! worth checking? .and.
|
||||
maxval(abs(Rinner/Lpguess),abs(dt*Lpguess) > relevantStrain) < reltol_Inner & ! below rel tol
|
||||
) &
|
||||
) &
|
||||
) &
|
||||
exit Inner ! convergence
|
||||
!
|
||||
! check for acceleration/deceleration in Newton--Raphson correction
|
||||
!
|
||||
if (any(Rinner/=Rinner) .and. & ! NaN occured at regular speed
|
||||
leapfrog == 1.0) then
|
||||
Lpguess = Lpguess_old ! restore known good guess
|
||||
msg = 'NaN present' ! croak for cutback
|
||||
return
|
||||
|
||||
elseif (leapfrog > 1.0_pReal .and. & ! at fast pace ?
|
||||
(sum(Rinner*Rinner) > sum(Rinner_old*Rinner_old) .or. & ! worse residuum
|
||||
sum(Rinner*Rinner_old) < 0.0_pReal) .or. & ! residuum changed sign (overshoot)
|
||||
any(Rinner/=Rinner) ) then ! NaN
|
||||
maxleap = 0.5_pReal * leapfrog ! limit next acceleration
|
||||
leapfrog = 1.0_pReal ! grinding halt
|
||||
|
||||
else ! better residuum
|
||||
dTdLp = 0.0_pReal ! calc dT/dLp
|
||||
forall (i=1:3,j=1:3,k=1:3,l=1:3,m=1:3,n=1:3) &
|
||||
dTdLp(3*(i-1)+j,3*(k-1)+l) = dTdLp(3*(i-1)+j,3*(k-1)+l) + &
|
||||
C(i,j,l,n)*AB(k,n)+C(i,j,m,l)*BTA(m,k)
|
||||
dTdLp = -0.5_pReal*dt*dTdLp
|
||||
dRdLp = eye2 - math_mul99x99(dLp,dTdLp) ! calc dR/dLp
|
||||
invdRdLp = 0.0_pReal
|
||||
call math_invert(9,dRdLp,invdRdLp,dummy,failed) ! invert dR/dLp --> dLp/dR
|
||||
if (failed) then
|
||||
msg = 'inversion dR/dLp'
|
||||
if (debugger) then
|
||||
!$OMP CRITICAL (write2out)
|
||||
write (6,*) msg
|
||||
write (6,'(a,/,9(9(e9.3,x)/))') 'dRdLp', dRdLp(1:9,:)
|
||||
write (6,'(a,/,3(4(f9.3,x)/))') 'state / MPa',state/1e6_pReal
|
||||
write (6,'(a,/,3(3(f12.7,x)/))') 'Lpguess',Lpguess(1:3,:)
|
||||
write (6,'(a,/,3(3(e12.7,x)/))') 'Lp',Lp(1:3,:)
|
||||
write (6,'(a,/,6(f9.3,x))') 'Tstar / MPa',Tstar_v/1e6_pReal
|
||||
!$OMP END CRITICAL (write2out)
|
||||
endif
|
||||
return
|
||||
endif
|
||||
!
|
||||
Rinner_old = Rinner ! remember current residuum
|
||||
Lpguess_old = Lpguess ! remember current Lp guess
|
||||
if (iInner > 1 .and. leapfrog < maxleap) &
|
||||
leapfrog = 2.0_pReal * leapfrog ! accelerate if ok
|
||||
endif
|
||||
!
|
||||
Lpguess = Lpguess_old ! start from current guess
|
||||
Rinner = Rinner_old ! use current residuum
|
||||
forall (i=1:3,j=1:3,k=1:3,l=1:3) & ! leapfrog to updated Lpguess
|
||||
Lpguess(i,j) = Lpguess(i,j) - leapfrog*invdRdLp(3*(i-1)+j,3*(k-1)+l)*Rinner(k,l)
|
||||
enddo Inner
|
||||
!
|
||||
!$OMP CRITICAL (in)
|
||||
debug_InnerLoopDistribution(iInner) = debug_InnerLoopDistribution(iInner)+1
|
||||
!$OMP END CRITICAL (in)
|
||||
! ROuter = state - state_old - &
|
||||
! dt*constitutive_dotState(Tstar_v,state,Temperature,&
|
||||
! grain,ip,cp_en) ! residuum from evolution of microstructure
|
||||
! state = state - ROuter ! update of microstructure
|
||||
!
|
||||
! if (iOuter==nOuter) then
|
||||
!!$OMP CRITICAL (write2out)
|
||||
! write (6,*) 'Terminated outer loop at el,ip,grain',cp_en,ip,grain
|
||||
!!$OMP END CRITICAL (write2out)
|
||||
! exit Outer
|
||||
! endif
|
||||
! if (maxval(abs(Router/state),state /= 0.0_pReal) < reltol_Outer) exit Outer
|
||||
! enddo Outer
|
||||
!
|
||||
!!$OMP CRITICAL (out)
|
||||
! debug_OuterLoopDistribution(iOuter) = debug_OuterLoopDistribution(iOuter)+1
|
||||
!!$OMP END CRITICAL (out)
|
||||
invFp_new = math_mul33x33(invFp_old,B)
|
||||
call math_invert3x3(invFp_new,Fp_new,det,failed)
|
||||
if (failed) then
|
||||
msg = 'inversion Fp_new^-1'
|
||||
return
|
||||
endif
|
||||
!
|
||||
! if (wantsConstitutiveResults) then ! get the post_results upon request
|
||||
! results = 0.0_pReal
|
||||
! results = constitutive_post_results(Tstar_v,state,Temperature,dt,grain,ip,cp_en)
|
||||
! endif
|
||||
!
|
||||
Fp_new = Fp_new*det**(1.0_pReal/3.0_pReal) ! regularize Fp by det = det(InvFp_new) !!
|
||||
forall (i=1:3) Tstar_v(i) = Tstar_v(i)+p_hydro ! add hydrostatic component back
|
||||
Fe_new = math_mul33x33(Fg_new,invFp_new) ! calc resulting Fe
|
||||
! P = math_mul33x33(Fe_new,math_mul33x33(Tstar,transpose(invFp_new))) ! first PK stress
|
||||
P = math_mul33x33(Fe_new,math_mul33x33(math_Mandel6to33(Tstar_v),transpose(invFp_new))) ! first PK stress
|
||||
|
||||
return
|
||||
!
|
||||
END SUBROUTINE
|
||||
!
|
||||
END MODULE
|
||||
!##############################################################
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,931 +0,0 @@
|
|||
|
||||
!************************************
|
||||
!* Module: CONSTITUTIVE *
|
||||
!************************************
|
||||
!* contains: *
|
||||
!* - constitutive equations *
|
||||
!* - parameters definition *
|
||||
!* - orientations *
|
||||
!************************************
|
||||
|
||||
MODULE constitutive
|
||||
|
||||
!*** Include other modules ***
|
||||
use prec, only: pReal,pInt
|
||||
implicit none
|
||||
|
||||
! MISSING consistency check after reading 'mattex.mpie'
|
||||
character(len=300), parameter :: mattexFile = 'mattex.mpie'
|
||||
|
||||
|
||||
!*************************************
|
||||
!* Definition of material properties *
|
||||
!*************************************
|
||||
!* Number of materials
|
||||
integer(pInt) material_maxN
|
||||
!* Crystal structure and number of selected slip systems per material
|
||||
integer(pInt), dimension(:) , allocatable :: material_CrystalStructure
|
||||
integer(pInt), dimension(:) , allocatable :: material_Nslip
|
||||
!* Maximum number of selected slip systems over materials
|
||||
integer(pInt) material_maxNslip
|
||||
!* Elastic constants and matrices
|
||||
real(pReal), dimension(:) , allocatable :: material_C11
|
||||
real(pReal), dimension(:) , allocatable :: material_C12
|
||||
real(pReal), dimension(:) , allocatable :: material_C13
|
||||
real(pReal), dimension(:) , allocatable :: material_C33
|
||||
real(pReal), dimension(:) , allocatable :: material_C44
|
||||
real(pReal), dimension(:,:,:), allocatable :: material_Cslip_66
|
||||
!* Visco-plastic material parameters
|
||||
real(pReal), dimension(:) , allocatable :: material_s0_slip
|
||||
real(pReal), dimension(:) , allocatable :: material_gdot0_slip
|
||||
real(pReal), dimension(:) , allocatable :: material_n_slip
|
||||
real(pReal), dimension(:) , allocatable :: material_h0
|
||||
real(pReal), dimension(:) , allocatable :: material_s_sat
|
||||
real(pReal), dimension(:) , allocatable :: material_w0
|
||||
real(pReal), dimension(:,:) , allocatable :: material_SlipIntCoeff
|
||||
!* GIA material parameters
|
||||
real(pReal), dimension(:,:) , allocatable :: material_AspectRatio
|
||||
real(pReal), dimension(:) , allocatable :: material_GrainSize
|
||||
real(pReal), dimension(:) , allocatable :: material_bg
|
||||
|
||||
!************************************
|
||||
!* Definition of texture properties *
|
||||
!************************************
|
||||
!* Number of textures, maximum number of Gauss and Fiber components
|
||||
integer(pInt) texture_maxN
|
||||
integer(pInt) texture_maxNGauss
|
||||
integer(pInt) texture_maxNFiber
|
||||
!* Textures definition
|
||||
character(len=80), dimension(:), allocatable :: texture_ODFfile
|
||||
character(len=80), dimension(:), allocatable :: texture_symmetry
|
||||
integer(pInt), dimension(:) , allocatable :: texture_Ngrains
|
||||
integer(pInt), dimension(:) , allocatable :: texture_NGauss
|
||||
integer(pInt),dimension(:) , allocatable :: texture_NFiber
|
||||
integer(pInt),dimension(:) , allocatable :: texture_NRandom
|
||||
integer(pInt),dimension(:) , allocatable :: texture_totalNgrains
|
||||
real(pReal), dimension(:,:,:) , allocatable :: texture_Gauss
|
||||
real(pReal), dimension(:,:,:) , allocatable :: texture_Fiber
|
||||
real(pReal), dimension(:,:,:,:), allocatable :: constitutive_EulerAngles
|
||||
|
||||
!************************************
|
||||
!* Grains *
|
||||
!************************************
|
||||
integer(pInt) constitutive_maxNgrains
|
||||
integer(pInt), dimension(:,:) , allocatable :: constitutive_Ngrains
|
||||
integer(pInt), dimension(:,:,:) , allocatable :: constitutive_matID
|
||||
real(pReal), dimension(:,:,:) , allocatable :: constitutive_matVolFrac
|
||||
integer(pInt), dimension(:,:,:) , allocatable :: constitutive_texID
|
||||
real(pReal), dimension(:,:,:) , allocatable :: constitutive_texVolFrac
|
||||
|
||||
!************************************
|
||||
!* State variables *
|
||||
!************************************
|
||||
logical :: wantsConstitutiveResults = .false.
|
||||
integer(pInt) constitutive_maxNstatevars
|
||||
integer(pInt), dimension(:,:,:) , allocatable :: constitutive_Nstatevars
|
||||
real(pReal), dimension(:,:,:,:) , allocatable :: constitutive_state_old
|
||||
real(pReal), dimension(:,:,:,:) , allocatable :: constitutive_state_new
|
||||
|
||||
!************************************
|
||||
!* Hardening matrices *
|
||||
!************************************
|
||||
real(pReal), dimension(:,:,:), allocatable :: constitutive_HardeningMatrix
|
||||
|
||||
!************************************
|
||||
!* Results *
|
||||
!************************************
|
||||
integer(pInt) constitutive_maxNresults
|
||||
integer(pInt), dimension(:,:,:), allocatable :: constitutive_Nresults
|
||||
|
||||
|
||||
|
||||
CONTAINS
|
||||
!****************************************
|
||||
!* - constitutive_Init
|
||||
!* - constitutive_CountSections
|
||||
!* - constitutive_Parse_UnknownPart
|
||||
!* - constitutive_Parse_MaterialPart
|
||||
!* - constitutive_Parse_TexturePart
|
||||
!* - constitutive_Parse_MatTexDat
|
||||
!* - constitutive_Assignment
|
||||
!* - constitutive_HomogenizedC
|
||||
!* - constitutive_Microstructure
|
||||
!* - constitutive_LpAndItsTangent
|
||||
!* - consistutive_DotState
|
||||
!****************************************
|
||||
|
||||
|
||||
subroutine constitutive_Init()
|
||||
!**************************************
|
||||
!* Module initialization *
|
||||
!**************************************
|
||||
call constitutive_Parse_MatTexDat(mattexFile)
|
||||
call constitutive_Assignment()
|
||||
end subroutine
|
||||
|
||||
|
||||
subroutine constitutive_CountSections(file,count,part)
|
||||
!*********************************************************************
|
||||
!* This subroutine reads a "part" from the input file until the next *
|
||||
!* part is reached and counts the number of "sections" in the part *
|
||||
!* INPUT: *
|
||||
!* - file : file ID *
|
||||
!* OUTPUT: *
|
||||
!* - part : name of the next "part" *
|
||||
!* - count : number of sections inside the current "part" *
|
||||
!*********************************************************************
|
||||
use prec, only: pInt
|
||||
use IO, only: IO_stringPos,IO_stringValue,IO_lc
|
||||
implicit none
|
||||
|
||||
!* Definition of variables
|
||||
character(len=80) part,line,tag
|
||||
integer(pInt) file,count
|
||||
integer(pInt), dimension(3) :: positions
|
||||
|
||||
count=0
|
||||
part=''
|
||||
|
||||
do
|
||||
read(file,'(a80)',END=100) line
|
||||
positions=IO_stringPos(line,1)
|
||||
tag=IO_lc(IO_stringValue(line,positions,1))
|
||||
if (tag(1:1)=='#' .OR. positions(1)==0) then ! skip comment and empty lines
|
||||
cycle
|
||||
elseif (tag(1:1)=='<'.AND.tag(len_trim(tag):len_trim(tag))=='>') then
|
||||
part=tag(2:len_trim(tag)-1)
|
||||
exit
|
||||
elseif (tag(1:1)=='[') then
|
||||
count=count+1
|
||||
endif
|
||||
enddo
|
||||
100 return
|
||||
|
||||
end subroutine
|
||||
|
||||
|
||||
character(len=80) function constitutive_assignNGaussAndFiber(file)
|
||||
!*********************************************************************
|
||||
!*********************************************************************
|
||||
use prec, only: pInt
|
||||
use IO, only: IO_stringPos,IO_stringValue,IO_lc
|
||||
implicit none
|
||||
|
||||
!* Definition of variables
|
||||
character(len=80) line,tag
|
||||
integer(pInt) file,section
|
||||
integer(pInt), dimension(3) :: positions
|
||||
|
||||
constitutive_assignNGaussAndFiber=''
|
||||
section = 0_pInt
|
||||
|
||||
do
|
||||
read(file,'(a80)',END=100) line
|
||||
positions=IO_stringPos(line,1)
|
||||
tag=IO_lc(IO_stringValue(line,positions,1))
|
||||
if (tag(1:1)=='#' .OR. positions(1)==0) then ! skip comment and empty lines
|
||||
cycle
|
||||
elseif (tag(1:1)=='<'.AND.tag(len_trim(tag):len_trim(tag))=='>') then
|
||||
constitutive_assignNGaussAndFiber=tag(2:len_trim(tag)-1)
|
||||
exit
|
||||
elseif (tag(1:1)=='[') then
|
||||
section=section+1
|
||||
texture_NGauss(section) = 0_pInt
|
||||
texture_NFiber(section) = 0_pInt
|
||||
elseif (tag=='(gauss)') then
|
||||
texture_NGauss(section)=texture_NGauss(section)+1
|
||||
elseif (tag=='(fiber)') then
|
||||
texture_NFiber(section)=texture_NFiber(section)+1
|
||||
endif
|
||||
enddo
|
||||
100 return
|
||||
|
||||
end function
|
||||
|
||||
|
||||
character(len=80) function constitutive_Parse_UnknownPart(file)
|
||||
!*********************************************************************
|
||||
!* read an unknown "part" from the input file until *
|
||||
!* the next part is reached *
|
||||
!* INPUT: *
|
||||
!* - file : file ID *
|
||||
!*********************************************************************
|
||||
use prec, only: pInt
|
||||
use IO, only: IO_stringPos,IO_stringValue,IO_lc
|
||||
implicit none
|
||||
|
||||
!* Definition of variables
|
||||
character(len=80) line,tag
|
||||
integer(pInt), parameter :: maxNchunks = 1
|
||||
integer(pInt) file
|
||||
integer(pInt), dimension(1+2*maxNchunks) :: positions
|
||||
|
||||
constitutive_parse_unknownPart=''
|
||||
|
||||
do
|
||||
read(file,'(a80)',END=100) line
|
||||
positions=IO_stringPos(line,maxNchunks)
|
||||
tag=IO_lc(IO_stringValue(line,positions,1))
|
||||
if (tag(1:1)=='#' .OR. positions(1)==0) then ! skip comment and empty lines
|
||||
cycle
|
||||
elseif (tag(1:1)=='<'.AND.tag(len_trim(tag):len_trim(tag))=='>') then
|
||||
constitutive_Parse_UnknownPart=tag(2:len_trim(tag)-1)
|
||||
exit
|
||||
endif
|
||||
enddo
|
||||
100 return
|
||||
|
||||
end function
|
||||
|
||||
|
||||
character(len=80) function constitutive_Parse_MaterialPart(file)
|
||||
!*********************************************************************
|
||||
!* This function reads a material "part" from the input file until *
|
||||
!* the next part is reached *
|
||||
!* INPUT: *
|
||||
!* - file : file ID *
|
||||
!*********************************************************************
|
||||
use prec, only: pInt
|
||||
use IO
|
||||
implicit none
|
||||
|
||||
!* Definition of variables
|
||||
character(len=80) line,tag
|
||||
integer(pInt) i
|
||||
integer(pInt), parameter :: maxNchunks = 3
|
||||
integer(pInt) file,section
|
||||
integer(pInt), dimension(1+2*maxNchunks) :: positions
|
||||
|
||||
section = 0
|
||||
constitutive_parse_materialPart = ''
|
||||
|
||||
do while(.true.)
|
||||
read(file,'(a80)',END=100) line
|
||||
positions=IO_stringPos(line,maxNchunks) ! parse leading chunks
|
||||
tag=IO_lc(IO_stringValue(line,positions,1))
|
||||
if (tag(1:1)=='#' .OR. positions(1)==0) then ! skip comment and empty lines
|
||||
cycle
|
||||
elseif (tag(1:1)=='<'.AND.tag(len_trim(tag):len_trim(tag))=='>') then
|
||||
constitutive_parse_materialPart=tag(2:len_trim(tag)-1)
|
||||
exit
|
||||
elseif (tag(1:1)=='[') then
|
||||
section=section+1
|
||||
else
|
||||
if (section>0) then
|
||||
select case(tag)
|
||||
case ('lattice_structure')
|
||||
material_CrystalStructure(section)=IO_intValue(line,positions,2)
|
||||
case ('nslip')
|
||||
material_Nslip(section)=IO_intValue(line,positions,2)
|
||||
case ('c11')
|
||||
material_C11(section)=IO_floatValue(line,positions,2)
|
||||
case ('c12')
|
||||
material_C12(section)=IO_floatValue(line,positions,2)
|
||||
case ('c13')
|
||||
material_C13(section)=IO_floatValue(line,positions,2)
|
||||
case ('c33')
|
||||
material_C33(section)=IO_floatValue(line,positions,2)
|
||||
case ('c44')
|
||||
material_C44(section)=IO_floatValue(line,positions,2)
|
||||
case ('s0_slip')
|
||||
material_s0_slip(section)=IO_floatValue(line,positions,2)
|
||||
case ('gdot0_slip')
|
||||
material_gdot0_slip(section)=IO_floatValue(line,positions,2)
|
||||
case ('n_slip')
|
||||
material_n_slip(section)=IO_floatValue(line,positions,2)
|
||||
case ('h0')
|
||||
material_h0(section)=IO_floatValue(line,positions,2)
|
||||
case ('s_sat')
|
||||
material_s_sat(section)=IO_floatValue(line,positions,2)
|
||||
case ('w0')
|
||||
material_w0(section)=IO_floatValue(line,positions,2)
|
||||
case ('hardening_coefficients')
|
||||
do i=1,2
|
||||
material_SlipIntCoeff(i,section)=IO_floatValue(line,positions,i+1)
|
||||
enddo
|
||||
case ('grain_size')
|
||||
material_GrainSize(section)=IO_floatValue(line,positions,2)
|
||||
case ('burgers')
|
||||
material_bg(section)=IO_floatValue(line,positions,2)
|
||||
case ('grain_aspect_ratio')
|
||||
do i=1,2
|
||||
material_AspectRatio(i,section)=IO_floatValue(line,positions,i+1)
|
||||
enddo
|
||||
end select
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
100 return
|
||||
|
||||
end function
|
||||
|
||||
|
||||
character(len=80) function constitutive_Parse_TexturePart(file)
|
||||
!*********************************************************************
|
||||
!* This function reads a texture "part" from the input file until *
|
||||
!* the next part is reached *
|
||||
!* INPUT: *
|
||||
!* - file : file ID *
|
||||
!*********************************************************************
|
||||
use prec, only: pInt
|
||||
use IO
|
||||
use math, only: inRad
|
||||
implicit none
|
||||
|
||||
!* Definition of variables
|
||||
character(len=80) line,tag
|
||||
integer(pInt), parameter :: maxNchunks = 13 ! may be more than 10 chunks ..?
|
||||
integer(pInt) file,section,gaussCount,fiberCount,i
|
||||
integer(pInt), dimension(1+2*maxNchunks) :: positions
|
||||
|
||||
section = 0
|
||||
gaussCount = 0
|
||||
fiberCount = 0
|
||||
constitutive_parse_texturePart = ''
|
||||
|
||||
do while(.true.)
|
||||
read(file,'(a80)',END=100) line
|
||||
positions=IO_stringPos(line,maxNchunks) ! parse leading chunks
|
||||
tag=IO_lc(IO_stringValue(line,positions,1))
|
||||
if (tag(1:1)=='#' .OR. positions(1)==0) then ! skip comment and empty lines
|
||||
cycle
|
||||
elseif (tag(1:1)=='<'.AND.tag(len_trim(tag):len_trim(tag))=='>') then
|
||||
constitutive_parse_texturePart=tag(2:len_trim(tag)-1)
|
||||
exit
|
||||
elseif (tag(1:1)=='[') then
|
||||
section=section+1
|
||||
gaussCount=0
|
||||
fiberCount=0
|
||||
else
|
||||
if (section>0) then
|
||||
select case(tag)
|
||||
case ('hybridia')
|
||||
texture_ODFfile(section)=IO_stringValue(line,positions,2)
|
||||
case ('(gauss)')
|
||||
gaussCount=gaussCount+1
|
||||
do i=2,10,2
|
||||
tag=IO_lc(IO_stringValue(line,positions,i))
|
||||
select case (tag)
|
||||
case('phi1')
|
||||
texture_Gauss(1,gaussCount,section)=IO_floatValue(line,positions,i+1)*inRad
|
||||
case('phi')
|
||||
texture_Gauss(2,gaussCount,section)=IO_floatValue(line,positions,i+1)*inRad
|
||||
case('phi2')
|
||||
texture_Gauss(3,gaussCount,section)=IO_floatValue(line,positions,i+1)*inRad
|
||||
case('scatter')
|
||||
texture_Gauss(4,gaussCount,section)=IO_floatValue(line,positions,i+1)*inRad
|
||||
case('fraction')
|
||||
texture_Gauss(5,gaussCount,section)=IO_floatValue(line,positions,i+1)
|
||||
end select
|
||||
enddo
|
||||
case ('(fiber)')
|
||||
fiberCount=fiberCount+1
|
||||
do i=2,12,2
|
||||
tag=IO_lc(IO_stringValue(line,positions,i))
|
||||
select case (tag)
|
||||
case('alpha1')
|
||||
texture_fiber(1,fiberCount,section)=IO_floatValue(line,positions,i+1)*inRad
|
||||
case('alpha2')
|
||||
texture_fiber(2,fiberCount,section)=IO_floatValue(line,positions,i+1)*inRad
|
||||
case('beta1')
|
||||
texture_fiber(3,fiberCount,section)=IO_floatValue(line,positions,i+1)*inRad
|
||||
case('beta2')
|
||||
texture_fiber(4,fiberCount,section)=IO_floatValue(line,positions,i+1)*inRad
|
||||
case('scatter')
|
||||
texture_fiber(5,fiberCount,section)=IO_floatValue(line,positions,i+1)*inRad
|
||||
case('fraction')
|
||||
texture_fiber(6,fiberCount,section)=IO_floatValue(line,positions,i+1)
|
||||
end select
|
||||
enddo
|
||||
case ('ngrains')
|
||||
texture_Ngrains(section)=IO_intValue(line,positions,2)
|
||||
case ('symmetry')
|
||||
texture_symmetry(section)=IO_stringValue(line,positions,2)
|
||||
end select
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
100 return
|
||||
|
||||
end function
|
||||
|
||||
|
||||
subroutine constitutive_Parse_MatTexDat(filename)
|
||||
!*********************************************************************
|
||||
!* This function reads the material and texture input file *
|
||||
!* INPUT: *
|
||||
!* - filename : name of input file *
|
||||
!*********************************************************************
|
||||
use prec, only: pReal,pInt
|
||||
use IO, only: IO_error, IO_open_file
|
||||
use math, only: math_Mandel3333to66, math_Voigt66to3333
|
||||
use lattice, only: lattice_SlipIntType
|
||||
implicit none
|
||||
|
||||
!* Definition of variables
|
||||
character(len=*) filename
|
||||
character(len=80) part,formerPart
|
||||
integer(pInt) sectionCount,i,j,k, fileunit
|
||||
|
||||
! set fileunit
|
||||
fileunit=200
|
||||
!-----------------------------
|
||||
!* First reading: number of materials and textures
|
||||
!-----------------------------
|
||||
!* determine material_maxN and texture_maxN from last respective parts
|
||||
if(.not. IO_open_file(fileunit,filename)) call IO_error (200) ! corrupt mattex file
|
||||
part = '_dummy_'
|
||||
do while (part/='')
|
||||
formerPart = part
|
||||
call constitutive_CountSections(fileunit,sectionCount,part)
|
||||
select case (formerPart)
|
||||
case ('materials')
|
||||
material_maxN = sectionCount
|
||||
case ('textures')
|
||||
texture_maxN = sectionCount
|
||||
end select
|
||||
enddo
|
||||
!* Array allocation
|
||||
allocate(material_CrystalStructure(material_maxN)) ; material_CrystalStructure=0_pInt
|
||||
allocate(material_Nslip(material_maxN)) ; material_Nslip=0_pInt
|
||||
allocate(material_C11(material_maxN)) ; material_C11=0.0_pReal
|
||||
allocate(material_C12(material_maxN)) ; material_C12=0.0_pReal
|
||||
allocate(material_C13(material_maxN)) ; material_C13=0.0_pReal
|
||||
allocate(material_C33(material_maxN)) ; material_C33=0.0_pReal
|
||||
allocate(material_C44(material_maxN)) ; material_C44=0.0_pReal
|
||||
allocate(material_Cslip_66(6,6,material_maxN)) ; material_Cslip_66=0.0_pReal
|
||||
allocate(material_s0_slip(material_maxN)) ; material_s0_slip=0.0_pReal
|
||||
allocate(material_gdot0_slip(material_maxN)) ; material_gdot0_slip=0.0_pReal
|
||||
allocate(material_n_slip(material_maxN)) ; material_n_slip=0.0_pReal
|
||||
allocate(material_h0(material_maxN)) ; material_h0=0.0_pReal
|
||||
allocate(material_s_sat(material_maxN)) ; material_s_sat=0.0_pReal
|
||||
allocate(material_w0(material_maxN)) ; material_w0=0.0_pReal
|
||||
allocate(material_SlipIntCoeff(maxval(lattice_SlipIntType),material_maxN)) ; material_SlipIntCoeff=0.0_pReal
|
||||
allocate(material_GrainSize(material_maxN)) ; material_GrainSize=0.0_pReal
|
||||
allocate(material_bg(material_maxN)) ; material_bg=0.0_pReal
|
||||
allocate(material_AspectRatio(2,material_maxN)) ; material_AspectRatio=0.0_pReal
|
||||
allocate(texture_ODFfile(texture_maxN)) ; texture_ODFfile=''
|
||||
allocate(texture_Ngrains(texture_maxN)) ; texture_Ngrains=0_pInt
|
||||
allocate(texture_symmetry(texture_maxN)) ; texture_symmetry=''
|
||||
allocate(texture_NGauss(texture_maxN)) ; texture_NGauss=0_pInt
|
||||
allocate(texture_NFiber(texture_maxN)) ; texture_NFiber=0_pInt
|
||||
allocate(texture_NRandom(texture_maxN)) ; texture_NRandom=0_pInt
|
||||
|
||||
!-----------------------------
|
||||
!* Second reading: number of Gauss and Fiber
|
||||
!-----------------------------
|
||||
rewind(fileunit)
|
||||
part = '_dummy_'
|
||||
do while (part/='')
|
||||
select case (part)
|
||||
case ('textures')
|
||||
part = constitutive_assignNGaussAndFiber(fileunit)
|
||||
case default
|
||||
part = constitutive_Parse_UnknownPart(fileunit)
|
||||
end select
|
||||
enddo
|
||||
!* Array allocation
|
||||
texture_maxNGauss=maxval(texture_NGauss)
|
||||
texture_maxNFiber=maxval(texture_NFiber)
|
||||
allocate(texture_Gauss(5,texture_maxNGauss,texture_maxN)) ; texture_Gauss=0.0_pReal
|
||||
allocate(texture_Fiber(6,texture_maxNFiber,texture_maxN)) ; texture_Fiber=0.0_pReal
|
||||
|
||||
!-----------------------------
|
||||
!* Third reading: materials and textures are stored
|
||||
!-----------------------------
|
||||
rewind(fileunit)
|
||||
part='_dummy_'
|
||||
do while (part/='')
|
||||
select case (part)
|
||||
case ('materials')
|
||||
part=constitutive_Parse_MaterialPart(fileunit)
|
||||
case ('textures')
|
||||
part=constitutive_Parse_TexturePart(fileunit)
|
||||
case default
|
||||
part=constitutive_Parse_UnknownPart(fileunit)
|
||||
end select
|
||||
enddo
|
||||
close(fileunit)
|
||||
|
||||
!*
|
||||
do i=1,material_maxN
|
||||
write(6,*) 'echo: material(',i,')'
|
||||
write(6,*) 'lattice_structure',material_CrystalStructure(i)
|
||||
write(6,*) 'nslip',material_Nslip(i)
|
||||
write(6,*) 'c11',material_C11(i)
|
||||
write(6,*) 'c12',material_C12(i)
|
||||
write(6,*) 'c13',material_C13(i)
|
||||
write(6,*) 'c33',material_C33(i)
|
||||
write(6,*) 'c44',material_C44(i)
|
||||
write(6,*) 's0_slip',material_s0_slip(i)
|
||||
write(6,*) 'gdot0_slip',material_gdot0_slip(i)
|
||||
write(6,*) 'n_slip',material_n_slip(i)
|
||||
write(6,*) 'h0',material_h0(i)
|
||||
write(6,*) 's_sat',material_s_sat(i)
|
||||
write(6,*) 'w0',material_w0(i)
|
||||
write(6,*) 'hardening_coefficients',material_SlipIntCoeff(1,i),material_SlipIntCoeff(2,i)
|
||||
write(6,*) 'grain_size',material_GrainSize(i)
|
||||
write(6,*) 'burgers',material_bg(i)
|
||||
write(6,*) 'grain_aspect_ratio',material_AspectRatio(1,i),material_AspectRatio(2,i)
|
||||
enddo
|
||||
|
||||
!* Construction of the elasticity matrices
|
||||
do i=1,material_maxN
|
||||
select case (material_CrystalStructure(i))
|
||||
case(1:2) ! cubic(s)
|
||||
forall(k=1:3)
|
||||
forall(j=1:3)
|
||||
material_Cslip_66(k,j,i)=material_C12(i)
|
||||
endforall
|
||||
material_Cslip_66(k,k,i)=material_C11(i)
|
||||
material_Cslip_66(k+3,k+3,i)=material_C44(i)
|
||||
endforall
|
||||
case(3) ! hcp
|
||||
material_Cslip_66(1,1,i)=material_C11(i)
|
||||
material_Cslip_66(2,2,i)=material_C11(i)
|
||||
material_Cslip_66(3,3,i)=material_C33(i)
|
||||
material_Cslip_66(1,2,i)=material_C12(i)
|
||||
material_Cslip_66(2,1,i)=material_C12(i)
|
||||
material_Cslip_66(1,3,i)=material_C13(i)
|
||||
material_Cslip_66(3,1,i)=material_C13(i)
|
||||
material_Cslip_66(2,3,i)=material_C13(i)
|
||||
material_Cslip_66(3,2,i)=material_C13(i)
|
||||
material_Cslip_66(4,4,i)=material_C44(i)
|
||||
material_Cslip_66(5,5,i)=material_C44(i)
|
||||
material_Cslip_66(6,6,i)=0.5_pReal*(material_C11(i)-material_C12(i))
|
||||
end select
|
||||
material_Cslip_66(:,:,i) = math_Mandel3333to66(math_Voigt66to3333(material_Cslip_66(:,:,i)))
|
||||
! Check
|
||||
enddo
|
||||
|
||||
|
||||
! MISSING some consistency checks may be..?
|
||||
! if ODFfile present then set NGauss NFiber =0
|
||||
return
|
||||
end subroutine
|
||||
|
||||
|
||||
subroutine constitutive_Assignment()
|
||||
!*********************************************************************
|
||||
!* This subroutine assign material parameters according to ipc,ip,el *
|
||||
!*********************************************************************
|
||||
use prec, only: pReal,pInt
|
||||
use math, only: math_sampleGaussOri,math_sampleFiberOri,math_sampleRandomOri,math_symmetricEulers,math_EulerToR
|
||||
use mesh, only: mesh_NcpElems,FE_Nips,mesh_maxNips,mesh_element
|
||||
use IO, only: IO_hybridIA
|
||||
use lattice, only: lattice_SlipIntType
|
||||
|
||||
implicit none
|
||||
|
||||
!* Definition of variables
|
||||
integer(pInt) e,i,j,k,l,m,o,g,s
|
||||
integer(pInt) matID,texID
|
||||
integer(pInt), dimension(texture_maxN) :: Ncomponents,Nsym,multiplicity,ODFmap,sampleCount
|
||||
real(pReal), dimension(:,:,:), allocatable :: hybridIA_population
|
||||
real(pReal), dimension(3,4*(1+texture_maxNGauss+texture_maxNfiber)) :: Euler
|
||||
real(pReal), dimension(4*(1+texture_maxNGauss+texture_maxNfiber)) :: texVolfrac
|
||||
real(pReal), dimension(texture_maxN) :: sumVolfrac
|
||||
|
||||
! process textures
|
||||
o = 0_pInt ! ODF counter
|
||||
ODFmap = 0_pInt ! blank mapping
|
||||
sampleCount = 0_pInt ! count orientations assigned per texture
|
||||
|
||||
do texID=1,texture_maxN
|
||||
select case (texture_symmetry(texID)) ! set symmetry factor
|
||||
case ('orthotropic')
|
||||
Nsym(texID) = 4_pInt
|
||||
case ('monoclinic')
|
||||
Nsym(texID) = 2_pInt
|
||||
case default
|
||||
Nsym(texID) = 1_pInt
|
||||
end select
|
||||
if (texture_ODFfile(texID)=='') then ! texture components
|
||||
sumVolfrac(texID) = sum(texture_gauss(5,:,texID))+sum(texture_fiber(6,:,texID))
|
||||
if (sumVolfrac(texID)<1.0_pReal) texture_NRandom(texID) = 1_pInt ! check whether random component missing
|
||||
Ncomponents(texID) = texture_NGauss(texID)+texture_NFiber(texID)+texture_NRandom(texID)
|
||||
else ! hybrid IA
|
||||
o = o+1
|
||||
ODFmap(texID) = o ! remember mapping
|
||||
Ncomponents(texID) = 1_pInt ! single "component"
|
||||
endif
|
||||
! adjust multiplicity and number of grains per IP of components
|
||||
multiplicity(texID) = max(1_pInt,texture_Ngrains(texID)/Ncomponents(texID)/Nsym(texID))
|
||||
if (mod(texture_Ngrains(texID),Ncomponents(texID)*Nsym(texID)) /= 0_pInt) then
|
||||
texture_Ngrains(texID) = multiplicity(texID)*Ncomponents(texID)*Nsym(texID)
|
||||
!$OMP CRITICAL (write2out)
|
||||
write (6,*) 'changed Ngrains to',texture_Ngrains(texID),' for texture',texID
|
||||
!$OMP END CRITICAL (write2out)
|
||||
endif
|
||||
enddo
|
||||
|
||||
!* publish globals
|
||||
constitutive_maxNgrains = maxval(texture_Ngrains)
|
||||
material_maxNslip = maxval(material_Nslip) ! max # of slip systems among materials present
|
||||
constitutive_maxNstatevars = material_maxNslip + 0_pInt
|
||||
|
||||
|
||||
!* calc texture_totalNgrains
|
||||
allocate(texture_totalNgrains(texture_maxN)) ; texture_totalNgrains=0_pInt
|
||||
do i=1,mesh_NcpElems
|
||||
texID = mesh_element(4,i)
|
||||
texture_totalNgrains(texID) = texture_totalNgrains(texID) + FE_Nips(mesh_element(2,i))*texture_Ngrains(texID)
|
||||
enddo
|
||||
|
||||
! generate hybridIA samplings for ODFfile textures to later draw from these populations
|
||||
allocate(hybridIA_population(3,maxval(texture_totalNgrains/Nsym,ODFmap /= 0),o))
|
||||
do texID = 1,texture_maxN
|
||||
if (ODFmap(texID) > 0) then
|
||||
!$OMP CRITICAL (write2out)
|
||||
write (6,*) 'hybridIA',texture_totalNgrains(texID)/Nsym(texID),texture_ODFfile(texID)
|
||||
!$OMP END CRITICAL (write2out)
|
||||
hybridIA_population(:,:,ODFmap(texID)) = IO_hybridIA(texture_totalNgrains(texID)/Nsym(texID),texture_ODFfile(texID))
|
||||
endif
|
||||
enddo
|
||||
|
||||
!* Array allocation
|
||||
allocate(constitutive_Ngrains(mesh_maxNips,mesh_NcpElems)) ; constitutive_Ngrains=0_pInt
|
||||
allocate(constitutive_matID(constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; constitutive_matID=0_pInt
|
||||
allocate(constitutive_texID(constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; constitutive_texID=0_pInt
|
||||
allocate(constitutive_MatVolFrac(constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; constitutive_MatVolFrac=0.0_pReal
|
||||
allocate(constitutive_TexVolFrac(constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; constitutive_TexVolFrac=0.0_pReal
|
||||
allocate(constitutive_EulerAngles(3,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; constitutive_EulerAngles=0.0_pReal
|
||||
allocate(constitutive_Nresults(constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; constitutive_Nresults=0_pInt
|
||||
allocate(constitutive_Nstatevars(constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems)) ; constitutive_Nstatevars=0_pInt
|
||||
allocate(constitutive_state_old(constitutive_maxNstatevars,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems))
|
||||
constitutive_state_old=0.0_pReal
|
||||
allocate(constitutive_state_new(constitutive_maxNstatevars,constitutive_maxNgrains,mesh_maxNips,mesh_NcpElems))
|
||||
constitutive_state_new=0.0_pReal
|
||||
allocate(constitutive_HardeningMatrix(material_maxNslip,material_maxNslip,material_maxN))
|
||||
constitutive_HardeningMatrix=0.0_pReal
|
||||
|
||||
!* Assignment of all grains in all IPs of all cp-elements
|
||||
do e=1,mesh_NcpElems
|
||||
matID=mesh_element(3,e)
|
||||
texID=mesh_element(4,e)
|
||||
do i=1,FE_Nips(mesh_element(2,e))
|
||||
g = 0_pInt ! grain counter
|
||||
do m = 1,multiplicity(texID)
|
||||
o = 0_pInt ! component counter
|
||||
if (texture_ODFfile(texID)=='') then
|
||||
do k = 1,texture_nGauss(texID) ! *** gauss ***
|
||||
o = o+1
|
||||
Euler(:,o) = math_sampleGaussOri(texture_Gauss(1:3,k,texID),texture_Gauss(4,k,texID))
|
||||
texVolFrac(o) = texture_Gauss(5,k,texID)
|
||||
enddo
|
||||
do k = 1,texture_nFiber(texID) ! *** fiber ***
|
||||
o = o+1
|
||||
Euler(:,o) = math_sampleFiberOri(texture_Fiber(1:2,k,texID),texture_Fiber(3:4,k,texID),texture_Fiber(5,k,texID))
|
||||
texVolFrac(o) = texture_Fiber(6,k,texID)
|
||||
enddo
|
||||
do k = 1,texture_nRandom(texID) ! *** random ***
|
||||
o = o+1
|
||||
Euler(:,o) = math_sampleRandomOri()
|
||||
texVolfrac(o) = 1.0_pReal-sumVolfrac(texID)
|
||||
enddo
|
||||
else ! *** hybrid IA ***
|
||||
o = 1 ! only singular orientation, i.e. single "component"
|
||||
Euler(:,o) = hybridIA_population(:,1+sampleCount(texID),ODFmap(texID))
|
||||
texVolfrac(o) = 1.0_pReal
|
||||
endif
|
||||
if (Nsym(texID) > 1) then ! symmetry generates additional orientations
|
||||
forall (k=1:o)
|
||||
Euler(:,1+o+(Nsym(texID)-1)*(k-1):3+o+(Nsym(texID)-1)*(k-1)) = &
|
||||
math_symmetricEulers(texture_symmetry(texID),Euler(:,k))
|
||||
texVolfrac(1+o+(Nsym(texID)-1)*(k-1):3+o+(Nsym(texID)-1)*(k-1)) = texVolfrac(k)
|
||||
end forall
|
||||
endif
|
||||
do s = 1,Nsym(texID)*o ! loop over orientations to be assigned to ip (ex multiplicity)
|
||||
g = g+1 ! next "grain"
|
||||
constitutive_matID(g,i,e) = matID ! copy matID of element
|
||||
constitutive_texID(g,i,e) = texID ! copy texID of element
|
||||
constitutive_MatVolFrac(g,i,e) = 1.0_pReal ! singular material (so far)
|
||||
constitutive_TexVolFrac(g,i,e) = texVolfrac(s)/multiplicity(texID)/Nsym(texID)
|
||||
constitutive_Nstatevars(g,i,e) = material_Nslip(matID) ! number of state variables (i.e. tau_c of each slip system)
|
||||
! constitutive_Nresults(g,i,e) = 2*material_Nslip(matID) ! number of constitutive results (shears in this case)
|
||||
constitutive_EulerAngles(:,g,i,e) = Euler(:,s) ! store initial orientation
|
||||
forall (l=1:constitutive_Nstatevars(g,i,e)) ! initialize state variables
|
||||
constitutive_state_old(l,g,i,e) = material_s0_slip(matID)
|
||||
constitutive_state_new(l,g,i,e) = material_s0_slip(matID)
|
||||
end forall
|
||||
enddo ! components
|
||||
sampleCount(texID) = sampleCount(texID)+1 ! next member of hybrid IA population
|
||||
enddo ! multiplicity
|
||||
enddo ! ip
|
||||
enddo ! cp_element
|
||||
|
||||
|
||||
!* Construction of the hardening matrices
|
||||
do i=1,material_maxN
|
||||
!* Iteration over the systems
|
||||
do j=1,material_Nslip(i)
|
||||
do k=1,material_Nslip(i)
|
||||
!* min function is used to distinguish self hardening from latent hardening
|
||||
constitutive_HardeningMatrix(k,j,i) = material_SlipIntCoeff(max(2,min(3,lattice_SlipIntType(k,j,i)))-1,i) ! 1,2,3,4,5 --> 1,1,2,2,2
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
!* publish globals
|
||||
constitutive_maxNresults = maxval(constitutive_Nresults)
|
||||
|
||||
end subroutine
|
||||
|
||||
|
||||
function constitutive_HomogenizedC(state,ipc,ip,el)
|
||||
!*********************************************************************
|
||||
!* This function returns the homogenized elacticity matrix *
|
||||
!* INPUT: *
|
||||
!* - state : state variables *
|
||||
!* - ipc : component-ID of current integration point *
|
||||
!* - ip : current integration point *
|
||||
!* - el : current element *
|
||||
!*********************************************************************
|
||||
use prec, only: pReal,pInt
|
||||
implicit none
|
||||
|
||||
!* Definition of variables
|
||||
integer(pInt) ipc,ip,el
|
||||
real(pReal), dimension(6,6) :: constitutive_homogenizedC
|
||||
real(pReal), dimension(constitutive_Nstatevars(ipc,ip,el)) :: state
|
||||
|
||||
!* Homogenization scheme
|
||||
constitutive_homogenizedC=material_Cslip_66(:,:,constitutive_matID(ipc,ip,el))
|
||||
|
||||
return
|
||||
end function
|
||||
|
||||
|
||||
subroutine constitutive_Microstructure(state,Temperature,ipc,ip,el)
|
||||
!*********************************************************************
|
||||
!* This function calculates from state needed variables *
|
||||
!* INPUT: *
|
||||
!* - state : state variables *
|
||||
!* - Tp : temperature *
|
||||
!* - ipc : component-ID of current integration point *
|
||||
!* - ip : current integration point *
|
||||
!* - el : current element *
|
||||
!*********************************************************************
|
||||
use prec, only: pReal,pInt
|
||||
implicit none
|
||||
|
||||
!* Definition of variables
|
||||
integer(pInt) ipc,ip,el
|
||||
real(pReal) Temperature
|
||||
real(pReal), dimension(constitutive_Nstatevars(ipc,ip,el)) :: state
|
||||
|
||||
end subroutine
|
||||
|
||||
|
||||
subroutine constitutive_LpAndItsTangent(Lp,dLp_dTstar,Tstar_v,state,Temperature,ipc,ip,el)
|
||||
!*********************************************************************
|
||||
!* This subroutine contains the constitutive equation for *
|
||||
!* calculating the velocity gradient *
|
||||
!* INPUT: *
|
||||
!* - Tstar_v : 2nd Piola Kirchhoff stress tensor (Mandel) *
|
||||
!* - state : current microstructure *
|
||||
!* - ipc : component-ID of current integration point *
|
||||
!* - ip : current integration point *
|
||||
!* - el : current element *
|
||||
!* OUTPUT: *
|
||||
!* - Lp : plastic velocity gradient *
|
||||
!* - dLp_dTstar : derivative of Lp (4th-order tensor) *
|
||||
!*********************************************************************
|
||||
use prec, only: pReal,pInt
|
||||
use lattice, only: lattice_Sslip,lattice_Sslip_v
|
||||
use math, only: math_Plain3333to99
|
||||
use debug
|
||||
|
||||
implicit none
|
||||
|
||||
!* Definition of variables
|
||||
integer(pInt) ipc,ip,el
|
||||
integer(pInt) matID,i,k,l,m,n
|
||||
real(pReal) Temperature
|
||||
real(pReal), dimension(6) :: Tstar_v
|
||||
real(pReal), dimension(3,3) :: Lp
|
||||
real(pReal), dimension(3,3,3,3) :: dLp_dTstar3333
|
||||
real(pReal), dimension(9,9) :: dLp_dTstar
|
||||
real(pReal), dimension(constitutive_Nstatevars(ipc,ip,el)) :: state
|
||||
real(pReal), dimension(material_Nslip(constitutive_matID(ipc,ip,el))) :: gdot_slip,dgdot_dtauslip,tau_slip
|
||||
|
||||
!* Get the material-ID from the triplet(ipc,ip,el)
|
||||
matID = constitutive_matID(ipc,ip,el)
|
||||
|
||||
!* Calculation of Lp
|
||||
Lp = 0.0_pReal
|
||||
do i=1,material_Nslip(matID)
|
||||
tau_slip(i)=dot_product(Tstar_v,lattice_Sslip_v(:,i,material_CrystalStructure(matID)))
|
||||
gdot_slip(i)=material_gdot0_slip(matID)*(abs(tau_slip(i))/state(i))**&
|
||||
material_n_slip(matID)*sign(1.0_pReal,tau_slip(i))
|
||||
Lp=Lp+gdot_slip(i)*lattice_Sslip(:,:,i,material_CrystalStructure(matID))
|
||||
enddo
|
||||
|
||||
!* Calculation of the tangent of Lp
|
||||
dLp_dTstar3333 = 0.0_pReal
|
||||
dLp_dTstar = 0.0_pReal
|
||||
do i=1,material_Nslip(matID)
|
||||
dgdot_dtauslip(i) = material_gdot0_slip(matID)*(abs(tau_slip(i))/state(i))**&
|
||||
(material_n_slip(matID)-1.0_pReal)*material_n_slip(matID)/state(i)
|
||||
forall (k=1:3,l=1:3,m=1:3,n=1:3) &
|
||||
dLp_dTstar3333(k,l,m,n) = dLp_dTstar3333(k,l,m,n) + &
|
||||
dgdot_dtauslip(i)*lattice_Sslip(k,l,i,material_CrystalStructure(matID))* &
|
||||
lattice_Sslip(m,n,i,material_CrystalStructure(matID))
|
||||
enddo
|
||||
dLp_dTstar = math_Plain3333to99(dLp_dTstar3333)
|
||||
|
||||
return
|
||||
end subroutine
|
||||
|
||||
|
||||
function constitutive_dotState(Tstar_v,state,Temperature,ipc,ip,el)
|
||||
!*********************************************************************
|
||||
!* This subroutine contains the constitutive equation for *
|
||||
!* calculating the rate of change of microstructure *
|
||||
!* INPUT: *
|
||||
!* - Tstar_v : 2nd Piola Kirchhoff stress tensor (Mandel) *
|
||||
!* - state : current microstructure *
|
||||
!* - ipc : component-ID of current integration point *
|
||||
!* - ip : current integration point *
|
||||
!* - el : current element *
|
||||
!* OUTPUT: *
|
||||
!* - constitutive_dotState : evolution of state variable *
|
||||
!*********************************************************************
|
||||
use prec, only: pReal,pInt
|
||||
use lattice, only: lattice_Sslip_v
|
||||
implicit none
|
||||
|
||||
!* Definition of variables
|
||||
integer(pInt) ipc,ip,el
|
||||
integer(pInt) matID,i
|
||||
real(pReal) Temperature,tau_slip,gdot_slip
|
||||
real(pReal), dimension(6) :: Tstar_v
|
||||
real(pReal), dimension(constitutive_Nstatevars(ipc,ip,el)) :: constitutive_dotState,state,self_hardening
|
||||
|
||||
!* Get the material-ID from the triplet(ipc,ip,el)
|
||||
matID = constitutive_matID(ipc,ip,el)
|
||||
|
||||
!* Self-Hardening of each system
|
||||
do i=1,constitutive_Nstatevars(ipc,ip,el)
|
||||
tau_slip = dot_product(Tstar_v,lattice_Sslip_v(:,i,material_CrystalStructure(matID)))
|
||||
gdot_slip = material_gdot0_slip(matID)*(abs(tau_slip)/state(i))**&
|
||||
material_n_slip(matID)*sign(1.0_pReal,tau_slip)
|
||||
self_hardening(i)=material_h0(matID)*(1.0_pReal-state(i)/&
|
||||
material_s_sat(matID))**material_w0(matID)*abs(gdot_slip)
|
||||
enddo
|
||||
|
||||
!* Hardening for all systems
|
||||
!$OMP CRITICAL (evilmatmul)
|
||||
constitutive_dotState=matmul(constitutive_HardeningMatrix(1:material_Nslip(matID),1:material_Nslip(matID),&
|
||||
matID),self_hardening)
|
||||
!$OMP END CRITICAL (evilmatmul)
|
||||
return
|
||||
end function
|
||||
|
||||
|
||||
function constitutive_post_results(Tstar_v,state,Temperature,dt,ipc,ip,el)
|
||||
!*********************************************************************
|
||||
!* return array of constitutive results *
|
||||
!* INPUT: *
|
||||
!* - Tstar_v : 2nd Piola Kirchhoff stress tensor (Mandel) *
|
||||
!* - state : current microstructure *
|
||||
!* - dt : current time increment *
|
||||
!* - ipc : component-ID of current integration point *
|
||||
!* - ip : current integration point *
|
||||
!* - el : current element *
|
||||
!*********************************************************************
|
||||
use prec, only: pReal,pInt
|
||||
use lattice, only: lattice_Sslip_v
|
||||
implicit none
|
||||
|
||||
!* Definition of variables
|
||||
integer(pInt) ipc,ip,el
|
||||
integer(pInt) matID,i
|
||||
real(pReal) dt,Temperature,tau_slip, active_rate
|
||||
real(pReal), dimension(6) :: Tstar_v
|
||||
real(pReal), dimension(constitutive_Nstatevars(ipc,ip,el)) :: state
|
||||
real(pReal), dimension(constitutive_Nresults(ipc,ip,el)) :: constitutive_post_results
|
||||
|
||||
!* Get the material-ID from the triplet(ipc,ip,el)
|
||||
matID = constitutive_matID(ipc,ip,el)
|
||||
|
||||
if(constitutive_Nresults(ipc,ip,el)==0) return
|
||||
|
||||
constitutive_post_results=0
|
||||
do i=1,material_Nslip(matID)
|
||||
!do i=1,constitutive_Nresults(ipc,ip,el)
|
||||
! constitutive_post_results(i) = state(i)
|
||||
tau_slip=dot_product(Tstar_v,lattice_Sslip_v(:,i,material_CrystalStructure(matID)))
|
||||
! constitutive_post_results(i+material_Nslip(matID)) = &
|
||||
constitutive_post_results(i) = &
|
||||
material_gdot0_slip(matID)*(abs(tau_slip)/state(i))**material_n_slip(matID)*sign(1.0_pReal,tau_slip)
|
||||
enddo
|
||||
active_rate = 0.1_pReal*MAXVAL(abs(constitutive_post_results))
|
||||
do i=1,material_Nslip(matID)
|
||||
if(abs(constitutive_post_results(i)) > active_rate) constitutive_post_results(i+material_Nslip(matID))=1.0_pReal
|
||||
enddo
|
||||
return
|
||||
|
||||
end function
|
||||
|
||||
END MODULE
|
|
@ -1,83 +0,0 @@
|
|||
<materials>
|
||||
[TWIP steel FeMnC]
|
||||
lattice_structure 1
|
||||
Nslip 12
|
||||
Ntwin 0
|
||||
## Elastic constants
|
||||
# Unit in [Pa]
|
||||
C11 183.9e9
|
||||
C12 101.9e9
|
||||
C44 115.4e9
|
||||
|
||||
## Parameters for phenomenological modeling
|
||||
# Unit in [Pa]
|
||||
s0_slip 85.0e6
|
||||
gdot0_slip 0.001
|
||||
n_slip 100.0
|
||||
h0 355.0e6
|
||||
s_sat 265.0e6
|
||||
w0 1.0
|
||||
# Self and latent hardening coefficients
|
||||
hardening_coefficients 1.0 1.4
|
||||
|
||||
## Parameters for dislocation-based modeling
|
||||
# Burgers vector [m]
|
||||
burgers 2.56e-10
|
||||
# Activation energy for dislocation glide [J/K] (0.5*G*b^3)
|
||||
Qedge 5.5e-19
|
||||
# Activation energy for self diffusion [J/K] (gamma-iron)
|
||||
Qsd 4.7e-19
|
||||
# Vacancy diffusion coeffficent (gamma-iron)
|
||||
diff0 4.0e-5
|
||||
# Average grain size [m]
|
||||
grain_size 2.0e-5
|
||||
# Dislocation interaction coefficients
|
||||
interaction_coefficients 1.0 2.2 3.0 1.6 3.8 4.5
|
||||
|
||||
# Initial dislocation density [m]²
|
||||
rho0 6.0e12
|
||||
# Passing stress adjustment
|
||||
c1 0.1
|
||||
# Jump width adjustment
|
||||
c2 2.0
|
||||
# Activation volume adjustment
|
||||
c3 1.0
|
||||
# Average slip distance adjustment for lock formation
|
||||
c4 50.0
|
||||
# Average slip distance adjustment when grain boundaries
|
||||
c5 1.0
|
||||
# Athermal recovery adjustment
|
||||
c7 8.0
|
||||
# Thermal recovery adjustment (plays no role for me)
|
||||
c8 1.0e10
|
||||
|
||||
## Parameters for mechanical twinning
|
||||
# Average twin thickness (stacks) [m]
|
||||
stack_size 5.0e-8
|
||||
# Total twin volume fraction saturation
|
||||
f_sat 1.0
|
||||
# Average slip distance adjustment when twin boundaries
|
||||
c6
|
||||
# Scaling potential nucleation sites
|
||||
site_scaling 1.0e-6
|
||||
# Scaling the P-K force on the twinning dislocation
|
||||
q1 1.0
|
||||
# Scaling the resolved shear stress
|
||||
q2 1.0
|
||||
|
||||
|
||||
|
||||
<textures>
|
||||
[cube SX]
|
||||
symmetry no /monoclinic /orthorhombic
|
||||
Ngrains 10 /2 /4
|
||||
#(gauss) phi1 0.0 phi 29.21 phi2 -26.57 scatter 0.0 fraction 1.0
|
||||
#(gauss) phi1 0.0 phi 54.74 phi2 -45.0 scatter 0.0 fraction 0.1
|
||||
#(gauss) phi1 0.0 phi 45.0 phi2 0.0 scatter 0.0 fraction 0.1
|
||||
#(gauss) phi1 0.0 phi 0.0 phi2 0.0 scatter 0.0 fraction 0.1
|
||||
#(gauss) phi1 0.0 phi 35.26 phi2 -45.0 scatter 0.0 fraction 0.1
|
||||
#(gauss) phi1 0.0 phi 48.19 phi2 -26.57 scatter 0.0 fraction 0.1
|
||||
#(gauss) phi1 0.0 phi 26.57 phi2 0.0 scatter 0.0 fraction 0.1
|
||||
#(gauss) phi1 0.0 phi 42.03 phi2 -33.69 scatter 0.0 fraction 0.1
|
||||
#(gauss) phi1 0.0 phi 40.36 phi2 -11.31 scatter 0.0 fraction 0.1
|
||||
#(gauss) phi1 0.0 phi 15.62 phi2 -26.57 scatter 0.0 fraction 0.1
|
|
@ -1,20 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [[ $# < 2 ]]; then # check the number of command line arguments
|
||||
echo "usage: $0 homogenization_scheme constitutive_law"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ !(-f "CPFEM_$1.f90") ]]; then
|
||||
echo "no file CPFEM_$1.f90 present"
|
||||
else
|
||||
if [[ !(-f "constitutive_$2.f90") ]]; then
|
||||
echo "no file constitutive_$2.f90 present"
|
||||
exit
|
||||
else
|
||||
rm CPFEM.f90
|
||||
ln -s CPFEM_$1.f90 CPFEM.f90
|
||||
rm constitutive.f90
|
||||
ln -s constitutive_$2.f90 constitutive.f90
|
||||
fi
|
||||
fi
|
Loading…
Reference in New Issue