Skip to content

Commit

Permalink
Merge pull request wannier-developers#168 from stiegerc/develop
Browse files Browse the repository at this point in the history
edited the hamiltonian_write_rmn to correspond to hamiltonian_write_t…
  • Loading branch information
Ivo Souza authored May 24, 2018
2 parents f2a435d + 261df52 commit 928a5bd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGE.log
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

The Maximally-Localised Generalised Wannier Functions Code

* adapted the subroutine hamiltonian_write_rmn in file hamiltonian.f90
to produce the same results as in hamiltonian_write_tb.

* bug fix in kslice.F90 & example17 (change to floor division in the python
scripts for plotting Fermi lines), minor bug fix in example18 & tutorial

Expand Down
1 change: 1 addition & 0 deletions doc/user_guide/files.tex
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ \section{{\tt seedname\_r.dat}}
Written if $\verb#write_rmn#=\verb#true#$. The matrix elements
$\langle m\mathbf{0}|\mathbf{r}|n\mathbf{R}\rangle$ (where $n\mathbf{R}$ refers to MLWF $n$ in unit cell $\mathbf{R}$). The first line gives the date and time at which the file was created.
The second line states the number of Wannier functions {\tt num\_wann}.
The third line states the number of $\mathbf{R}$ vectors {\tt nrpts}.
Similar to the case of the Hamiltonian matrix above, the
remaining {\tt num\_wann}$^2 \times$ {\tt nrpts} lines
each contain, respectively, the components of the vector $\mathbf{R}$
Expand Down
34 changes: 21 additions & 13 deletions src/hamiltonian.F90
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,6 @@ subroutine hamiltonian_write_rmn()

complex(kind=dp) :: fac
real(kind=dp) :: rdotk
real(kind=dp) :: delta
integer :: loop_rpt, m, n, nkp, ind, nn, file_unit
complex(kind=dp) :: position(3)
character (len=33) :: header
Expand All @@ -633,29 +632,40 @@ subroutine hamiltonian_write_rmn()
header='written on '//cdate//' at '//ctime
write(file_unit,*) header ! Date and time
write(file_unit,*) num_wann
write(file_unit,*) nrpts

do loop_rpt=1,nrpts
do m=1,num_wann
do n=1,num_wann
delta=0._dp
if (m.eq.n) delta=1._dp
position(:)=0._dp
do nkp=1,num_kpts
rdotk=twopi*dot_product(kpt_latt(:,nkp),real(irvec(:,loop_rpt),dp))
fac=exp(-cmplx_i*rdotk)/real(num_kpts,dp)
do ind = 1, 3
do nn = 1, nntot
! Eq. C16 of Marzari and Vanderbilt PRB 56, 12847 (1997) !
position(ind) = position(ind) + &
wb(nn) * bk(ind,nn,nkp) * (m_matrix(n,m,nn,nkp) - delta) * fac
if(m.eq.n) then
! For loop_rpt==rpt_origin, this reduces to
! Eq.(32) of Marzari and Vanderbilt PRB 56,
! 12847 (1997). Otherwise, is is Eq.(44)
! Wang, Yates, Souza and Vanderbilt PRB 74,
! 195118 (2006), modified according to
! Eqs.(27,29) of Marzari and Vanderbilt
position(ind)=position(ind) - &
wb(nn)*bk(ind,nn,nkp)*aimag(log(m_matrix(n,m,nn,nkp)))*fac
else
! Eq.(44) Wang, Yates, Souza and Vanderbilt PRB 74, 195118 (2006)
position(ind)=position(ind) + &
cmplx_i*wb(nn)*bk(ind,nn,nkp)*m_matrix(n,m,nn,nkp)*fac
endif
end do
end do
end do
write( file_unit ,'(5I5,6F12.6)') irvec(:,loop_rpt),n,m,cmplx_i*position(:)
end do
write( file_unit ,'(5I5,6F12.6)') irvec(:,loop_rpt),n,m,position(:)
end do
end do
end do



close(file_unit)

return
Expand Down Expand Up @@ -686,7 +696,7 @@ subroutine hamiltonian_write_tb()
character (len=33) :: header
character (len=9) :: cdate,ctime
complex(kind=dp) :: fac,pos_r(3)
real(kind=dp) :: rdotk,delta
real(kind=dp) :: rdotk

if (tb_written) return

Expand Down Expand Up @@ -728,8 +738,6 @@ subroutine hamiltonian_write_tb()
write(file_unit,'(/,3I5)') irvec(:,irpt)
do i=1,num_wann
do j=1,num_wann
delta=0._dp
if (i==j) delta=1._dp
pos_r(:)=0._dp
do ik=1,num_kpts
rdotk=twopi*dot_product(kpt_latt(:,ik),real(irvec(:,irpt),dp))
Expand All @@ -748,7 +756,7 @@ subroutine hamiltonian_write_tb()
else
! Eq.(44) Wang, Yates, Souza and Vanderbilt PRB 74, 195118 (2006)
pos_r(idir)=pos_r(idir)+&
cmplx_i*wb(nn)*bk(idir,nn,ik)*(m_matrix(j,i,nn,ik)-delta)*fac
cmplx_i*wb(nn)*bk(idir,nn,ik)*m_matrix(j,i,nn,ik)*fac
endif
end do
end do
Expand Down

0 comments on commit 928a5bd

Please sign in to comment.