10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-23 12:55:37 +01:00

Fixed bugs in model space id conversion. #143.

This commit is contained in:
v1j4y 2021-02-05 09:06:54 +01:00
parent d1dbe58010
commit 1a17f44020
2 changed files with 115 additions and 86 deletions

View File

@ -247,6 +247,7 @@ subroutine obtain_connected_I_foralpha(idxI, Ialpha, connectedI, nconnectedI, ex
integer*8 :: Isomo integer*8 :: Isomo
integer*8 :: Jdomo integer*8 :: Jdomo
integer*8 :: Jsomo integer*8 :: Jsomo
integer*8 :: IJsomo
integer*8 :: diffSOMO integer*8 :: diffSOMO
integer*8 :: diffDOMO integer*8 :: diffDOMO
integer :: ndiffSOMO integer :: ndiffSOMO
@ -281,10 +282,10 @@ subroutine obtain_connected_I_foralpha(idxI, Ialpha, connectedI, nconnectedI, ex
! SOMO -> VMO ! SOMO -> VMO
!print *,"obt SOMO -> VMO" !print *,"obt SOMO -> VMO"
excitationTypes(nconnectedI) = 3 excitationTypes(nconnectedI) = 3
Jsomo = IEOR(Isomo, Jsomo) IJsomo = IEOR(Isomo, Jsomo)
p = TRAILZ(Jsomo) + 1 p = TRAILZ(AND(Isomo,IJsomo)) + 1
Jsomo = IBCLR(Jsomo,p-1) IJsomo = IBCLR(IJsomo,p-1)
q = TRAILZ(Jsomo) + 1 q = TRAILZ(IJsomo) + 1
case (1) case (1)
! DOMO -> VMO ! DOMO -> VMO
! or ! or
@ -295,33 +296,33 @@ subroutine obtain_connected_I_foralpha(idxI, Ialpha, connectedI, nconnectedI, ex
! DOMO -> VMO ! DOMO -> VMO
!print *,"obt DOMO -> VMO" !print *,"obt DOMO -> VMO"
excitationTypes(nconnectedI) = 2 excitationTypes(nconnectedI) = 2
Isomo = IOR(IEOR(Isomo, Jsomo),IEOR(Idomo,Jdomo)) p = TRAILZ(IEOR(Idomo,Jdomo)) + 1
p = TRAILZ(Isomo) + 1 Isomo = IEOR(Isomo, Jsomo)
Isomo = IBCLR(Isomo,p-1) Isomo = IBCLR(Isomo,p-1)
q = TRAILZ(Isomo) + 1 q = TRAILZ(Isomo) + 1
else else
! SOMO -> SOMO ! SOMO -> SOMO
!print *,"obt SOMO -> SOMO" !print *,"obt SOMO -> SOMO"
excitationTypes(nconnectedI) = 1 excitationTypes(nconnectedI) = 1
Isomo = IOR(IEOR(Isomo, Jsomo),IEOR(Idomo,Jdomo)) q = TRAILZ(IEOR(Idomo,Jdomo)) + 1
Isomo = IEOR(Isomo, Jsomo)
Isomo = IBCLR(Isomo,q-1)
p = TRAILZ(Isomo) + 1 p = TRAILZ(Isomo) + 1
Isomo = IBCLR(Isomo,p-1)
q = TRAILZ(Isomo) + 1
end if end if
case (2) case (2)
! DOMO -> SOMO ! DOMO -> SOMO
!print *,"obt DOMO -> SOMO" !print *,"obt DOMO -> SOMO"
excitationTypes(nconnectedI) = 4 excitationTypes(nconnectedI) = 4
Isomo = IEOR(Isomo, Jsomo) IJsomo = IEOR(Isomo, Jsomo)
p = TRAILZ(Isomo) + 1 p = TRAILZ(AND(Jsomo,IJsomo)) + 1
Isomo = IBCLR(Isomo,p-1) IJsomo = IBCLR(IJsomo,p-1)
q = TRAILZ(Isomo) + 1 q = TRAILZ(IJsomo) + 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 print *,"------ > output p,q in obt=",p,q
endif endif
end do end do
@ -363,6 +364,8 @@ subroutine convertOrbIdsToModelSpaceIds(Ialpha, Jcfg, p, q, extype, pmodel, qmod
integer*8 :: Jsomo integer*8 :: Jsomo
integer*8 :: Jdomo integer*8 :: Jdomo
integer*8 :: mask integer*8 :: mask
integer*8 :: Isomotmp
integer*8 :: Jsomotmp
integer :: pos0,pos0prev integer :: pos0,pos0prev
! TODO Flag (print) when model space indices is > 64 ! TODO Flag (print) when model space indices is > 64
@ -373,43 +376,55 @@ subroutine convertOrbIdsToModelSpaceIds(Ialpha, Jcfg, p, q, extype, pmodel, qmod
pos0prev = 0 pos0prev = 0
pmodel = p pmodel = p
qmodel = q qmodel = q
!print *,"input pq=",p,q print *,"input pq=",p,q,"extype=",extype
!call debug_spindet(Isomo,1)
!call debug_spindet(Idomo,1)
!call debug_spindet(Jsomo,1)
!call debug_spindet(Jdomo,1)
select case(extype) select case(extype)
case (1) case (1)
! SOMO -> SOMO ! SOMO -> SOMO
! remove all domos ! remove all domos
!print *,"type -> SOMO -> SOMO" !print *,"type -> SOMO -> SOMO"
mask = IBSET(0_8,p) - 1 mask = ISHFT(1_8,p) - 1
pmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1 Isomotmp = AND(Isomo,mask)
mask = IBSET(0_8,q) - 1 pmodel = POPCNT(mask) - POPCNT(XOR(Isomotmp,mask))
qmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1 mask = ISHFT(1_8,q) - 1
Isomotmp = AND(Isomo,mask)
qmodel = POPCNT(mask) - POPCNT(XOR(Isomotmp,mask))
case (2) case (2)
! DOMO -> VMO ! DOMO -> VMO
! remove all domos except one at p ! remove all domos except one at p
!print *,"type -> DOMO -> VMO" !print *,"type -> DOMO -> VMO"
mask = IBSET(0_8,p) - 1 mask = ISHFT(1_8,p) - 1
pmodel = POPCNT(mask) - POPCNT(AND(Jsomo,mask)) - n_core_orb + 1 Jsomotmp = AND(Jsomo,mask)
mask = IBSET(0_8,q) - 1 pmodel = POPCNT(mask) - POPCNT(XOR(Jsomotmp,mask))
qmodel = POPCNT(mask) - POPCNT(AND(Jsomo,mask)) - n_core_orb + 1 mask = ISHFT(1_8,q) - 1
Jsomotmp = AND(Jsomo,mask)
qmodel = POPCNT(mask) - POPCNT(XOR(Jsomotmp,mask))
case (3) case (3)
! SOMO -> VMO ! SOMO -> VMO
!print *,"type -> SOMO -> VMO" !print *,"type -> SOMO -> VMO"
Isomo = IEOR(Isomo,Jsomo) !Isomo = IEOR(Isomo,Jsomo)
mask = IBSET(0_8,p) - 1 mask = ISHFT(1_8,p) - 1
pmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1 Isomo = AND(Isomo,mask)
mask = IBSET(0_8,q) - 1 pmodel = POPCNT(mask) - POPCNT(XOR(Isomo,mask))
qmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1 mask = ISHFT(1_8,q) - 1
Jsomo = AND(Jsomo,mask)
qmodel = POPCNT(mask) - POPCNT(XOR(Jsomo,mask))
case (4) case (4)
! DOMO -> SOMO ! DOMO -> SOMO
! remove all domos except one at p ! remove all domos except one at p
!print *,"type -> DOMO -> SOMO" !print *,"type -> DOMO -> SOMO"
Isomo = IEOR(Isomo,Jsomo) !Isomo = IEOR(Isomo,Jsomo)
mask = IBSET(0_8,p) - 1 mask = ISHFT(1_8,p) - 1
pmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1 Jsomo = AND(Jsomo,mask)
mask = IBSET(0_8,q) - 1 pmodel = POPCNT(mask) - POPCNT(XOR(Jsomo,mask))
qmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1 mask = ISHFT(1_8,q) - 1
Isomo = AND(Isomo,mask)
qmodel = POPCNT(mask) - POPCNT(XOR(Isomo,mask))
case default case default
print *,"something is wrong in convertOrbIdsToModelSpaceIds" print *,"something is wrong in convertOrbIdsToModelSpaceIds"
end select end select
!print *,p,q,"model ids=",pmodel,qmodel print *,p,q,"model ids=",pmodel,qmodel
end subroutine convertOrbIdsToModelSpaceIds end subroutine convertOrbIdsToModelSpaceIds

View File

@ -272,6 +272,7 @@ subroutine obtain_connected_I_foralpha(idxI, Ialpha, connectedI, nconnectedI, ex
integer*8 :: Isomo integer*8 :: Isomo
integer*8 :: Jdomo integer*8 :: Jdomo
integer*8 :: Jsomo integer*8 :: Jsomo
integer*8 :: IJsomo
integer*8 :: diffSOMO integer*8 :: diffSOMO
integer*8 :: diffDOMO integer*8 :: diffDOMO
integer :: ndiffSOMO integer :: ndiffSOMO
@ -306,10 +307,10 @@ subroutine obtain_connected_I_foralpha(idxI, Ialpha, connectedI, nconnectedI, ex
! SOMO -> VMO ! SOMO -> VMO
!print *,"obt SOMO -> VMO" !print *,"obt SOMO -> VMO"
excitationTypes(nconnectedI) = 3 excitationTypes(nconnectedI) = 3
Jsomo = IEOR(Isomo, Jsomo) IJsomo = IEOR(Isomo, Jsomo)
p = TRAILZ(Jsomo) + 1 p = TRAILZ(AND(Isomo,IJsomo)) + 1
Jsomo = IBCLR(Jsomo,p-1) IJsomo = IBCLR(IJsomo,p-1)
q = TRAILZ(Jsomo) + 1 q = TRAILZ(IJsomo) + 1
case (1) case (1)
! DOMO -> VMO ! DOMO -> VMO
! or ! or
@ -320,33 +321,33 @@ subroutine obtain_connected_I_foralpha(idxI, Ialpha, connectedI, nconnectedI, ex
! DOMO -> VMO ! DOMO -> VMO
!print *,"obt DOMO -> VMO" !print *,"obt DOMO -> VMO"
excitationTypes(nconnectedI) = 2 excitationTypes(nconnectedI) = 2
Isomo = IOR(IEOR(Isomo, Jsomo),IEOR(Idomo,Jdomo)) p = TRAILZ(IEOR(Idomo,Jdomo)) + 1
p = TRAILZ(Isomo) + 1 Isomo = IEOR(Isomo, Jsomo)
Isomo = IBCLR(Isomo,p-1) Isomo = IBCLR(Isomo,p-1)
q = TRAILZ(Isomo) + 1 q = TRAILZ(Isomo) + 1
else else
! SOMO -> SOMO ! SOMO -> SOMO
!print *,"obt SOMO -> SOMO" !print *,"obt SOMO -> SOMO"
excitationTypes(nconnectedI) = 1 excitationTypes(nconnectedI) = 1
Isomo = IOR(IEOR(Isomo, Jsomo),IEOR(Idomo,Jdomo)) q = TRAILZ(IEOR(Idomo,Jdomo)) + 1
Isomo = IEOR(Isomo, Jsomo)
Isomo = IBCLR(Isomo,q-1)
p = TRAILZ(Isomo) + 1 p = TRAILZ(Isomo) + 1
Isomo = IBCLR(Isomo,p-1)
q = TRAILZ(Isomo) + 1
end if end if
case (2) case (2)
! DOMO -> SOMO ! DOMO -> SOMO
!print *,"obt DOMO -> SOMO" !print *,"obt DOMO -> SOMO"
excitationTypes(nconnectedI) = 4 excitationTypes(nconnectedI) = 4
Isomo = IEOR(Isomo, Jsomo) IJsomo = IEOR(Isomo, Jsomo)
p = TRAILZ(Isomo) + 1 p = TRAILZ(AND(Jsomo,IJsomo)) + 1
Isomo = IBCLR(Isomo,p-1) IJsomo = IBCLR(IJsomo,p-1)
q = TRAILZ(Isomo) + 1 q = TRAILZ(IJsomo) + 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 print *,"------ > output p,q in obt=",p,q
endif endif
end do end do
@ -355,14 +356,14 @@ end subroutine obtain_connected_I_foralpha
#+end_src #+end_src
#+begin_src fortran #+begin_src fortran
print *,TRAILZ(9) print *,TRAILZ(8)
print *,IBCLR(8,TRAILZ(9)) print *,IBCLR(8,TRAILZ(9))
print *,TRAILZ(IBCLR(8,TRAILZ(9))) print *,TRAILZ(IBCLR(8,TRAILZ(9)))
#+end_src #+end_src
#+RESULTS: #+RESULTS:
| 0 | | 3 |
| 8 | | 8 |
| 3 | | 3 |
@ -411,6 +412,8 @@ subroutine convertOrbIdsToModelSpaceIds(Ialpha, Jcfg, p, q, extype, pmodel, qmod
integer*8 :: Jsomo integer*8 :: Jsomo
integer*8 :: Jdomo integer*8 :: Jdomo
integer*8 :: mask integer*8 :: mask
integer*8 :: Isomotmp
integer*8 :: Jsomotmp
integer :: pos0,pos0prev integer :: pos0,pos0prev
! TODO Flag (print) when model space indices is > 64 ! TODO Flag (print) when model space indices is > 64
@ -421,72 +424,83 @@ subroutine convertOrbIdsToModelSpaceIds(Ialpha, Jcfg, p, q, extype, pmodel, qmod
pos0prev = 0 pos0prev = 0
pmodel = p pmodel = p
qmodel = q qmodel = q
!print *,"input pq=",p,q print *,"input pq=",p,q,"extype=",extype
!call debug_spindet(Isomo,1)
!call debug_spindet(Idomo,1)
!call debug_spindet(Jsomo,1)
!call debug_spindet(Jdomo,1)
select case(extype) select case(extype)
case (1) case (1)
! SOMO -> SOMO ! SOMO -> SOMO
! remove all domos ! remove all domos
!print *,"type -> SOMO -> SOMO" !print *,"type -> SOMO -> SOMO"
mask = IBSET(0_8,p) - 1 mask = ISHFT(1_8,p) - 1
pmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1 Isomotmp = AND(Isomo,mask)
mask = IBSET(0_8,q) - 1 pmodel = POPCNT(mask) - POPCNT(XOR(Isomotmp,mask))
qmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1 mask = ISHFT(1_8,q) - 1
Isomotmp = AND(Isomo,mask)
qmodel = POPCNT(mask) - POPCNT(XOR(Isomotmp,mask))
case (2) case (2)
! DOMO -> VMO ! DOMO -> VMO
! remove all domos except one at p ! remove all domos except one at p
!print *,"type -> DOMO -> VMO" !print *,"type -> DOMO -> VMO"
mask = IBSET(0_8,p) - 1 mask = ISHFT(1_8,p) - 1
pmodel = POPCNT(mask) - POPCNT(AND(Jsomo,mask)) - n_core_orb + 1 Jsomotmp = AND(Jsomo,mask)
mask = IBSET(0_8,q) - 1 pmodel = POPCNT(mask) - POPCNT(XOR(Jsomotmp,mask))
qmodel = POPCNT(mask) - POPCNT(AND(Jsomo,mask)) - n_core_orb + 1 mask = ISHFT(1_8,q) - 1
Jsomotmp = AND(Jsomo,mask)
qmodel = POPCNT(mask) - POPCNT(XOR(Jsomotmp,mask))
case (3) case (3)
! SOMO -> VMO ! SOMO -> VMO
!print *,"type -> SOMO -> VMO" !print *,"type -> SOMO -> VMO"
Isomo = IEOR(Isomo,Jsomo) !Isomo = IEOR(Isomo,Jsomo)
mask = IBSET(0_8,p) - 1 mask = ISHFT(1_8,p) - 1
pmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1 Isomo = AND(Isomo,mask)
mask = IBSET(0_8,q) - 1 pmodel = POPCNT(mask) - POPCNT(XOR(Isomo,mask))
qmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1 mask = ISHFT(1_8,q) - 1
Jsomo = AND(Jsomo,mask)
qmodel = POPCNT(mask) - POPCNT(XOR(Jsomo,mask))
case (4) case (4)
! DOMO -> SOMO ! DOMO -> SOMO
! remove all domos except one at p ! remove all domos except one at p
!print *,"type -> DOMO -> SOMO" !print *,"type -> DOMO -> SOMO"
Isomo = IEOR(Isomo,Jsomo) !Isomo = IEOR(Isomo,Jsomo)
mask = IBSET(0_8,p) - 1 mask = ISHFT(1_8,p) - 1
pmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1 Jsomo = AND(Jsomo,mask)
mask = IBSET(0_8,q) - 1 pmodel = POPCNT(mask) - POPCNT(XOR(Jsomo,mask))
qmodel = POPCNT(mask) - POPCNT(AND(Isomo,mask)) - n_core_orb + 1 mask = ISHFT(1_8,q) - 1
Isomo = AND(Isomo,mask)
qmodel = POPCNT(mask) - POPCNT(XOR(Isomo,mask))
case default case default
print *,"something is wrong in convertOrbIdsToModelSpaceIds" print *,"something is wrong in convertOrbIdsToModelSpaceIds"
end select end select
!print *,p,q,"model ids=",pmodel,qmodel print *,p,q,"model ids=",pmodel,qmodel
end subroutine convertOrbIdsToModelSpaceIds end subroutine convertOrbIdsToModelSpaceIds
#+end_src #+end_src
#+begin_src fortran #+begin_src fortran
integer :: i integer :: i
integer :: count integer :: count
integer :: mask
integer :: isomo
count = 0 count = 0
i = 8-1 mask = ISHFT(1_8,5)-1
do while(i.GT.0 .AND. count .LT.10) print *,mask
print *,i,TRAILZ(i),IBCLR(i,TRAILZ(i)) print *,POPCNT(mask)
i = IBCLR(i,TRAILZ(i)-1) isomo = 144
count = count + 1 isomo = AND(isomo,mask)
end do print *,isomo
print *,XOR(isomo,mask)
print *,POPCNT(mask) - POPCNT(XOR(isomo,mask))
#+end_src #+end_src
#+RESULTS: #+RESULTS:
| 7 | 0 | 6 | | 31 |
| 7 | 0 | 6 | | 5 |
| 7 | 0 | 6 | | 16 |
| 7 | 0 | 6 | | 15 |
| 7 | 0 | 6 | | 1 |
| 7 | 0 | 6 |
| 7 | 0 | 6 |
| 7 | 0 | 6 |
| 7 | 0 | 6 |
| 7 | 0 | 6 |
#+begin_src fortran #+begin_src fortran
print *,IBSET(0_8,4)-1 print *,IBSET(0_8,4)-1