makeb Subroutine

private subroutine makeb(n, nmat, ndiis, e, b)

assemble the DIIS B matrix:

Arguments

Type IntentOptional Attributes Name
integer(kind=ip), intent(in) :: n
integer(kind=ip), intent(in) :: nmat
integer(kind=ip), intent(in) :: ndiis
real(kind=rp), intent(in), dimension(n, ndiis) :: e
real(kind=rp), intent(inout), dimension(ndiis+1, ndiis+1) :: b

Called by

proc~~makeb~~CalledByGraph proc~makeb makeb proc~diis diis proc~diis->proc~makeb proc~jacobi_diis_solver jacobi_diis_solver proc~jacobi_diis_solver->proc~diis proc~polarization polarization proc~polarization->proc~jacobi_diis_solver proc~polelec_geomgrad polelec_geomgrad proc~polelec_geomgrad->proc~polarization proc~ommp_get_polelec_energy ommp_get_polelec_energy proc~ommp_get_polelec_energy->proc~polarization proc~ommp_set_external_field ommp_set_external_field proc~ommp_set_external_field->proc~polarization proc~ommp_polelec_geomgrad ommp_polelec_geomgrad proc~ommp_polelec_geomgrad->proc~polelec_geomgrad proc~c_ommp_get_polelec_energy C_ommp_get_polelec_energy proc~c_ommp_get_polelec_energy->proc~ommp_get_polelec_energy proc~ommp_get_full_ele_energy ommp_get_full_ele_energy proc~ommp_get_full_ele_energy->proc~ommp_get_polelec_energy proc~ommp_set_external_field_nomm ommp_set_external_field_nomm proc~ommp_set_external_field_nomm->proc~ommp_set_external_field proc~ommp_full_geomgrad ommp_full_geomgrad proc~ommp_full_geomgrad->proc~polelec_geomgrad proc~c_ommp_set_external_field_nomm C_ommp_set_external_field_nomm proc~c_ommp_set_external_field_nomm->proc~ommp_set_external_field proc~c_ommp_set_external_field C_ommp_set_external_field proc~c_ommp_set_external_field->proc~ommp_set_external_field proc~c_ommp_polelec_geomgrad C_ommp_polelec_geomgrad proc~c_ommp_polelec_geomgrad->proc~ommp_polelec_geomgrad proc~c_ommp_full_geomgrad C_ommp_full_geomgrad proc~c_ommp_full_geomgrad->proc~ommp_full_geomgrad proc~c_ommp_get_full_ele_energy C_ommp_get_full_ele_energy proc~c_ommp_get_full_ele_energy->proc~ommp_get_full_ele_energy proc~ommp_get_full_energy ommp_get_full_energy proc~ommp_get_full_energy->proc~ommp_get_full_ele_energy proc~c_ommp_get_full_energy C_ommp_get_full_energy proc~c_ommp_get_full_energy->proc~ommp_get_full_energy

Contents

Source Code


Source Code

    subroutine makeb(n,nmat,ndiis,e,b)
        !! assemble the DIIS B matrix:
        implicit none
        
        integer(ip), intent(in) :: n, nmat, ndiis
        real(rp), dimension(n, ndiis), intent(in) :: e
        real(rp), dimension(ndiis+1, ndiis+1), intent(inout) :: b

        integer(ip) :: i
        real(rp) :: bij
      
        if(nmat == 1) then
            ! 1st built:
            !         [ 0 |  1  ]
            !     b = [ --+---- ]
            !         [ 1 | e*e ]
            b(1,1) = 0.0_rp
            b(1,2) = 1.0_rp
            b(2,1) = 1.0_rp
            b(2,2) = dot_product(e(:,1),e(:,1))
        else
            ! subsequent builts
            ! first, update the lagrangian line:
            b(nmat+1,1) = 1.0_rp
            b(1,nmat+1) = 1.0_rp

            ! now, compute the new matrix elements:
            do i = 1, nmat - 1
                bij = dot_product(e(:,i),e(:,nmat))
                b(nmat+1,i+1) = bij
                b(i+1,nmat+1) = bij
            end do
            
            b(nmat+1,nmat+1) = dot_product(e(:,nmat),e(:,nmat))
        end if
    end subroutine makeb