2019-03-13 11:07:31 +01:00
|
|
|
program eDFT
|
|
|
|
|
|
|
|
! exchange-correlation density-functional theory calculations
|
|
|
|
|
2019-07-09 16:17:10 +02:00
|
|
|
implicit none
|
2019-03-13 11:07:31 +01:00
|
|
|
include 'parameters.h'
|
|
|
|
|
2019-07-09 16:17:10 +02:00
|
|
|
integer :: nNuc,nBas
|
|
|
|
integer :: nEl(nspin),nC(nspin),nO(nspin),nV(nspin),nR(nspin)
|
2019-03-13 11:07:31 +01:00
|
|
|
double precision :: ENuc,EKS
|
|
|
|
|
2019-03-13 11:34:51 +01:00
|
|
|
double precision,allocatable :: ZNuc(:),rNuc(:,:)
|
2019-03-13 11:07:31 +01:00
|
|
|
|
|
|
|
integer :: nShell
|
|
|
|
integer,allocatable :: TotAngMomShell(:)
|
|
|
|
integer,allocatable :: KShell(:)
|
|
|
|
double precision,allocatable :: CenterShell(:,:)
|
|
|
|
double precision,allocatable :: DShell(:,:)
|
|
|
|
double precision,allocatable :: ExpShell(:,:)
|
|
|
|
|
|
|
|
double precision,allocatable :: S(:,:),T(:,:),V(:,:),Hc(:,:),X(:,:)
|
|
|
|
double precision,allocatable :: ERI(:,:,:,:)
|
|
|
|
|
|
|
|
integer :: x_rung,c_rung
|
|
|
|
character(len=12) :: x_DFA ,c_DFA
|
|
|
|
integer :: SGn
|
|
|
|
integer :: nRad,nAng,nGrid
|
|
|
|
double precision,allocatable :: root(:,:)
|
|
|
|
double precision,allocatable :: weight(:)
|
|
|
|
double precision,allocatable :: AO(:,:)
|
|
|
|
double precision,allocatable :: dAO(:,:,:)
|
|
|
|
|
|
|
|
double precision :: start_KS,end_KS,t_KS
|
|
|
|
|
|
|
|
integer :: nEns
|
|
|
|
double precision,allocatable :: wEns(:)
|
|
|
|
|
|
|
|
integer :: maxSCF,max_diis
|
|
|
|
double precision :: thresh
|
2019-07-09 16:17:10 +02:00
|
|
|
logical :: DIIS
|
|
|
|
integer :: guess_type
|
|
|
|
integer :: ortho_type
|
2019-03-13 11:07:31 +01:00
|
|
|
|
|
|
|
! Hello World
|
|
|
|
|
|
|
|
write(*,*)
|
|
|
|
write(*,*) '******************************************'
|
|
|
|
write(*,*) '* eDFT: density-functional for ensembles *'
|
|
|
|
write(*,*) '******************************************'
|
|
|
|
write(*,*)
|
|
|
|
|
|
|
|
!------------------------------------------------------------------------
|
|
|
|
! Read input information
|
|
|
|
!------------------------------------------------------------------------
|
|
|
|
|
|
|
|
! Read number of atoms, number of electrons of the system
|
2019-07-09 16:17:10 +02:00
|
|
|
! nC = number of core orbitals
|
2019-03-13 11:07:31 +01:00
|
|
|
! nO = number of occupied orbitals
|
|
|
|
! nV = number of virtual orbitals (see below)
|
2019-07-09 16:17:10 +02:00
|
|
|
! nR = number of Rydberg orbitals
|
2019-03-13 11:07:31 +01:00
|
|
|
! nBas = number of basis functions (see below)
|
|
|
|
! = nO + nV
|
|
|
|
|
2019-07-09 16:17:10 +02:00
|
|
|
call read_molecule(nNuc,nEl(:),nO(:),nC(:),nR(:))
|
2019-03-13 11:34:51 +01:00
|
|
|
allocate(ZNuc(nNuc),rNuc(nNuc,ncart))
|
2019-03-13 11:07:31 +01:00
|
|
|
|
|
|
|
! Read geometry
|
|
|
|
|
2019-03-13 11:34:51 +01:00
|
|
|
call read_geometry(nNuc,ZNuc,rNuc,ENuc)
|
2019-03-13 11:07:31 +01:00
|
|
|
|
|
|
|
allocate(CenterShell(maxShell,ncart),TotAngMomShell(maxShell),KShell(maxShell), &
|
|
|
|
DShell(maxShell,maxK),ExpShell(maxShell,maxK))
|
|
|
|
|
|
|
|
!------------------------------------------------------------------------
|
|
|
|
! Read basis set information
|
|
|
|
!------------------------------------------------------------------------
|
|
|
|
|
2019-03-13 11:34:51 +01:00
|
|
|
call read_basis(nNuc,rNuc,nBas,nO,nV,nShell,TotAngMomShell,CenterShell,KShell,DShell,ExpShell)
|
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
|
|
|
!------------------------------------------------------------------------
|
|
|
|
|
2019-07-09 16:17:10 +02:00
|
|
|
! Allocate ensemble weights
|
2019-03-13 11:07:31 +01:00
|
|
|
|
2019-07-09 16:17:10 +02:00
|
|
|
allocate(wEns(maxEns))
|
|
|
|
call read_options(x_rung,x_DFA,c_rung,c_DFA,SGn,nEns,wEns,maxSCF,thresh,DIIS,max_diis,guess_type,ortho_type)
|
2019-03-13 11:07:31 +01:00
|
|
|
|
2019-07-09 16:17:10 +02:00
|
|
|
!------------------------------------------------------------------------
|
|
|
|
! Read one- and two-electron integrals
|
|
|
|
!------------------------------------------------------------------------
|
2019-03-13 11:07:31 +01:00
|
|
|
|
2019-07-09 16:17:10 +02:00
|
|
|
! Memory allocation for one- and two-electron integrals
|
2019-03-13 11:07:31 +01:00
|
|
|
|
2019-07-09 16:17:10 +02:00
|
|
|
allocate(S(nBas,nBas),T(nBas,nBas),V(nBas,nBas),Hc(nBas,nBas),X(nBas,nBas),ERI(nBas,nBas,nBas,nBas))
|
2019-03-13 11:07:31 +01:00
|
|
|
|
2019-07-09 16:17:10 +02:00
|
|
|
! Read integrals
|
2019-03-13 11:07:31 +01:00
|
|
|
|
2019-07-09 16:17:10 +02:00
|
|
|
call read_integrals(nEl(:),nBas,S,T,V,Hc,ERI)
|
2019-03-13 11:07:31 +01:00
|
|
|
|
2019-07-09 16:17:10 +02:00
|
|
|
! Orthogonalization X = S^(-1/2)
|
2019-03-13 11:07:31 +01:00
|
|
|
|
2019-07-09 16:17:10 +02:00
|
|
|
call orthogonalization_matrix(ortho_type,nBas,S,X)
|
2019-03-13 11:07:31 +01:00
|
|
|
|
|
|
|
!------------------------------------------------------------------------
|
|
|
|
! Construct quadrature grid
|
|
|
|
!------------------------------------------------------------------------
|
|
|
|
call read_grid(SGn,nRad,nAng,nGrid)
|
|
|
|
|
|
|
|
allocate(root(ncart,nGrid),weight(nGrid))
|
|
|
|
call quadrature_grid(nRad,nAng,nGrid,root,weight)
|
|
|
|
|
|
|
|
!------------------------------------------------------------------------
|
|
|
|
! 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
|
|
|
|
|
|
|
!------------------------------------------------------------------------
|
|
|
|
! Compute KS energy
|
|
|
|
!------------------------------------------------------------------------
|
|
|
|
|
|
|
|
call cpu_time(start_KS)
|
|
|
|
call Kohn_Sham(x_rung,x_DFA,c_rung,c_DFA,nEns,wEns(1:nEns),nGrid,weight(:),maxSCF,thresh,max_diis,guess_type, &
|
|
|
|
nBas,AO(:,:),dAO(:,:,:),nO(:),nV(:),S(:,:),T(:,:),V(:,:),Hc(:,:),ERI(:,:,:,:),X(:,:),ENuc,EKS)
|
|
|
|
call cpu_time(end_KS)
|
|
|
|
|
|
|
|
t_KS = end_KS - start_KS
|
|
|
|
write(*,'(A65,1X,F9.3,A8)') 'Total CPU time for KS = ',t_KS,' seconds'
|
|
|
|
write(*,*)
|
|
|
|
|
|
|
|
!------------------------------------------------------------------------
|
|
|
|
! End of eDFT
|
|
|
|
!------------------------------------------------------------------------
|
|
|
|
end program eDFT
|