10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-19 04:22:32 +01:00

Almost donw with blas. #143.

This commit is contained in:
v1j4y 2021-02-01 21:18:48 +01:00
parent 347889d2fb
commit 1117aa454f
2 changed files with 283 additions and 44 deletions

View File

@ -93,6 +93,8 @@
!print *,"Isomo" !print *,"Isomo"
!call debug_spindet(Isomo,1) !call debug_spindet(Isomo,1)
!call debug_spindet(Idomo,1) !call debug_spindet(Idomo,1)
! TODO cfg_seniority_index
do i = 1,nholes do i = 1,nholes
p = listholes(i) p = listholes(i)
do j = 1,nvmos do j = 1,nvmos
@ -178,6 +180,7 @@
p = listholes(i) p = listholes(i)
do j = 1, nvmos do j = 1, nvmos
q = listvmos(j) q = listvmos(j)
if(p .EQ. q) cycle
if(tableUniqueAlphas(p,q)) then if(tableUniqueAlphas(p,q)) then
if(holetype(i) .EQ. 1 .AND. vmotype(j) .EQ. 1) then if(holetype(i) .EQ. 1 .AND. vmotype(j) .EQ. 1) then
! SOMO -> VMO ! SOMO -> VMO
@ -205,7 +208,7 @@
endif endif
NalphaIcfg += 1 NalphaIcfg += 1
!print *,p,q,"|",holetype(i),vmotype(j) !print *,p,q,"|",holetype(i),vmotype(j),NalphaIcfg
!call debug_spindet(Jsomo,1) !call debug_spindet(Jsomo,1)
!call debug_spindet(Jdomo,1) !call debug_spindet(Jdomo,1)
alphasIcfg(1,1,NalphaIcfg) = Jsomo alphasIcfg(1,1,NalphaIcfg) = Jsomo
@ -247,61 +250,77 @@ subroutine obtain_connected_I_foralpha(Ialpha, connectedI, nconnectedI, excitati
integer*8 :: diffDOMO integer*8 :: diffDOMO
integer :: ndiffSOMO integer :: ndiffSOMO
integer :: ndiffDOMO integer :: ndiffDOMO
integer :: i,j,k,l,p,q,nsomoI,nsomoalpha integer :: i,j,k,l,p,q,nsomoJ,nsomoalpha
nconnectedI = 0 nconnectedI = 0
p = 0 p = 0
q = 0 q = 0
do i=1,N_configuration
Isomo = Ialpha(1,1) Isomo = Ialpha(1,1)
Idomo = Ialpha(1,2) Idomo = Ialpha(1,2)
do i=1,N_configuration Jsomo = psi_configuration(1,1,i)
diffSOMO = IEOR(Isomo,psi_configuration(1,1,i)) Jdomo = psi_configuration(1,2,i)
diffDOMO = IEOR(Idomo,psi_configuration(1,2,i)) !call debug_spindet(Isomo,1)
!call debug_spindet(Idomo,1)
!print *,"-J--i=",i,Jsomo,Isomo
!call debug_spindet(Jsomo,1)
!call debug_spindet(Jdomo,1)
diffSOMO = IEOR(Isomo,Jsomo)
diffDOMO = IEOR(Idomo,Jdomo)
ndiffSOMO = POPCNT(diffSOMO) ndiffSOMO = POPCNT(diffSOMO)
ndiffDOMO = POPCNT(diffDOMO) ndiffDOMO = POPCNT(diffDOMO)
if((ndiffSOMO + ndiffDOMO) .EQ. 0) cycle
!print *,"-I--i=",i,Isomo,Jsomo,ndiffSOMO,ndiffDOMO
if(POPCNT(IEOR(diffSOMO,diffDOMO)) .LE. 1 .AND. ndiffDOMO .LT. 3) then if(POPCNT(IEOR(diffSOMO,diffDOMO)) .LE. 1 .AND. ndiffDOMO .LT. 3) then
nconnectedI += 1 nconnectedI += 1
connectedI(:,:,nconnectedI) = psi_configuration(:,:,i) connectedI(:,:,nconnectedI) = psi_configuration(:,:,i)
select case(ndiffDOMO) select case(ndiffDOMO)
case (0) case (0)
! SOMO -> VMO ! SOMO -> VMO
!print *,"obt SOMO -> VMO"
excitationTypes(nconnectedI) = 3 excitationTypes(nconnectedI) = 3
Jsomo = IEOR(Isomo, psi_configuration(1,1,i)) Jsomo = IEOR(Isomo, Jsomo)
p = TRAILZ(iand(Jsomo,Isomo)) p = TRAILZ(Jsomo) + 1
q = TRAILZ(iand(Jsomo,psi_configuration(1,1,i))) Jsomo = IBCLR(Jsomo,p-1)
q = TRAILZ(Jsomo) + 1
case (1) case (1)
! DOMO -> VMO ! DOMO -> VMO
! or ! or
! SOMO -> SOMO ! SOMO -> SOMO
nsomoI = POPCNT(psi_configuration(1,1,i)) nsomoJ = POPCNT(Jsomo)
nsomoalpha = POPCNT(Isomo) nsomoalpha = POPCNT(Isomo)
if(nsomoI .GT. nsomoalpha) then if(nsomoJ .GT. nsomoalpha) then
! DOMO -> VMO ! DOMO -> VMO
!print *,"obt DOMO -> VMO"
excitationTypes(nconnectedI) = 2 excitationTypes(nconnectedI) = 2
Jdomo = IEOR(Idomo, psi_configuration(1,2,i)) Isomo = IOR(IEOR(Isomo, Jsomo),IEOR(Idomo,Jdomo))
Jsomo = IEOR(Jdomo,IEOR(Isomo, psi_configuration(1,1,i))) p = TRAILZ(Isomo) + 1
p = TRAILZ(Jdomo) Isomo = IBCLR(Isomo,p-1)
q = TRAILZ(Jsomo) q = TRAILZ(Isomo) + 1
else else
! SOMO -> SOMO ! SOMO -> SOMO
!print *,"obt SOMO -> SOMO"
excitationTypes(nconnectedI) = 1 excitationTypes(nconnectedI) = 1
Jdomo = IEOR(Idomo, psi_configuration(1,2,i)) Isomo = IOR(IEOR(Isomo, Jsomo),IEOR(Idomo,Jdomo))
Jsomo = IEOR(Jdomo,IEOR(Isomo, psi_configuration(1,1,i))) p = TRAILZ(Isomo) + 1
q = TRAILZ(Jdomo) Isomo = IBCLR(Isomo,p-1)
p = TRAILZ(Jsomo) q = TRAILZ(Isomo) + 1
end if end if
case (2) case (2)
! DOMO -> SOMO ! DOMO -> SOMO
!print *,"obt DOMO -> SOMO"
excitationTypes(nconnectedI) = 4 excitationTypes(nconnectedI) = 4
Jdomo = IEOR(Idomo, psi_configuration(1,2,i)) Isomo = IEOR(Isomo, Jsomo)
p = TRAILZ(iand(Jdomo,Idomo)) p = TRAILZ(Isomo) + 1
q = TRAILZ(iand(Jdomo,psi_configuration(1,2,i))) Isomo = IBCLR(Isomo,p-1)
q = TRAILZ(Isomo) + 1
case default case default
print *,"something went wront in get connectedI" print *,"something went wront in get connectedI"
end select end select
excitationIds(1,nconnectedI)=p excitationIds(1,nconnectedI)=p
excitationIds(2,nconnectedI)=q excitationIds(2,nconnectedI)=q
!print *,"------ > output p,q in obt=",p,q
endif endif
end do end do
@ -318,3 +337,77 @@ end subroutine obtain_connected_I_foralpha
NSOMO += POPCNT(Icfg(i,1)) NSOMO += POPCNT(Icfg(i,1))
enddo enddo
end function getNSOMO end function getNSOMO
subroutine convertOrbIdsToModelSpaceIds(Ialpha, Jcfg, p, q, extype, pmodel, qmodel)
implicit none
BEGIN_DOC
! This function converts the orbital ids
! in real space to those used in model space
! in order to identify the matrices required
! for the calculation of MEs.
!
! The type of excitations are ordered as follows:
! Type 1 - SOMO -> SOMO
! Type 2 - DOMO -> VMO
! Type 3 - SOMO -> VMO
! Type 4 - DOMO -> SOMO
END_DOC
integer(bit_kind),intent(in) :: Ialpha(N_int,2)
integer(bit_kind),intent(in) :: Jcfg(N_int,2)
integer,intent(in) :: p,q
integer,intent(in) :: extype
integer,intent(out) :: pmodel,qmodel
integer*8 :: Isomo
integer*8 :: Idomo
integer*8 :: Jsomo
integer*8 :: Jdomo
integer*8 :: mask
integer :: pos0,pos0prev
Isomo = Ialpha(1,1)
Idomo = Ialpha(1,2)
Jsomo = Jcfg(1,1)
Jdomo = Jcfg(1,2)
pos0prev = 0
pmodel = p
qmodel = q
!print *,"input pq=",p,q
select case(extype)
case (1)
! SOMO -> SOMO
! remove all domos
!print *,"type -> SOMO -> SOMO"
mask = IBSET(0_8,p) - 1
pmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1
mask = IBSET(0_8,q) - 1
qmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1
case (2)
! DOMO -> VMO
! remove all domos except one at p
!print *,"type -> DOMO -> VMO"
mask = IBSET(0_8,p) - 1
pmodel = POPCNT(mask) - POPCNT(AND(Jsomo,mask)) - n_core_orb + 1
mask = IBSET(0_8,q) - 1
qmodel = POPCNT(mask) - POPCNT(AND(Jsomo,mask)) - n_core_orb + 1
case (3)
! SOMO -> VMO
!print *,"type -> SOMO -> VMO"
Isomo = IEOR(Isomo,Jsomo)
mask = IBSET(0_8,p) - 1
pmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1
mask = IBSET(0_8,q) - 1
qmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1
case (4)
! DOMO -> SOMO
! remove all domos except one at p
!print *,"type -> DOMO -> SOMO"
Isomo = IEOR(Isomo,Jsomo)
mask = IBSET(0_8,p) - 1
pmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1
mask = IBSET(0_8,q) - 1
qmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1
case default
print *,"something is wrong in convertOrbIdsToModelSpaceIds"
end select
!print *,p,q,"model ids=",pmodel,qmodel
end subroutine convertOrbIdsToModelSpaceIds

View File

@ -198,6 +198,7 @@ the input determinant \(|D_I\rangle\).
p = listholes(i) p = listholes(i)
do j = 1, nvmos do j = 1, nvmos
q = listvmos(j) q = listvmos(j)
if(p .EQ. q) cycle
if(tableUniqueAlphas(p,q)) then if(tableUniqueAlphas(p,q)) then
if(holetype(i) .EQ. 1 .AND. vmotype(j) .EQ. 1) then if(holetype(i) .EQ. 1 .AND. vmotype(j) .EQ. 1) then
! SOMO -> VMO ! SOMO -> VMO
@ -225,7 +226,7 @@ the input determinant \(|D_I\rangle\).
endif endif
NalphaIcfg += 1 NalphaIcfg += 1
!print *,p,q,"|",holetype(i),vmotype(j) !print *,p,q,"|",holetype(i),vmotype(j),NalphaIcfg
!call debug_spindet(Jsomo,1) !call debug_spindet(Jsomo,1)
!call debug_spindet(Jdomo,1) !call debug_spindet(Jdomo,1)
alphasIcfg(1,1,NalphaIcfg) = Jsomo alphasIcfg(1,1,NalphaIcfg) = Jsomo
@ -274,61 +275,77 @@ subroutine obtain_connected_I_foralpha(Ialpha, connectedI, nconnectedI, excitati
integer*8 :: diffDOMO integer*8 :: diffDOMO
integer :: ndiffSOMO integer :: ndiffSOMO
integer :: ndiffDOMO integer :: ndiffDOMO
integer :: i,j,k,l,p,q,nsomoI,nsomoalpha integer :: i,j,k,l,p,q,nsomoJ,nsomoalpha
nconnectedI = 0 nconnectedI = 0
p = 0 p = 0
q = 0 q = 0
do i=1,N_configuration
Isomo = Ialpha(1,1) Isomo = Ialpha(1,1)
Idomo = Ialpha(1,2) Idomo = Ialpha(1,2)
do i=1,N_configuration Jsomo = psi_configuration(1,1,i)
diffSOMO = IEOR(Isomo,psi_configuration(1,1,i)) Jdomo = psi_configuration(1,2,i)
diffDOMO = IEOR(Idomo,psi_configuration(1,2,i)) !call debug_spindet(Isomo,1)
!call debug_spindet(Idomo,1)
!print *,"-J--i=",i,Jsomo,Isomo
!call debug_spindet(Jsomo,1)
!call debug_spindet(Jdomo,1)
diffSOMO = IEOR(Isomo,Jsomo)
diffDOMO = IEOR(Idomo,Jdomo)
ndiffSOMO = POPCNT(diffSOMO) ndiffSOMO = POPCNT(diffSOMO)
ndiffDOMO = POPCNT(diffDOMO) ndiffDOMO = POPCNT(diffDOMO)
if((ndiffSOMO + ndiffDOMO) .EQ. 0) cycle
!print *,"-I--i=",i,Isomo,Jsomo,ndiffSOMO,ndiffDOMO
if(POPCNT(IEOR(diffSOMO,diffDOMO)) .LE. 1 .AND. ndiffDOMO .LT. 3) then if(POPCNT(IEOR(diffSOMO,diffDOMO)) .LE. 1 .AND. ndiffDOMO .LT. 3) then
nconnectedI += 1 nconnectedI += 1
connectedI(:,:,nconnectedI) = psi_configuration(:,:,i) connectedI(:,:,nconnectedI) = psi_configuration(:,:,i)
select case(ndiffDOMO) select case(ndiffDOMO)
case (0) case (0)
! SOMO -> VMO ! SOMO -> VMO
!print *,"obt SOMO -> VMO"
excitationTypes(nconnectedI) = 3 excitationTypes(nconnectedI) = 3
Jsomo = IEOR(Isomo, psi_configuration(1,1,i)) Jsomo = IEOR(Isomo, Jsomo)
p = TRAILZ(iand(Jsomo,Isomo)) p = TRAILZ(Jsomo) + 1
q = TRAILZ(iand(Jsomo,psi_configuration(1,1,i))) Jsomo = IBCLR(Jsomo,p-1)
q = TRAILZ(Jsomo) + 1
case (1) case (1)
! DOMO -> VMO ! DOMO -> VMO
! or ! or
! SOMO -> SOMO ! SOMO -> SOMO
nsomoI = POPCNT(psi_configuration(1,1,i)) nsomoJ = POPCNT(Jsomo)
nsomoalpha = POPCNT(Isomo) nsomoalpha = POPCNT(Isomo)
if(nsomoI .GT. nsomoalpha) then if(nsomoJ .GT. nsomoalpha) then
! DOMO -> VMO ! DOMO -> VMO
!print *,"obt DOMO -> VMO"
excitationTypes(nconnectedI) = 2 excitationTypes(nconnectedI) = 2
Jdomo = IEOR(Idomo, psi_configuration(1,2,i)) Isomo = IOR(IEOR(Isomo, Jsomo),IEOR(Idomo,Jdomo))
Jsomo = IEOR(Jdomo,IEOR(Isomo, psi_configuration(1,1,i))) p = TRAILZ(Isomo) + 1
p = TRAILZ(Jdomo) Isomo = IBCLR(Isomo,p-1)
q = TRAILZ(Jsomo) q = TRAILZ(Isomo) + 1
else else
! SOMO -> SOMO ! SOMO -> SOMO
!print *,"obt SOMO -> SOMO"
excitationTypes(nconnectedI) = 1 excitationTypes(nconnectedI) = 1
Jdomo = IEOR(Idomo, psi_configuration(1,2,i)) Isomo = IOR(IEOR(Isomo, Jsomo),IEOR(Idomo,Jdomo))
Jsomo = IEOR(Jdomo,IEOR(Isomo, psi_configuration(1,1,i))) p = TRAILZ(Isomo) + 1
q = TRAILZ(Jdomo) Isomo = IBCLR(Isomo,p-1)
p = TRAILZ(Jsomo) q = TRAILZ(Isomo) + 1
end if end if
case (2) case (2)
! DOMO -> SOMO ! DOMO -> SOMO
!print *,"obt DOMO -> SOMO"
excitationTypes(nconnectedI) = 4 excitationTypes(nconnectedI) = 4
Jdomo = IEOR(Idomo, psi_configuration(1,2,i)) Isomo = IEOR(Isomo, Jsomo)
p = TRAILZ(iand(Jdomo,Idomo)) p = TRAILZ(Isomo) + 1
q = TRAILZ(iand(Jdomo,psi_configuration(1,2,i))) Isomo = IBCLR(Isomo,p-1)
q = TRAILZ(Isomo) + 1
case default case default
print *,"something went wront in get connectedI" print *,"something went wront in get connectedI"
end select end select
excitationIds(1,nconnectedI)=p excitationIds(1,nconnectedI)=p
excitationIds(2,nconnectedI)=q excitationIds(2,nconnectedI)=q
!print *,"------ > output p,q in obt=",p,q
endif endif
end do end do
@ -336,6 +353,18 @@ subroutine obtain_connected_I_foralpha(Ialpha, connectedI, nconnectedI, excitati
end subroutine obtain_connected_I_foralpha end subroutine obtain_connected_I_foralpha
#+end_src #+end_src
#+begin_src fortran
print *,TRAILZ(9)
print *,IBCLR(8,TRAILZ(9))
print *,TRAILZ(IBCLR(8,TRAILZ(9)))
#+end_src
#+RESULTS:
| 0 |
| 8 |
| 3 |
** Function to get the NSOMOs (seniority) ** Function to get the NSOMOs (seniority)
#+begin_src f90 :main no :tangle configuration_CI_sigma_helpers.irp.f #+begin_src f90 :main no :tangle configuration_CI_sigma_helpers.irp.f
@ -350,3 +379,120 @@ end subroutine obtain_connected_I_foralpha
enddo enddo
end function getNSOMO end function getNSOMO
#+end_src #+end_src
** Function to convert p,q to model space ids
This function converts the real orbital ids \(i,j\) to model
space ids \(p,q\) which depend only on the number of somos.
#+begin_src f90 :main no :tangle configuration_CI_sigma_helpers.irp.f
subroutine convertOrbIdsToModelSpaceIds(Ialpha, Jcfg, p, q, extype, pmodel, qmodel)
implicit none
BEGIN_DOC
! This function converts the orbital ids
! in real space to those used in model space
! in order to identify the matrices required
! for the calculation of MEs.
!
! The type of excitations are ordered as follows:
! Type 1 - SOMO -> SOMO
! Type 2 - DOMO -> VMO
! Type 3 - SOMO -> VMO
! Type 4 - DOMO -> SOMO
END_DOC
integer(bit_kind),intent(in) :: Ialpha(N_int,2)
integer(bit_kind),intent(in) :: Jcfg(N_int,2)
integer,intent(in) :: p,q
integer,intent(in) :: extype
integer,intent(out) :: pmodel,qmodel
integer*8 :: Isomo
integer*8 :: Idomo
integer*8 :: Jsomo
integer*8 :: Jdomo
integer*8 :: mask
integer :: pos0,pos0prev
Isomo = Ialpha(1,1)
Idomo = Ialpha(1,2)
Jsomo = Jcfg(1,1)
Jdomo = Jcfg(1,2)
pos0prev = 0
pmodel = p
qmodel = q
!print *,"input pq=",p,q
select case(extype)
case (1)
! SOMO -> SOMO
! remove all domos
!print *,"type -> SOMO -> SOMO"
mask = IBSET(0_8,p) - 1
pmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1
mask = IBSET(0_8,q) - 1
qmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1
case (2)
! DOMO -> VMO
! remove all domos except one at p
!print *,"type -> DOMO -> VMO"
mask = IBSET(0_8,p) - 1
pmodel = POPCNT(mask) - POPCNT(AND(Jsomo,mask)) - n_core_orb + 1
mask = IBSET(0_8,q) - 1
qmodel = POPCNT(mask) - POPCNT(AND(Jsomo,mask)) - n_core_orb + 1
case (3)
! SOMO -> VMO
!print *,"type -> SOMO -> VMO"
Isomo = IEOR(Isomo,Jsomo)
mask = IBSET(0_8,p) - 1
pmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1
mask = IBSET(0_8,q) - 1
qmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1
case (4)
! DOMO -> SOMO
! remove all domos except one at p
!print *,"type -> DOMO -> SOMO"
Isomo = IEOR(Isomo,Jsomo)
mask = IBSET(0_8,p) - 1
pmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1
mask = IBSET(0_8,q) - 1
qmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1
case default
print *,"something is wrong in convertOrbIdsToModelSpaceIds"
end select
!print *,p,q,"model ids=",pmodel,qmodel
end subroutine convertOrbIdsToModelSpaceIds
#+end_src
#+begin_src fortran
integer :: i
integer :: count
count = 0
i = 8-1
do while(i.GT.0 .AND. count .LT.10)
print *,i,TRAILZ(i),IBCLR(i,TRAILZ(i))
i = IBCLR(i,TRAILZ(i)-1)
count = count + 1
end do
#+end_src
#+RESULTS:
| 7 | 0 | 6 |
| 7 | 0 | 6 |
| 7 | 0 | 6 |
| 7 | 0 | 6 |
| 7 | 0 | 6 |
| 7 | 0 | 6 |
| 7 | 0 | 6 |
| 7 | 0 | 6 |
| 7 | 0 | 6 |
| 7 | 0 | 6 |
#+begin_src fortran
print *,IBSET(0_8,4)-1
print *,POPCNT(IBSET(0_8,4)-1) - POPCNT(AND(716,IBSET(0_8,4)-1))
print *,POPCNT(IBSET(0_8,8)-1) - POPCNT(AND(716,IBSET(0_8,8)-1))
#+end_src
#+RESULTS:
| 15 |
| 2 |
| 4 |