fill_frequency_histogram Subroutine

public subroutine fill_frequency_histogram(mat_ele, pgen)


Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: mat_ele
real(kind=dp), intent(in) :: pgen


Source Code

    subroutine fill_frequency_histogram(mat_ele, pgen)
        ! routine to accumulate the H_ij/pgen ration into the frequency bins
        ! keep parallelism in mind, especially if we have to adjust the
        ! bin list and boundary list on the fly.. this has to happen on
        ! all the processors then or? or can i just do it in the end of a loop
        ! adapt this function now, to discriminate between single and double
        ! excitations, and it pParallel is used, which can be determined
        ! through the excitation matrix and the 2 involved determinants
        ! (or even the starting determinant) and fill up to 3 frequency
        ! histograms .. this also means that we have to reset them maybe
        ! after pSingles or pParallel have been changed since the pgens
        ! and so the H_ij/pgen ratios change (or? can i modify that somehow
        ! on the fly?) think about that later and with ali..
        ! and for the guga stuff, if i finally implement similar pgens like
        ! pParallel, as it is already done in the nosym_guga case, i have
        ! to use even more histograms, but that should be fine.
        real(dp), intent(in) :: mat_ele, pgen
        character(*), parameter :: this_routine = "fill_frequency_histogram"
        integer, parameter :: cnt_threshold = 50

        real(dp) :: ratio
        integer :: ind
        ! first have to take correct matrix element, dependent if we use
        ! complex code or not, or no: for now just input the absolute value
        ! of H_ij, so its always a real then..
        ! nah.. it puts in 0 mat_eles too.. so just return if 0 mat_ele
        ASSERT(pgen > EPS)

        ! if the matrix element is 0, no excitation will or would be done
        ! and if the pgen is 0 i also shouldnt be here i guess.. so assert that
        if (mat_ele < matele_cutoff) then

            ! misuse doubles for the counting here
            zero_doubles = zero_doubles + 1

        end if

        if (pgen < EPS) return

        ! then i have to first check if i have to make the histogram bigger...
        ratio = mat_ele / pgen

        if (ratio < max_frequency_bound) then
            ! the ratio fits in to the bins now i just have to find the
            ! correct one
            if (.not. enough_doub_hist) then
                cnt_doub_hist = cnt_doub_hist + 1
                if (cnt_doub_hist > cnt_threshold) enough_doub_hist = .true.
            end if

            ind = int(ratio / frq_step_size) + 1

            ! increase counter
            frequency_bins(ind) = frequency_bins(ind) + 1

            above_max_doubles = above_max_doubles + 1
        end if

        if (ratio > gamma_doub) gamma_doub = ratio
        if (ratio < min_doub) min_doub = ratio

    end subroutine fill_frequency_histogram