Commit ebef1bb1 authored by Matthias Redies's avatar Matthias Redies

precompute stepfunction

parent e67caa94
......@@ -77,7 +77,6 @@ SUBROUTINE exchange_valence_hf(nk,kpts,nkpt_EIBZ,sym,atoms,hybrid,cell,dimension
IMPLICIT NONE
TYPE(t_hybdat), INTENT(IN) :: hybdat
TYPE(t_results), INTENT(IN) :: results
TYPE(t_xcpot_inbuild), INTENT(IN) :: xcpot
TYPE(t_mpi), INTENT(IN) :: mpi
......@@ -91,6 +90,7 @@ SUBROUTINE exchange_valence_hf(nk,kpts,nkpt_EIBZ,sym,atoms,hybrid,cell,dimension
TYPE(t_atoms), INTENT(IN) :: atoms
TYPE(t_lapw), INTENT(IN) :: lapw
TYPE(t_mat), INTENT(INOUT) :: mat_ex
TYPE(t_hybdat), INTENT(INOUT) :: hybdat
! scalars
INTEGER, INTENT(IN) :: it
......@@ -332,7 +332,8 @@ SUBROUTINE exchange_valence_hf(nk,kpts,nkpt_EIBZ,sym,atoms,hybrid,cell,dimension
END IF
! calculate exchange matrix at ikpt0
call timestart("exchange matrix")
DO n1=1,hybrid%nbands(nk)
DO iband = 1,psize
IF((ibando+iband-1).gt.hybrid%nobd(nkqpt)) CYCLE
......@@ -372,6 +373,7 @@ SUBROUTINE exchange_valence_hf(nk,kpts,nkpt_EIBZ,sym,atoms,hybrid,cell,dimension
END IF
END DO
END DO !n1
call timestop("exchange matrix")
END DO !ibando
END DO !ikpt
......
......@@ -59,12 +59,9 @@ SUBROUTINE hsfock(nk,atoms,hybrid,lapw,dimension,kpts,jsp,input,hybdat,eig_irr,s
IMPLICIT NONE
TYPE(t_hybdat), INTENT(IN) :: hybdat
TYPE(t_results), INTENT(INOUT) :: results
TYPE(t_xcpot_inbuild), INTENT(IN) :: xcpot
TYPE(t_mpi), INTENT(IN) :: mpi
TYPE(t_dimension), INTENT(IN) :: dimension
TYPE(t_hybrid), INTENT(INOUT) :: hybrid
TYPE(t_input), INTENT(IN) :: input
TYPE(t_noco), INTENT(IN) :: noco
TYPE(t_sym), INTENT(IN) :: sym
......@@ -72,6 +69,9 @@ SUBROUTINE hsfock(nk,atoms,hybrid,lapw,dimension,kpts,jsp,input,hybdat,eig_irr,s
TYPE(t_kpts), INTENT(IN) :: kpts
TYPE(t_atoms), INTENT(IN) :: atoms
TYPE(t_lapw), INTENT(IN) :: lapw
TYPE(t_hybrid), INTENT(INOUT) :: hybrid
TYPE(t_hybdat), INTENT(INOUT) :: hybdat
TYPE(t_results), INTENT(INOUT) :: results
! scalars
INTEGER, INTENT(IN) :: jsp
......
......@@ -596,6 +596,9 @@
! COMPLEX :: vecin1(dim,nobd,nbands),vecout1(dim,nobd,nbands)
COMPLEX, ALLOCATABLE :: vecin1(:,:,:),vecout1(:,:,:)
call timestart("bra trafo")
ALLOCATE ( vecin1( dim,nobd,nbands), &
& vecout1(dim,nobd,nbands), stat=ok )
IF ( ok /= 0 ) &
......@@ -773,7 +776,7 @@
vecout_c = vecout1
endif
DEALLOCATE ( vecout1 )
call timestop("bra trafo")
END SUBROUTINE bra_trafo2
......
......@@ -24,16 +24,16 @@
USE m_io_hybrid
IMPLICIT NONE
TYPE(t_input),INTENT(IN) :: input
TYPE(t_hybdat),INTENT(IN) :: hybdat
TYPE(t_input),INTENT(IN) :: input
TYPE(t_dimension),INTENT(IN) :: dimension
TYPE(t_hybrid),INTENT(IN) :: hybrid
TYPE(t_sym),INTENT(IN) :: sym
TYPE(t_noco),INTENT(IN) :: noco
TYPE(t_cell),INTENT(IN) :: cell
TYPE(t_kpts),INTENT(IN) :: kpts
TYPE(t_atoms),INTENT(IN) :: atoms
TYPE(t_lapw),INTENT(IN) :: lapw
TYPE(t_hybrid),INTENT(IN) :: hybrid
TYPE(t_sym),INTENT(IN) :: sym
TYPE(t_noco),INTENT(IN) :: noco
TYPE(t_cell),INTENT(IN) :: cell
TYPE(t_kpts),INTENT(IN) :: kpts
TYPE(t_atoms),INTENT(IN) :: atoms
TYPE(t_lapw),INTENT(IN) :: lapw
TYPE(t_hybdat),INTENT(INOUT) :: hybdat
! - scalars -
INTEGER,INTENT(IN) :: nk,iq ,jsp
......@@ -1254,16 +1254,16 @@
USE m_types
USE m_io_hybrid
IMPLICIT NONE
TYPE(t_hybdat),INTENT(IN) :: hybdat
TYPE(t_dimension),INTENT(IN) :: dimension
TYPE(t_hybrid),INTENT(IN) :: hybrid
TYPE(t_input),INTENT(IN) :: input
TYPE(t_noco),INTENT(IN) :: noco
TYPE(t_sym),INTENT(IN) :: sym
TYPE(t_cell),INTENT(IN) :: cell
TYPE(t_kpts),INTENT(IN) :: kpts
TYPE(t_atoms),INTENT(IN) :: atoms
TYPE(t_lapw),INTENT(IN) :: lapw
TYPE(t_dimension),INTENT(IN) :: dimension
TYPE(t_hybrid),INTENT(IN) :: hybrid
TYPE(t_input),INTENT(IN) :: input
TYPE(t_noco),INTENT(IN) :: noco
TYPE(t_sym),INTENT(IN) :: sym
TYPE(t_cell),INTENT(IN) :: cell
TYPE(t_kpts),INTENT(IN) :: kpts
TYPE(t_atoms),INTENT(IN) :: atoms
TYPE(t_lapw),INTENT(IN) :: lapw
TYPE(t_hybdat),INTENT(INOUT) :: hybdat
! - scalars -
INTEGER,INTENT(IN) :: bandi,bandf,bandoi,bandof
......@@ -1315,7 +1315,6 @@
REAL :: rarr1(bandoi:bandof)
REAL :: rarr2(bandoi:bandof,bandf-bandi+1)
REAL :: rarr3(2,bandoi:bandof,bandf-bandi+1)
REAL, ALLOCATABLE :: stepfunc(:,:,:)
REAL, ALLOCATABLE :: z0(:,:)
COMPLEX :: cexp(atoms%nat),cexp_nk(atoms%nat)
......@@ -1365,8 +1364,10 @@
call z_kqpt%alloc(.true.,nbasfcn,dimension%neigd)
! read in z at k-point nk and nkqpt
call timestart("read_z")
CALL read_z(z_nk,nk)
call read_z(z_kqpt,nkqpt)
call timestop("read_z")
g(1) = maxval(abs(lapw%k1 (:lapw%nv(jsp) ,jsp))) &
& + maxval(abs(lapw_nkqpt%k1(:lapw_nkqpt%nv(jsp),jsp)))&
......@@ -1379,20 +1380,27 @@
& + maxval(abs(hybrid%gptm(3,hybrid%pgptm(:hybrid%ngptm(iq),iq) ))) + 1
ALLOCATE ( stepfunc(-g(1):g(1),-g(2):g(2),-g(3):g(3)),stat=ok)
IF( ok .ne. 0 ) STOP 'wavefproducts_inv5: error allocation stepfunc'
ALLOCATE ( pointer(-g(1):g(1),-g(2):g(2),-g(3):g(3)),stat=ok )
IF( ok .ne. 0 ) STOP 'wavefproducts_inv5: error allocation pointer'
ALLOCATE ( gpt0(3,size(pointer)),stat=ok )
IF( ok .ne. 0 ) STOP 'wavefproducts_inv5: error allocation gpt0'
DO i = -g(1),g(1)
DO j = -g(2),g(2)
DO k = -g(3),g(3)
stepfunc(i,j,k) = stepfunction(cell,atoms,(/i,j,k/))
END DO
END DO
END DO
if(.not. allocated(hybdat%stepfunc_r)) then
call timestart("setup stepfunction")
ALLOCATE (hybdat%stepfunc_r(-g(1):g(1),-g(2):g(2),-g(3):g(3)),stat=ok)
IF(ok /= 0) then
call juDFT_error('wavefproducts_inv5: error allocation stepfunc_r')
endif
DO i = -g(1),g(1)
DO j = -g(2),g(2)
DO k = -g(3),g(3)
hybdat%stepfunc_r(i,j,k) = stepfunction(cell,atoms,(/i,j,k/))
END DO
END DO
END DO
call timestop("setup stepfunction")
endif
......@@ -1401,6 +1409,7 @@
!
!(1) prepare list of G vectors
call timestart("prep list of Gvec")
pointer = 0
ic = 0
DO ig1 = 1,lapw%nv(jsp)
......@@ -1417,24 +1426,29 @@
END DO
END DO
ngpt0 = ic
call timestop("prep list of Gvec")
!(2) calculate convolution
call timestart("calc convolution")
ALLOCATE ( z0(bandoi:bandof,ngpt0), stat=ok )
IF( ok .ne. 0 ) STOP 'wavefproducts_inv5: error allocation z0'
z0 = 0
call timestart("step function")
DO ig2 = 1,lapw_nkqpt%nv(jsp)
rarr1 = z_kqpt%data_r(ig2,bandoi:bandof)
DO ig = 1,ngpt0
g(1) = gpt0(1,ig) - lapw_nkqpt%k1(ig2,jsp)
g(2) = gpt0(2,ig) - lapw_nkqpt%k2(ig2,jsp)
g(3) = gpt0(3,ig) - lapw_nkqpt%k3(ig2,jsp)
rdum = stepfunc(g(1),g(2),g(3)) / svol
rdum = hybdat%stepfunc_r(g(1),g(2),g(3)) / svol
DO n2 = bandoi,bandof
z0(n2,ig) = z0(n2,ig) + rarr1(n2)*rdum
END DO
END DO
END DO
call timestop("step function")
call timestart("hybrid gptm")
ic = nbasm_mt
DO igptm = 1,hybrid%ngptm(iq)
rarr2 = 0
......@@ -1464,6 +1478,8 @@
END DO
cprod(ic,:,:) = rarr2(:,:)
END DO
call timestop("hybrid gptm")
call timestop("calc convolution")
WRITE(2005,*) 'Point B'
DO n2 = 1, 1
......@@ -1474,7 +1490,7 @@
END DO
END DO
DEALLOCATE(z0,stepfunc,pointer,gpt0)
DEALLOCATE(z0,pointer,gpt0)
CALL timestop("wavefproducts_inv5 IR")
! lmstart = lm start index for each l-quantum number and atom type (for cmt-coefficients)
......@@ -2287,16 +2303,16 @@
USE m_types
USE m_io_hybrid
IMPLICIT NONE
TYPE(t_hybdat),INTENT(IN) :: hybdat
TYPE(t_dimension),INTENT(IN) :: dimension
TYPE(t_hybrid),INTENT(IN) :: hybrid
TYPE(t_input),INTENT(IN) :: input
TYPE(t_noco),INTENT(IN) :: noco
TYPE(t_sym),INTENT(IN) :: sym
TYPE(t_cell),INTENT(IN) :: cell
TYPE(t_kpts),INTENT(IN) :: kpts
TYPE(t_atoms),INTENT(IN) :: atoms
TYPE(t_lapw),INTENT(IN) :: lapw
TYPE(t_input),INTENT(IN) :: input
TYPE(t_noco),INTENT(IN) :: noco
TYPE(t_sym),INTENT(IN) :: sym
TYPE(t_cell),INTENT(IN) :: cell
TYPE(t_kpts),INTENT(IN) :: kpts
TYPE(t_atoms),INTENT(IN) :: atoms
TYPE(t_lapw),INTENT(IN) :: lapw
TYPE(t_hybrid),INTENT(IN) :: hybrid
TYPE(t_hybdat),INTENT(INOUT) :: hybdat
! - scalars -
INTEGER,INTENT(IN) :: bandi,bandf,bandoi,bandof
......@@ -2344,7 +2360,6 @@
TYPE(t_mat) :: z_nk,z_kqpt
COMPLEX :: cmt (dimension%neigd,hybrid%maxlmindx,atoms%nat)
COMPLEX :: cmt_nk(dimension%neigd,hybrid%maxlmindx,atoms%nat)
COMPLEX,ALLOCATABLE :: stepfunc(:,:,:)
COMPLEX,ALLOCATABLE :: z0(:,:)
call timestart("wavefproducts_noinv5")
......@@ -2389,9 +2404,10 @@
call z_kqpt%alloc(.false.,nbasfcn,dimension%neigd)
! read in z at k-point nk and nkqpt
call timestart("read_z")
call read_z(z_nk,nk)
call read_z(z_kqpt,nkqpt)
call timestop("read_z")
g(1) = maxval(abs(lapw%k1 (:lapw%nv(jsp) ,jsp))) &
& + maxval(abs(lapw_nkqpt%k1(:lapw_nkqpt%nv(jsp),jsp)))&
......@@ -2405,26 +2421,33 @@
ALLOCATE ( stepfunc(-g(1):g(1),-g(2):g(2),-g(3):g(3)), stat= ok)
IF( ok .ne. 0 ) STOP 'wavefproducts_noinv2: error allocation stepfunc'
ALLOCATE ( pointer(-g(1):g(1),-g(2):g(2),-g(3):g(3)), stat= ok )
IF( ok .ne. 0 ) STOP 'wavefproducts_noinv2: error allocation pointer'
ALLOCATE ( gpt0(3,size(pointer)),stat=ok )
IF( ok .ne. 0 ) STOP 'wavefproducts_noinv2: error allocation gpt0'
DO i = -g(1),g(1)
DO j = -g(2),g(2)
DO k = -g(3),g(3)
stepfunc(i,j,k) = stepfunction(cell,atoms,(/i,j,k/))
END DO
END DO
END DO
if(.not. allocated(hybdat%stepfunc_c)) then
call timestart("setup stepfunc")
ALLOCATE (hybdat%stepfunc_c(-g(1):g(1),-g(2):g(2),-g(3):g(3)), stat= ok)
IF(ok/=0) then
call juDFT_error('wavefproducts_noinv2: error allocation stepfunc')
endif
DO i = -g(1),g(1)
DO j = -g(2),g(2)
DO k = -g(3),g(3)
hybdat%stepfunc_c(i,j,k) = stepfunction(cell,atoms,(/i,j,k/))
END DO
END DO
END DO
call timestart("setup stepfunc")
endif
!
! convolute phi(n,k) with the step function and store in cpw0
!
!(1) prepare list of G vectors
call timestart("prep list of Gvec")
pointer = 0
ic = 0
DO ig1 = 1,lapw%nv(jsp)
......@@ -2441,8 +2464,10 @@
END DO
END DO
ngpt0 = ic
call timestop("prep list of Gvec")
!(2) calculate convolution
call timestart("calc convolution")
ALLOCATE ( z0(bandoi:bandof,ngpt0) )
z0 = 0
DO ig2 = 1,lapw_nkqpt%nv(jsp)
......@@ -2451,7 +2476,7 @@
g(1) = gpt0(1,ig) - lapw_nkqpt%k1(ig2,jsp)
g(2) = gpt0(2,ig) - lapw_nkqpt%k2(ig2,jsp)
g(3) = gpt0(3,ig) - lapw_nkqpt%k3(ig2,jsp)
cdum = stepfunc(g(1),g(2),g(3)) / svol
cdum = hybdat%stepfunc_c(g(1),g(2),g(3)) / svol
DO n2 = bandoi,bandof
z0(n2,ig) = z0(n2,ig) + carr1(n2)*cdum
END DO
......@@ -2485,7 +2510,8 @@
END DO
cprod(ic,:,:) = carr2(:,:)
END DO
DEALLOCATE(z0,stepfunc,pointer,gpt0)
DEALLOCATE(z0,pointer,gpt0)
call timestop("calc convolution")
call timestop("wavefproducts_noinv5 IR")
......
......@@ -40,6 +40,8 @@ MODULE m_types_misc
INTEGER, ALLOCATABLE :: pntgptd(:) !alloc in eigen_HF_setup
INTEGER, ALLOCATABLE :: pntgpt(:,:,:,:) !alloc in eigen_HF_setup
INTEGER,ALLOCATABLE :: nindxp1(:,:)
REAL, ALLOCATABLE :: stepfunc_r(:,:,:)
COMPLEX,ALLOCATABLE :: stepfunc_c(:,:,:)
END TYPE t_hybdat
TYPE t_results
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment