6.3 KiB
CFG-CI
Configuration based CI
Here we write the main functions that perform the functions necessary for the Configuration based CI.
There are three main functions required for doing the CI
- Convert wavefunction from determinant basis to configuration state function (CSF) basis
- Apply the Hamiltonian to the wavefunction in CSF basis
- Convert the converged wavefunction back to determinant basis
TODO[0/3]
Convert basis from DET to CSF
The conversion of basis is done by going via bonded functions (BFs). Importantly, all the CSFs of a chosen configuration (CFG) are kept.
The advantage is that the sigma-vector can be performed efficiently via BLAS level 3 operations.
-
Write a function to calculate the maximum dimensions required
Prototype array contains the \( <I|\hat{E}_{pq}|J> \) for all possible CFGs \( I, J\) and all \(4\) types of excitations for all possible model orbitals \(p,q\). Note that the orbital ids \(p,q\) here do not refer to the actual MO ids, they simply refer to the orbitals involved in that spefcific SOMO, for e.g. an excitation of the type [2 2 2 1 1 1 1 0] -> [ 2 2 1 1 1 1 1] implies an excitation from orbital \(3\) to orbital \(8\) which are the real MO ids. However, the prototype only concerns the SOMOs like so [2 1 1 1 1 0] -> [ 1 1 1 1 1 1] therefore \(p,q\) are model space ids \(1,6\).
BEGIN_PROVIDER [ integer*8, NSOMOMax] &BEGIN_PROVIDER [ integer*8, NCSFMax] &BEGIN_PROVIDER [ integer*8, NMO] implicit none BEGIN_DOC ! Documentation for NSOMOMax ! The maximum number of SOMOs for the current calculation. ! required for the calculation of prototype arrays. END_DOC NSOMOMax = 8 NCSFMax = 14 ! TODO: NCSFs for MS=0 NMO = NSOMOMax ! TODO: remove this END_PROVIDER
The prototype matrix AIJpqMatrixList has the following dimensions \(\left(NSOMOMax, NSOMOMax, 4, NSOMOMax, NSOMOMax,NCSFMAx,NCSFMax\right)\) where the first two indices represent the somos in \(I,J\) followed by the type of excitation and finally the two model space orbitals \(p,q\).
The dimensions for each Isomo, Jsomo pair are precalculated and stored in the AIJpqMatrixDimsList variable which is provided here.
BEGIN_PROVIDER [ double precision, AIJpqMatrixDimsList, (NSOMOMax,NSOMOMax,4,NSOMOMax,NSOMOMax,2)]
use cfunctions
implicit none
BEGIN_DOC
! Documentation for AIJpqMatrixList
! The prototype matrix containing the <I|E_{pq}|J>
! matrices for each I,J somo pair and orb ids.
END_DOC
integer i,j,k,l
integer*8 Isomo, Jsomo
Isomo = 0
Jsomo = 0
integer*8 rows, cols
rows = -1
cols = -1
integer*8 MS
MS = 0
print *,"NSOMOMax = ",NSOMOMax
!allocate(AIJpqMatrixDimsList(NSOMOMax,NSOMOMax,4,NSOMOMax,NSOMOMax,2))
do i = 2, NSOMOMax, 2
Isomo = ISHFT(1,i)-1
do j = i-2,i+2, 2
Jsomo = ISHFT(1,j)-1
if(j .GT. NSOMOMax .OR. j .LE. 0) then
cycle
end if
do k = 1,NSOMOMax
do l = k,NSOMOMax
call getApqIJMatrixDims(Isomo, &
Jsomo, &
MS, &
rows, &
cols)
print *, i,j,k,l,">",Isomo,Jsomo,">",rows, cols
! i -> j
AIJpqMatrixDimsList(i,j,1,k,l,1) = rows
AIJpqMatrixDimsList(i,j,1,k,l,2) = cols
AIJpqMatrixDimsList(i,j,1,l,k,1) = rows
AIJpqMatrixDimsList(i,j,1,l,k,2) = cols
! j -> i
AIJpqMatrixDimsList(j,i,1,k,l,1) = rows
AIJpqMatrixDimsList(j,i,1,k,l,2) = cols
AIJpqMatrixDimsList(j,i,1,l,k,1) = rows
AIJpqMatrixDimsList(j,i,1,l,k,2) = cols
end do
end do
end do
end do
END_PROVIDER
-
Read the transformation matrix based on the number of SOMOs
We go through all the possible SOMOs and build the matrix-elements \(<I|E_{pq}|I>\) and store it in the AIJpq container.
BEGIN_PROVIDER [ real*8, AIJpqContainer, (NSOMOMax,NSOMOMax,4,NSOMOMax,NSOMOMax,NSOMOMax,NSOMOMax)] use cfunctions implicit none BEGIN_DOC ! Documentation for AIJpqMatrixList ! The prototype matrix containing the <I|E_{pq}|J> ! matrices for each I,J somo pair and orb ids. END_DOC integer i,j,k,l, orbp, orbq, ri, ci orbp = 0 orbq = 0 integer*8 Isomo, Jsomo Isomo = 0 Jsomo = 0 integer*8 rows, cols rows = -1 cols = -1 integer*8 MS MS = 0 real*8,dimension(:),allocatable :: meMatrix print *,"NSOMOMax = ",NSOMOMax !allocate(AIJpqMatrixDimsList(NSOMOMax,NSOMOMax,4,NSOMOMax,NSOMOMax,2)) do i = 2, NSOMOMax, 2 Isomo = ISHFT(1,i)-1 do j = i-2,i+2, 2 Jsomo = ISHFT(1,j)-1 if(j .GT. NSOMOMax .OR. j .LE. 0) then cycle end if do k = 1,NSOMOMax do l = k,NSOMOMax call getApqIJMatrixDims(Isomo, & Jsomo, & MS, & rows, & cols) ! allocate matrix allocate(meMatrix(rows*cols)) ! fill matrix call getApqIJMatrixDriver(Isomo, & Jsomo, & orbp, & orbq, & MS, & NMO, & meMatrix, & rows, & cols) print *, i,j,k,l,">",Isomo,Jsomo,">",rows, cols ! i -> j do ri = 1,rows do ci = 1,cols AIJpqContainer(i,j,1,k,l,ri,ci) = meMatrix(ri*(cols-1) + ci) end do end do end do end do end do end do END_PROVIDER
- Perform the conversion by matrix-vector BLAS level 2 call