TestifDETinCAS Function

public function TestifDETinCAS(CASDet)


Type IntentOptional Attributes Name
integer :: CASDet(NEl)

Return Value logical


Source Code

Source Code

        INTEGER :: k, z, CASDet(NEl), orb
        LOGICAL :: tElecInVirt

        ! CASmax is the max spin orbital number (when ordered energetically)
        ! within the chosen active space. Spin orbitals with energies larger
        ! than this maximum value must be unoccupied for the determinant to
        ! be in the active space.
!        CASmax=NEl+VirtCASorbs

        ! CASmin is the max spin orbital number below the active space.  As
        ! well as the above criteria, spin orbitals with energies equal to,
        ! or below that of the CASmin orbital must be completely occupied for
        ! the determinant to be in the active space.
        ! (These have been moved to the InitCalc subroutine so they're not
        !  calculated each time).
!        CASmin=NEl-OccCASorbs

        z = 0
        tElecInVirt = .false.
        do k = 1, NEl      ! running over all electrons
            orb = CASDet(k)

            if (SpinInvBRR(orb) > CASmax) THEN
                tElecInVirt = .true.
                ! if at any stage an electron has an energy greater than the
                ! CASmax value, the determinant can be ruled out of the active
                ! space.  Upon identifying this, it is not necessary to check
                ! the remaining electrons.
                if (SpinInvBRR(orb) <= CASmin) THEN
                    z = z + 1
                end if
                ! while running over all electrons, the number that occupy
                ! orbitals equal to or below the CASmin cutoff are counted.
            end if
        end do

        if (tElecInVirt .or. (z /= CASmin)) THEN
            ! if an electron is in an orbital above the active space, or the
            ! inactive orbitals are not full, the determinant is automatically
            ! ruled out.
            TestifDETinCAS = .false.
            ! no orbital in virtual and the inactive orbitals are completely
            ! full - det in active space.
            TestifDETinCAS = .true.
        end if