create_all_dets Function

public function create_all_dets(n_orbs, n_alpha, n_beta) result(all_dets)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n_orbs
integer, intent(in) :: n_alpha
integer, intent(in) :: n_beta

Return Value integer(kind=n_int), allocatable, (:)


Contents

Source Code


Source Code

    function create_all_dets(n_orbs, n_alpha, n_beta) result(all_dets)
        integer, intent(in) :: n_orbs, n_alpha, n_beta
        integer(n_int), allocatable :: all_dets(:)
        character(*), parameter :: this_routine = "create_all_dets"

        integer, allocatable :: n_dets(:)
        integer(n_int), allocatable :: alpha_basis(:), beta_basis(:)
        integer :: i, n_states, n_total, j

        n_dets = calc_n_double(n_orbs, n_alpha, n_beta)

        ! cannot deal with more than 32 orbitals yet.. since i am lazy!
        ASSERT(n_orbs <= 32)

        ! do it in a really simple way for now..
        ! just run over all the alpha and beta spin-bases and combine them
        ! to the full-basis

        alpha_basis = create_one_spin_basis(n_orbs, n_alpha)
        beta_basis = create_one_spin_basis(n_orbs, n_beta)

        ! keep an count on all the states
        n_states = 0

        ! and allocate the array, which keeps all the states
        n_total = sum(n_dets)

        allocate(all_dets(n_total))
        all_dets = 0_n_int

        ! check if everything went correctly:
        ASSERT(size(alpha_basis) * size(beta_basis) == n_total)

        do i = 1, size(alpha_basis)
            do j = 1, size(beta_basis)
                n_states = n_states + 1
                all_dets(n_states) = general_product(alpha_basis(i), beta_basis(j), n_orbs)
            end do
        end do

        call sort(all_dets)

        ASSERT(n_states == n_total)

    end function create_all_dets