pwdft  0.1
PW-DFT code for education
diag_direct.F90
Go to the documentation of this file.
1 !
2 ! Copyright (c) 2018 Mitsuaki Kawamura
3 !
4 ! Permission is hereby granted, free of charge, to any person obtaining a
5 ! copy of this software and associated documentation files (the
6 ! "Software"), to deal in the Software without restriction, including
7 ! without limitation the rights to use, copy, modify, merge, publish,
8 ! distribute, sublicense, and/or sell copies of the Software, and to
9 ! permit persons to whom the Software is furnished to do so, subject to
10 ! the following conditions:
11 !
12 ! The above copyright notice and this permission notice shall be included
13 ! in all copies or substantial portions of the Software.
14 !
15 ! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 ! OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 ! MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 ! IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 ! CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 ! TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 ! SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 !
24  !
25  implicit none
26  !
27 contains
28  !
29  subroutine direct(npw,kvec,evec,eval)
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  !
79  end subroutine direct
80  !
81 end module diag_direct
diag_direct
Definition: diag_direct.F90:23
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
diag_direct::direct
subroutine direct(npw, kvec, evec, eval)
Definition: diag_direct.F90:30