subroutine tran_write_xyz()
!=====================================!
! !
! Write xyz file with Wannier centres !
! and atomic positions !
! !
!=====================================!
use w90_io, only: seedname, io_file_unit, io_date, stdout
use w90_parameters, only: num_wann, &
atoms_pos_cart, atoms_symbol, num_species, &
atoms_species_num, num_atoms, transport_mode
use w90_hamiltonian, only: wannier_centres_translated
implicit none
integer :: iw, ind, xyz_unit, nat, nsp
character(len=9) :: cdate, ctime
real(kind=dp) :: wc(3, num_wann)
if (index(transport_mode, 'bulk') > 0) wc = wannier_centres_translated
if (index(transport_mode, 'lcr') > 0) then
do iw = 1, num_wann
wc(:, iw) = wannier_centres_translated(:, tran_sorted_idx(iw))
enddo
endif
xyz_unit = io_file_unit()
open (xyz_unit, file=trim(seedname)//'_centres.xyz', form='formatted')
!
write (xyz_unit, '(i6)') num_wann + num_atoms
!
call io_date(cdate, ctime)
write (xyz_unit, '(a84)') 'Wannier centres and atomic positions, written by Wannier90 on '//cdate//' at '//ctime
!
do iw = 1, num_wann
write (xyz_unit, '("X",6x,3(f14.8,3x))') (wc(ind, iw), ind=1, 3)
end do
do nsp = 1, num_species
do nat = 1, atoms_species_num(nsp)
write (xyz_unit, '(a2,5x,3(f14.8,3x))') atoms_symbol(nsp), atoms_pos_cart(:, nat, nsp)
end do
end do
write (stdout, *) ' Wannier centres written to file '//trim(seedname)//'_centres.xyz'
return
end subroutine tran_write_xyz