subroutine start_walkers_from_core_ground_nonhermit(tPrintInfo, run)
logical, intent(in) :: tPrintInfo
integer, intent(in) :: run
integer :: i, counter, ierr
integer :: nI(nel)
real(dp), allocatable :: e_values(:)
HElement_t(dp), allocatable :: e_vectors(:, :)
integer(n_int) :: tmp
real(dp) :: eigenvec_pop, pop_sign(lenof_sign)
character(len=*), parameter :: t_r = "start_walkers_from_core_ground_nonhermit"
if (tPrintInfo) then
write(stdout, '(a69)') "Using the deterministic ground state as initial walker configuration."
write(stdout, '(a53)') "Performing diagonalization of non-Hermitian matrix..."
call neci_flush(stdout)
end if
associate(rep => cs_replicas(run))
! Call the non-Hermitian diagonalizer to find the ground state of the core space.
call diagonalize_core_non_hermitian(e_values, e_vectors, rep)
if (tPrintInfo) then
write(stdout, '("Energies of the deterministic subspace:")')
write(stdout, *) e_values(1:rep%determ_space_size)
call neci_flush(stdout)
end if
! We need to normalise this vector to have the correct 'number of walkers'.
eigenvec_pop = 0.0_dp
do i = 1, rep%determ_space_size
eigenvec_pop = eigenvec_pop + abs(e_vectors(i, 1))
end do
if (tStartSinglePart) then
e_vectors(:, 1) = e_vectors(:, 1) * InitialPart / eigenvec_pop
else
e_vectors(:, 1) = e_vectors(:, 1) * InitWalkers / eigenvec_pop
end if
write(stdout, *) 'The ground state vector:'
write(stdout, *) e_vectors(:, 1)
! Then copy these amplitudes across to the corresponding states in CurrentDets.
counter = 0
do i = 1, iProcIndex
counter = counter + rep%determ_sizes(i - 1)
end do
do i = 1, rep%determ_space_size !int(TotWalkers)
if (check_determ_flag(CurrentDets(:, i), run)) then
counter = counter + 1
pop_sign = e_vectors(counter, 1)
tmp = transfer(pop_sign(min_pt:max_pt), tmp)
CurrentDets(IlutBits%ind_pop + min_part_type(run) - 1:IlutBits%ind_pop + max_part_type(run) - 1, i) = tmp
end if
end do
end associate
deallocate(e_values, e_vectors)
end subroutine start_walkers_from_core_ground_nonhermit