pwdft  0.1
PW-DFT code for education
stdin Module Reference

Functions/Subroutines

subroutine read_stdin ()
 

Function/Subroutine Documentation

◆ read_stdin()

subroutine stdin::read_stdin

Definition at line 30 of file stdin.F90.

30  !
31  use constant, only : bohr2ang, pi, htr2ev
32  use kohn_sham, only : calculation, nbnd
34  use k_point, only : nk, kvec, kgrd
35  use atm_spec, only : atm, spec, avec, nat, ntyp, bvec, vcell
36  use gvec, only : g_rh, g_wf, setup_gvec
37  !
38  integer :: iat, jtyp, ii, jj, lwork = 3, ipiv(3), &
39  & info, i1, i2, i3, nn, ik
40  real(8) :: work(3), ecutrho, ecutwfc
41  character(256) :: key
42  !
43  namelist/control/ calculation
44  namelist/system/ nat, ntyp, ecutwfc, ecutrho, nbnd
45  namelist/electrons/ electron_maxstep, conv_thr, mixing_beta
46  !
47  read(*,control)
48  !
49  write(*,*) " calculation : ", trim(calculation)
50  !
51  nbnd = 0
52  !
53  read(*,system)
54  !
55  write(*,*) " Number of atoms : ", nat
56  write(*,*) " Number of species : ", ntyp
57  write(*,*) " Plane-wave cutoff (wfc) [Ry] : ", ecutwfc
58  write(*,*) " Plane-wave cutoff (rho,V) [Ry] : ", ecutrho
59  !
60  allocate(atm(nat), spec(ntyp))
61  !
62  electron_maxstep = 100
63  conv_thr = 1.0d-10
64  mixing_beta = 0.3d0
65  !
66  read(*,electrons)
67  !
68  write(*,*) " Max iteration : ", electron_maxstep
69  write(*,*) " Convergence threshold : ", conv_thr
70  write(*,*) " Initial mixing : ", mixing_beta
71  !
72  conv_thr = conv_thr / htr2ev
73  !
74  do jj = 1, 4
75  !
76  read(*,*) key
77  !
78  if(key == "ATOMIC_SPECIES") then
79  !
80  write(*,*) " Atomic species :"
81  !
82  do jtyp = 1, ntyp
83  read(*,*) spec(jtyp)%elem, spec(jtyp)%ps_file
84  write(*,*) jtyp, trim(spec(jtyp)%elem), " ", trim(spec(jtyp)%ps_file)
85  end do
86  !
87  else if(key == "ATOMIC_POSITIONS") then
88  !
89  do iat = 1, nat
90  read(*,*) atm(iat)%elem, atm(iat)%pos(1:3)
91  end do
92  !
93  else if(key == "K_POINTS") then
94  !
95  if(calculation == "bands") then
96  read(*,*) nn
97  nk = 10*(nn-1)+1
98  allocate(kvec(3,nk))
99  read(*,*) kvec(1:3,1)
100  do ii = 1, nn - 1
101  read(*,*) kvec(1:3,10*ii+1)
102  do ik = 2, 10
103  kvec(1:3,10*(ii-1)+ik) &
104  & = kvec(1:3,10*(ii-1)+1) * dble(11-ik)/10.0d0 &
105  & + kvec(1:3,10* ii +1) * dble(ik-1)/10.0d0
106  end do
107  end do
108  else if (calculation == "direct" .or. calculation == "iterative") then
109  read(*,*) nk
110  allocate(kvec(3,nk))
111  read(*,*) kvec(1:3,1:nk)
112  else
113  read(*,*) kgrd(1:3)
114  nk = product(kgrd(1:3))
115  allocate(kvec(3,nk))
116  nk = 0
117  do i3 = 0, kgrd(3) - 1
118  do i2 = 0, kgrd(2) - 1
119  do i1 = 0, kgrd(1) - 1
120  nk = nk + 1
121  kvec(1:3,nk) = dble(modulo((/i1,i2,i3/)+kgrd(1:3)/2,kgrd(1:3)) &
122  & -kgrd(1:3)/2) &
123  & / dble(kgrd(1:3))
124  end do
125  end do
126  end do
127  end if
128  !
129  write(*,*) " Number of k : ", nk
130  !
131  else if(key == "CELL_PARAMETERS") then
132  !
133  read(*,*) avec(1:3,1:3)
134  avec(1:3,1:3) = avec(1:3,1:3) / bohr2ang
135  write(*,*) " Cell parameters [Bohr] :"
136  !
137  do ii = 1, 3
138  write(*,*) " ", avec(1:3,ii)
139  end do
140  vcell = (avec(2,1)*avec(3,2) - avec(3,1)*avec(2,2)) * avec(1,3) &
141  & + (avec(3,1)*avec(1,2) - avec(1,1)*avec(3,2)) * avec(2,3) &
142  & + (avec(1,1)*avec(2,2) - avec(2,1)*avec(1,2)) * avec(3,3)
143  vcell = abs(vcell)
144  write(*,*) " Cell volume [Bohr^3] :", vcell
145  !
146  ! Reciprocal lattice vectors
147  !
148  bvec(1:3,1:3) = transpose(avec(1:3,1:3))
149  call dgetrf(3, 3, bvec, 3, ipiv, info)
150  call dgetri(3, bvec, 3, ipiv, work, lwork, info)
151  if(info /= 0) stop 'read_stdin : inverce of avec.'
152  bvec(1:3,1:3) = 2.0d0 * pi * bvec(1:3,1:3)
153  write(*,*) " Reciplocal lattice vector [Bohr^-1] :"
154  do ii = 1, 3
155  write(*,*) " ", bvec(1:3,ii)
156  end do
157  !
158  end if
159  !
160  end do
161  kvec(1:3,1:nk) = matmul(bvec(1:3,1:3), kvec(1:3,1:nk))
162  !
163  write(*,*) " Atomic position"
164  !
165  do iat = 1, nat
166  !
167  do jtyp = 1, ntyp
168  if(trim(spec(jtyp)%elem) == trim(atm(iat)%elem)) then
169  atm(iat)%ityp = jtyp
170  exit
171  end if
172  end do
173  !
174  write(*,*) iat, trim(atm(iat)%elem), atm(iat)%ityp, atm(iat)%pos(1:3)
175  !
176  end do
177  !
178  write(*,*) " FFT and G-vector for wfc"
179  call setup_gvec(g_wf, ecutwfc)
180  write(*,*) " FFT and G-vector for rho and V"
181  call setup_gvec(g_rh, ecutrho)
182  !

References atm_spec::atm, atm_spec::avec, constant::bohr2ang, atm_spec::bvec, kohn_sham::calculation, scf::conv_thr, scf::electron_maxstep, gvec::g_rh, gvec::g_wf, constant::htr2ev, k_point::kgrd, k_point::kvec, scf::mixing_beta, atm_spec::nat, kohn_sham::nbnd, k_point::nk, atm_spec::ntyp, constant::pi, gvec::setup_gvec(), atm_spec::spec, and atm_spec::vcell.

Referenced by pwdft().

Here is the call graph for this function:
Here is the caller graph for this function:
atm_spec::spec
type(spec_t), dimension(:), allocatable, save spec
(ntyp) Species
Definition: atm_spec.F90:57
atm_spec::vcell
real(8), save vcell
Unit cell volume [Bohr^3].
Definition: atm_spec.F90:50
atm_spec::avec
real(8), dimension(3, 3), save avec
Unit lattice vector [Bohr].
Definition: atm_spec.F90:50
constant
Definition: constant.F90:23
kohn_sham::calculation
character(256), save calculation
Calculation mode.
Definition: kohn_sham.F90:27
atm_spec::ntyp
integer, save ntyp
Number of species (elements)
Definition: atm_spec.F90:47
k_point
Definition: k_point.F90:23
atm_spec::atm
type(atm_t), dimension(:), allocatable, save atm
(nat) Atom
Definition: atm_spec.F90:55
gvec
Definition: gvec.F90:23
scf::mixing_beta
real(8), save mixing_beta
Mixing for SCF.
Definition: scf.F90:29
gvec::setup_gvec
subroutine setup_gvec(xfft, g2cut)
Definition: gvec.F90:43
scf
Definition: scf.F90:23
scf::electron_maxstep
integer, save electron_maxstep
Max number of iteration.
Definition: scf.F90:27
scf::conv_thr
real(8), save conv_thr
Convergence threshold [Htr].
Definition: scf.F90:29
atm_spec
Definition: atm_spec.F90:23
kohn_sham
Definition: kohn_sham.F90:23