|
| 1 | +subroutine CVS_phRRPAx(dotest,TDA,doACFDT,exchange_kernel,singlet,triplet,nBas,nC,nO,nV,nR,nS,nCVS,FC,occupations,ENuc,ERHF,ERI,dipole_int,eHF) |
| 2 | + |
| 3 | +! Perform a direct random phase approximation calculation |
| 4 | + |
| 5 | + implicit none |
| 6 | + include 'parameters.h' |
| 7 | + include 'quadrature.h' |
| 8 | + |
| 9 | +! Input variables |
| 10 | + |
| 11 | + logical,intent(in) :: dotest |
| 12 | + |
| 13 | + logical,intent(in) :: TDA |
| 14 | + logical,intent(in) :: doACFDT |
| 15 | + logical,intent(in) :: exchange_kernel |
| 16 | + logical,intent(in) :: singlet |
| 17 | + logical,intent(in) :: triplet |
| 18 | + integer,intent(in) :: nBas |
| 19 | + integer,intent(in) :: nC |
| 20 | + integer,intent(in) :: nO |
| 21 | + integer,intent(in) :: nV |
| 22 | + integer,intent(in) :: nR |
| 23 | + integer,intent(in) :: nS |
| 24 | + integer,intent(in) :: nCVS |
| 25 | + integer,intent(in) :: FC |
| 26 | + integer,intent(in) :: occupations(nO) |
| 27 | + double precision,intent(in) :: ENuc |
| 28 | + double precision,intent(in) :: ERHF |
| 29 | + double precision,intent(in) :: eHF(nBas) |
| 30 | + double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas) |
| 31 | + double precision,intent(in) :: dipole_int(nBas,nBas,ncart) |
| 32 | + |
| 33 | +! Local variables |
| 34 | + |
| 35 | + integer :: ia,i |
| 36 | + integer :: ispin |
| 37 | + integer :: nSCVS, nFC |
| 38 | + logical :: dRPA,found |
| 39 | + double precision :: t1, t2 |
| 40 | + double precision :: lambda |
| 41 | + double precision,allocatable :: Aph(:,:) |
| 42 | + double precision,allocatable :: Bph(:,:) |
| 43 | + double precision,allocatable :: Om(:) |
| 44 | + double precision,allocatable :: XpY(:,:) |
| 45 | + double precision,allocatable :: XmY(:,:) |
| 46 | + integer,allocatable :: virtuals(:) |
| 47 | + integer,allocatable :: occupations_fc(:) |
| 48 | + |
| 49 | + double precision :: EcRPA(nspin) |
| 50 | + |
| 51 | +! Hello world |
| 52 | + |
| 53 | + write(*,*) |
| 54 | + write(*,*)'*********************************' |
| 55 | + write(*,*)'* Restricted ph-RPA Calculation *' |
| 56 | + write(*,*)'*********************************' |
| 57 | + write(*,*) |
| 58 | + |
| 59 | +! CVS |
| 60 | + |
| 61 | + print *, "No exications to the first", nCVS, "orbital(s) are considered." |
| 62 | + if(nC/=0) then |
| 63 | + print *, "Do not use PyDuck frozen core with CVS !" |
| 64 | + stop |
| 65 | + end if |
| 66 | + |
| 67 | +! Frozen Core |
| 68 | + |
| 69 | + nFC = MERGE(1,0,FC/=0) |
| 70 | + allocate(occupations_fc(nO-nFC)) |
| 71 | + ! remove FC from occupations |
| 72 | + do ispin=1,nspin |
| 73 | + occupations_fc(1:nO-nFC) = occupations(1:nO - nFC) |
| 74 | + found = .false. |
| 75 | + do i=1,nO-1 |
| 76 | + if(.not. found) then |
| 77 | + if(occupations(i)==FC) then |
| 78 | + found = .true. |
| 79 | + occupations_fc(i) = occupations(i+1) |
| 80 | + else |
| 81 | + occupations_fc(i) = occupations(i) |
| 82 | + endif |
| 83 | + else |
| 84 | + occupations_fc(i) = occupations(i+1) |
| 85 | + endif |
| 86 | + enddo |
| 87 | + enddo |
| 88 | + print *, "Not Frozen orbitals:" |
| 89 | + print *,occupations_fc(1:nO-nFC) |
| 90 | + |
| 91 | +! TDA |
| 92 | + |
| 93 | + if(TDA) then |
| 94 | + write(*,*) 'Tamm-Dancoff approximation activated!' |
| 95 | + write(*,*) |
| 96 | + end if |
| 97 | + |
| 98 | +! Initialization |
| 99 | + |
| 100 | + dRPA = .false. |
| 101 | + EcRPA(:) = 0d0 |
| 102 | + lambda = 1d0 |
| 103 | + |
| 104 | +! Memory allocation |
| 105 | + if(nC/=0) then |
| 106 | + print *, "No frozen core with CVS available !" |
| 107 | + stop |
| 108 | + end if |
| 109 | + nSCVS = (nV - nCVS)*(nO - nFC) |
| 110 | + allocate(Om(nSCVS),XpY(nSCVS,nSCVS),XmY(nSCVS,nSCVS),Aph(nSCVS,nSCVS),Bph(nSCVS,nSCVS),virtuals(nV)) |
| 111 | + call non_occupied(nO,nBas,occupations,virtuals) |
| 112 | + |
| 113 | +! Singlet manifold |
| 114 | + |
| 115 | + if(singlet) then |
| 116 | + |
| 117 | + ispin = 1 |
| 118 | + |
| 119 | + call CVS_phRLR_A(ispin,dRPA,nBas,nC,nO,nV,nR,nSCVS,nCVS,nFC,occupations_fc,virtuals,lambda,eHF,ERI,Aph) |
| 120 | + if(.not.TDA) call CVS_phRLR_B(ispin,dRPA,nBas,nC,nO,nV,nR,nSCVS,nCVS,nFC,occupations_fc,virtuals,lambda,ERI,Bph) |
| 121 | + |
| 122 | + call CVS_phRLR(TDA,nSCVS,Aph,Bph,EcRPA(ispin),Om,XpY,XmY) |
| 123 | + call print_excitation_energies('phRPAx@RHF','singlet',nSCVS,Om) |
| 124 | + call CVS_phLR_transition_vectors(.true.,nBas,nC,nO,nV,nR,nSCVS,dipole_int,Om,XpY,XmY) |
| 125 | + |
| 126 | + end if |
| 127 | + |
| 128 | +! Triplet manifold |
| 129 | + |
| 130 | + if(triplet) then |
| 131 | + |
| 132 | + ispin = 2 |
| 133 | + |
| 134 | + call CVS_phRLR_A(ispin,dRPA,nBas,nC,nO,nV,nR,nSCVS,nCVS,nFC,occupations_fc,virtuals,lambda,eHF,ERI,Aph) |
| 135 | + if(.not.TDA) call CVS_phRLR_B(ispin,dRPA,nBas,nC,nO,nV,nR,nSCVS,nCVS,nFC,occupations_fc,virtuals,lambda,ERI,Bph) |
| 136 | + |
| 137 | + call CVS_phRLR(TDA,nSCVS,Aph,Bph,EcRPA(ispin),Om,XpY,XmY) |
| 138 | + call print_excitation_energies('phRPAx@RHF','triplet',nSCVS,Om) |
| 139 | + call CVS_phLR_transition_vectors(.false.,nBas,nC,nO,nV,nR,nSCVS,dipole_int,Om,XpY,XmY) |
| 140 | + |
| 141 | + end if |
| 142 | + |
| 143 | + if(exchange_kernel) then |
| 144 | + |
| 145 | + EcRPA(1) = 0.5d0*EcRPA(1) |
| 146 | + EcRPA(2) = 1.5d0*EcRPA(2) |
| 147 | + |
| 148 | + end if |
| 149 | + |
| 150 | + write(*,*) |
| 151 | + write(*,*)'-------------------------------------------------------------------------------' |
| 152 | + write(*,'(2X,A50,F20.10,A3)') 'Tr@phRPA@RHF correlation energy (singlet) = ',EcRPA(1),' au' |
| 153 | + write(*,'(2X,A50,F20.10,A3)') 'Tr@phRPA@RHF correlation energy (triplet) = ',EcRPA(2),' au' |
| 154 | + write(*,'(2X,A50,F20.10,A3)') 'Tr@phRPA@RHF correlation energy = ',sum(EcRPA),' au' |
| 155 | + write(*,'(2X,A50,F20.10,A3)') 'Tr@phRPA@RHF total energy = ',ENuc + ERHF + sum(EcRPA),' au' |
| 156 | + write(*,*)'-------------------------------------------------------------------------------' |
| 157 | + write(*,*) |
| 158 | + |
| 159 | + deallocate(Om,XpY,XmY,Aph,Bph) |
| 160 | + |
| 161 | +! Compute the correlation energy via the adiabatic connection |
| 162 | + |
| 163 | + if(doACFDT) then |
| 164 | + print *,"No ADC implemented with CVS." |
| 165 | + end if |
| 166 | + |
| 167 | + if(dotest) then |
| 168 | + |
| 169 | + call dump_test_value('R','phRPA correlation energy',sum(EcRPA)) |
| 170 | + |
| 171 | + end if |
| 172 | + |
| 173 | +end subroutine |
0 commit comments