subroutine CalcConstraints(CurrCoeff, Constraint, TotConstraints)
! This calculates the value of each orthonomalisation constraint, using the shifted coefficients.
! Each of these should tend to 0 when the coefficients become orthonomal.
integer :: l, i, j
HElement_t(dp) :: CurrCoeff(NoOrbs, NoOrbs)
real(dp) :: TotConstraints, Constraint(TotNoConstraints)
TotConstraints = 0.0_dp
do l = 1, TotNoConstraints
i = lab(1, l)
j = lab(2, l)
if (i == j) then
Constraint(l) = Dot_Product(CurrCoeff(:, i), CurrCoeff(:, j)) - 1.0_dp
else
Constraint(l) = Dot_Product(CurrCoeff(:, i), CurrCoeff(:, j))
! Each of these components should tend towards 0 when the coefficients become orthonormal.
end if
TotConstraints = TotConstraints + ABS(Constraint(l))
end do
end subroutine CalcConstraints