The Elk Code
writeefield.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2024 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 
6 subroutine writeefield(fnum)
7 use modmain
8 implicit none
9 ! arguments
10 integer, intent(in) :: fnum
11 ! local variables
12 integer is,ia,ias,i
13 real(8) efc(3),t1
14 if (natmtot == 0) return
15 ! determine the average electric field in each muffin-tin
16 call efieldmt
17 ! write the electric fields to file
18 write(fnum,*)
19 write(fnum,'("Average electric field in each muffin-tin")')
20 do is=1,nspecies
21  write(fnum,'(" species : ",I4," (",A,")")') is,trim(spsymb(is))
22  do ia=1,natoms(is)
23  ias=idxas(ia,is)
24  write(fnum,'(" atom ",I4,T30,": ",3G18.10)') ia,efcmt(:,ias)
25  end do
26 end do
27 ! compute the average electric field
28 do i=1,3
29  efc(i)=sum(efcmt(i,1:natmtot))/dble(natmtot)
30 end do
31 write(fnum,*)
32 write(fnum,'("Average of muffin-tin electric fields :")')
33 write(fnum,'(3G18.10)') efc
34 t1=norm2(efc(1:3))
35 write(fnum,'(" magnitude : ",G18.10)') t1
36 write(fnum,'(" volts/nanometer : ",G18.10)') t1*ef_si/1.d9
37 end subroutine
38 
integer, dimension(maxatoms, maxspecies) idxas
Definition: modmain.f90:42
subroutine efieldmt
Definition: efieldmt.f90:10
integer, dimension(maxspecies) natoms
Definition: modmain.f90:36
real(8), parameter ef_si
Definition: modmain.f90:1273
subroutine writeefield(fnum)
Definition: writeefield.f90:7
integer nspecies
Definition: modmain.f90:34
real(8), dimension(:,:), allocatable efcmt
Definition: modmain.f90:316
integer natmtot
Definition: modmain.f90:40
character(64), dimension(maxspecies) spsymb
Definition: modmain.f90:78