Some k-point cleanup. No warranty it works: I don't have the possibility to

make extensive tests now. 


git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@8051 c92efa57-630b-4861-b058-cf58834340f0
This commit is contained in:
giannozz 2011-08-05 16:05:06 +00:00
parent 56ff1e29e6
commit 4a1c59d710
8 changed files with 81 additions and 158 deletions

View File

@ -396,8 +396,8 @@ SUBROUTINE compute_scf( fii, lii, stat )
!
END IF
!
! ... input values are restored at the end of each iteration ( they are
! ... modified by init_run )
! ... input values are restored at the end of each iteration
! ... ( they are modified by init_run ) - OBSOLETE?
!
! starting_pot = 'atomic'
! starting_wfc = 'file'
@ -405,7 +405,6 @@ SUBROUTINE compute_scf( fii, lii, stat )
ethr = diago_thr_init
!
CALL close_files(.FALSE.)
CALL reset_k_points ( )
!
RETURN
!

View File

@ -24,7 +24,7 @@ SUBROUTINE phq_readin()
USE mp, ONLY : mp_bcast
USE ions_base, ONLY : amass, pmass, atm
USE input_parameters, ONLY : max_seconds, nk1, nk2, nk3, k1, k2, k3
USE start_k, ONLY : init_start_grid
USE start_k, ONLY : reset_grid
USE klist, ONLY : xk, nks, nkstot, lgauss, two_fermi_energies, lgauss
USE ktetra, ONLY : ltetra
USE control_flags, ONLY : gamma_only, tqr, restart, lkpoint_dir
@ -364,7 +364,7 @@ SUBROUTINE phq_readin()
! read from input (this happens if nk1*nk2*nk3, else it returns .false.,
! leaves the current values, as read in read_file, unchanged)
!
newgrid = init_start_grid (nk1, nk2, nk3, k1, k2, k3)
newgrid = reset_grid (nk1, nk2, nk3, k1, k2, k3)
!
tmp_dir=tmp_dir_save
!

View File

@ -155,7 +155,6 @@ read_pseudo.o \
regterg.o \
remove_atomic_rho.o \
report_mag.o \
reset_k_points.o \
restart_from_file.o \
restart_in_electrons.o \
restart_in_ions.o \

View File

@ -1483,16 +1483,7 @@ SUBROUTINE read_cards_pw ( psfile, tau_format )
trd_ht, f_inp, rd_for, tavel, sp_vel
USE cell_base, ONLY : at, ibrav, symm_type
USE ions_base, ONLY : nat, ntyp => nsp, ityp, tau, atm, extfor
USE start_k, ONLY : nk1_ => nk1, &
nk2_ => nk2, &
nk3_ => nk3, &
k1_ => k1, &
k2_ => k2, &
k3_ => k3
USE klist, ONLY : nkstot_ => nkstot, &
lxkcry, &
xk_ => xk, &
wk_ => wk
USE start_k, ONLY : init_start_k
USE fixed_occ, ONLY : tfixed_occ, &
f_inp_ => f_inp
USE ions_base, ONLY : if_pos_ => if_pos, amass, fixatom
@ -1556,12 +1547,12 @@ SUBROUTINE read_cards_pw ( psfile, tau_format )
!
tau_format = trim( atomic_positions )
!
CALL reset_k_points ( )
CALL init_start_k ( nk1, nk2, nk3, k1, k2, k3, k_points, nkstot, xk, wk )
gamma_only = ( k_points == 'gamma' )
!
IF ( tfixed_occ ) THEN
!
IF ( nkstot_ > 1 .or. ( nk1 * nk2 * nk3 ) > 1 ) &
IF ( nkstot > 1 .or. ( nk1 * nk2 * nk3 ) > 1 ) &
CALL errore( 'read_cards_pw', &
& 'only one k point with fixed occupations', 1 )
!

View File

@ -1260,9 +1260,6 @@ report_mag.o : ../Modules/kind.o
report_mag.o : noncol.o
report_mag.o : pwcom.o
report_mag.o : scf_mod.o
reset_k_points.o : ../Modules/input_parameters.o
reset_k_points.o : pwcom.o
reset_k_points.o : start_k.o
restart_from_file.o : ../Modules/control_flags.o
restart_from_file.o : ../Modules/io_files.o
restart_from_file.o : ../Modules/io_global.o

View File

@ -1,84 +0,0 @@
!
! Copyright (C) 2001-2008 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 http://www.gnu.org/copyleft/gpl.txt .
!
!-------------------------------------------------------------------------------
SUBROUTINE reset_k_points()
!-----------------------------------------------------------------------------
! ... Copy input data for k-points into internal variables
! ... Used both at startup and in neb/strings calculations
!
USE start_k, ONLY : nk1_ => nk1, &
nk2_ => nk2, &
nk3_ => nk3, &
k1_ => k1, &
k2_ => k2, &
k3_ => k3
USE klist, ONLY : lxkcry, &
xk_ => xk, &
wk_ => wk, &
nkstot_ => nkstot
USE input_parameters, ONLY : k_points, xk, wk, nk1, nk2, nk3, &
k1, k2, k3, nkstot
!
IMPLICIT NONE
!
nk1_ = 0
nk2_ = 0
nk3_ = 0
k1_ = 0
k2_ = 0
k3_ = 0
lxkcry = .FALSE.
!
IF ( k_points == 'automatic' ) THEN
!
! ... automatic generation of k-points
!
nkstot_ = 0
nk1_ = nk1
nk2_ = nk2
nk3_ = nk3
k1_ = k1
k2_ = k2
k3_ = k3
!
ELSE IF ( k_points == 'tpiba' ) THEN
!
! ... input k-points are in 2pi/a units
!
nkstot_ = nkstot
xk_(:,1:nkstot_) = xk(:,1:nkstot_)
wk_(1:nkstot_) = wk(1:nkstot_)
!
ELSE IF ( k_points == 'crystal' ) THEN
!
! ... input k-points are in crystal (reciprocal lattice) axis
!
lxkcry = .TRUE.
nkstot_ = nkstot
xk_(:,1:nkstot_) = xk(:,1:nkstot_)
wk_(1:nkstot_) = wk(1:nkstot_)
!
ELSE IF ( k_points == 'gamma' ) THEN
!
! ... Only Gamma (k=0) is used
!
nkstot_ = 1
xk_(:,1) = 0.0d0
wk_(1) = 1.0d0
!
ELSE
!
! ... default: input k-points are in 2pi/a units
!
nkstot_ = nkstot
xk_(:,1:nkstot_) = xk(:,1:nkstot_)
wk_(1:nkstot_) = wk(1:nkstot_)
!
END IF
!
END SUBROUTINE reset_k_points

View File

@ -90,7 +90,7 @@ SUBROUTINE setup()
!
IMPLICIT NONE
!
INTEGER :: na, nt, input_nks, is, ierr, ibnd, ik
INTEGER :: na, nt, is, ierr, ibnd, ik
LOGICAL :: magnetic_sym
REAL(DP) :: iocc, ionic_charge
!
@ -106,7 +106,7 @@ SUBROUTINE setup()
#if ! defined (EXX)
IF ( dft_is_hybrid() ) CALL errore( 'setup ', &
'HYBRID XC not implemented in PWscf', 1 )
'PWscf not compiled for hybrid functionals', 1 )
#else
IF ( dft_is_hybrid() ) THEN
IF (.NOT. lscf) CALL errore( 'setup ', &
@ -409,10 +409,6 @@ SUBROUTINE setup()
!
CALL realspace_grids_init ( dfftp, dffts, at, bg, gcutm, gcutms )
!
! DCC
! IF( do_coarse ) CALL set_fft_dim_coarse()
! IF( do_mltgrid ) CALL set_mltgrid_dim()
!
! ... generate transformation matrices for the crystal point group
! ... First we generate all the symmetry matrices of the Bravais lattice
!
@ -431,15 +427,9 @@ SUBROUTINE setup()
magnetic_sym = noncolin .AND. domag
time_reversal = .NOT. noinv .AND. .NOT. magnetic_sym
!
! ... If lxkcry = .TRUE. , the input k-point components in crystal
! ... axis are transformed into cartesian coordinates - done here
! ... and not in input because the reciprocal lattice is needed
!
IF ( lxkcry .AND. nkstot > 0 ) CALL cryst_to_cart( nkstot, xk, bg, 1 )
!
! ... Automatic generation of k-points (if required)
!
IF ( nkstot == 0 ) THEN
IF ( nks_start == 0 ) THEN
!
IF (lelfield) THEN
!
@ -464,17 +454,19 @@ SUBROUTINE setup()
!
END IF
!
ELSE IF( lelfield) THEN
ELSE
nkstot = nks_start
xk(:,1:nkstot) = xk_start(:,1:nks_start)
wk(1:nkstot) = wk_start(1:nks_start)
!
IF( lelfield) THEN
!
allocate(nx_el(nkstot*nspin,3))
! <AF>
IF ( gdir<0 .OR. gdir>3 ) CALL errore('setup','invalid gdir value',10)
IF ( gdir == 0 ) CALL errore('setup','needed gdir probably not set',10)
!
do ik=1,nkstot
nx_el(ik,gdir)=ik
enddo
!
nx_el(1:nkstot,gdir)=ik
if(nspin==2) nx_el(nkstot+1:2*nkstot,:) = nx_el(1:nkstot,:) + nkstot
nppstr_3d(gdir)=nppstr
l3dstring=.false.
@ -483,15 +475,6 @@ SUBROUTINE setup()
nsym = 1
!
END IF
!
! Save the initial k point for phonon calculation
!
IF (nks_start==0) THEN
nks_start=nkstot
IF ( .NOT. ALLOCATED( xk_start ) ) ALLOCATE( xk_start( 3, nks_start ) )
IF ( .NOT. ALLOCATED( wk_start ) ) ALLOCATE( wk_start( nks_start ) )
xk_start(:,:)=xk(:,1:nkstot)
wk_start(:)=wk(1:nkstot)
END IF
!
IF ( nat==0 ) THEN
@ -515,7 +498,6 @@ SUBROUTINE setup()
.AND. .NOT. ( calc == 'mm' .OR. calc == 'nm' ) ) &
CALL infomsg( 'setup', 'Dynamics, you should have no symmetries' )
!
input_nks = nkstot
IF ( nat > 0 ) THEN
!
! ... Input k-points are assumed to be given in the IBZ of the Bravais
@ -535,7 +517,7 @@ SUBROUTINE setup()
! ... if calculating bands, we leave k-points unchanged and read the
! Fermi energy
!
nkstot = input_nks
nkstot = nks_start
CALL pw_readfile( 'reset', ierr )
CALL pw_readfile( 'ef', ierr )
CALL errore( 'setup ', 'problem reading ef from file ' // &

View File

@ -9,9 +9,10 @@
!
MODULE start_k
!
! ... Basic variables for k-points generations, as read from input
! ... Basic variables for k-point generations, as read from input
!
USE kinds, ONLY : DP
USE cell_base, ONLY : bg
!
SAVE
!
@ -22,17 +23,54 @@ MODULE start_k
k1, k2, k3 ! the offset from the origin
!
!
! ... list of k-points and weights
! ... k points and weights, read from input, if any
!
INTEGER :: nks_start=0 ! number of initial k points
REAL(DP), ALLOCATABLE :: wk_start(:)
! initial weight of k points
REAL(DP), ALLOCATABLE :: xk_start(:,:)
! initial coordinates of k points
INTEGER :: nks_start=0 ! number of k points
REAL(DP), ALLOCATABLE :: wk_start(:) ! weights of k points
REAL(DP), ALLOCATABLE :: xk_start(:,:) ! coordinates of k points
CONTAINS
LOGICAL FUNCTION init_start_grid ( nk1_, nk2_, nk3_, k1_, k2_, k3_ )
SUBROUTINE init_start_k ( nk1_, nk2_, nk3_, k1_, k2_, k3_, &
k_points, nk_, xk_, wk_ )
!
! initialize the grid of k points
!
INTEGER, INTENT (IN) :: nk1_, nk2_, nk3_, k1_, k2_, k3_, nk_
CHARACTER(LEN=*), INTENT (IN) :: k_points
REAL(dp),INTENT (IN) :: xk_(3,nk_), wk_(nk_)
!
LOGICAL :: done
!
! variables for automatic grid
!
nk1 = 0; nk2 = 0; nk3 = 0; k1 = 0; k2 = 0; k3 = 0
done = reset_grid ( nk1_, nk2_, nk3_, k1_, k2_, k3_ )
IF ( k_points == 'automatic' .AND. .not. done ) &
CALL errore ('init_start_k','automatic k-points and nk*=0?',1)
!
! variables for manual grid
!
nks_start = nk_
IF ( nks_start > 0) THEN
IF ( .NOT. ALLOCATED (xk_start) ) ALLOCATE ( xk_start(3,nks_start) )
IF ( .NOT. ALLOCATED (wk_start) ) ALLOCATE ( wk_start(nks_start) )
!
! k-points in crystal axis: transform to cartesian (in unist 2pi/a)
! BEWARE: reciprocal axis bg NEEDED, must have been initialized
!
IF ( k_points == 'crystal' ) CALL cryst_to_cart(nk_, xk_, bg, 1)
!
xk_start(:,:) = xk_(:,1:nk_)
wk_start(:) = wk_(1:nk_)
END IF
!
END SUBROUTINE init_start_k
!
LOGICAL FUNCTION reset_grid ( nk1_, nk2_, nk3_, k1_, k2_, k3_ )
!
! reset the automatic grid to new values if these are > 0
!
INTEGER, INTENT (IN) :: nk1_, nk2_, nk3_, k1_, k2_, k3_
!
IF ( nk1_ > 0 ) nk1 = nk1_
@ -41,8 +79,9 @@ MODULE start_k
IF ( k1_ > 0 ) k1 = k1_
IF ( k2_ > 0 ) k2 = k2_
IF ( k3_ > 0 ) k3 = k3_
init_start_grid = (nk1_*nk2_*nk3_ > 0)
!
END FUNCTION init_start_grid
reset_grid = (nk1_*nk2_*nk3_ > 0)
!
END FUNCTION reset_grid
END MODULE start_k