pwdft  0.1
PW-DFT code for education
diag_direct Module Reference

Functions/Subroutines

subroutine direct (npw, kvec, evec, eval)
 

Function/Subroutine Documentation

◆ direct()

subroutine diag_direct::direct ( integer, intent(in)  npw,
real(8), dimension(3), intent(in)  kvec,
complex(8), dimension(npw,nbnd), intent(out)  evec,
real(8), dimension(nbnd), intent(out)  eval 
)

Definition at line 30 of file diag_direct.F90.

30  !
31  use atm_spec, only : bvec
32  use kohn_sham, only : nbnd
33  use gvec, only : g_rh, g_wf
34  use rho_v, only : vks
35  use fftw_wrapper, only : fft_r2g
36  !
37  integer,intent(in) :: npw
38  real(8),intent(in) :: kvec(3)
39  complex(8),intent(out) :: evec(npw,nbnd)
40  real(8),intent(out) :: eval(nbnd)
41  !
42  integer :: info, ipw, jpw, lwork, dmill(3)
43  real(8) :: rwork(3*npw-2), eval_full(npw), kgv(3)
44  complex(8) :: ham(npw,npw), &
45  & VksG(g_rh%nft(1), g_rh%nft(2), g_rh%nft(3))
46  complex(8),allocatable :: work(:)
47  !
48  ! Local potential term
49  !
50  call fft_r2g(vks, vksg)
51  !
52  do ipw = 1, npw
53  do jpw = 1, npw
54  dmill(1:3) = g_wf%mill(1:3,g_wf%map(jpw)) - g_wf%mill(1:3,g_wf%map(ipw))
55  dmill(1:3) = modulo(dmill(1:3), g_rh%nft(1:3)) + 1
56  ham(jpw,ipw) = vksg(dmill(1), dmill(2), dmill(3))
57  end do
58  end do
59  !
60  ! Kinetic energy term
61  !
62  do ipw = 1, npw
63  kgv(1:3) = kvec(1:3) + matmul(bvec(1:3,1:3), dble(g_wf%mill(1:3,g_wf%map(ipw))))
64  ham(ipw,ipw) = ham(ipw,ipw) + 0.5d0 * dot_product(kgv,kgv)
65  end do
66  !
67  lwork = -1
68  allocate(work(1))
69  call zheev('V', 'U', npw, ham, npw, eval_full, work, lwork, rwork, info)
70  lwork = nint(dble(work(1)))
71  deallocate(work)
72  allocate(work(lwork))
73  call zheev('V', 'U', npw, ham, npw, eval_full, work, lwork, rwork, info)
74  deallocate(work)
75  !
76  eval( 1:nbnd) = eval_full(1:nbnd)
77  evec(1:npw,1:nbnd) = ham(1:npw,1:nbnd)
78  !

References atm_spec::bvec, fftw_wrapper::fft_r2g(), gvec::g_rh, gvec::g_wf, kohn_sham::nbnd, and rho_v::vks.

Referenced by scf::kohn_sham_eq().

Here is the call graph for this function:
Here is the caller graph for this function:
fftw_wrapper::fft_r2g
subroutine fft_r2g(VlocR, VlocG)
v(r) e^{-iGr} -> V(G)
Definition: fftw_wrapper.F90:75
gvec::g_wf
type(fft), save g_wf
Definition: gvec.F90:38
rho_v
Definition: rho_v.F90:23
fftw_wrapper
Definition: fftw_wrapper.F90:23
gvec
Definition: gvec.F90:23
kohn_sham::nbnd
integer, save nbnd
Number of bands.
Definition: kohn_sham.F90:29
rho_v::vks
real(8), dimension(:), allocatable vks
(g_rhnr) Kohn-Sham potential [Htr]
Definition: rho_v.F90:27
gvec::g_rh
type(fft), save g_rh
Definition: gvec.F90:37
atm_spec::bvec
real(8), dimension(3, 3), save bvec
Unit reciplocal lattice vector [Bohr^-1].
Definition: atm_spec.F90:50
atm_spec
Definition: atm_spec.F90:23
kohn_sham
Definition: kohn_sham.F90:23