Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dirac.f90
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ subroutine Ffunc(x, y, eng)
real(dp) :: E_dirac_shift
integer :: idx
logical :: accurate_eigensolver
accurate_eigensolver = .true.
accurate_eigensolver = .false.
iter = iter + 1
print *, "SCF iteration:", iter
Vin = reshape(x, shape(Vin))
Expand Down
12 changes: 12 additions & 0 deletions src/lapack.f90
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ SUBROUTINE DSYGVD( ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK, &
REAL(dp) A( LDA, * ), B( LDB, * ), W( * ), WORK( * )
END SUBROUTINE

SUBROUTINE DSYGVX( ITYPE, JOBZ, RANGE, UPLO, N, A, LDA, B, LDB, &
VL, VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK, &
LWORK, IWORK, IFAIL, INFO )
import :: dp
CHARACTER JOBZ, RANGE, UPLO
INTEGER IL, INFO, ITYPE, IU, LDA, LDB, LDZ, LWORK, M, N
REAL(dp) ABSTOL, VL, VU
INTEGER IFAIL( * ), IWORK( * )
REAL(dp) A( LDA, * ), B( LDB, * ), W( * ), WORK( * ), &
Z( LDZ, * )
END SUBROUTINE

REAL(dp) FUNCTION DLAMCH( CMACH )
import :: dp
CHARACTER CMACH
Expand Down
27 changes: 21 additions & 6 deletions src/linalg.f90
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module linalg
use types, only: dp
use lapack, only: dsyevd, dsygvd, dgesv
use lapack, only: dsyevd, dsygvd, dgesv, dsygvx
implicit none
private
public eigh, solve
Expand All @@ -24,8 +24,10 @@ subroutine deigh_generalized(Am, Bm, lam, c)
integer :: n
! lapack variables
integer :: lwork, liwork, info
integer, allocatable :: iwork(:)
real(dp), allocatable :: Bmt(:,:), work(:)
integer, allocatable :: iwork(:), ifail(:)
real(dp), allocatable :: Bmt(:,:), work(:), Z(:,:), Amt(:,:)
integer :: il, iu, M
real(dp) :: abstol

! solve
n = size(Am,1)
Expand All @@ -34,9 +36,22 @@ subroutine deigh_generalized(Am, Bm, lam, c)
call assert_shape(c, [n, n], "eigh", "c")
lwork = 1 + 6*n + 2*n**2
liwork = 3 + 5*n
allocate(Bmt(n,n), work(lwork), iwork(liwork))
c = Am; Bmt = Bm ! Bmt temporaries overwritten by dsygvd
call dsygvd(1,'V','L',n,c,n,Bmt,n,lam,work,lwork,iwork,liwork,info)
allocate(work(lwork), iwork(liwork))
allocate(ifail(n))
!call dsygvd(1,'V','L',n,c,n,Bmt,n,lam,work,lwork,iwork,liwork,info)
il = 1
iu = 7
M = iu-il+1
allocate(z(n,M))
abstol = 1e-4_dp
call dsygvx(1,'V','I','L',n,Am,n,Bm,n, &
0._dp, 0._dp, 1, 7, abstol, M, lam, c, n, work, &
lwork, iwork, ifail, info)
!SUBROUTINE DSYGVD( ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK, &
! LWORK, IWORK, LIWORK, INFO )
!SUBROUTINE DSYGVX( ITYPE, JOBZ, RANGE, UPLO, N, A, LDA, B, LDB, &
! VL, VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK, &
! LWORK, IWORK, IFAIL, INFO )
if (info /= 0) then
print *, "dsygvd returned info =", info
if (info < 0) then
Expand Down