calculate_residual_ss Subroutine

public subroutine calculate_residual_ss(this, basis_index)

Arguments

Type IntentOptional Attributes Name
type(davidson_ss), intent(inout) :: this
integer, intent(in) :: basis_index

Contents

Source Code


Source Code

    subroutine calculate_residual_ss(this, basis_index)

        type(davidson_ss), intent(inout) :: this
        integer, intent(in) :: basis_index

        if (this%space_size_this_proc > 0) then
            ! This routine calculates the residual, r, corresponding to the new estimate of the
            ! ground state, stored in davidson_eigenvector. This is defined as
            ! r = Hv - Ev,
            ! where H is the Hamiltonian, v is the ground state vector estimate and E is the
            ! ground state energy estimate.

            ! Calculate r = Hv - Ev:
            ! Note that, here, eigenvector_proj holds the components of v in the Krylov basis,
            ! and multiplied_basis_vectors holds the Krylov vectors multiplied by H, hence
            ! the matmul below does indeed retturn Hv.
            this%residual = matmul(this%multiplied_basis_vectors(:, 1:basis_index), this%eigenvector_proj(1:basis_index))
            this%residual = this%residual - this%davidson_eigenvalue * this%davidson_eigenvector

        end if

    end subroutine calculate_residual_ss