The Elk Code
 
Loading...
Searching...
No Matches
eveqnwxy.f90
Go to the documentation of this file.
1
2! Copyright (C) 2019 Chung-Yu Wang, J. K. Dewhurst, S. Sharma and
3! E. K. U. Gross. This file is distributed under the terms of the GNU General
4! Public License. See the file COPYING for license details.
5
6subroutine eveqnwxy(n,p,dw,ex,fy,w)
7implicit none
8! arguments
9integer, intent(in) :: n,p
10complex(8), intent(inout) :: dw(n,n),ex(n,n),fy(n)
11real(8), intent(out) :: w(n)
12! local variables
13integer n2,i,j
14real(8) t1,t2
15! allocatable arrays
16integer, allocatable :: idx(:)
17real(8), allocatable :: r(:)
18complex(8), allocatable :: w2(:),h(:,:)
19complex(8), allocatable :: x(:),a(:,:)
20! external functions
21real(8), external :: dznrm2
22n2=2*n
23! setup the bosonic Bogoliubov Hamiltonian
24allocate(w2(n2),h(n2,n2))
25do j=1,n
26 do i=1,n
27 h(i,j)=dw(i,j)
28 h(n+i,n+j)=-dw(i,j)
29 h(i,n+j)=-ex(i,j)
30 h(n+i,j)=ex(i,j)
31 end do
32end do
33! find the eigenvalues and right eigenvectors
34call eveqnzg(n2,n2,h,w2)
35! select the eigenpairs corresponding to W†W - X†X = I
36allocate(idx(n2),r(n2))
37do j=1,n2
38 t1=dznrm2(n,h(1,j),1)**2
39 t2=dznrm2(n,h(n+1,j),1)**2
40 r(j)=t1-t2
41end do
42call sortidx(n2,r,idx)
43! pseudo-normalise the eigenvectors and store in output arrays
44do i=1,n
45 j=idx(n+i)
46 t1=abs(r(j))+1.d-8
47 t1=(1.d0-(1.d0-t1)**p)/sqrt(t1)
48 w(i)=dble(w2(j))
49 dw(1:n,i)=t1*h(1:n,j)
50 ex(1:n,i)=t1*h(n+1:n2,j)
51end do
52deallocate(idx,r,w2,h)
53! solve for the vector y
54allocate(x(n),a(n,n))
55a(:,:)=dw(:,:)-ex(:,:)
56x(:)=fy(:)
57call zgemv('T',n,n,(1.d0,0.d0),a,n,x,1,(0.d0,0.d0),fy,1)
58do i=1,n
59 if (w(i) > 1.d-6) then
60 fy(i)=fy(i)/w(i)
61 else
62 fy(i)=0.d0
63 end if
64end do
65deallocate(x,a)
66end subroutine
67
subroutine eveqnwxy(n, p, dw, ex, fy, w)
Definition eveqnwxy.f90:7
subroutine eveqnzg(n, ld, a, w)
Definition eveqnzg.f90:7
pure subroutine sortidx(n, x, idx)
Definition sortidx.f90:10