pwdft  0.1
PW-DFT code for education
pwdft.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 !
30 program pwdft
31  !
32  use kohn_sham, only : calculation, nbnd, eval, evec, ef
33  use stdin, only : read_stdin
34  use constant, only : htr2ev
35  use gvec, only : g_rh, g_wf
36  use rho_v, only : vks, init_rho_v
37  use k_point, only : nk, ksum_dos
38  use pp, only : read_pp
39  use scf, only : scf_loop, kohn_sham_eq
40  use fftw_wrapper, only : init_fft
42  use plot, only : fermi_plot, band_plot
43  use energy, only : total_e
44  !
45  implicit none
46  !
47  real(8) :: t1, t2, t3, t4
48  real(8),allocatable :: dummy(:)
49  !
50  call cpu_time(t1)
51  !
52  call read_stdin()
53  !
54  call read_pp()
55  !
56  call init_fft()
57  call init_rho_v()
58  !
59  allocate(eval(nbnd,nk), evec(g_wf%npw,nbnd,nk))
60  !
61  if(calculation == "scf") then
62  !
63  call cpu_time(t3)
64  call scf_loop()
65  call cpu_time(t4)
66  write(*,*) " SCF time : ", t4 - t3, " sec"
67  !
68  call total_e()
69  !
70  vks(1:g_rh%nr) = (vks(1:g_rh%nr) - ef)*htr2ev
71  call write_griddata("vks.xsf", vks)
72  vks(1:g_rh%nr) = vks(1:g_rh%nr)/htr2ev + ef
73  !
74  else
75  !
76  if(calculation == "bands" .or. calculation == "nscf") then
77  call read_griddata("vks.xsf", vks)
78  write(*,*) " Average potential [eV] : ", &
79  & sum(vks(1:g_rh%nr)) / dble(g_rh%nr)
80  vks(1:g_rh%nr) = vks(1:g_rh%nr) / htr2ev
81  end if
82  !
83  allocate(dummy(g_rh%nr))
84  call cpu_time(t3)
85  call kohn_sham_eq(.true., dummy)
86  call cpu_time(t4)
87  write(*,*) " Kohn-Sham time : ", t4 - t3, " sec"
88  !
89  end if
90  !
91  if(calculation == "scf" .or. calculation=="nscf") then
92  call ksum_dos()
93  call fermi_plot()
94  else
95  call band_plot()
96  end if
97  !
98  call cpu_time(t2)
99  !
100  write(*,*) " Total time : ", t2 - t1, " sec"
101  write(*,*) " End"
102  !
103 end program pwdft
plot::fermi_plot
subroutine fermi_plot()
Output FermiSurfer file.
Definition: plot.F90:65
pp::read_pp
subroutine read_pp()
Definition: pp.F90:30
constant
Definition: constant.F90:23
kohn_sham::calculation
character(256), save calculation
Calculation mode.
Definition: kohn_sham.F90:27
pp
Definition: pp.F90:23
griddata::read_griddata
subroutine read_griddata(filename, gdata)
Read unit-cell grid data such as Vks.
Definition: griddata.F90:32
scf::scf_loop
subroutine scf_loop()
Definition: scf.F90:36
gvec::g_wf
type(fft), save g_wf
Definition: gvec.F90:38
kohn_sham::ef
real(8), save ef
Fermi energy [Htr].
Definition: kohn_sham.F90:31
plot
Definition: plot.F90:23
rho_v
Definition: rho_v.F90:23
kohn_sham::evec
complex(8), dimension(:,:,:), allocatable, save evec
(g_wfnpw,nbnd,nk) Kohn-Sham eigenvector (orbital)
Definition: kohn_sham.F90:35
fftw_wrapper
Definition: fftw_wrapper.F90:23
rho_v::init_rho_v
subroutine init_rho_v()
Initialize rho, Vps, Vks.
Definition: rho_v.F90:37
k_point
Definition: k_point.F90:23
griddata
Definition: griddata.F90:23
gvec
Definition: gvec.F90:23
kohn_sham::nbnd
integer, save nbnd
Number of bands.
Definition: kohn_sham.F90:29
k_point::nk
integer, save nk
Definition: k_point.F90:27
fftw_wrapper::init_fft
subroutine init_fft()
Definition: fftw_wrapper.F90:47
kohn_sham::eval
real(8), dimension(:,:), allocatable, save eval
(nbnd,nk) Kohn-Sham eigenvalue (energy)
Definition: kohn_sham.F90:33
rho_v::vks
real(8), dimension(:), allocatable vks
(g_rhnr) Kohn-Sham potential [Htr]
Definition: rho_v.F90:27
stdin::read_stdin
subroutine read_stdin()
Definition: stdin.F90:30
gvec::g_rh
type(fft), save g_rh
Definition: gvec.F90:37
scf
Definition: scf.F90:23
constant::htr2ev
real(8), parameter htr2ev
Definition: constant.F90:27
energy::total_e
subroutine total_e()
Definition: energy.F90:30
griddata::write_griddata
subroutine write_griddata(filename, gdata)
Write unit-cell grid data such as Vks.
Definition: griddata.F90:96
pwdft
program pwdft
Definition: pwdft.F90:30
scf::kohn_sham_eq
subroutine kohn_sham_eq(linit, Fvec)
Definition: scf.F90:100
k_point::ksum_dos
subroutine ksum_dos()
DOS.
Definition: k_point.F90:63
energy
Definition: energy.F90:23
plot::band_plot
subroutine band_plot()
Output band dispersion.
Definition: plot.F90:32
kohn_sham
Definition: kohn_sham.F90:23
stdin
Definition: stdin.F90:23