4
1
mirror of https://github.com/pfloos/quack synced 2024-11-13 09:34:04 +01:00
quack/src/eDFT/eDFT.f90

188 lines
6.5 KiB
Fortran
Raw Normal View History

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)
2020-03-18 11:10:21 +01:00
double precision :: ENuc,Ew,EwGIC
2019-03-13 11:07:31 +01:00
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(:,:,:,:)
2020-03-15 08:23:01 +01:00
character(len=7) :: method
2019-03-13 11:07:31 +01:00
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
2020-03-14 23:00:44 +01:00
double precision :: start_int,end_int,t_int
2019-03-13 11:07:31 +01:00
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))
2020-03-15 08:23:01 +01:00
call read_options(method,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
2020-03-14 23:00:44 +01:00
call cpu_time(start_int)
call system('./GoQCaml')
call read_integrals(nEl(:),nBas,S,T,V,Hc,ERI)
call cpu_time(end_int)
t_int = end_int - start_int
write(*,*)
write(*,'(A65,1X,F9.3,A8)') 'Total CPU time for reading integrals = ',t_int,' seconds'
write(*,*)
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
!------------------------------------------------------------------------
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-03-15 08:23:01 +01:00
call GOK_RKS(x_rung,x_DFA,c_rung,c_DFA,nEns,wEns(:),nGrid,weight(:),maxSCF,thresh,max_diis,guess_type, &
2020-03-18 11:10:21 +01:00
nBas,AO(:,:),dAO(:,:,:),nO(1),nV(1),S(:,:),T(:,:),V(:,:),Hc(:,:),ERI(:,:,:,:),X(:,:),ENuc,Ew,EwGIC)
call cpu_time(end_KS)
t_KS = end_KS - start_KS
write(*,'(A65,1X,F9.3,A8)') 'Total CPU time for GOC-RKS = ',t_KS,' seconds'
write(*,*)
end if
!------------------------------------------------------------------------
! Compute RKS energy
!------------------------------------------------------------------------
if(method == 'LIM-RKS') then
call cpu_time(start_KS)
call LIM_RKS(x_rung,x_DFA,c_rung,c_DFA,nEns,wEns(:),nGrid,weight(:),maxSCF,thresh,max_diis,guess_type, &
nBas,AO(:,:),dAO(:,:,:),nO(1),nV(1),S(:,:),T(:,:),V(:,:),Hc(:,:),ERI(:,:,:,:),X(:,:),ENuc)
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-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(:),maxSCF,thresh,max_diis,guess_type, &
2020-03-18 11:10:21 +01:00
nBas,AO(:,:),dAO(:,:,:),nO(:),nV(:),S(:,:),T(:,:),V(:,:),Hc(:,:),ERI(:,:,:,:),X(:,:),ENuc,Ew)
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
2019-03-13 11:07:31 +01:00
!------------------------------------------------------------------------
! End of eDFT
!------------------------------------------------------------------------
end program eDFT