subroutine start_walkers_from_core_ground(tPrintInfo, run)
use davidson_semistoch, only: davidson_ss, perform_davidson_ss, destroy_davidson_ss
use Parallel_neci, only: MPISumAll
logical, intent(in) :: tPrintInfo
integer, intent(in) :: run
integer :: nI(nel)
integer :: i, counter, ierr
real(dp) :: eigenvec_pop, eigenvec_pop_tot, pop_sign(lenof_sign)
integer(n_int) :: tmp
character(len=*), parameter :: t_r = "start_walkers_from_core_ground"
type(davidson_ss) :: dc
if (tPrintInfo) then
write(stdout, '(a69)') "Using the deterministic ground state as initial walker configuration."
write(stdout, '(a34)') "Performing Davidson calculation..."
call neci_flush(stdout)
end if
! Call the Davidson routine to find the ground state of the core space.
call perform_davidson_ss(dc, .true., run)
if (tPrintInfo) then
write(stdout, '(a30)') "Davidson calculation complete."
write(stdout, '("Deterministic total energy:",1X,f15.10)') dc%davidson_eigenvalue + Hii
call neci_flush(stdout)
end if
associate(rep => cs_replicas(run))
! We need to normalise this vector to have the correct 'number of walkers'.
eigenvec_pop = 0.0_dp
do i = 1, rep%determ_sizes(iProcIndex)
eigenvec_pop = eigenvec_pop + abs(dc%davidson_eigenvector(i))
end do
call MPISumAll(eigenvec_pop, eigenvec_pop_tot)
if (tStartSinglePart) then
dc%davidson_eigenvector = dc%davidson_eigenvector &
* InitialPart / eigenvec_pop_tot
else
dc%davidson_eigenvector = dc%davidson_eigenvector &
* InitWalkers / eigenvec_pop_tot
end if
! Then copy these amplitudes across to the corresponding states in CurrentDets.
counter = 0
do i = 1, int(TotWalkers)
if (check_determ_flag(CurrentDets(:, i), run)) then
counter = counter + 1
pop_sign = dc%davidson_eigenvector(counter)
call decode_bit_det(nI, CurrentDets(:, i))
tmp = transfer(pop_sign(rep%min_part():rep%max_part()), tmp)
CurrentDets(IlutBits%ind_pop + rep%min_part() - 1:IlutBits%ind_pop + rep%max_part() - 1, i) = tmp
end if
end do
end associate
call destroy_davidson_ss(dc)
end subroutine start_walkers_from_core_ground