init_hist_tau_search Subroutine

public subroutine init_hist_tau_search()

Arguments

None

Contents

Source Code


Source Code

    subroutine init_hist_tau_search
        ! split the new and old tau-search routines up, to no mix up
        ! too much stuff
        character(*), parameter :: this_routine = "init_hist_tau_search"

        integer :: ierr

        if (.not. input_tau_search_method == possible_tau_search_methods%HISTOGRAMMING ) then
            write(stdout, '(A)') 'init_hist_tau_search called but &
                &HISTOGRAMMING was not given as tau-search method'
            call stop_all(this_routine, 'Inconsistent input')
        end if

        ! if no truncating spawns is chosen warn here againg that that might
        ! cause problems!
        if (.not. t_truncate_spawns) then
            write(stdout, '("WARNING: NO spawn truncation chosen with keyword: &
                &truncate-spawns [float] in input. this might cause &
                &bloom problems with histogramming tau-search! BE CAUTIOUS!")')
        end if

        if (tHub) then
            ! for the transcorrelated hamiltonian we need to re-enable the
            ! Histogramming tau-search!
            if (.not.(t_trans_corr .or. t_trans_corr_2body)) then
                call optimize_hubbard_time_step()
                return
            end if
        end if

        ! print out the standard quantities:
        root_print "Setup of the Histogramming tau-search: "
        root_print "  Integration cut-off: ", frq_ratio_cutoff
        root_print "  Number of bins: ", n_frequency_bins
        root_print "  Max. ratio: ", max_frequency_bound

        ! do the initialization of the frequency analysis here..
        ! i think otherwise it is not done on all the nodes..
        ! don't need to check if t_frequency_analysis here anymore
        ! determine the global and fixed step-size quantitiy!
        frq_step_size = max_frequency_bound / real(n_frequency_bins, dp)

        root_print "  Bin-width: ", frq_step_size

        ! and do the rest of the initialisation:

        ! Are we considering parallel-spin bias in the doubles?
        ! Do this logic here, so that if we add opposite spin bias to more
        ! excitation generators, then there is only one place that this logic
        ! needs to be updated!
        if (tGen_4ind_weighted .or. tGen_4ind_2) then
            consider_par_bias = .true.
        else if (tGen_4ind_reverse) then
            consider_par_bias = .true.
            n_opp = AB_hole_pairs
            n_par = par_hole_pairs
        else if (t_k_space_hubbard .and. t_trans_corr_2body) then
            ! for the 2-body transcorrelated k-space hubbard we also have
            ! possible parallel excitations now. and to make the tau-search
            ! working we need to set this to true ofc:
            consider_par_bias = .true.
        else if (t_fci_pchb_excitgen .and. .not. tGUGA) then
            ! The default pchb excitgen also uses parallel biases
            consider_par_bias = .true.
        else if (tGAS) then
            consider_par_bias = .true.
        else
            consider_par_bias = .false.
        end if

        ! If there are only a few electrons in the system, then this has
        ! impacts for the choices that can be made.
        if (nOccAlpha == 0 .or. nOccBeta == 0) then
            ! do i really need a histogramming tau-search in this case??
            ! come on..
            call stop_all(this_routine, &
                          "Do you really need a tau-search for such a small system?")
            consider_par_bias = .false.
            pParallel = 1.0_dp
        end if
        if (nOccAlpha == 1 .and. nOccBeta == 1) then
            consider_par_bias = .false.
            call stop_all(this_routine, &
                          "Do you really need a tau-search for such a small system?")
            pParallel = 0.0_dp
        end if

        if (t_mixed_hubbard .or. t_olle_hubbard) then
            pParallel = 0.0_dp
        end if

        t_consider_par_bias = consider_par_bias

        cnt_sing_hist = 0
        enough_sing_hist = .false.
        above_max_singles = 0
        below_thresh_singles = 0
        gamma_sing = 0.0_dp
        min_sing = huge(0.0_dp)
        zero_singles = 0

        cnt_doub_hist = 0
        enough_doub_hist = .false.
        above_max_doubles = 0
        below_thresh_doubles = 0
        zero_doubles = 0
        gamma_doub = 0.0_dp
        min_doub = huge(0.0_dp)

        ! triples data
        cnt_trip_hist = 0
        enough_trip_hist = .false.
        gamma_trip = 0.0_dp
        min_trip = huge(0.0_dp)
        above_max_triples = 0
        below_thresh_triples = 0

        ! dependent if we use pParallel or not init specific hists
        if (consider_par_bias) then

            cnt_par_hist = 0
            cnt_opp_hist = 0

            enough_par_hist = .false.
            enough_opp_hist = .false.

            above_max_para = 0
            below_thresh_para = 0
            above_max_anti = 0
            below_thresh_anti = 0

            zero_para = 0
            zero_anti = 0

            gamma_par = 0.0_dp
            gamma_opp = 0.0_dp
            min_opp = huge(0.0_dp)
            min_par = huge(0.0_dp)

            allocate(frequency_bins_anti(n_frequency_bins), &
                     frequency_bins_para(n_frequency_bins), &
                     frequency_bins_singles(n_frequency_bins), &
                     stat=ierr, source=0_int64)

            call LogMemAlloc('frequency_bins', n_frequency_bins * 3, int(sizeof(frequency_bins_anti(1))), &
                             this_routine, mem_tag_histograms, ierr)

        else if (tGen_sym_guga_mol .or. &
                 (tgen_guga_crude .and. .not. &
                  (t_new_real_space_hubbard .or. t_k_space_hubbard))) then

            ! i always use the singles histogram dont I? i think so..
            allocate(frequency_bins_singles(n_frequency_bins), &
                     frequency_bins_doubles(n_frequency_bins), source=0_int64)

        else
            ! just to be save also use my new flags..
            if (tHub .or. tUEG .or. &
                (t_k_space_hubbard .and. .not. t_trans_corr_2body) .or. &
                (t_new_real_space_hubbard .and. .not. t_trans_corr_hop)) then
                ! only one histogram is used!
                allocate(frequency_bins(n_frequency_bins), stat=ierr, source=0_int64)

                call LogMemAlloc('frequency_bins', n_frequency_bins, int(sizeof(frequency_bins(1))), &
                                 this_routine, mem_tag_histograms, ierr)

            else

                ! i always use the singles histogram dont I? i think so..
                allocate(frequency_bins_singles(n_frequency_bins), &
                         frequency_bins_doubles(n_frequency_bins), source=0_int64, stat=ierr)
                call LogMemAlloc('frequency_bins', n_frequency_bins * 2, int(sizeof(frequency_bins(1))), &
                                 this_routine, mem_tag_histograms, ierr)
            end if
        end if

        if (t_mol_3_body) then
            ! when doing integral-based triples, we are here
            allocate(frequency_bins_triples(n_frequency_bins), source=0_int64)
        end if

        if (t_log_ija) then
            ! allocate the new bins (although i am not sure i should do this
            ! here..
            ! change the logging of these functions to sepereate between the
            ! different sorts of excitations and log them through spatial orbitals!
            allocate(ija_bins_sing(nBasis / 2), &
                    ija_bins_para(nBasis / 2, nBasis / 2, nBasis / 2), &
                    ija_bins_anti(nBasis / 2, nBasis / 2, nBasis / 2), &
                    ija_orbs_sing(nBasis / 2), &
                    ija_orbs_para(nBasis / 2, nBasis / 2, nBasis / 2), &
                    ija_orbs_anti(nBasis / 2, nBasis / 2, nBasis / 2), &
                source=0)

            root_print "Logging dead-end (a|ij) excitations below threshold: ", ija_thresh

        end if
    end subroutine init_hist_tau_search