File: bdginv.f90

package info (click to toggle)
elkcode 5.4.24-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 12,840 kB
  • sloc: f90: 48,415; fortran: 22,457; perl: 965; makefile: 384; sh: 369; python: 105; ansic: 67
file content (49 lines) | stat: -rw-r--r-- 1,294 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

! Copyright (C) 2011 J. K. Dewhurst, S. Sharma and E. K. U. Gross.
! This file is distributed under the terms of the GNU General Public License.
! See the file COPYING for license details.

subroutine bdginv(achi0,adelta)
use modmain
use modscdft
implicit none
! arguments
complex(8), intent(in) :: achi0(nbdg,nbdg)
complex(8), intent(out) :: adelta(nbdg,nbdg)
! local variables
integer, parameter :: maxit=1000
integer it
real(8) d,dp
! allocatable arrays
complex(8), allocatable :: achi(:,:)
complex(8), allocatable :: evecbdg(:,:)
! external functions
real(8) dznrm2
allocate(achi(nbdg,nbdg))
allocate(evecbdg(nmbdg,nmbdg))
! zero the anomalous potential
adelta(:,:)=0.d0
dp=0.d0
do it=1,maxit
! set up the BdG Hamiltonian
  call hmlbdg(adelta,evecbdg)
! solve the BdG eigenvalue equations
  call eveqnbdg(evecbdg)
! generate the anomalous density Chi
  call genachi(evecbdg,achi)
! add the residual to the potential
  adelta(:,:)=adelta(:,:)+taubdg*(achi(:,:)-achi0(:,:))
! compute the sum of diagonal elements squared
  d=dznrm2(nbdg,adelta,nbdg)
  if (it.ge.2) then
    d=sqrt(abs(d)/dble(nbdg))
    if (abs(d-dp).lt.epspot) return
  end if
  dp=d
end do
write(*,*)
write(*,'("Warning(bdginv): BdG equation inverter failed to converge")')
deallocate(achi,evecbdg)
return
end subroutine