@@ -16,6 +16,7 @@ module dirac
1616 nlsf2focc, get_atomic_states_rel, nlf2focc, get_atomic_states_nonrel
1717use energies, only: thomas_fermi_potential
1818use iso_c_binding, only: c_double, c_int
19+ use lapack, only: dpotrf
1920implicit none
2021private
2122public solve_dirac, csolve_dirac, solve_dirac_eigenproblem
@@ -37,7 +38,8 @@ subroutine solve_dirac_eigenproblem(Nb, Nq, Lmin, Lmax, alpha, alpha_j, xe, xiq_
3738real (dp), intent (out ) :: V(:,:)
3839integer , intent (out ) :: idx
3940real (dp), intent (in ) :: E_dirac_shift
40- integer :: kappa, i
41+ real (dp) :: SU(size (S,1 ),size (S,2 ))
42+ integer :: kappa, i, info, j
4143idx = 0
4244do kappa = Lmin, Lmax
4345 if (kappa == 0 ) cycle
@@ -58,6 +60,13 @@ subroutine solve_dirac_eigenproblem(Nb, Nq, Lmin, Lmax, alpha, alpha_j, xe, xiq_
5860 ! we still need two seperate eigensolves for 1e-8 accuracy:
5961 ! H = (H + transpose(H))/2
6062 ! S = (S + transpose(S))/2
63+ SU = S
64+ do j = 1 , size (SU,1 )
65+ SU(j+1 :,j) = 0
66+ end do
67+ call dpotrf(' U' , size (SU,1 ), SU, size (SU,1 ), info)
68+ if (info /= 0 ) error stop
69+ S = matmul (transpose (SU), SU)
6170
6271 if (accurate_eigensolver) then
6372 call eigh(H, S, lam)
0 commit comments