9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-10-05 07:35:59 +02:00

Optimizations, maybe wrong

This commit is contained in:
Anthony Scemama 2021-03-18 00:55:37 +01:00
parent 8b5d4a5bb9
commit 46d9f3c847
2 changed files with 248 additions and 248 deletions

View File

@ -1,6 +1,6 @@
use bitmasks use bitmasks
BEGIN_PROVIDER [ integer(bit_kind), alphasIcfg_list , (N_int,2,N_configuration,mo_num*mo_num)] BEGIN_PROVIDER [ integer(bit_kind), alphasIcfg_list , (N_int,2,N_configuration,elec_num)]
&BEGIN_PROVIDER [ integer, NalphaIcfg_list, (N_configuration) ] &BEGIN_PROVIDER [ integer, NalphaIcfg_list, (N_configuration) ]
implicit none implicit none
!use bitmasks !use bitmasks
@ -45,6 +45,8 @@ use bitmasks
logical :: pqExistsQ logical :: pqExistsQ
logical :: ppExistsQ logical :: ppExistsQ
double precision :: t0, t1
call wall_time(t0)
allocate(tableUniqueAlphas(mo_num,mo_num)) allocate(tableUniqueAlphas(mo_num,mo_num))
NalphaIcfg_list = 0 NalphaIcfg_list = 0
@ -80,16 +82,17 @@ use bitmasks
vmotype = -1 vmotype = -1
nvmos = 0 nvmos = 0
do i = 1,mo_num do i = 1,mo_num
!print *,i,IBSET(0,i-1),POPCNT(IAND(Isomo,(IBSET(0_8,i-1)))), POPCNT(IAND(Idomo,(IBSET(0_8,i-1)))) if(IAND(Idomo,(IBSET(0_8,i-1))) .EQ. 0) then
if(POPCNT(IAND(Isomo,(IBSET(0_8,i-1)))) .EQ. 0 .AND. POPCNT(IAND(Idomo,(IBSET(0_8,i-1)))) .EQ. 0) then if(IAND(Isomo,(IBSET(0_8,i-1))) .EQ. 0) then
nvmos += 1 nvmos += 1
listvmos(nvmos) = i listvmos(nvmos) = i
vmotype(nvmos) = 1 vmotype(nvmos) = 1
else if(POPCNT(IAND(Isomo,(IBSET(0_8,i-1)))) .EQ. 1 .AND. POPCNT(IAND(Idomo,(IBSET(0_8,i-1)))) .EQ. 0 ) then else if(POPCNT(IAND(Isomo,(IBSET(0_8,i-1)))) .EQ. 1) then
nvmos += 1 nvmos += 1
listvmos(nvmos) = i listvmos(nvmos) = i
vmotype(nvmos) = 2 vmotype(nvmos) = 2
end if end if
end if
end do end do
tableUniqueAlphas = .FALSE. tableUniqueAlphas = .FALSE.
@ -144,7 +147,7 @@ use bitmasks
endif endif
! Again, we don't have to search from 1 ! Again, we don't have to search from 1
! we just use seniorty to find the ! we just use seniority to find the
! first index with NSOMO - 2 to NSOMO + 2 ! first index with NSOMO - 2 to NSOMO + 2
! this is what is done in kstart, kend ! this is what is done in kstart, kend
@ -234,14 +237,16 @@ use bitmasks
ppExistsQ = .False. ppExistsQ = .False.
Isomo = iand(reunion_of_act_virt_bitmask(1,1),Icfg(1,1)) Isomo = iand(reunion_of_act_virt_bitmask(1,1),Icfg(1,1))
Idomo = iand(reunion_of_act_virt_bitmask(1,1),Icfg(1,2)) Idomo = iand(reunion_of_act_virt_bitmask(1,1),Icfg(1,2))
do k = 1, idxI-1 kstart = max(1,cfg_seniority_index(max(0,Nsomo_I-2)))
do k = kstart, idxI-1
diffSOMO = IEOR(Isomo,iand(reunion_of_act_virt_bitmask(1,1),psi_configuration(1,1,k))) diffSOMO = IEOR(Isomo,iand(reunion_of_act_virt_bitmask(1,1),psi_configuration(1,1,k)))
ndiffSOMO = POPCNT(diffSOMO)
if (ndiffSOMO /= 2) cycle
diffDOMO = IEOR(Idomo,iand(reunion_of_act_virt_bitmask(1,1),psi_configuration(1,2,k))) diffDOMO = IEOR(Idomo,iand(reunion_of_act_virt_bitmask(1,1),psi_configuration(1,2,k)))
xordiffSOMODOMO = IEOR(diffSOMO,diffDOMO) xordiffSOMODOMO = IEOR(diffSOMO,diffDOMO)
ndiffSOMO = POPCNT(diffSOMO)
ndiffDOMO = POPCNT(diffDOMO) ndiffDOMO = POPCNT(diffDOMO)
nxordiffSOMODOMO = POPCNT(xordiffSOMODOMO) nxordiffSOMODOMO = POPCNT(xordiffSOMODOMO)
if((ndiffSOMO+ndiffDOMO+nxordiffSOMODOMO .EQ. 4) .AND. ndiffSOMO .EQ. 2) then if((ndiffSOMO+ndiffDOMO+nxordiffSOMODOMO .EQ. 4)) then
ppExistsQ = .TRUE. ppExistsQ = .TRUE.
EXIT EXIT
endif endif
@ -257,6 +262,8 @@ use bitmasks
NalphaIcfg = 0 NalphaIcfg = 0
enddo ! end loop idxI enddo ! end loop idxI
call wall_time(t1)
print *, 'Preparation : ', t1 - t0
END_PROVIDER END_PROVIDER
@ -416,7 +423,7 @@ END_PROVIDER
endif endif
! Again, we don't have to search from 1 ! Again, we don't have to search from 1
! we just use seniorty to find the ! we just use seniortiy to find the
! first index with NSOMO - 2 to NSOMO + 2 ! first index with NSOMO - 2 to NSOMO + 2
! this is what is done in kstart, kend ! this is what is done in kstart, kend

View File

@ -144,6 +144,7 @@ end subroutine get_phase_qp_to_cfg
integer :: nt integer :: nt
norm_det1 = 0.d0 norm_det1 = 0.d0
MS = elec_alpha_num - elec_beta_num MS = elec_alpha_num - elec_beta_num
print *,"Maxbfdim=",NBFMax print *,"Maxbfdim=",NBFMax
@ -444,7 +445,6 @@ end subroutine get_phase_qp_to_cfg
print *,"Rowsmax=",rowsmax," Colsmax=",colsmax print *,"Rowsmax=",rowsmax," Colsmax=",colsmax
END_PROVIDER END_PROVIDER
!BEGIN_PROVIDER [ real*8, AIJpqContainer, (NSOMOMin:NSOMOMax,4,NSOMOMax+1,NSOMOMax+1,NBFMax,NBFMax)]
BEGIN_PROVIDER [ real*8, AIJpqContainer, (NBFMax,NBFmax,NSOMOMax+1,NSOMOMax+1,4,NSOMOMin:NSOMOMax)] BEGIN_PROVIDER [ real*8, AIJpqContainer, (NBFMax,NBFmax,NSOMOMax+1,NSOMOMax+1,4,NSOMOMin:NSOMOMax)]
use cfunctions use cfunctions
implicit none implicit none
@ -476,54 +476,50 @@ end subroutine get_phase_qp_to_cfg
cols = -1 cols = -1
integer*8 MS integer*8 MS
MS = 0 MS = 0
touch AIJpqMatrixDimsList
real*8,dimension(:,:),allocatable :: meMatrix real*8,dimension(:,:),allocatable :: meMatrix
integer maxdim integer maxdim
!maxdim = max(rowsmax,colsmax)
! allocate matrix
!print *,"rowsmax =",rowsmax," colsmax=",colsmax
!print *,"NSOMOMax = ",NSOMOMax
! Type ! Type
! 1. SOMO -> SOMO ! 1. SOMO -> SOMO
!print *,"Doing SOMO -> SOMO" AIJpqContainer = 0.d0
!AIJpqContainer(NSOMOMin,1,1,1,1,1) = 1.0d0
AIJpqContainer(1,1,1,1,1,NSOMOMin) = 1.0d0 AIJpqContainer(1,1,1,1,1,NSOMOMin) = 1.0d0
integer :: rows_old, cols_old
rows_old = -1
cols_old = -1
allocate(meMatrix(1,1))
do i = NSOMOMin+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 j=i-2
if(j .GT. NSOMOMax .OR. j .LT. 0) cycle if(j .GT. NSOMOMax .OR. j .LT. 0) cycle
!print *,"i,j=",i,j nsomoi = i
do k = 1,i do k = 1,i
orbp = k
do l = 1,i do l = 1,i
! Define Jsomo ! Define Jsomo
if(k .NE. l) then if(k .NE. l) then
Jsomo = IBCLR(Isomo, k-1) Jsomo = IBCLR(Isomo, k-1)
Jsomo = IBCLR(Jsomo, l-1) Jsomo = IBCLR(Jsomo, l-1)
nsomoi = i
nsomoj = j nsomoj = j
else else
Isomo = ISHFT(1_8,i)-1 Isomo = ISHFT(1_8,i)-1
Jsomo = ISHFT(1_8,i)-1 Jsomo = ISHFT(1_8,i)-1
nsomoi = i
nsomoj = i nsomoj = i
endif endif
!print *,"k,l=",k,l
!call debug_spindet(Jsomo,1)
!call debug_spindet(Isomo,1)
!AIJpqContainer(nsomoi,1,k,l,:,:) = 0.0d0
AIJpqContainer(:,:,k,l,1,nsomoi) = 0.0d0
call getApqIJMatrixDims(Isomo, & call getApqIJMatrixDims(Isomo, &
Jsomo, & Jsomo, &
MS, & MS, &
rows, & rows, &
cols) cols)
orbp = k
orbq = l orbq = l
if ((rows /= rows_old).or.(cols /= cols_old)) then
deallocate(meMatrix)
allocate(meMatrix(rows,cols)) allocate(meMatrix(rows,cols))
rows_old = rows
cols_old = cols
endif
meMatrix = 0.0d0 meMatrix = 0.0d0
! fill matrix ! fill matrix
call getApqIJMatrixDriver(Isomo, & call getApqIJMatrixDriver(Isomo, &
@ -535,20 +531,17 @@ end subroutine get_phase_qp_to_cfg
meMatrix, & meMatrix, &
rows, & rows, &
cols) cols)
!print *, i,j,k,l,">",Isomo,Jsomo,">",rows, cols,">",rowsmax,colsmax
!call printMatrix(meMatrix,rows,cols)
! i -> j ! i -> j
do ri = 1,rows do ri = 1,rows
do ci = 1,cols do ci = 1,cols
!AIJpqContainer(nsomoi,1,k,l,ri,ci) = meMatrix(ri, ci)
AIJpqContainer(ri,ci,k,l,1,nsomoi) = meMatrix(ri, ci) AIJpqContainer(ri,ci,k,l,1,nsomoi) = meMatrix(ri, ci)
end do end do
end do end do
end do
end do
end do
deallocate(meMatrix) deallocate(meMatrix)
end do
end do
end do
end do
! Type ! Type
! 2. DOMO -> VMO ! 2. DOMO -> VMO
!print *,"Doing DOMO -> VMO" !print *,"Doing DOMO -> VMO"