recalc_core_hamil_diag Subroutine

public subroutine recalc_core_hamil_diag(old_Hii, new_Hii)

Arguments

Type IntentOptional Attributes Name
real(kind=dp) :: old_Hii
real(kind=dp) :: new_Hii

Contents


Source Code

    subroutine recalc_core_hamil_diag(old_Hii, new_Hii)

        real(dp) :: old_Hii, new_Hii
        real(dp) :: Hii_shift
        integer :: i, j, run

        ! Only attempt this if we have already performed the semi-stochastic
        ! initialisation, in which case determ_sizes will have been allocated.
        do run = 1, size(cs_replicas)
            associate(rep => cs_replicas(run))
                if (allocated(rep%determ_sizes)) then
                    write(stdout, '(a56)') "Recalculating diagonal elements of the core Hamiltonian."

                    Hii_shift = old_Hii - new_Hii

                    do i = 1, rep%determ_sizes(iProcIndex)
                        do j = 1, rep%sparse_core_ham(i)%num_elements
                            if (rep%sparse_core_ham(i)%positions(j) == &
                                i + rep%determ_displs(iProcIndex)) then
                                    rep%sparse_core_ham(i)%elements(j) = &
                                        rep%sparse_core_ham(i)%elements(j) + Hii_shift
                            end if
                        end do
                    end do

                    rep%core_ham_diag = rep%core_ham_diag + Hii_shift
                end if
            end associate
        end do

    end subroutine recalc_core_hamil_diag