subroutine GenExcitations4_non_initd(session, nI, nJ, tParity, tAllExcitFound, ti_lt_a_only)
! this is the variant for use in the case that session has not been initialised
implicit none
type(ExcitGenSessionType), intent(inout) :: session
integer, intent(in) :: nI(nEl)
integer, intent(out) :: nJ(nEl)
logical, intent(out) :: tParity, tAllExcitFound
logical, intent(in) :: ti_lt_a_only
logical :: tReachedLimit
integer :: elecPosIdentifier, holePosIdentifier
integer :: i, spinDiff
integer :: minRankDefault, maxRankDefault, minSpinDiffDefault, maxSpinDiffDefault
! this is defined in symrandexcit2.F90, but it is external to the
! main module defined therein
tAllExcitFound = .false.
if (.not. session%tInitialised) then
minRankDefault = 1
maxRankDefault = 2
minSpinDiffDefault = 0
if (tReltvy) then
maxSpinDiffDefault = 2
else
maxSpinDiffDefault = 2
end if
session = InitExcitGenSession(nI, minRankDefault, maxRankDefault, minSpinDiffDefault, maxSpinDiffDefault)
end if
do while (.true.)
! exit loop when we find a legal excitation
if (session%elecIndices(1) == 0) then
! new session
! hole indices get reset in the following call:
call GoToNextElecIndices(session, tReachedLimit)
else
call GoToNextHoleIndices(session, tReachedLimit)
if (tReachedLimit) then
! reached the end of the combinations of unocc spin orbs
call GoToNextElecIndices(session, tReachedLimit)
if (tReachedLimit) then
! reached the end of the combinations of occ spin orbs
call GoToNextRank(session, tReachedLimit)
if (tReachedLimit) then
! exhausted all excitation classes
tAllExcitFound = .true.
exit
end if
end if
end if
end if
if (ti_lt_a_only) then
elecPosIdentifier = getElecPosIdentifier(session)
holePosIdentifier = getHolePosIdentifier(session)
if (elecPosIdentifier >= holePosIdentifier) then
cycle
end if
end if
! first, dereference the indices
call setSpinOrbs(session)
! we now have a new set of session%rank electron-hole pairs
! to return an nJ, the selection must satisfy the following criteria
! 1. total spin difference between occupied and unoccupied spin orbs must
! lie within the bounds specified in the initialisation of the session
! 2. point group spatial symmetry must be conserved
! 3. mL must be conserved
! 4. k-point symmetry must be conserved
! 1. spin difference
if (session%spinDiff > session%maxSpinDiff .or. session%spinDiff < session%minSpinDiff) then
cycle
end if
! 2. spatial symmetry
if (session%elecSymLabel - session%holeSymLabel /= 0) then
cycle
end if
! 3. mL number conservation
if (session%elecTotMl - session%holeTotMl /= 0) then
cycle
end if
! 4. k-point symmetry
! at this point we have to generate the target determinant
call FindNewDet(session, nJ, tParity)
if (tkPntSym) then
if (.not. IsMomAllowedDetAnyParent(nJ, session%nISym%Sym)) then
cycle
end if
end if
! if we made it this far, the selected electron hole pairs have
! passed all the selection criteria
return
end do
if (tAllExcitFound) then
! tidy up
call DestructSession(session)
end if
end subroutine GenExcitations4_non_initd