9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-25 04:53:32 +01:00

Added dgemv in sigma vector.

This commit is contained in:
vijay gopal chilkuri 2021-03-12 19:24:02 +01:00
parent 5a8c58c8d2
commit 77949a12a0
3 changed files with 69 additions and 36 deletions

View File

@ -114,14 +114,14 @@ use bitmasks
Jsomo = IBCLR(Isomo,p-1) Jsomo = IBCLR(Isomo,p-1)
Jsomo = IBSET(Jsomo,q-1) Jsomo = IBSET(Jsomo,q-1)
Jdomo = Idomo Jdomo = Idomo
kstart = max(0,cfg_seniority_index(max(0,Nsomo_I-2))) kstart = max(1,cfg_seniority_index(max(0,Nsomo_I-2)))
kend = idxI-1 kend = idxI-1
else if(holetype(i) .EQ. 1 .AND. vmotype(j) .EQ. 2) then else if(holetype(i) .EQ. 1 .AND. vmotype(j) .EQ. 2) then
! SOMO -> SOMO ! SOMO -> SOMO
Jsomo = IBCLR(Isomo,p-1) Jsomo = IBCLR(Isomo,p-1)
Jsomo = IBCLR(Jsomo,q-1) Jsomo = IBCLR(Jsomo,q-1)
Jdomo = IBSET(Idomo,q-1) Jdomo = IBSET(Idomo,q-1)
kstart = max(0,cfg_seniority_index(max(0,Nsomo_I-4))) kstart = max(1,cfg_seniority_index(max(0,Nsomo_I-4)))
kend = idxI-1 kend = idxI-1
else if(holetype(i) .EQ. 2 .AND. vmotype(j) .EQ. 1) then else if(holetype(i) .EQ. 2 .AND. vmotype(j) .EQ. 1) then
! DOMO -> VMO ! DOMO -> VMO
@ -136,7 +136,7 @@ use bitmasks
Jsomo = IBCLR(Jsomo,q-1) Jsomo = IBCLR(Jsomo,q-1)
Jdomo = IBCLR(Idomo,p-1) Jdomo = IBCLR(Idomo,p-1)
Jdomo = IBSET(Jdomo,q-1) Jdomo = IBSET(Jdomo,q-1)
kstart = max(0,cfg_seniority_index(max(0,Nsomo_I-2))) kstart = max(1,cfg_seniority_index(max(0,Nsomo_I-2)))
kend = idxI-1 kend = idxI-1
else else
print*,"Something went wrong in obtain_associated_alphaI" print*,"Something went wrong in obtain_associated_alphaI"
@ -386,14 +386,14 @@ END_PROVIDER
Jsomo = IBCLR(Isomo,p-1) Jsomo = IBCLR(Isomo,p-1)
Jsomo = IBSET(Jsomo,q-1) Jsomo = IBSET(Jsomo,q-1)
Jdomo = Idomo Jdomo = Idomo
kstart = max(0,cfg_seniority_index(max(0,Nsomo_I-2))) kstart = max(1,cfg_seniority_index(max(0,Nsomo_I-2)))
kend = idxI-1 kend = idxI-1
else if(holetype(i) .EQ. 1 .AND. vmotype(j) .EQ. 2) then else if(holetype(i) .EQ. 1 .AND. vmotype(j) .EQ. 2) then
! SOMO -> SOMO ! SOMO -> SOMO
Jsomo = IBCLR(Isomo,p-1) Jsomo = IBCLR(Isomo,p-1)
Jsomo = IBCLR(Jsomo,q-1) Jsomo = IBCLR(Jsomo,q-1)
Jdomo = IBSET(Idomo,q-1) Jdomo = IBSET(Idomo,q-1)
kstart = max(0,cfg_seniority_index(max(0,Nsomo_I-4))) kstart = max(1,cfg_seniority_index(max(0,Nsomo_I-4)))
kend = idxI-1 kend = idxI-1
else if(holetype(i) .EQ. 2 .AND. vmotype(j) .EQ. 1) then else if(holetype(i) .EQ. 2 .AND. vmotype(j) .EQ. 1) then
! DOMO -> VMO ! DOMO -> VMO
@ -408,7 +408,7 @@ END_PROVIDER
Jsomo = IBCLR(Jsomo,q-1) Jsomo = IBCLR(Jsomo,q-1)
Jdomo = IBCLR(Idomo,p-1) Jdomo = IBCLR(Idomo,p-1)
Jdomo = IBSET(Jdomo,q-1) Jdomo = IBSET(Jdomo,q-1)
kstart = max(0,cfg_seniority_index(max(0,Nsomo_I-2))) kstart = max(1,cfg_seniority_index(max(0,Nsomo_I-2)))
kend = idxI-1 kend = idxI-1
else else
print*,"Something went wrong in obtain_associated_alphaI" print*,"Something went wrong in obtain_associated_alphaI"

View File

@ -460,16 +460,19 @@ END_PROVIDER
BEGIN_PROVIDER [ integer, cfg_seniority_index, (0:elec_num) ] BEGIN_PROVIDER [ integer, cfg_seniority_index, (0:elec_num) ]
&BEGIN_PROVIDER [ integer, cfg_nsomo_max ] &BEGIN_PROVIDER [ integer, cfg_nsomo_max ]
&BEGIN_PROVIDER [ integer, cfg_nsomo_min ]
implicit none implicit none
BEGIN_DOC BEGIN_DOC
! Returns the index in psi_configuration of the first cfg with ! Returns the index in psi_configuration of the first cfg with
! the requested seniority ! the requested seniority
! !
! cfg_nsomo_max : Max number of SOMO in the current wave function ! cfg_nsomo_max : Max number of SOMO in the current wave function
! cfg_nsomo_min : Min number of SOMO in the current wave function
END_DOC END_DOC
integer :: i, k, s, sold integer :: i, k, s, sold, soldmin
cfg_seniority_index(:) = -1 cfg_seniority_index(:) = -1
sold = -1 sold = -1
soldmin = 2000
cfg_nsomo_max = 0 cfg_nsomo_max = 0
do i=1,N_configuration do i=1,N_configuration
s = 0 s = 0
@ -482,6 +485,10 @@ END_PROVIDER
cfg_seniority_index(s) = i cfg_seniority_index(s) = i
cfg_nsomo_max = s cfg_nsomo_max = s
endif endif
if (soldmin .GT. s ) then
soldmin = s
cfg_nsomo_min = s
endif
enddo enddo
END_PROVIDER END_PROVIDER

View File

@ -1,4 +1,5 @@
BEGIN_PROVIDER [ integer, NSOMOMax] BEGIN_PROVIDER [ integer, NSOMOMax]
&BEGIN_PROVIDER [ integer, NSOMOMin]
&BEGIN_PROVIDER [ integer, NCSFMax] &BEGIN_PROVIDER [ integer, NCSFMax]
&BEGIN_PROVIDER [ integer*8, NMO] &BEGIN_PROVIDER [ integer*8, NMO]
&BEGIN_PROVIDER [ integer, NBFMax] &BEGIN_PROVIDER [ integer, NBFMax]
@ -11,6 +12,7 @@
! required for the calculation of prototype arrays. ! required for the calculation of prototype arrays.
END_DOC END_DOC
NSOMOMax = min(elec_num, cfg_nsomo_max + 2) NSOMOMax = min(elec_num, cfg_nsomo_max + 2)
NSOMOMin = cfg_nsomo_min
! Note that here we need NSOMOMax + 2 sizes ! Note that here we need NSOMOMax + 2 sizes
NCSFMax = max(1,nint((binom(NSOMOMax,(NSOMOMax+1)/2)-binom(NSOMOMax,((NSOMOMax+1)/2)+1)))) ! TODO: NCSFs for MS=0 NCSFMax = max(1,nint((binom(NSOMOMax,(NSOMOMax+1)/2)-binom(NSOMOMax,((NSOMOMax+1)/2)+1)))) ! TODO: NCSFs for MS=0
NBFMax = NCSFMax NBFMax = NCSFMax
@ -27,11 +29,13 @@
integer ncfgpersomo integer ncfgpersomo
detDimperBF = 0 detDimperBF = 0
MS = elec_alpha_num-elec_beta_num MS = elec_alpha_num-elec_beta_num
!print *,"NSOMOMax=",NSOMOMax, cfg_seniority_index(0) !print *,"NSOMOMax=",NSOMOMax, cfg_seniority_index(NSOMOMin)
!print *,"NSOMOMin=",NSOMOMin
! number of cfgs = number of dets for 0 somos ! number of cfgs = number of dets for 0 somos
n_CSF = cfg_seniority_index(0)-1 n_CSF = cfg_seniority_index(NSOMOMin)-1
ncfgprev = cfg_seniority_index(0) ncfgprev = cfg_seniority_index(NSOMOMin)
do i = 0-iand(MS,1)+2, NSOMOMax,2 !do i = 0-iand(MS,1)+2, NSOMOMax,2
do i = NSOMOMin, NSOMOMax,2
if(cfg_seniority_index(i) .EQ. -1)then if(cfg_seniority_index(i) .EQ. -1)then
ncfgpersomo = N_configuration + 1 ncfgpersomo = N_configuration + 1
else else
@ -163,6 +167,7 @@ end subroutine get_phase_qp_to_cfg
countdet = 0 countdet = 0
integer istate integer istate
istate = 1 istate = 1
psi_csf_to_config_data(1) = 1
phasedet = 1.0d0 phasedet = 1.0d0
do i = 1,N_configuration do i = 1,N_configuration
startdet = psi_configuration_to_psi_det(1,i) startdet = psi_configuration_to_psi_det(1,i)
@ -208,15 +213,17 @@ end subroutine get_phase_qp_to_cfg
deallocate(tempCoeff) deallocate(tempCoeff)
deallocate(tempBuffer) deallocate(tempBuffer)
psi_config_data(i,1) = countcsf + 1 psi_config_data(i,1) = countcsf + 1
do k=1,bfIcfg
psi_csf_to_config_data(countcsf+k) = i
enddo
countcsf += bfIcfg countcsf += bfIcfg
psi_config_data(i,2) = countcsf psi_config_data(i,2) = countcsf
psi_csf_to_config_data(countcsf) = i
enddo enddo
print *,"Norm det=",norm_det1, size(psi_coef_config,1), " Dim csf=", countcsf print *,"Norm det=",norm_det1, size(psi_coef_config,1), " Dim csf=", countcsf
END_PROVIDER END_PROVIDER
BEGIN_PROVIDER [ integer, AIJpqMatrixDimsList, (0:NSOMOMax,4,NSOMOMax+1,NSOMOMax+1,2)] BEGIN_PROVIDER [ integer, AIJpqMatrixDimsList, (NSOMOMin:NSOMOMax,4,NSOMOMax+1,NSOMOMax+1,2)]
&BEGIN_PROVIDER [ integer, rowsmax] &BEGIN_PROVIDER [ integer, rowsmax]
&BEGIN_PROVIDER [ integer, colsmax] &BEGIN_PROVIDER [ integer, colsmax]
use cfunctions use cfunctions
@ -235,7 +242,6 @@ end subroutine get_phase_qp_to_cfg
cols = -1 cols = -1
integer*8 MS integer*8 MS
MS = elec_alpha_num-elec_beta_num MS = elec_alpha_num-elec_beta_num
integer nsomomin
nsomomin = elec_alpha_num-elec_beta_num nsomomin = elec_alpha_num-elec_beta_num
rowsmax = 0 rowsmax = 0
colsmax = 0 colsmax = 0
@ -246,7 +252,7 @@ end subroutine get_phase_qp_to_cfg
!print *,"Doing SOMO->SOMO" !print *,"Doing SOMO->SOMO"
AIJpqMatrixDimsList(0,1,1,1,1) = 1 AIJpqMatrixDimsList(0,1,1,1,1) = 1
AIJpqMatrixDimsList(0,1,1,1,2) = 1 AIJpqMatrixDimsList(0,1,1,1,2) = 1
do i = 2-iand(nsomomin,1), NSOMOMax, 2 do i = NSOMOMin, NSOMOMax, 2
Isomo = ISHFT(1_8,i)-1 Isomo = ISHFT(1_8,i)-1
do j = i-2,i-2, 2 do j = i-2,i-2, 2
Jsomo = ISHFT(1_8,j)-1 Jsomo = ISHFT(1_8,j)-1
@ -292,7 +298,7 @@ end subroutine get_phase_qp_to_cfg
!print *,"Doing DOMO->VMO" !print *,"Doing DOMO->VMO"
AIJpqMatrixDimsList(0,2,1,1,1) = 1 AIJpqMatrixDimsList(0,2,1,1,1) = 1
AIJpqMatrixDimsList(0,2,1,1,2) = 1 AIJpqMatrixDimsList(0,2,1,1,2) = 1
do i = 0+iand(nsomomin,1), NSOMOMax, 2 do i = NSOMOMin, NSOMOMax, 2
Isomo = ISHFT(1_8,i)-1 Isomo = ISHFT(1_8,i)-1
tmpsomo = ISHFT(1_8,i+2)-1 tmpsomo = ISHFT(1_8,i+2)-1
do j = i+2,i+2, 2 do j = i+2,i+2, 2
@ -344,7 +350,7 @@ end subroutine get_phase_qp_to_cfg
!print *,"Doing SOMO->VMO" !print *,"Doing SOMO->VMO"
AIJpqMatrixDimsList(0,3,1,1,1) = 1 AIJpqMatrixDimsList(0,3,1,1,1) = 1
AIJpqMatrixDimsList(0,3,1,1,2) = 1 AIJpqMatrixDimsList(0,3,1,1,2) = 1
do i = 2-iand(nsomomin,1), NSOMOMax, 2 do i = NSOMOMin, NSOMOMax, 2
Isomo = ISHFT(1_8,i)-1 Isomo = ISHFT(1_8,i)-1
do j = i,i, 2 do j = i,i, 2
Jsomo = ISHFT(1_8,j)-1 Jsomo = ISHFT(1_8,j)-1
@ -386,7 +392,7 @@ end subroutine get_phase_qp_to_cfg
!print *,"Doing DOMO->SOMO" !print *,"Doing DOMO->SOMO"
AIJpqMatrixDimsList(0,4,1,1,1) = 1 AIJpqMatrixDimsList(0,4,1,1,1) = 1
AIJpqMatrixDimsList(0,4,1,1,2) = 1 AIJpqMatrixDimsList(0,4,1,1,2) = 1
do i = 2-iand(nsomomin,1), NSOMOMax, 2 do i = NSOMOMin, NSOMOMax, 2
do j = i,i, 2 do j = i,i, 2
if(j .GT. NSOMOMax .OR. j .LE. 0) then if(j .GT. NSOMOMax .OR. j .LE. 0) then
cycle cycle
@ -425,7 +431,6 @@ end subroutine get_phase_qp_to_cfg
END_PROVIDER END_PROVIDER
BEGIN_PROVIDER [ real*8, AIJpqContainer, (0:NSOMOMax,4,NSOMOMax+1,NSOMOMax+1,NBFMax,NBFMax)] BEGIN_PROVIDER [ real*8, AIJpqContainer, (0:NSOMOMax,4,NSOMOMax+1,NSOMOMax+1,NBFMax,NBFMax)]
!BEGIN_PROVIDER [ real*8, AIJpqContainer, (0:NSOMOMax,-1:1,4,NSOMOMax+1,-1:1,NBFMax,NBFMax)]
use cfunctions use cfunctions
implicit none implicit none
BEGIN_DOC BEGIN_DOC
@ -467,7 +472,7 @@ end subroutine get_phase_qp_to_cfg
! 1. SOMO -> SOMO ! 1. SOMO -> SOMO
!print *,"Doing SOMO -> SOMO" !print *,"Doing SOMO -> SOMO"
AIJpqContainer(0,1,1,1,1,1) = 1.0d0 AIJpqContainer(0,1,1,1,1,1) = 1.0d0
do i = 2, NSOMOMax, 2 do i = NSOMOMin+2, NSOMOMax, 2
Isomo = ISHFT(1_8,i)-1 Isomo = ISHFT(1_8,i)-1
do j = i-2,i-2, 2 do j = i-2,i-2, 2
if(j .GT. NSOMOMax .OR. j .LT. 0) cycle if(j .GT. NSOMOMax .OR. j .LT. 0) cycle
@ -530,7 +535,7 @@ end subroutine get_phase_qp_to_cfg
! 2. DOMO -> VMO ! 2. DOMO -> VMO
!print *,"Doing DOMO -> VMO" !print *,"Doing DOMO -> VMO"
AIJpqContainer(0,2,1,1,1,1) = 1.0d0 AIJpqContainer(0,2,1,1,1,1) = 1.0d0
do i = 0, NSOMOMax, 2 do i = NSOMOMin, NSOMOMax, 2
Isomo = ISHFT(1_8,i)-1 Isomo = ISHFT(1_8,i)-1
tmpsomo = ISHFT(1_8,i+2)-1 tmpsomo = ISHFT(1_8,i+2)-1
do j = i+2,i+2, 2 do j = i+2,i+2, 2
@ -596,7 +601,7 @@ end subroutine get_phase_qp_to_cfg
! Type ! Type
! 3. SOMO -> VMO ! 3. SOMO -> VMO
!print *,"Doing SOMO -> VMO" !print *,"Doing SOMO -> VMO"
do i = 2, NSOMOMax, 2 do i = NSOMOMin, NSOMOMax, 2
Isomo = ISHFT(1_8,i)-1 Isomo = ISHFT(1_8,i)-1
do j = i,i, 2 do j = i,i, 2
Jsomo = ISHFT(1_8,j)-1 Jsomo = ISHFT(1_8,j)-1
@ -655,7 +660,7 @@ end subroutine get_phase_qp_to_cfg
! 4. DOMO -> SOMO ! 4. DOMO -> SOMO
!print *,"Doing DOMO -> SOMO" !print *,"Doing DOMO -> SOMO"
AIJpqContainer(0,4,1,1,1,1) = 1.0d0 AIJpqContainer(0,4,1,1,1,1) = 1.0d0
do i = 2, NSOMOMax, 2 do i = NSOMOMin+2, NSOMOMax, 2
Isomo = ISHFT(1_8,i)-1 Isomo = ISHFT(1_8,i)-1
do j = i,i, 2 do j = i,i, 2
Jsomo = ISHFT(1_8,i)-1 Jsomo = ISHFT(1_8,i)-1
@ -902,6 +907,8 @@ subroutine calculate_sigma_vector_cfg_nst_naive_store(psi_out, psi_in, n_st, sze
real*8,dimension(:,:,:),allocatable :: TKI real*8,dimension(:,:,:),allocatable :: TKI
real*8,dimension(:,:),allocatable :: GIJpqrs real*8,dimension(:,:),allocatable :: GIJpqrs
real*8,dimension(:,:,:),allocatable :: TKIGIJ real*8,dimension(:,:,:),allocatable :: TKIGIJ
real*8,dimension(:),allocatable :: psi_out_tmp
real*8,dimension(:,:),allocatable :: CCmattmp
real*8, external :: mo_two_e_integral real*8, external :: mo_two_e_integral
real*8, external :: get_two_e_integral real*8, external :: get_two_e_integral
real*8 :: diag_energies(n_CSF) real*8 :: diag_energies(n_CSF)
@ -1187,11 +1194,29 @@ subroutine calculate_sigma_vector_cfg_nst_naive_store(psi_out, psi_in, n_st, sze
colsikpq = AIJpqMatrixDimsList(NSOMOalpha,extype,pmodel,qmodel,2) colsikpq = AIJpqMatrixDimsList(NSOMOalpha,extype,pmodel,qmodel,2)
!print *,">j=",j,rowsikpq,colsikpq, ">>",totcolsTKI,",",idxs_connectedI_alpha(j) !print *,">j=",j,rowsikpq,colsikpq, ">>",totcolsTKI,",",idxs_connectedI_alpha(j)
do kk = 1,n_st do kk = 1,n_st
!do m = 1,colsikpq
! do l = 1,rowsTKI
! psi_out(idxs_connectedI_alpha(j)+m-1,kk) += AIJpqContainer(NSOMOalpha,extype,pmodel,qmodel,l,m) * TKIGIJ(l,kk,j)
! enddo
!enddo
allocate(psi_out_tmp(colsikpq))
!allocate(CCmattmp(rowsTKI,colsikpq))
!do m=1,colsikpq
! do l=1,rowsTKI
! CCmattmp(l,m) = AIJpqContainer(NSOMOalpha,extype,pmodel,qmodel,l,m)
! enddo
!enddo
!call dgemv('T',rowsTKI, colsikpq, 1.d0, &
! CCmattmp, size(CCmattmp,1), TKIGIJ(:,kk,j), 1, 0.d0, &
! psi_out_tmp, 1)
call dgemv('T',rowsTKI, colsikpq, 1.d0, &
AIJpqContainer(NSOMOalpha,extype,pmodel,qmodel,1:rowsTKI,1:colsikpq), rowsTKI, TKIGIJ(:,kk,j), 1, 0.d0, &
psi_out_tmp, 1)
do m = 1,colsikpq do m = 1,colsikpq
do l = 1,rowsTKI psi_out(idxs_connectedI_alpha(j)+m-1,kk) += psi_out_tmp(m)
psi_out(idxs_connectedI_alpha(j)+m-1,kk) += AIJpqContainer(NSOMOalpha,extype,pmodel,qmodel,l,m) * TKIGIJ(l,kk,j)
enddo
enddo enddo
deallocate(psi_out_tmp)
!deallocate(CCmattmp)
enddo enddo
totcolsTKI += colsikpq totcolsTKI += colsikpq
enddo enddo
@ -1274,16 +1299,16 @@ subroutine calculate_sigma_vector_cfg_nst(psi_out, psi_in, n_st, sze, istart, ie
real*8 :: diag_energies(n_CSF) real*8 :: diag_energies(n_CSF)
! allocate ! allocate
allocate(alphas_Icfg(N_INT,2,max(sze,100))) allocate(alphas_Icfg(N_INT,2,max(sze/2,100)))
allocate(singlesI(N_INT,2,max(sze,100))) allocate(singlesI(N_INT,2,max(sze/2,100)))
allocate(connectedI_alpha(N_INT,2,max(sze,100))) allocate(connectedI_alpha(N_INT,2,max(sze/2,100)))
allocate(idxs_singlesI(max(sze,100))) allocate(idxs_singlesI(max(sze/2,100)))
allocate(idxs_connectedI_alpha(max(sze,100))) allocate(idxs_connectedI_alpha(max(sze/2,100)))
allocate(excitationIds_single(2,max(sze,100))) allocate(excitationIds_single(2,max(sze/2,100)))
allocate(excitationTypes_single(max(sze,100))) allocate(excitationTypes_single(max(sze/2,100)))
allocate(excitationIds(2,max(sze,100))) allocate(excitationIds(2,max(sze/2,100)))
allocate(excitationTypes(max(sze,100))) allocate(excitationTypes(max(sze/2,100)))
allocate(diagfactors(max(sze,100))) allocate(diagfactors(max(sze/2,100)))
!print *," sze = ",sze !print *," sze = ",sze
@ -1300,6 +1325,7 @@ subroutine calculate_sigma_vector_cfg_nst(psi_out, psi_in, n_st, sze, istart, ie
!!! Single Excitations !!! !!! Single Excitations !!!
do i=istart_cfg,iend_cfg do i=istart_cfg,iend_cfg
print *,"I=",i
! if Seniority_range > 8 then ! if Seniority_range > 8 then
! continue ! continue