pick_uniform_spatial_hole Subroutine

public subroutine pick_uniform_spatial_hole(csf_i, src_orb, tgt_orb, pgen)

Arguments

Type IntentOptional Attributes Name
type(CSF_Info_t), intent(in) :: csf_i
integer, intent(in) :: src_orb
integer, intent(out) :: tgt_orb
real(kind=dp), intent(out) :: pgen

Contents


Source Code

    subroutine pick_uniform_spatial_hole(csf_i, src_orb, tgt_orb, pgen)
        type(CSF_Info_t), intent(in) :: csf_i
        integer, intent(in) :: src_orb
        integer, intent(out) :: tgt_orb
        real(dp), intent(out) :: pgen

        integer :: cc_i, nOrb, sym_index
        integer, allocatable :: sym_orbs(:), valid_orbs(:)
        ! get the symmetry index for this electron
        cc_i = ClassCountInd(1, SpinOrbSymLabel(2*src_orb), G1(2*src_orb)%ml)
        ! and the number of orbitals
        nOrb = OrbClassCount(cc_i)
        ! get the symmetry index for later use
        sym_index = SymLabelCounts2(1, cc_i)
        sym_orbs = sym_label_list_spat(sym_index : sym_index + nOrb - 1)
        ! now keep drawing from the symmetry orbitals until we pick an
        ! non-doubly occupied orbital that is not the source.
        valid_orbs = pack(sym_orbs, csf_i%stepvector(sym_orbs) /= 3 .and. sym_orbs /= src_orb)

        if (size(valid_orbs) == 0) then
            pgen = 0.0_dp
            tgt_orb = 0
        else
            tgt_orb = valid_orbs(1 + floor(genrand_real2_dSFMT() * size(valid_orbs)))
            pgen = 1.0_dp / real(size(valid_orbs), dp)
        end if
    end subroutine pick_uniform_spatial_hole