The Elk Code
 
Loading...
Searching...
No Matches
bornechg.f90
Go to the documentation of this file.
1
2! Copyright (C) 2020 J. K. Dewhurst and S. Sharma.
3! This file is distributed under the terms of the GNU General Public License.
4! See the file COPYING for license details.
5
6subroutine bornechg
7use modmain
8use modphonon
9use modmpi
10use modtest
11use moddelf
12implicit none
13! local variables
14integer ip,i
15real(8) vc(3),pvl1(3),pvl2(3)
16real(8) becl(3),becc(3),t1
17! initialise universal variables
18call init0
19call init1
20! store original parameters
21atposl0(:,:,:)=atposl(:,:,:)
22atposc0(:,:,:)=atposc(:,:,:)
23ngridk0(:)=ngridk(:)
26! no shifting of the atomic basis
27tshift=.false.
28! begin new Born effective charge task
2910 continue
30call bectask(80,filext)
31! if nothing more to do then restore original input parameters and return
32if (isph == 0) then
33 filext='.OUT'
35 atposl(:,:,:)=atposl0(:,:,:)
36 return
37end if
38if (mp_mpi) then
39 write(*,'("Info(bornechg): working on ",A)') 'BEC'//trim(filext)
40end if
41! dry run: just generate empty BEC files
42if (task == 209) goto 10
43! apply negative atomic displacement
44atposl(:,:,:)=atposl0(:,:,:)
45atposc(:,:,:)=atposc0(:,:,:)
46vc(:)=atposc(:,iaph,isph)
47vc(ipph)=vc(ipph)-0.5d0*deltaph
48call r3mv(ainv,vc,atposl(:,iaph,isph))
49! initial ground-state run should start from atomic densities
50trdstate=.false.
51! run the ground-state calculation
52call gndstate
53! subsequent calculations will read in the previous potential
54trdstate=.true.
55! compute the first polarisation in lattice coordinates
56call polar(pvl1)
57! apply positive atomic displacement
58atposl(:,:,:)=atposl0(:,:,:)
59atposc(:,:,:)=atposc0(:,:,:)
60vc(:)=atposc(:,iaph,isph)
61vc(ipph)=vc(ipph)+0.5d0*deltaph
62call r3mv(ainv,vc,atposl(:,iaph,isph))
63! run the ground-state calculation again
64call gndstate
65! compute the second polarisation
66call polar(pvl2)
67do i=1,3
68! add multiple of 2*pi to bring polarisation vectors into coincidence
69 pvl1(i)=modulo(pvl1(i),twopi)
70 pvl2(i)=modulo(pvl2(i),twopi)
71 t1=pvl1(i)-pvl2(i)
72 if (abs(t1-twopi) < abs(t1)) then
73 pvl1(i)=pvl1(i)-twopi
74 else if (abs(t1+twopi) < abs(t1)) then
75 pvl1(i)=pvl1(i)+twopi
76 end if
77! calculate the Born effective charge from the difference in polarisations
79 becl(i)=t1*(pvl2(i)-pvl1(i))
80end do
81! convert from lattice to Cartesian coordinates
82call r3mv(avec,becl,becc)
83! add the core and nuclear charge
84becc(ipph)=becc(ipph)+chgcr(isph)+spzn(isph)
85! write Born effective charge matrix row to file
86if (mp_mpi) then
87 do ip=1,3
88 write(80,'(G18.10," : ip = ",I4)') becc(ip),ip
89 end do
90 close(80)
91end if
92! write test file if required and return
93if (test) then
94 call writetest(208,'Born effective charge',nv=3,tol=1.d-3,rva=becc)
95 return
96end if
97! delete the non-essential files
98call delfiles(evec=.true.,eval=.true.,occ=.true.)
99! synchronise MPI processes
100call mpi_barrier(mpicom,ierror)
101goto 10
102end subroutine
103
subroutine bectask(fnum, fext)
Definition bectask.f90:7
subroutine bornechg
Definition bornechg.f90:7
subroutine gndstate
Definition gndstate.f90:10
subroutine init0
Definition init0.f90:10
subroutine init1
Definition init1.f90:10
subroutine delfiles(evec, devec, eval, occ, pmat, epsi)
Definition moddelf.f90:25
logical tshift
Definition modmain.f90:352
integer, dimension(3) ngridk0
Definition modmain.f90:448
real(8), dimension(3, maxatoms, maxspecies) atposc
Definition modmain.f90:54
character(256) filext
Definition modmain.f90:1300
real(8), parameter twopi
Definition modmain.f90:1230
real(8), dimension(maxspecies) chgcr
Definition modmain.f90:716
real(8), dimension(3, 3) avec
Definition modmain.f90:12
logical tshift0
Definition modmain.f90:352
integer nkspolar
Definition modmain.f90:485
integer, dimension(3) ngridk
Definition modmain.f90:448
integer maxscl0
Definition modmain.f90:1046
real(8), dimension(3, maxatoms, maxspecies) atposl0
Definition modmain.f90:51
logical trdstate
Definition modmain.f90:682
integer task
Definition modmain.f90:1298
real(8), dimension(3, maxatoms, maxspecies) atposc0
Definition modmain.f90:54
real(8), dimension(3, 3) ainv
Definition modmain.f90:14
integer maxscl
Definition modmain.f90:1046
real(8) occmax
Definition modmain.f90:898
real(8), dimension(3, maxatoms, maxspecies) atposl
Definition modmain.f90:51
real(8) wkptnr
Definition modmain.f90:477
real(8), dimension(maxspecies) spzn
Definition modmain.f90:80
integer ierror
Definition modmpi.f90:19
integer mpicom
Definition modmpi.f90:11
logical mp_mpi
Definition modmpi.f90:17
integer iaph
Definition modphonon.f90:15
integer ipph
Definition modphonon.f90:15
integer isph
Definition modphonon.f90:15
real(8) deltaph
Definition modphonon.f90:48
logical test
Definition modtest.f90:11
subroutine writetest(id, descr, nv, iv, iva, tol, rv, rva, zv, zva)
Definition modtest.f90:16
subroutine polar(pvl)
Definition polar.f90:10
pure subroutine r3mv(a, x, y)
Definition r3mv.f90:10