I have the following code which finds the eigenvalues of a non-Hermitian complex matrix H
.
Program Eigen_nonHermitian
implicit none
integer:: Nstate,i
double precision:: t,eps,tm,tp,U
double complex:: H(6,6),E(6)
double precision:: l
! Parameters
t=1.0; eps=0.5d0; U = 2.d0
Nstate=6
! Initialize H
H=dcmplx(0.d0,0.d0)
l=2.d0
do i=1,3
! Construct H-matrix (size: 6 x 6)
tm=t-l; tp=t+l
!H(1,1)=2.d0*eps; H(3,3)=H(1,1); H(4,4)=H(1,1); H(6,6)=H(1,1)
!H(2,2)=2.d0*eps+U; H(5,5)=H(2,2)
!H(2,3)=tm; H(3,5)=tm
!H(3,2)=tp; H(5,3)=tp
!H(2,4)=-tm; H(4,5)=-tm
!H(4,2)=-tp; H(5,4)=-tp
H(1,1)=dcmplx(2.d0*eps,0.d0); H(3,3)=H(1,1); H(4,4)=H(1,1); H(6,6)=H(1,1)
H(2,2)=dcmplx(2.d0*eps+U,0.d0); H(5,5)=H(2,2)
H(2,3)=dcmplx(tm,0.d0); H(3,5)=dcmplx(tm,0.d0)
H(3,2)=dcmplx(tp,0.d0); H(5,3)=dcmplx(tp,0.d0)
H(2,4)=dcmplx(-tm,0.d0); H(4,5)=dcmplx(-tm,0.d0)
H(4,2)=dcmplx(-tp,0.d0); H(5,4)=dcmplx(-tp,0.d0)
! Diagonalize H
call CEigen(H,E,Nstate)
print*,'<== Dissipative parameter, lambda=',l
end do
End Program Eigen_nonHermitian
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Subroutine CEigen(A,ev,N)
implicit none
integer:: i
integer:: N,LDA,LDVL,LDVR,LWORK,INFO
double complex:: A(N,N),ev(N)
double complex:: vecL(N,N), vecR(N,N), WORK(2*N)
double precision:: RWORK(2*N)
LDA=N; LDVL=N; LDVR=N
LWORK=2*N
RWORK=2*N
call ZGEEV('V', 'V', N, A, LDA, ev, vecL, LDVL, vecR, LDVR, &
& WORK, LWORK, RWORK, info)
! Syntax: ZGEEV( JOBVL, JOBVR, N, A, LDA, W, VL, LDVL, VR, LDVR,
! WORK, LWORK, RWORK, INFO )
print*,'Eigenvalues are:'
do i=1, N
write(*,'(f8.3,a,f8.3,a)') dreal(ev(i)),' +', &
& dimag(ev(i)),'i'
enddo
print*,'info=',info
end Subroutine CEigen
In this code, I used a dissipative or asymmetric parameter lambda
which I fix as l=2.d0
and run a do-loop three times. I was supposed to get the same eigenvalues in each iteration. To my surprise, the first two loops give the same sets of eigenvalues but their orderings differ, and the third loop generates a completely different set of eigenvalues!
What could be the possible error?
The output:
Eigenvalues are:
2.000 + 3.317i
3.000 + -0.000i
2.000 + -3.317i
1.000 + 0.000i
1.000 + 0.000i
1.000 + 0.000i
info= 0
<== Dissipative parameter, lambda= 2.0000000000000000
Eigenvalues are:
1.000 + 0.000i
2.000 + -3.317i
3.000 + 0.000i
2.000 + 3.317i
1.000 + 0.000i
1.000 + 0.000i
info= 0
<== Dissipative parameter, lambda= 2.0000000000000000
Eigenvalues are:
1.000 + 0.000i
2.140 + 3.421i
2.180 + -3.329i
3.000 + 0.000i
0.680 + -0.092i
1.000 + 0.000i
info= 0
<== Dissipative parameter, lambda= 2.0000000000000000
N.B.: There's an earlier post with a similar objection, but I don't think I have made a mistake like wrongly defining RWORK
as it was done in that post. So please don't mark my question as a duplicate immediately.