Commit c95c8238 authored by Matthias Redies's avatar Matthias Redies

clean up hybrid a little

parent 1ee818fe
......@@ -172,18 +172,7 @@ SUBROUTINE hsfock(nk,atoms,hybrid,lapw,dimension,kpts,jsp,input,hybdat,eig_irr,s
eig_irr,results,parent,pointer_EIBZ,n_q,wl_iks,it,xcpot,noco,nsest,indx_sest,&
mpi,ex)
CALL timestop("valence exchange calculation")
WRITE(1224,'(a,i7)') 'kpoint: ', nk
DO i = 1, ex%matsize1
DO j = 1, i
IF (ex%l_real) THEN
WRITE(1224,'(2i7,2f15.8)') i, j, ex%data_r(j,i) !ex%data_r(i,j), ex%data_r(j,i)
ELSE
WRITE(1224,'(2i7,4f15.8)') i, j, ex%data_c(j,i) !ex%data_c(i,j), ex%data_c(j,i)
ENDIF
END DO
END DO
CALL timestart("core exchange calculation")
! calculate contribution from the core states to the HF exchange
......@@ -225,45 +214,14 @@ SUBROUTINE hsfock(nk,atoms,hybrid,lapw,dimension,kpts,jsp,input,hybdat,eig_irr,s
ENDDO
ENDDO
WRITE(1225,'(a,i7)') 'kpoint: ', nk
DO i = 1, ex%matsize1
DO j = 1, i
IF (ex%l_real) THEN
WRITE(1225,'(2i7,2f15.8)') i, j, ex%data_r(i,j), ex%data_r(j,i)
ELSE
WRITE(1225,'(2i7,4f15.8)') i, j, ex%data_c(i,j), ex%data_c(j,i)
ENDIF
END DO
END DO
CALL ex%multiply(invtrafo,tmp)
CALL trafo%multiply(tmp,v_x)
CALL timestop("time for performing T^-1*mat_ex*T^-1*")
WRITE(1231,'(a,i7)') 'kpoint: ', nk
DO i = 1, v_x%matsize1
DO j = 1, i
IF (v_x%l_real) THEN
WRITE(1231,'(2i7,1f15.8)') i, j, v_x%data_r(i,j)
ELSE
WRITE(1231,'(2i7,2f15.8)') i, j, v_x%data_c(i,j)
ENDIF
END DO
END DO
call timestart("symmetrizeh")
CALL symmetrizeh(atoms,kpts%bkf(:,nk),dimension,jsp,lapw,sym,hybdat%kveclo_eig,cell,nsymop,psym,v_x)
WRITE(1232,'(a,i7)') 'kpoint: ', nk
DO i = 1, v_x%matsize1
DO j = 1, i
IF (v_x%l_real) THEN
WRITE(1232,'(2i7,1f15.8)') i, j, v_x%data_r(j,i) ! Note the different indices in comparison to points above. This is wanted!
ELSE
WRITE(1232,'(2i7,2f15.8)') i, j, v_x%data_c(j,i) ! Note the different indices in comparison to points above. This is wanted!
ENDIF
END DO
END DO
call timestop("symmetrizeh")
CALL write_v_x(v_x,kpts%nkpt*(jsp-1) + nk)
END IF ! hybrid%l_calhf
......
......@@ -53,7 +53,8 @@ CONTAINS
REAL :: bkpt(3)
REAL, ALLOCATABLE :: eig_irr(:,:)
CALL timestart("Hybrid code")
INQUIRE(file="v_x.mat",exist=hybrid%l_addhf)
CALL open_hybrid_io1(DIMENSION,sym%invs)
......@@ -68,6 +69,7 @@ CONTAINS
hybrid%l_calhf = (results%last_distance.GE.0.0).AND.(results%last_distance.LT.input%minDistance)
IF(.NOT.hybrid%l_calhf) THEN
hybrid%l_subvxc = hybrid%l_subvxc.AND.hybrid%l_addhf
CALL timestop("Hybrid code")
RETURN
ENDIF
......@@ -93,47 +95,51 @@ CONTAINS
hybrid%l_subvxc = (hybrid%l_subvxc.AND.hybrid%l_addhf)
IF(.NOT.ALLOCATED(results%w_iks)) ALLOCATE (results%w_iks(DIMENSION%neigd2,kpts%nkpt,input%jspins))
IF (.NOT.hybrid%l_calhf) RETURN !use existing non-local potential
iterHF = iterHF + 1
!Delete broyd files
CALL system("rm -f broyd*")
IF (hybrid%l_calhf) THEN
iterHF = iterHF + 1
!check if z-reflection trick can be used
!Delete broyd files
CALL system("rm -f broyd*")
l_zref = (sym%zrfs.AND.(SUM(ABS(kpts%bk(3,:kpts%nkpt))).LT.1e-9).AND..NOT.noco%l_noco)
!check if z-reflection trick can be used
CALL timestart("Preparation for Hybrid functionals")
! CALL juDFT_WARN ("Hybrid functionals not working in this version")
l_zref = (sym%zrfs.AND.(SUM(ABS(kpts%bk(3,:kpts%nkpt))).LT.1e-9).AND..NOT.noco%l_noco)
!construct the mixed-basis
CALL timestart("generation of mixed basis")
CALL mixedbasis(atoms,kpts,dimension,input,cell,sym,xcpot,hybrid,enpara,mpi,v,l_restart)
CALL timestop("generation of mixed basis")
CALL timestart("Preparation for Hybrid functionals")
! CALL juDFT_WARN ("Hybrid functionals not working in this version")
CALL open_hybrid_io2(hybrid,DIMENSION,atoms,sym%invs)
!construct the mixed-basis
CALL timestart("generation of mixed basis")
CALL mixedbasis(atoms,kpts,dimension,input,cell,sym,xcpot,hybrid,enpara,mpi,v,l_restart)
CALL timestop("generation of mixed basis")
CALL timestart("generation of coulomb matrix")
CALL coulombmatrix(mpi,atoms,kpts,cell,sym,hybrid,xcpot,l_restart)
CALL timestop("generation of coulomb matrix")
CALL open_hybrid_io2(hybrid,DIMENSION,atoms,sym%invs)
CALL hf_init(hybrid,kpts,atoms,input,DIMENSION,hybdat,sym%invs)
CALL timestop("Preparation for Hybrid functionals")
CALL timestart("generation of coulomb matrix")
CALL coulombmatrix(mpi,atoms,kpts,cell,sym,hybrid,xcpot,l_restart)
CALL timestop("generation of coulomb matrix")
CALL timestart("Calculation of non-local HF potential")
DO jsp = 1,input%jspins
CALL HF_setup(hybrid,input,sym,kpts,dimension,atoms,mpi,noco,cell,oneD,results,jsp,enpara,eig_id,&
hybdat,iterHF,sym%invs,v%mt(:,0,:,:),eig_irr)
CALL hf_init(hybrid,kpts,atoms,input,DIMENSION,hybdat,sym%invs)
CALL timestop("Preparation for Hybrid functionals")
CALL timestart("Calculation of non-local HF potential")
DO jsp = 1,input%jspins
call timestart("HF_setup")
CALL HF_setup(hybrid,input,sym,kpts,dimension,atoms,mpi,noco,cell,oneD,results,jsp,enpara,eig_id,&
hybdat,iterHF,sym%invs,v%mt(:,0,:,:),eig_irr)
call timestop("HF_setup")
DO nk = mpi%n_start,kpts%nkpt,mpi%n_stride
CALL lapw%init(input,noco, kpts,atoms,sym,nk,cell,l_zref)
CALL hsfock(nk,atoms,hybrid,lapw,DIMENSION,kpts,jsp,input,hybdat,eig_irr,sym,cell,&
noco,results,iterHF,MAXVAL(hybrid%nobd),xcpot,mpi)
DO nk = mpi%n_start,kpts%nkpt,mpi%n_stride
CALL lapw%init(input,noco, kpts,atoms,sym,nk,cell,l_zref)
CALL hsfock(nk,atoms,hybrid,lapw,DIMENSION,kpts,jsp,input,hybdat,eig_irr,sym,cell,&
noco,results,iterHF,MAXVAL(hybrid%nobd),xcpot,mpi)
END DO
END DO
END DO
CALL timestop("Calculation of non-local HF potential")
CALL close_eig(eig_id)
CALL timestop("Calculation of non-local HF potential")
CALL close_eig(eig_id)
ENDIF
CALL timestop("Hybrid code")
END SUBROUTINE calc_hybrid
END MODULE m_calc_hybrid
......@@ -23,9 +23,9 @@ contains
if (opened) return
opened=.true.
print *,"Open olap.mat"
!print *,"Open olap.mat"
id_olap=OPEN_MATRIX(l_real,DIMENSION%nbasfcn,1,1,"olap.mat")
print *,"Open z.mat"
!print *,"Open z.mat"
id_z=OPEN_MATRIX(l_real,DIMENSION%nbasfcn,1,1,"z.mat")
END SUBROUTINE open_hybrid_io1
......@@ -39,7 +39,7 @@ contains
if (opened) return
opened=.true.
print *,"Open v_x.mat"
!print *,"Open v_x.mat"
id_v_x=OPEN_MATRIX(l_real,DIMENSION%nbasfcn,1,1,"v_x.mat")
END SUBROUTINE open_hybrid_io1b
......@@ -115,7 +115,7 @@ contains
real,intent(in) :: coulomb_mtir(:)
integer,intent(in) :: nk
print *, "write coulomb",nk,size(coulomb_mt1),size(coulomb_mt2),size(coulomb_mt3),size(coulomb_mtir)
!print *, "write coulomb",nk,size(coulomb_mt1),size(coulomb_mt2),size(coulomb_mt3),size(coulomb_mtir)
write(id_coulomb_spm,rec=nk) coulomb_mt1,coulomb_mt2,coulomb_mt3,coulomb_mtir
end subroutine write_coulomb_spm_r
......@@ -136,7 +136,7 @@ contains
real,intent(out) :: coulomb_mtir(:)
integer,intent(in) :: nk
print *, "read coulomb",nk,size(coulomb_mt1),size(coulomb_mt2),size(coulomb_mt3),size(coulomb_mtir)
!print *, "read coulomb",nk,size(coulomb_mt1),size(coulomb_mt2),size(coulomb_mt3),size(coulomb_mtir)
read(id_coulomb_spm,rec=nk) coulomb_mt1,coulomb_mt2,coulomb_mt3,coulomb_mtir
end subroutine read_coulomb_spm_r
......@@ -187,7 +187,7 @@ contains
implicit none
TYPE(t_mat),INTENT(INOUT):: mat
INTEGER,INTENT(IN) :: rec
print *,"read z:",rec
!print *,"read z:",rec
CALL read_matrix(mat,rec,id_z)
END subroutine read_z
......@@ -196,7 +196,7 @@ contains
implicit none
TYPE(t_mat),INTENT(IN) :: mat
INTEGER,INTENT(IN) :: rec
print *,"write z:",rec
!print *,"write z:",rec
CALL write_matrix(mat,rec,id_z)
END subroutine write_z
......
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