subroutine update_delta_psi()
! here, we add H^2 psi to delta_psi to generate the new delta_psi
! this might cause trouble as stochastic error is not averaged out,
! but we just carry over the error from the last iteration
character(*), parameter :: this_routine = "update_delta_psi"
! add up delta_psi from the last iteration and spawnedParts (i.e. H^2 psi)
call merge_ilut_lists(spawnedParts, dpsi_cache, spawn_ht, spawnBufSize, &
dpsi_size, maxSpawned)
! if semistochastic mode is run, we add the semistochastic spawns now
! because they have to be included in delta psi
if (tSemiStochastic) call add_semistoch_spawns(spawnedParts, spawnBufSize, &
spawn_ht, maxSpawned, spawnBuf)
! cache delta_psi for the next iteration
if (spawnBufSize > max_cache_size) call stop_all(this_routine, &
"Insufficient memory for creating delta_psi")
dpsi_cache(:, 1:spawnBufSize) = spawnedParts(:, 1:spawnBufSize)
dpsi_size = spawnBufSize
! for now, consider all entries in delta_psi as safe spawns for the next iteration
if (tTruncInitiator) call set_initiator_flags_array(dpsi_cache, dpsi_size)
end subroutine update_delta_psi