10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-07-22 18:57:36 +02:00

Updated binary search and added cfg_somo_min.

This commit is contained in:
v1j4y 2022-06-06 17:28:48 +02:00
parent abe662757e
commit 48e48fbf16

View File

@ -460,6 +460,7 @@ 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
@ -467,9 +468,10 @@ END_PROVIDER
! !
! cfg_nsomo_max : Max number of SOMO in the current wave function ! cfg_nsomo_max : Max 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 +484,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
@ -743,41 +749,112 @@ BEGIN_PROVIDER [ integer(bit_kind), dominant_dets_of_cfgs, (N_int,2,N_dominant_d
enddo enddo
END_PROVIDER END_PROVIDER
subroutine binary_search_cfg(cfgInp,addcfg) subroutine binary_search_cfg(cfgInp,addcfg,bit_tmp)
use bitmasks use bitmasks
implicit none implicit none
BEGIN_DOC BEGIN_DOC
! Documentation for binary_search ! Documentation for binary_search
! !
! Does a binary search to find ! Does a binary search to find
! the address of a configuration in a list of ! the address of a configuration in a list of
! configurations. ! configurations.
END_DOC END_DOC
integer(bit_kind), intent(in) :: cfgInp(N_int,2) integer(bit_kind), intent(in) :: cfgInp(N_int,2)
integer , intent(out) :: addcfg integer , intent(out) :: addcfg
integer :: i,j,k,r,l integer*8, intent(in) :: bit_tmp(0:N_configuration+1)
integer*8 :: key, key2
logical :: found
!integer*8, allocatable :: bit_tmp(:)
!integer*8, external :: configuration_search_key
!allocate(bit_tmp(0:N_configuration)) logical :: found
!bit_tmp(0) = 0 integer :: l, r, j, k
do i=1,N_configuration integer*8 :: key
!bit_tmp(i) = configuration_search_key(psi_configuration(1,1,i),N_int)
found = .True. integer*8, external :: configuration_search_key
do k=1,N_int
found = found .and. (psi_configuration(k,1,i) == cfgInp(k,1)) & key = configuration_search_key(cfgInp,N_int)
.and. (psi_configuration(k,2,i) == cfgInp(k,2))
enddo ! Binary search
if (found) then l = 0
addcfg = i r = N_configuration+1
exit IRP_IF WITHOUT_SHIFTRL
j = ishft(r-l,-1)
IRP_ELSE
j = shiftr(r-l,1)
IRP_ENDIF
do while (j>=1)
j = j+l
if (bit_tmp(j) == key) then
! Find 1st element which matches the key
if (j > 1) then
do while (j>1 .and. bit_tmp(j-1) == key)
j = j-1
enddo
endif
! Find correct element matching the key
do while (bit_tmp(j) == key)
found = .True.
do k=1,N_int
found = found .and. (psi_configuration(k,1,j) == cfgInp(k,1))&
.and. (psi_configuration(k,2,j) == cfgInp(k,2))
enddo
if (found) then
addcfg = j
return
endif
j = j+1
enddo
addcfg = -1
return
else if (bit_tmp(j) > key) then
r = j
else
l = j
endif endif
IRP_IF WITHOUT_SHIFTRL
j = ishft(r-l,-1)
IRP_ELSE
j = shiftr(r-l,1)
IRP_ENDIF
enddo enddo
addcfg = -1
return
end subroutine end subroutine
!subroutine binary_search_cfg(cfgInp,addcfg)
! use bitmasks
! implicit none
! BEGIN_DOC
! ! Documentation for binary_search
! !
! ! Does a binary search to find
! ! the address of a configuration in a list of
! ! configurations.
! END_DOC
! integer(bit_kind), intent(in) :: cfgInp(N_int,2)
! integer , intent(out) :: addcfg
! integer :: i,j,k,r,l
! integer*8 :: key, key2
! logical :: found
! !integer*8, allocatable :: bit_tmp(:)
! !integer*8, external :: configuration_search_key
!
! !allocate(bit_tmp(0:N_configuration))
! !bit_tmp(0) = 0
! do i=1,N_configuration
! !bit_tmp(i) = configuration_search_key(psi_configuration(1,1,i),N_int)
! found = .True.
! do k=1,N_int
! found = found .and. (psi_configuration(k,1,i) == cfgInp(k,1)) &
! .and. (psi_configuration(k,2,i) == cfgInp(k,2))
! enddo
! if (found) then
! addcfg = i
! exit
! endif
! enddo
!
!end subroutine
!
BEGIN_PROVIDER [ integer, psi_configuration_to_psi_det, (2,N_configuration) ] BEGIN_PROVIDER [ integer, psi_configuration_to_psi_det, (2,N_configuration) ]
&BEGIN_PROVIDER [ integer, psi_configuration_to_psi_det_data, (N_det) ] &BEGIN_PROVIDER [ integer, psi_configuration_to_psi_det_data, (N_det) ]