Commit 8b1387bc authored by Alberto Otero de la Roza's avatar Alberto Otero de la Roza Committed by giannozz

pw2critic & another fft_fact related bug fix for open_grid.x

parent a6b492f0
......@@ -57,7 +57,7 @@ TLDEPS= pwlibs
all : tldeps open_grid.x average.x bands.x dos.x epsilon.x initial_state.x fs.x \
plan_avg.x plotband.x plotproj.x plotrho.x pmw.x pp.x projwfc.x \
pawplot.x sumpdos.x pw2wannier90.x pw_export.x pw2gw.x \
pawplot.x sumpdos.x pw2wannier90.x pw2critic.x pw_export.x pw2gw.x \
wannier_ham.x wannier_plot.x molecularpdos.x \
pw2bgw.x wfck2r.x fermi_velocity.x fermi_proj.x
......@@ -141,6 +141,11 @@ pw2wannier90.x : pw2wannier90.o libpp.a $(MODULES) $(LIBOBJS)
pw2wannier90.o libpp.a $(MODULES) $(LIBOBJS) $(QELIBS)
- ( cd ../../bin ; ln -fs ../PP/src/$@ . )
pw2critic.x : pw2critic.o libpp.a $(MODULES) $(LIBOBJS)
$(LD) $(LDFLAGS) -o $@ \
pw2critic.o libpp.a $(MODULES) $(LIBOBJS) $(QELIBS)
- ( cd ../../bin ; ln -fs ../PP/src/$@ . )
wfck2r.x : wfck2r.o libpp.a $(MODULES) $(LIBOBJS)
$(LD) $(LDFLAGS) -o $@ \
wfck2r.o libpp.a $(MODULES) $(LIBOBJS) $(QELIBS)
......@@ -11,10 +11,12 @@ PROGRAM open_grid
USE lsda_mod, ONLY : nspin, isk
USE klist, ONLY : nks, nkstot, xk, wk, igk_k, ngk, qnorm
USE io_files, ONLY : prefix, tmp_dir, nwordwfc, iunwfc, diropn
USE noncollin_module, ONLY : noncolin
USE noncollin_module, ONLY : noncolin, m_loc
USE spin_orb, ONLY : domag
USE control_flags, ONLY : gamma_only, twfcollect
USE environment, ONLY : environment_start, environment_end
USE symm_base, ONLY : nrot, nsym, s, t_rev, fft_fact
USE ions_base, ONLY : nat, tau, ityp
USE symm_base, ONLY : nrot, nsym, s, t_rev, fft_fact, find_sym
USE parameters, ONLY : npk
USE exx_base, ONLY : nq1,nq2,nq3, xkq_collect, &
nkqs, exx_mp_init, index_xk, exx_grid_init
......@@ -39,6 +41,7 @@ PROGRAM open_grid
!USE qexsd_input, ONLY : qexsd_init_k_points_ibz
USE control_flags, ONLY : gamma_only, io_level
USE start_k, ONLY : init_start_k
USE extfield, ONLY : gate
......@@ -56,7 +59,7 @@ PROGRAM open_grid
CHARACTER(len=4) :: spin_component
CHARACTER(len=256) :: outdir
!INTEGER :: nq(3)
LOGICAL :: exst, opnd, exst_mem
LOGICAL :: exst, opnd, exst_mem, magnetic_sym
REAL(DP),ALLOCATABLE :: et0(:,:), wg0(:,:), yk(:,:), wk0(:)
INTEGER, EXTERNAL :: n_plane_waves
COMPLEX(DP),ALLOCATABLE :: psic(:), evx(:,:)
......@@ -129,8 +132,10 @@ PROGRAM open_grid
nq_back = (/ nq1, nq2, nq3 /)
exx_status_back = .true.
CALL dft_force_hybrid(exx_status_back)
fft_fact = 1
magnetic_sym = noncolin .AND. domag
CALL find_sym ( nat, tau, ityp, magnetic_sym, m_loc, gate )
nq1 = -1
nq2 = -1
nq3 = -1
! Copyright (C) 2001-2009 Quantum ESPRESSO group
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or .
! This program writes the structure and wavefunction to a binary file
! (with extension pwc) read by critic2. At present, this is used
! in combination with the output of wannier90 in the calculation of
! delocalization indices via maximally localized Wannier functions
! (
! Preferred use: with norm-conserving pseudos, since critic2 will not
! know about the transformation near the atoms. Some notes:
! - The density in critic2 won't match exactly the one generated by
! pp.x in general because QE symmetrizes the contributions in
! reciprocal space (see the sym_rho subroutine in
! PW/src/symme.f90). critic2 will not do this, so the densities will
! be slightly different, but nothing too bad in general. If you
! still feel uneasy about it, use nosym=.true. in the calculation.
! - Non-colinear case not supported.
! - Right now, pw2critic only works in serial mode (no mpirun xx)
! and the SCF calculation needs to be run with wf_collect=.true.
! Input: only one namelist (&inputpp) with variables:
! - outdir - the output directory.
! - prefix - the prefix for the SCF calculation.
! - seedname - the prefix for the generated pwc file
! - smoothgrid - if .true., write the smooth grid dimensions.
! (default:.false.)
! TODO: handle parallelization.
! Contact: Alberto Otero de la Roza <>
PROGRAM pw2critic
USE io_global, ONLY : ionode, ionode_id
USE mp_global, ONLY : mp_startup
USE wavefunctions, ONLY: evc
USE wvfct, ONLY: nbnd, npwx, et, wg
USE gvecs, ONLY: ngms
USE mp, ONLY : mp_bcast
USE mp_world, ONLY : world_comm, nproc
USE cell_base, ONLY : at, alat
USE ions_base, ONLY: nat, nsp, atm, ityp, tau
USE lsda_mod, ONLY : nspin
USE klist, ONLY : nkstot, ngk, igk_k, wk, xk
USE fft_base, ONLY: dffts, dfftp
USE io_files, ONLY : prefix, tmp_dir, nwordwfc, iunwfc
USE control_flags, ONLY : gamma_only, twfcollect
USE environment, ONLY : environment_start, environment_end
USE start_k, ONLY : nk1, nk2, nk3
INTEGER, EXTERNAL :: find_free_unit
CHARACTER(LEN=256), EXTERNAL :: trimcheck
INTEGER :: ios, i, j, ibnd, ik, is, lu1, n1, n2, n3, nk, npw
CHARACTER(len=256) :: outdir, seedname
logical :: smoothgrid
NAMELIST /inputpp/ outdir, prefix, seedname, smoothgrid
! initialise environment
#if defined(__MPI)
CALL mp_startup()
if (nproc /= 1) &
CALL errore('pw2wannier90','pw2critic only works with 1 processor',1)
CALL environment_start('PW2CRITIC')
! read the input variables
ios = 0
IF(ionode) THEN
CALL input_from_file()
CALL get_environment_variable( 'ESPRESSO_TMPDIR', outdir )
IF (trim(outdir) == ' ' ) outdir = './'
prefix = ' '
seedname = 'wannier'
smoothgrid = .false.
READ (5, inputpp, iostat=ios)
tmp_dir = trimcheck(outdir)
! broadcast to all processors
CALL mp_bcast(ios, ionode_id, world_comm)
IF (ios /= 0) CALL errore('pw2critic','reading inputpp namelist',abs(ios))
CALL mp_bcast(outdir, ionode_id, world_comm)
CALL mp_bcast(tmp_dir, ionode_id, world_comm)
CALL mp_bcast(prefix, ionode_id, world_comm)
CALL mp_bcast(seedname, ionode_id, world_comm)
CALL mp_bcast(smoothgrid, ionode_id, world_comm)
! read the calculation info
CALL read_file()
if (.not.twfcollect) &
CALL errore('pw2critic','pw2critic requires wf_collect=.true. in the nscf calculation', 1)
CALL openfil_pp()
IF (nspin > 2) &
CALL errore('pw2critic','nspin > 2 not implemented',1)
nk = nkstot / nspin
! open the pwc file
lu1 = find_free_unit()
! header and structural info
WRITE (lu1) 1 ! version number
WRITE (lu1) nsp, nat
WRITE (lu1) atm(1:nsp)
WRITE (lu1) ityp(1:nat)
WRITE (lu1) tau(:,1:nat) * alat
WRITE (lu1) at(1:3,1:3) * alat
! global info for the wavefunction
write (lu1) nk, nbnd, nspin, gamma_only
write (lu1) nk1, nk2, nk3
if (smoothgrid) then
write (lu1) dffts%nr1, dffts%nr2, dffts%nr3
write (lu1) dfftp%nr1, dfftp%nr2, dfftp%nr3
end if
write (lu1) npwx, ngms
! k-point information in nspin==2, these are doubled (nkstot = 2 *
! nk), but it seems to be a convention in the rest of the code that
! xk(:,1:nk) is the same as xk(:,nk+1:nkstot), so I write only the
! relevant part of it
write (lu1) xk(:,1:nk)
write (lu1) wk(1:nk)
! Band energies (in Ry) and occupations. 1->nk is spin up and nk+1
! -> nkstot is spin down. The occupations (wg) already factor in the
! k-point weights (wk).
write (lu1) et(1:nbnd,1:nkstot)
write (lu1) wg(1:nbnd,1:nkstot)
! k-point mapping
write (lu1) ngk(1:nk)
write (lu1) igk_k(1:npwx,1:nk)
if (smoothgrid) then
write (lu1) dffts%nl
if (gamma_only) then
write (lu1) dffts%nlm
end if
write (lu1) dfftp%nl
if (gamma_only) then
write (lu1) dfftp%nlm
end if
end if
! KS state coefficients. Note the loop over nkstot writes both
! spins if nspin == 2.
do ik = 1, nkstot
npw = ngk(ik)
call davcio(evc, 2*nwordwfc, iunwfc, ik, -1 )
do ibnd = 1, nbnd
write (lu1) evc(1:npw,ibnd)
end do
end DO
! clean up and exit
CALL environment_end('PW2CRITIC')
CALL stop_pp()
END PROGRAM pw2critic
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment