10
1
mirror of https://github.com/pfloos/quack synced 2024-12-25 13:53:41 +01:00
QuAcK/src/eDFT/eDFT.f90

225 lines
8.1 KiB
Fortran
Raw Normal View History

2021-01-31 23:24:25 +01:00
subroutine eDFT(maxSCF,thresh,max_diis,guess_type,mix,nNuc,ZNuc,rNuc,ENuc,nBas,nEl,nC,nO,nV,nR, &
2020-10-14 09:44:03 +02:00
nShell,TotAngMomShell,CenterShell,KShell,DShell,ExpShell, &
max_ang_mom,min_exponent,max_exponent,S,T,V,Hc,X,ERI,dipole_int)
2019-03-13 11:07:31 +01:00
! exchange-correlation density-functional theory calculations
2021-01-26 21:28:05 +01:00
! use xc_f90_lib_m
2020-10-13 13:44:24 +02:00
2019-07-09 16:17:10 +02:00
implicit none
2019-03-13 11:07:31 +01:00
include 'parameters.h'
2020-10-14 09:27:42 +02:00
! Input variables
2020-10-14 09:44:03 +02:00
integer,intent(in) :: maxSCF
integer,intent(in) :: max_diis
integer,intent(in) :: guess_type
2021-01-31 23:24:25 +01:00
logical,intent(in) :: mix
2020-10-14 09:44:03 +02:00
double precision,intent(in) :: thresh
2020-10-14 09:27:42 +02:00
integer,intent(in) :: nNuc
integer,intent(in) :: nBas
integer,intent(in) :: nEl(nspin)
integer,intent(in) :: nC(nspin)
integer,intent(in) :: nO(nspin)
integer,intent(in) :: nV(nspin)
integer,intent(in) :: nR(nspin)
2020-10-14 09:44:03 +02:00
double precision,intent(in) :: ENuc
2020-10-14 09:27:42 +02:00
double precision,intent(in) :: ZNuc(nNuc)
double precision,intent(in) :: rNuc(nNuc,ncart)
2020-10-14 09:44:03 +02:00
integer,intent(in) :: nShell
2020-10-14 09:27:42 +02:00
double precision,intent(in) :: CenterShell(maxShell,ncart)
integer,intent(in) :: TotAngMomShell(maxShell)
integer,intent(in) :: KShell(maxShell)
double precision,intent(in) :: DShell(maxShell,maxK)
double precision,intent(in) :: ExpShell(maxShell,maxK)
integer,intent(in) :: max_ang_mom(nNuc)
double precision,intent(in) :: min_exponent(nNuc,maxL+1)
double precision,intent(in) :: max_exponent(nNuc)
double precision,intent(in) :: S(nBas,nBas)
double precision,intent(in) :: T(nBas,nBas)
double precision,intent(in) :: V(nBas,nBas)
double precision,intent(in) :: Hc(nBas,nBas)
double precision,intent(in) :: X(nBas,nBas)
double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas)
double precision,intent(in) :: dipole_int(nBas,nBas,ncart)
! Local variables
2019-03-13 11:07:31 +01:00
2020-10-14 09:44:03 +02:00
double precision :: Ew
2020-03-31 23:33:48 +02:00
double precision,allocatable :: c(:,:)
2019-03-13 11:07:31 +01:00
character(len=8) :: method
2019-03-13 11:07:31 +01:00
integer :: x_rung,c_rung
character(len=12) :: x_DFA ,c_DFA
logical :: LDA_centered = .true.
2020-03-25 11:25:48 +01:00
2019-03-13 11:07:31 +01:00
integer :: SGn
2020-03-25 11:25:48 +01:00
double precision :: radial_precision
integer :: nRad
integer :: nAng
integer :: nGrid
2019-03-13 11:07:31 +01:00
double precision,allocatable :: root(:,:)
double precision,allocatable :: weight(:)
double precision :: aCC_w1(3)
double precision :: aCC_w2(3)
2020-03-25 11:25:48 +01:00
2019-03-13 11:07:31 +01:00
double precision,allocatable :: AO(:,:)
double precision,allocatable :: dAO(:,:,:)
double precision :: start_KS,end_KS,t_KS
2020-03-14 23:00:44 +01:00
double precision :: start_int,end_int,t_int
2019-03-13 11:07:31 +01:00
2020-09-29 11:47:18 +02:00
integer :: nEns
logical :: doNcentered
2019-03-13 11:07:31 +01:00
double precision,allocatable :: wEns(:)
2020-08-04 12:30:52 +02:00
double precision,allocatable :: occnum(:,:,:)
integer :: Cx_choice
2020-10-14 09:27:42 +02:00
integer :: i,vmajor,vminor,vmicro
2020-10-13 13:44:24 +02:00
2019-03-13 11:07:31 +01:00
! Hello World
write(*,*)
write(*,*) '******************************************'
write(*,*) '* eDFT: density-functional for ensembles *'
write(*,*) '******************************************'
write(*,*)
2020-10-13 13:44:24 +02:00
! Libxc version
2021-01-26 21:28:05 +01:00
! call xc_f90_version(vmajor, vminor, vmicro)
! write(*,'("Libxc version: ",I1,".",I1,".",I1)') vmajor, vminor, vmicro
2020-10-13 13:44:24 +02:00
2020-10-13 20:59:41 +02:00
! call xcinfo()
2020-10-13 13:44:24 +02:00
2019-03-13 11:07:31 +01:00
!------------------------------------------------------------------------
2019-07-09 16:17:10 +02:00
! DFT options
2019-03-13 11:07:31 +01:00
!------------------------------------------------------------------------
2020-10-14 09:44:03 +02:00
! Allocate ensemble weights and MO coefficients
2020-09-11 11:55:04 +02:00
2020-10-14 09:44:03 +02:00
allocate(c(nBas,nspin),wEns(maxEns),occnum(nBas,nspin,maxEns))
call read_options_dft(nBas,method,x_rung,x_DFA,c_rung,c_DFA,SGn,nEns,wEns,aCC_w1,aCC_w2, &
2020-10-14 09:44:03 +02:00
doNcentered,occnum,Cx_choice)
2019-03-13 11:07:31 +01:00
!------------------------------------------------------------------------
! Construct quadrature grid
!------------------------------------------------------------------------
2020-03-25 12:56:28 +01:00
call read_grid(SGn,radial_precision,nRad,nAng,nGrid)
2020-03-25 10:39:45 +01:00
2020-03-31 12:39:26 +02:00
call allocate_grid(nNuc,ZNuc,max_ang_mom,min_exponent,max_exponent,radial_precision,nAng,nGrid)
2019-03-13 11:07:31 +01:00
allocate(root(ncart,nGrid),weight(nGrid))
2020-03-31 12:39:26 +02:00
call build_grid(nNuc,ZNuc,rNuc,max_ang_mom,min_exponent,max_exponent, &
2020-03-25 13:03:31 +01:00
radial_precision,nRad,nAng,nGrid,weight,root)
2020-03-23 17:26:12 +01:00
2019-03-13 11:07:31 +01:00
!------------------------------------------------------------------------
! Calculate AO values at grid points
!------------------------------------------------------------------------
allocate(AO(nBas,nGrid),dAO(ncart,nBas,nGrid))
2019-07-09 16:17:10 +02:00
call AO_values_grid(nBas,nShell,CenterShell,TotAngMomShell,KShell,DShell,ExpShell,nGrid,root,AO,dAO)
2019-03-13 11:07:31 +01:00
LDA_centered = .true.
2019-03-13 11:07:31 +01:00
!------------------------------------------------------------------------
2020-03-18 11:10:21 +01:00
! Compute GOK-RKS energy
2019-03-13 11:07:31 +01:00
!------------------------------------------------------------------------
2020-03-15 08:23:01 +01:00
if(method == 'GOK-RKS') then
2019-03-13 11:07:31 +01:00
call cpu_time(start_KS)
2020-07-04 14:32:06 +02:00
call GOK_RKS(.false.,x_rung,x_DFA,c_rung,c_DFA,LDA_centered,nEns,wEns,aCC_w1,aCC_w2,nGrid,weight, &
maxSCF,thresh,max_diis,guess_type,nBas,AO,dAO,nO(1),nV(1), &
S,T,V,Hc,ERI,X,ENuc,Ew,c,occnum,Cx_choice)
2020-03-18 11:10:21 +01:00
call cpu_time(end_KS)
t_KS = end_KS - start_KS
2020-03-30 17:50:07 +02:00
write(*,'(A65,1X,F9.3,A8)') 'Total CPU time for GOK-RKS = ',t_KS,' seconds'
2020-03-18 11:10:21 +01:00
write(*,*)
end if
!------------------------------------------------------------------------
2020-04-26 23:17:27 +02:00
! Compute LIM excitation energies
2020-03-18 11:10:21 +01:00
!------------------------------------------------------------------------
if(method == 'LIM-RKS') then
call cpu_time(start_KS)
2020-04-26 23:17:27 +02:00
call LIM_RKS(x_rung,x_DFA,c_rung,c_DFA,LDA_centered,nEns,nGrid,weight(:), &
aCC_w1,aCC_w2,maxSCF,thresh,max_diis,guess_type,nBas,AO(:,:),dAO(:,:,:),nO(1),nV(1), &
2020-09-29 09:43:01 +02:00
S(:,:),T(:,:),V(:,:),Hc(:,:),ERI(:,:,:,:),X(:,:),ENuc,c(:,:),occnum,Cx_choice,doNcentered)
2020-03-15 08:23:01 +01:00
call cpu_time(end_KS)
t_KS = end_KS - start_KS
2020-03-18 11:10:21 +01:00
write(*,'(A65,1X,F9.3,A8)') 'Total CPU time for LIM-RKS = ',t_KS,' seconds'
2020-03-15 08:23:01 +01:00
write(*,*)
end if
2020-04-26 23:17:27 +02:00
!------------------------------------------------------------------------
! Compute MOM excitation energies
!------------------------------------------------------------------------
if(method == 'MOM-RKS') then
call cpu_time(start_KS)
call MOM_RKS(x_rung,x_DFA,c_rung,c_DFA,LDA_centered,nEns,nGrid,weight(:), &
aCC_w1,aCC_w2,maxSCF,thresh,max_diis,guess_type,nBas,AO(:,:),dAO(:,:,:),nO(1),nV(1), &
2020-09-29 09:43:01 +02:00
S(:,:),T(:,:),V(:,:),Hc(:,:),ERI(:,:,:,:),X(:,:),ENuc,c(:,:),occnum,Cx_choice,doNcentered)
2020-04-26 23:17:27 +02:00
call cpu_time(end_KS)
t_KS = end_KS - start_KS
write(*,'(A65,1X,F9.3,A8)') 'Total CPU time for MOM-RKS = ',t_KS,' seconds'
write(*,*)
end if
2020-03-15 08:23:01 +01:00
!------------------------------------------------------------------------
2020-03-18 11:10:21 +01:00
! Compute GOK-UKS energy (BROKEN)
2020-03-15 08:23:01 +01:00
!------------------------------------------------------------------------
if(method == 'GOK-UKS') then
call cpu_time(start_KS)
call GOK_UKS(x_rung,x_DFA,c_rung,c_DFA,nEns,wEns(:),nGrid,weight(:),aCC_w1,aCC_w2,maxSCF,thresh,max_diis,guess_type, &
2020-09-29 09:43:01 +02:00
nBas,AO(:,:),dAO(:,:,:),nO(:),nV(:),S(:,:),T(:,:),V(:,:),Hc(:,:),ERI(:,:,:,:),X(:,:),ENuc,Ew,occnum, &
Cx_choice,doNcentered)
2019-03-13 11:07:31 +01:00
call cpu_time(end_KS)
t_KS = end_KS - start_KS
2020-03-15 08:23:01 +01:00
write(*,'(A65,1X,F9.3,A8)') 'Total CPU time for UKS = ',t_KS,' seconds'
2019-03-13 11:07:31 +01:00
write(*,*)
2020-03-15 08:23:01 +01:00
end if
!------------------------------------------------------------------------
2021-01-31 23:24:25 +01:00
! Compute N-centered UKS energy
!------------------------------------------------------------------------
if(method == 'eDFT-UKS') then
call cpu_time(start_KS)
2021-01-31 23:24:25 +01:00
call eDFT_UKS(x_rung,x_DFA,c_rung,c_DFA,nEns,wEns,aCC_w1,aCC_w2,nGrid,weight(:),maxSCF,thresh,max_diis,guess_type,mix, &
2020-09-29 09:43:01 +02:00
nBas,AO,dAO,S,T,V,Hc,ERI,X,ENuc,Ew,occnum,Cx_choice,doNcentered)
call cpu_time(end_KS)
t_KS = end_KS - start_KS
write(*,'(A65,1X,F9.3,A8)') 'Total CPU time for UKS = ',t_KS,' seconds'
write(*,*)
end if
2019-03-13 11:07:31 +01:00
!------------------------------------------------------------------------
! End of eDFT
!------------------------------------------------------------------------
2020-10-14 09:44:03 +02:00
end subroutine eDFT