subroutine create_perturbed_ground()
! routine to create from the already read in popsfile info in
! popsfile_dets the left hand <y(0)| by applying the corresponding
! creation or annihilation operator
implicit none
character(*), parameter :: this_routine = "create_perturbed_ground"
integer :: tmp_totwalkers, totwalkers_backup, TotWalkers_orig_max
integer :: ierr, i, totNOccDets, iProc, nPertRefs
integer(n_int), allocatable :: perturbed_buf(:, :)
logical :: t_use_perturbed_buf
if (tReadPops .and. .not. tNewOverlap) then
tmp_totwalkers = int(TotWalkers_orig)
else
tmp_totwalkers = int(TotWalkers)
end if
write(stdout, *) "Creating the wavefunction to projected on!"
write(stdout, *) "Initial number of walkers: ", tmp_totwalkers
if (allocated(overlap_pert)) then
call MPISumAll(tmp_totwalkers, TotWalkers_orig_max)
else
TotWalkers_orig_max = MaxWalkersPart
end if
t_use_perturbed_buf = allocated(overlap_pert) .and. tNewOverlap
if (.not. allGfs == 0) call setup_pert_array(allGfs)
allocate(overlap_states(gf_count), stat=ierr)
if (t_use_perturbed_buf) &
allocate(perturbed_buf(0:niftot, TotWalkers_orig_max), stat=ierr)
write(stdout, *) "Read-in dets", TotWalkers_orig
do i = 1, gf_count
totwalkers_backup = tmp_totwalkers
if (t_use_perturbed_buf) then
if (.not. t_kspace_operators) then
if (tReadPops) then
! if the perturbation is to be created from the read-in population
! explicitly
perturbed_buf = 0_n_int
call apply_perturbation(overlap_pert(i), tmp_totwalkers, popsfile_dets, &
perturbed_buf)
! The HF-Overlap option makes us use a reference for projection
! instead of the full wavefunction
if (tHFOverlap) call create_perturbed_ref(perturbed_buf, TotWalkers_orig_max)
else
! else, perturb the current population (this is for starting from
! a defined determinant)
call apply_perturbation(overlap_pert(i), tmp_totwalkers, CurrentDets, &
perturbed_buf)
end if
else
! a less useful feature for fourier-transforming the perturbation
if (gf_count > 1) call stop_all("create_perturbed_ground", &
"Unable to use momentum operators for multiple correlation functions")
if (tReadPops) then
perturbed_buf = 0_n_int
call apply_perturbation_array(overlap_pert, tmp_totwalkers, popsfile_dets, &
perturbed_buf, phase_factors)
else
call apply_perturbation_array(overlap_pert, tmp_totwalkers, CurrentDets, &
perturbed_buf, phase_factors)
end if
end if
call write_overlap_state_serial(perturbed_buf, TotWalkers_orig_max, i)
else
write(stdout, *) "Generated overlap state"
call write_overlap_state_serial(CurrentDets, int(TotWalkers), i)
write(stdout, *) "Written overlap state to array"
end if
call MPISumAll(overlap_states(i)%nDets, totNOccDets)
if (totNOccDets == 0) then
if (gf_count == 1) then
call stop_all('create_perturbed_ground', 'No walkers survived perturbation')
else
write(stdout, *) "WARNING, EMPTY PERTURBED STATE WITH INDEX", i
end if
end if
tmp_totwalkers = totwalkers_backup
end do
if (allocated(overlap_states)) write(stdout, *) &
"Determinants remaining in perturbed ground state:", overlap_states(1)%nDets
if (allocated(perturbed_buf)) deallocate(perturbed_buf, stat=ierr)
end subroutine create_perturbed_ground