create_rand_det_no_sym Subroutine

public subroutine create_rand_det_no_sym(ilut)

Arguments

Type IntentOptional Attributes Name
integer(kind=n_int), intent(out) :: ilut(0:NIfTot)

Contents


Source Code

    subroutine create_rand_det_no_sym(ilut)

        ! Create a determinant with no symmetry imposed whatsoever, apart from using nel electrons.
        ! This routine simply picks nel orbitals uniformly and returns a determinant with these occupied.

        use bit_rep_data, only: NIfTot
        USE dSFMT_interface, only: genrand_real2_dSFMT
        use SystemData, only: nbasis, nel

        integer(n_int), intent(out) :: ilut(0:NIfTot)
        integer :: i, n_occ, orb_ind, elem
        real(dp) :: r

        ! Start from all orbitals unoccupied.
        ilut = 0_n_int
        n_occ = 0

        do
            r = genrand_real2_dSFMT()
            orb_ind = int(r * nbasis) + 1
            elem = (orb_ind - 1) / bits_n_int
            ! If this orbital has already been occupied then choose another.
            if (btest(ilut(elem), mod(orb_ind - 1, bits_n_int))) cycle
            ! Occupy the orbital.
            ilut(elem) = ibset(ilut(elem), mod(orb_ind - 1, bits_n_int))
            n_occ = n_occ + 1
            if (n_occ == nel) exit
        end do

    end subroutine create_rand_det_no_sym