init_overlap_buffers Subroutine

public subroutine init_overlap_buffers()

Arguments

None

Contents

Source Code


Source Code

    subroutine init_overlap_buffers
        use CalcData, only: tSemiStochastic, ss_space_in
        use semi_stoch_gen, only: init_semi_stochastic
        use real_time_procs, only: reset_tot_parts
        implicit none
        ! this subroutine sets up everything required to compute green's functions
        integer :: ierr, j, i
        complex(dp), allocatable :: norm_buf(:)
        logical :: tStartedFromCoreGround

        normsize = inum_runs**2
        allocate(overlap_real(gf_count), overlap_imag(gf_count))
        allocate(gf_overlap(normsize, gf_count), stat=ierr)
        allocate(pert_norm(normsize, gf_count), stat=ierr)
        allocate(dyn_norm_psi(normsize), stat=ierr)
        dyn_norm_psi = 1.0_dp
        allocate(dyn_norm_red(normsize, gf_count), stat=ierr)
        allocate(current_overlap(normsize, gf_count), stat=ierr)
        dyn_norm_red = 1.0_dp
        gf_overlap = 0.0_dp

        ! also need to create the perturbed ground state to calculate the
        ! overlaps to |y(t)>
        call create_perturbed_ground()

        if (tSemiStochastic) call init_semi_stochastic(ss_space_in, tStartedFromCoreGround)

        ! If only the corespace time-evolution is to be taken, truncate the
        ! initial wavefunction to the corespace
        ! We currently do not truncate the overlap state too, but it might come
        ! later
        if (tGZero) then
            call truncate_initial_state()
            call truncate_overlap_states()
            call reset_tot_parts()
            TotWalkers = cs_replicas(core_run)%determ_sizes(iProcIndex)
        end if

        ! if a ground-state POPSFILE is used, we need to ensure coherence between the replicas
        if (.not. tRealTimePopsfile) call equalize_initial_phase()

        allocate(norm_buf(normsize), stat=ierr)
        ! to avoid dividing by 0 if not all entries get filled
        pert_norm = 1.0_dp
        norm_buf = calc_norm(CurrentDets, int(TotWalkers))
        call MPIReduce(norm_buf, MPI_SUM, dyn_norm_psi)
        do j = 1, gf_count
            ! calc. the norm of the perturbed ground states
            norm_buf = calc_norm(overlap_states(j)%dets, overlap_states(j)%nDets)
            write(stdout, *) "Number of walkers / in overlap state", TotWalkers, overlap_states(j)%nDets
            ! the norm (squared) can be obtained by reduction over all processes
            call MPIReduce(norm_buf, MPI_SUM, pert_norm(:, j))
            ! for diagonal green's functions, this is the same as pert_norm, but
            ! in general, this general normalization is required.
            do i = 1, normsize
                dyn_norm_red(i, j) = sqrt(pert_norm(i, j) * dyn_norm_psi(i))
            end do
        end do

        deallocate(norm_buf)

        if (.not. allocated(shift_damping)) then
            allocate(shift_damping(inum_runs), stat=ierr)
            shift_damping = 0.0_dp
        end if

        if (tLogTrajectory) call openTauContourFile()

    end subroutine init_overlap_buffers