2003-01-20 05:58:50 +08:00
|
|
|
!
|
2015-10-20 03:49:51 +08:00
|
|
|
! Copyright (C) 2001-2015 Quantum ESPRESSO group
|
2003-01-20 05:58:50 +08:00
|
|
|
! 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 .
|
|
|
|
!
|
2011-08-08 03:37:01 +08:00
|
|
|
!=----------------------------------------------------------------------------=!
|
|
|
|
MODULE read_pseudo_mod
|
|
|
|
!=----------------------------------------------------------------------------=!
|
|
|
|
!
|
2015-10-20 03:49:51 +08:00
|
|
|
! read pseudopotential files. Note that all processors read the same file!
|
|
|
|
!
|
|
|
|
! Required on input:
|
2011-08-08 03:37:01 +08:00
|
|
|
USE io_files, ONLY: pseudo_dir, pseudo_dir_cur, psfile
|
2011-08-08 16:44:31 +08:00
|
|
|
USE ions_base, ONLY: ntyp => nsp
|
2015-10-20 03:49:51 +08:00
|
|
|
! Modified on output:
|
2011-08-08 03:37:01 +08:00
|
|
|
USE atom, ONLY: msh, rgrid
|
2011-08-08 16:44:31 +08:00
|
|
|
USE ions_base, ONLY: zv
|
2011-08-08 03:37:01 +08:00
|
|
|
USE uspp_param, ONLY: upf, newpseudo, oldvan, nvb
|
|
|
|
USE uspp, ONLY: okvan, nlcc_any
|
|
|
|
|
|
|
|
IMPLICIT NONE
|
|
|
|
SAVE
|
|
|
|
PRIVATE
|
|
|
|
!
|
2011-08-08 16:44:31 +08:00
|
|
|
PUBLIC :: readpp, check_order
|
2011-08-08 03:37:01 +08:00
|
|
|
!
|
|
|
|
CONTAINS
|
|
|
|
!
|
|
|
|
!-----------------------------------------------------------------------
|
2015-10-20 03:49:51 +08:00
|
|
|
SUBROUTINE readpp ( input_dft, printout, ecutwfc_pp, ecutrho_pp )
|
2003-01-20 05:58:50 +08:00
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
!
|
2015-10-20 03:49:51 +08:00
|
|
|
! Reads PP files and puts the result into the "upf" structure
|
|
|
|
! Sets DFT to input_dft if present, to the value read in PP files otherwise
|
|
|
|
! Sets number of valence electrons Zv, control variables okvan and nlcc_any,
|
|
|
|
! compatibility variables newpseudo, oldvan, nvb
|
|
|
|
! Optionally returns cutoffs read from PP files into ecutwfc_pp, ecutrho_pp
|
2011-08-08 16:44:31 +08:00
|
|
|
!
|
2011-08-08 03:37:01 +08:00
|
|
|
USE kinds, ONLY: DP
|
2013-10-09 16:17:40 +08:00
|
|
|
USE mp, ONLY: mp_bcast, mp_sum
|
2014-01-13 18:08:27 +08:00
|
|
|
USE mp_images, ONLY: intra_image_comm
|
2011-08-08 16:44:31 +08:00
|
|
|
USE io_global, ONLY: stdout, ionode
|
2011-08-08 03:37:01 +08:00
|
|
|
USE pseudo_types, ONLY: pseudo_upf, nullify_pseudo_upf, deallocate_pseudo_upf
|
|
|
|
USE funct, ONLY: enforce_input_dft, &
|
|
|
|
get_iexch, get_icorr, get_igcx, get_igcc, get_inlc
|
|
|
|
use radial_grids, ONLY: deallocate_radial_grid, nullify_radial_grid
|
|
|
|
USE wrappers, ONLY: md5_from_file
|
|
|
|
USE upf_module, ONLY: read_upf
|
|
|
|
USE upf_to_internal, ONLY: set_pseudo_upf
|
|
|
|
USE read_uspp_module, ONLY: readvan, readrrkj
|
2015-06-12 16:24:39 +08:00
|
|
|
USE m_gth, ONLY: readgth
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2011-08-08 03:37:01 +08:00
|
|
|
IMPLICIT NONE
|
2004-06-12 21:44:18 +08:00
|
|
|
!
|
2011-08-08 03:37:01 +08:00
|
|
|
CHARACTER(len=*), INTENT(INOUT) :: input_dft
|
2011-08-08 16:44:31 +08:00
|
|
|
LOGICAL, OPTIONAL, INTENT(IN) :: printout
|
2015-10-20 03:49:51 +08:00
|
|
|
REAL(DP), OPTIONAL, INTENT(OUT) :: ecutwfc_pp, ecutrho_pp
|
2006-03-14 18:59:14 +08:00
|
|
|
!
|
2011-08-08 03:37:01 +08:00
|
|
|
REAL(DP), parameter :: rcut = 10.d0
|
|
|
|
CHARACTER(len=256) :: file_pseudo ! file name complete with path
|
2011-08-08 16:44:31 +08:00
|
|
|
LOGICAL :: printout_ = .FALSE.
|
2011-08-08 03:37:01 +08:00
|
|
|
INTEGER :: iunps, isupf, nt, nb, ir, ios
|
|
|
|
INTEGER :: iexch_, icorr_, igcx_, igcc_, inlc_
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2011-08-08 03:37:01 +08:00
|
|
|
! ... initialization: allocate radial grids etc
|
2011-06-05 16:37:47 +08:00
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
iunps = 4
|
2008-04-27 16:58:55 +08:00
|
|
|
IF( ALLOCATED( rgrid ) ) THEN
|
|
|
|
DO nt = 1, SIZE( rgrid )
|
|
|
|
CALL deallocate_radial_grid( rgrid( nt ) )
|
|
|
|
CALL nullify_radial_grid( rgrid( nt ) )
|
|
|
|
END DO
|
|
|
|
DEALLOCATE( rgrid )
|
2011-12-12 23:33:48 +08:00
|
|
|
if(allocated(msh)) DEALLOCATE( msh )
|
2008-04-27 16:58:55 +08:00
|
|
|
END IF
|
|
|
|
|
|
|
|
ALLOCATE( rgrid( ntyp ), msh( ntyp ) )
|
|
|
|
|
|
|
|
DO nt = 1, ntyp
|
|
|
|
CALL nullify_radial_grid( rgrid( nt ) )
|
|
|
|
END DO
|
|
|
|
|
2007-10-08 01:34:26 +08:00
|
|
|
IF( ALLOCATED( upf ) ) THEN
|
|
|
|
DO nt = 1, SIZE( upf )
|
|
|
|
CALL deallocate_pseudo_upf( upf( nt ) )
|
|
|
|
CALL nullify_pseudo_upf( upf( nt ) )
|
|
|
|
END DO
|
|
|
|
DEALLOCATE( upf )
|
|
|
|
END IF
|
2008-04-27 16:58:55 +08:00
|
|
|
!
|
|
|
|
ALLOCATE ( upf( ntyp ) )
|
|
|
|
!
|
|
|
|
! nullify upf objects as soon as they are instantiated
|
|
|
|
!
|
|
|
|
do nt = 1, ntyp
|
2008-04-23 23:58:35 +08:00
|
|
|
CALL nullify_pseudo_upf( upf( nt ) )
|
2008-04-27 16:58:55 +08:00
|
|
|
end do
|
2011-08-08 03:37:01 +08:00
|
|
|
!
|
2011-08-08 16:44:31 +08:00
|
|
|
IF (input_dft /='none') CALL enforce_input_dft (input_dft)
|
|
|
|
!
|
|
|
|
IF ( PRESENT(printout) ) THEN
|
2015-10-20 03:49:51 +08:00
|
|
|
printout_ = printout .AND. ionode
|
2011-08-08 16:44:31 +08:00
|
|
|
END IF
|
2015-10-20 03:49:51 +08:00
|
|
|
IF ( printout_) THEN
|
2011-08-08 16:44:31 +08:00
|
|
|
WRITE( stdout,"(//,3X,'Atomic Pseudopotentials Parameters',/, &
|
|
|
|
& 3X,'----------------------------------' )" )
|
|
|
|
END IF
|
2011-08-08 03:37:01 +08:00
|
|
|
!
|
|
|
|
nvb = 0
|
2008-04-27 16:58:55 +08:00
|
|
|
do nt = 1, ntyp
|
2004-01-06 02:11:01 +08:00
|
|
|
!
|
2011-08-08 03:37:01 +08:00
|
|
|
! variables not necessary for USPP, but necessary for PAW;
|
|
|
|
! will be read from file if it is a PAW dataset.
|
2004-01-06 02:11:01 +08:00
|
|
|
!
|
2007-08-12 08:08:53 +08:00
|
|
|
rgrid(nt)%xmin = 0.d0
|
|
|
|
rgrid(nt)%dx = 0.d0
|
2006-03-06 21:31:27 +08:00
|
|
|
!
|
2011-08-07 15:25:02 +08:00
|
|
|
! try first pseudo_dir_cur if set: in case of restart from file,
|
|
|
|
! this is where PP files should be located
|
2006-03-06 21:31:27 +08:00
|
|
|
!
|
2011-08-07 15:25:02 +08:00
|
|
|
ios = 1
|
|
|
|
IF ( pseudo_dir_cur /= ' ' ) THEN
|
|
|
|
file_pseudo = TRIM (pseudo_dir_cur) // TRIM (psfile(nt))
|
2011-08-08 03:37:01 +08:00
|
|
|
OPEN (unit = iunps, file = file_pseudo, status = 'old', &
|
|
|
|
form = 'formatted', action='read', iostat = ios)
|
2014-01-13 18:08:27 +08:00
|
|
|
CALL mp_sum (ios,intra_image_comm)
|
2011-08-07 15:25:02 +08:00
|
|
|
IF ( ios /= 0 ) CALL infomsg &
|
|
|
|
('readpp', 'file '//TRIM(file_pseudo)//' not found')
|
|
|
|
!
|
|
|
|
! file not found? no panic (yet): if the restart file is not visible
|
|
|
|
! to all processors, this may happen. Try the original location
|
|
|
|
END IF
|
2010-08-13 18:53:51 +08:00
|
|
|
!
|
2011-08-07 15:25:02 +08:00
|
|
|
! try the original location pseudo_dir, as set in input
|
2012-03-15 04:10:06 +08:00
|
|
|
! (it should already contain a slash at the end)
|
2003-08-21 00:16:26 +08:00
|
|
|
!
|
2011-08-07 15:25:02 +08:00
|
|
|
IF ( ios /= 0 ) THEN
|
|
|
|
file_pseudo = TRIM (pseudo_dir) // TRIM (psfile(nt))
|
|
|
|
OPEN (unit = iunps, file = file_pseudo, status = 'old', &
|
|
|
|
form = 'formatted', action='read', iostat = ios)
|
2014-01-13 18:08:27 +08:00
|
|
|
CALL mp_sum (ios,intra_image_comm)
|
2011-08-07 15:25:02 +08:00
|
|
|
CALL errore('readpp', 'file '//TRIM(file_pseudo)//' not found',ABS(ios))
|
|
|
|
END IF
|
2006-03-06 21:31:27 +08:00
|
|
|
!
|
2011-08-08 03:37:01 +08:00
|
|
|
upf(nt)%grid => rgrid(nt)
|
|
|
|
!
|
|
|
|
! start reading - UPF first: the UPF format is detected via the
|
2006-03-06 21:31:27 +08:00
|
|
|
! presence of the keyword '<PP_HEADER>' at the beginning of the file
|
|
|
|
!
|
2015-10-20 03:49:51 +08:00
|
|
|
IF( printout_ ) THEN
|
2011-08-08 16:44:31 +08:00
|
|
|
WRITE( stdout, "(/,3X,'Reading pseudopotential for specie # ',I2, &
|
|
|
|
& ' from file :',/,3X,A)") nt, TRIM(file_pseudo)
|
|
|
|
END IF
|
|
|
|
!
|
This is a quite complex check-in, but actually not very much is done. Changelog follows.
LP
UPF file format updated completely, UPFv2 introduced:
* ld1.x can still produce old format, with the switch upf_v1_format=.true. in inputp
this is disabled by default, but we can discuss if it should be the opposite.
* pw.x cp.x and all utilities should notice no difference
* some utilities in upftools still need to be updated, anyway conversion UPFv1 to UPFv2
is very easy, so this should be no big issue
* starting from now to produce an UPF file you need to fill the pseudo_upf derivedd type
and feed it to write_upf woutine in upf_module (Modules/upf.f90)
* extensive use of iotk
I have tried to make the new format as self contained as possible, e.g. there should be
minimal need for post-processing after the data is read, no more reconstruction of known
quantities, and no more odd syntax to save negligible quantity of space. Also the human
readable section is a bit richer, all the rest is more machine readable.
I hope this will not cause any throuble, and tried really hard to, all examples and all
tests works as fine as before and gives (what really looks like) the same results.
Other changes that I needed to make:
* radial grids are now allocatable, they management is a bit less of a hack too
* paw and uspp augmentation are stored in the same place
* paw print total all-electron energy if all atoms are paw, not very useful, but nice
* most of the pseudopotential-writing reading files have been renamed to some more
logical name, I spare you the list. E.g. read_oldpseudo -> read_pseudo_rrkj3
* paw_t derived type was only used in atomic, so I have put it there (as the pseudo_type
module take ages to recompile it was awkward to leave it there).
PAW tests inserted in test/ there are 6 of them, as a consequence I have also put 5 paw
pseudopotentials in the pseudo/ directory.
I will update the PAW scf examples soon, by deleting them (as running a pw with a PAW
pseudopotential requires no option at all). PAW generation examples should be updated.
A lot of small bugfixes here & there mostly uninitialized variables or unallocated
pointers used as subrotuine arguments.
git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@4769 c92efa57-630b-4861-b058-cf58834340f0
2008-04-03 23:50:43 +08:00
|
|
|
call read_upf(upf(nt), rgrid(nt), isupf, unit=iunps)
|
2006-03-06 21:31:27 +08:00
|
|
|
!
|
2015-06-12 16:24:39 +08:00
|
|
|
upf(nt)%is_gth=.false.
|
2011-08-08 03:37:01 +08:00
|
|
|
if (isupf ==-1 .OR. isupf== 0) then
|
|
|
|
!
|
2015-10-20 03:49:51 +08:00
|
|
|
IF( printout_ ) &
|
2011-08-29 22:06:12 +08:00
|
|
|
WRITE( stdout, "(3X,'file type is UPF v.',i1)") isupf+2
|
2007-10-06 16:23:39 +08:00
|
|
|
call set_pseudo_upf (nt, upf(nt))
|
2007-10-29 18:20:01 +08:00
|
|
|
!
|
|
|
|
! UPF is assumed to be multi-projector
|
|
|
|
!
|
2006-03-06 21:31:27 +08:00
|
|
|
newpseudo (nt) = .true.
|
2007-03-19 17:14:21 +08:00
|
|
|
!
|
2006-03-06 21:31:27 +08:00
|
|
|
else
|
2011-08-08 03:37:01 +08:00
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
rewind (unit = iunps)
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! The type of the pseudopotential is determined by the file name:
|
|
|
|
! *.vdb or *.van Vanderbilt US pseudopotential code pseudo_type=1
|
|
|
|
! *.RRKJ3 Andrea's US new code pseudo_type=2
|
2015-06-12 16:24:39 +08:00
|
|
|
! *.gth Goedecker-Teter-Hutter NC pseudo pseudo_type=3
|
2003-01-20 05:58:50 +08:00
|
|
|
! none of the above: PWSCF norm-conserving format pseudo_type=0
|
|
|
|
!
|
2004-01-06 18:53:30 +08:00
|
|
|
if ( pseudo_type (psfile (nt) ) == 1 .or. &
|
|
|
|
pseudo_type (psfile (nt) ) == 2 ) then
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2007-10-29 18:20:01 +08:00
|
|
|
! PPs produced by Andrea Dal Corso's atomic code are assumed to
|
|
|
|
! be multiprojector; NCPP produced by Vanderbilt's core are not
|
|
|
|
!
|
2006-03-06 21:31:27 +08:00
|
|
|
newpseudo (nt) = ( pseudo_type (psfile (nt) ) == 2 )
|
|
|
|
!
|
2007-10-03 00:54:13 +08:00
|
|
|
IF ( newpseudo (nt) ) THEN
|
2015-10-20 03:49:51 +08:00
|
|
|
IF( printout_ ) &
|
2011-08-08 16:44:31 +08:00
|
|
|
WRITE( stdout, "(3X,'file type is RRKJ3')")
|
The following pseudopotential-related variables in module uspp_param:
zp, psd, dion, betar, jjj, qqq, qfunc, qfcoef, vloc_at, rinner,
nbeta, kkbeta, nqf, nqlc, lll, tvanp
have been replaced by the corresponding variables in structure 'upf'.
There shouldn't be any side effects, but who knows. There is still a
copy of the above variables that will be removed sooner or later.
Basically : variable([i,j,k,..,]n) => upf(n)%variable [(i,j,k,..)]
Note that upf%qfunc has for the time being three indices instead of two,
and that upf%kkbeta is the analogous of kkbeta and not what it used to be.
The logic of this operation will be clearer when it will be completed
git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@4308 c92efa57-630b-4861-b058-cf58834340f0
2007-10-05 17:26:23 +08:00
|
|
|
call readrrkj (iunps, nt, upf(nt))
|
2007-10-03 00:54:13 +08:00
|
|
|
ELSE
|
2015-10-20 03:49:51 +08:00
|
|
|
IF( printout_ ) &
|
2011-08-08 16:44:31 +08:00
|
|
|
WRITE( stdout, "(3X,'file type is Vanderbilt US PP')")
|
The following pseudopotential-related variables in module uspp_param:
zp, psd, dion, betar, jjj, qqq, qfunc, qfcoef, vloc_at, rinner,
nbeta, kkbeta, nqf, nqlc, lll, tvanp
have been replaced by the corresponding variables in structure 'upf'.
There shouldn't be any side effects, but who knows. There is still a
copy of the above variables that will be removed sooner or later.
Basically : variable([i,j,k,..,]n) => upf(n)%variable [(i,j,k,..)]
Note that upf%qfunc has for the time being three indices instead of two,
and that upf%kkbeta is the analogous of kkbeta and not what it used to be.
The logic of this operation will be clearer when it will be completed
git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@4308 c92efa57-630b-4861-b058-cf58834340f0
2007-10-05 17:26:23 +08:00
|
|
|
CALL readvan (iunps, nt, upf(nt))
|
2007-10-03 00:54:13 +08:00
|
|
|
ENDIF
|
This is a quite complex check-in, but actually not very much is done. Changelog follows.
LP
UPF file format updated completely, UPFv2 introduced:
* ld1.x can still produce old format, with the switch upf_v1_format=.true. in inputp
this is disabled by default, but we can discuss if it should be the opposite.
* pw.x cp.x and all utilities should notice no difference
* some utilities in upftools still need to be updated, anyway conversion UPFv1 to UPFv2
is very easy, so this should be no big issue
* starting from now to produce an UPF file you need to fill the pseudo_upf derivedd type
and feed it to write_upf woutine in upf_module (Modules/upf.f90)
* extensive use of iotk
I have tried to make the new format as self contained as possible, e.g. there should be
minimal need for post-processing after the data is read, no more reconstruction of known
quantities, and no more odd syntax to save negligible quantity of space. Also the human
readable section is a bit richer, all the rest is more machine readable.
I hope this will not cause any throuble, and tried really hard to, all examples and all
tests works as fine as before and gives (what really looks like) the same results.
Other changes that I needed to make:
* radial grids are now allocatable, they management is a bit less of a hack too
* paw and uspp augmentation are stored in the same place
* paw print total all-electron energy if all atoms are paw, not very useful, but nice
* most of the pseudopotential-writing reading files have been renamed to some more
logical name, I spare you the list. E.g. read_oldpseudo -> read_pseudo_rrkj3
* paw_t derived type was only used in atomic, so I have put it there (as the pseudo_type
module take ages to recompile it was awkward to leave it there).
PAW tests inserted in test/ there are 6 of them, as a consequence I have also put 5 paw
pseudopotentials in the pseudo/ directory.
I will update the PAW scf examples soon, by deleting them (as running a pw with a PAW
pseudopotential requires no option at all). PAW generation examples should be updated.
A lot of small bugfixes here & there mostly uninitialized variables or unallocated
pointers used as subrotuine arguments.
git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@4769 c92efa57-630b-4861-b058-cf58834340f0
2008-04-03 23:50:43 +08:00
|
|
|
CALL set_pseudo_upf (nt, upf(nt), rgrid(nt))
|
2006-03-06 21:31:27 +08:00
|
|
|
!
|
2015-06-12 16:24:39 +08:00
|
|
|
elseif ( pseudo_type (psfile (nt) ) == 3 ) then
|
|
|
|
newpseudo (nt) = .true.
|
|
|
|
!
|
|
|
|
CALL readgth (iunps, nt, upf(nt))
|
|
|
|
!
|
|
|
|
CALL set_pseudo_upf (nt, upf(nt), rgrid(nt))
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
else
|
|
|
|
newpseudo (nt) = .false.
|
2015-10-20 03:49:51 +08:00
|
|
|
IF( printout_ ) &
|
2011-08-08 16:44:31 +08:00
|
|
|
WRITE( stdout, "(3X,'file type is old PWscf NC format')")
|
2007-03-19 17:14:21 +08:00
|
|
|
!
|
The following pseudopotential-related variables in module uspp_param:
zp, psd, dion, betar, jjj, qqq, qfunc, qfcoef, vloc_at, rinner,
nbeta, kkbeta, nqf, nqlc, lll, tvanp
have been replaced by the corresponding variables in structure 'upf'.
There shouldn't be any side effects, but who knows. There is still a
copy of the above variables that will be removed sooner or later.
Basically : variable([i,j,k,..,]n) => upf(n)%variable [(i,j,k,..)]
Note that upf%qfunc has for the time being three indices instead of two,
and that upf%kkbeta is the analogous of kkbeta and not what it used to be.
The logic of this operation will be clearer when it will be completed
git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@4308 c92efa57-630b-4861-b058-cf58834340f0
2007-10-05 17:26:23 +08:00
|
|
|
call read_ncpp (iunps, nt, upf(nt))
|
2007-10-03 00:54:13 +08:00
|
|
|
!
|
This is a quite complex check-in, but actually not very much is done. Changelog follows.
LP
UPF file format updated completely, UPFv2 introduced:
* ld1.x can still produce old format, with the switch upf_v1_format=.true. in inputp
this is disabled by default, but we can discuss if it should be the opposite.
* pw.x cp.x and all utilities should notice no difference
* some utilities in upftools still need to be updated, anyway conversion UPFv1 to UPFv2
is very easy, so this should be no big issue
* starting from now to produce an UPF file you need to fill the pseudo_upf derivedd type
and feed it to write_upf woutine in upf_module (Modules/upf.f90)
* extensive use of iotk
I have tried to make the new format as self contained as possible, e.g. there should be
minimal need for post-processing after the data is read, no more reconstruction of known
quantities, and no more odd syntax to save negligible quantity of space. Also the human
readable section is a bit richer, all the rest is more machine readable.
I hope this will not cause any throuble, and tried really hard to, all examples and all
tests works as fine as before and gives (what really looks like) the same results.
Other changes that I needed to make:
* radial grids are now allocatable, they management is a bit less of a hack too
* paw and uspp augmentation are stored in the same place
* paw print total all-electron energy if all atoms are paw, not very useful, but nice
* most of the pseudopotential-writing reading files have been renamed to some more
logical name, I spare you the list. E.g. read_oldpseudo -> read_pseudo_rrkj3
* paw_t derived type was only used in atomic, so I have put it there (as the pseudo_type
module take ages to recompile it was awkward to leave it there).
PAW tests inserted in test/ there are 6 of them, as a consequence I have also put 5 paw
pseudopotentials in the pseudo/ directory.
I will update the PAW scf examples soon, by deleting them (as running a pw with a PAW
pseudopotential requires no option at all). PAW generation examples should be updated.
A lot of small bugfixes here & there mostly uninitialized variables or unallocated
pointers used as subrotuine arguments.
git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@4769 c92efa57-630b-4861-b058-cf58834340f0
2008-04-03 23:50:43 +08:00
|
|
|
CALL set_pseudo_upf (nt, upf(nt), rgrid(nt))
|
2006-03-06 21:31:27 +08:00
|
|
|
!
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
2007-10-16 23:07:42 +08:00
|
|
|
!
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
2011-08-08 03:37:01 +08:00
|
|
|
!
|
|
|
|
! end of reading
|
|
|
|
!
|
2006-03-06 21:31:27 +08:00
|
|
|
close (iunps)
|
2008-07-15 05:50:33 +08:00
|
|
|
!
|
2010-08-13 18:53:51 +08:00
|
|
|
! Calculate MD5 checksum for this pseudopotential
|
|
|
|
!
|
2010-08-31 00:19:06 +08:00
|
|
|
CALL md5_from_file(file_pseudo, upf(nt)%md5_cksum)
|
2010-08-13 18:53:51 +08:00
|
|
|
!
|
2007-10-07 23:39:02 +08:00
|
|
|
! ... Zv = valence charge of the (pseudo-)atom, read from PP files,
|
|
|
|
! ... is set equal to Zp = pseudo-charge of the pseudopotential
|
|
|
|
!
|
|
|
|
zv(nt) = upf(nt)%zp
|
|
|
|
!
|
2011-08-08 03:37:01 +08:00
|
|
|
! ... count US species
|
|
|
|
!
|
|
|
|
IF (upf(nt)%tvanp) nvb=nvb+1
|
|
|
|
!
|
|
|
|
! ... Check for DFT consistency - ignored if dft enforced from input
|
|
|
|
!
|
|
|
|
IF (nt == 1) THEN
|
2005-11-02 23:42:06 +08:00
|
|
|
iexch_ = get_iexch()
|
|
|
|
icorr_ = get_icorr()
|
|
|
|
igcx_ = get_igcx()
|
|
|
|
igcc_ = get_igcc()
|
2011-05-26 20:37:10 +08:00
|
|
|
inlc_ = get_inlc()
|
2011-08-08 03:37:01 +08:00
|
|
|
ELSE
|
|
|
|
IF ( iexch_ /= get_iexch() .OR. icorr_ /= get_icorr() .OR. &
|
|
|
|
igcx_ /= get_igcx() .OR. igcc_ /= get_igcc() .OR. &
|
|
|
|
inlc_ /= get_inlc() ) THEN
|
|
|
|
CALL errore( 'readpp','inconsistent DFT read from PP files', nt)
|
|
|
|
END IF
|
|
|
|
END IF
|
2006-03-14 18:59:14 +08:00
|
|
|
!
|
|
|
|
! the radial grid is defined up to r(mesh) but we introduce
|
|
|
|
! an auxiliary variable msh to limit the grid up to rcut=10 a.u.
|
2007-03-19 17:14:21 +08:00
|
|
|
! This is used to cut off the numerical noise arising from the
|
2006-03-14 18:59:14 +08:00
|
|
|
! large-r tail in cases like the integration of V_loc-Z/r
|
|
|
|
!
|
2007-08-12 08:08:53 +08:00
|
|
|
do ir = 1, rgrid(nt)%mesh
|
|
|
|
if (rgrid(nt)%r(ir) > rcut) then
|
2006-03-14 18:59:14 +08:00
|
|
|
msh (nt) = ir
|
|
|
|
goto 5
|
|
|
|
endif
|
|
|
|
enddo
|
2007-08-12 08:08:53 +08:00
|
|
|
msh (nt) = rgrid(nt)%mesh
|
2006-03-14 18:59:14 +08:00
|
|
|
5 msh (nt) = 2 * ( (msh (nt) + 1) / 2) - 1
|
2005-10-07 02:16:17 +08:00
|
|
|
!
|
2011-08-08 03:37:01 +08:00
|
|
|
! msh is forced to be odd for simpson integration (maybe obsolete?)
|
2005-10-07 02:16:17 +08:00
|
|
|
!
|
2011-08-08 03:37:01 +08:00
|
|
|
! check for zero atomic wfc,
|
|
|
|
! check that (occupied) atomic wfc are properly normalized
|
2008-09-10 22:01:33 +08:00
|
|
|
!
|
|
|
|
call check_atwfc_norm(nt)
|
|
|
|
!
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
2006-01-19 23:44:56 +08:00
|
|
|
!
|
2013-12-13 05:01:15 +08:00
|
|
|
! more initializations
|
2011-08-08 03:37:01 +08:00
|
|
|
!
|
2011-08-08 06:36:45 +08:00
|
|
|
okvan = ( nvb > 0 )
|
2011-08-08 03:37:01 +08:00
|
|
|
nlcc_any = ANY ( upf(1:ntyp)%nlcc )
|
|
|
|
!
|
2015-10-20 03:49:51 +08:00
|
|
|
! return cutoff read from PP file, if required
|
|
|
|
!
|
|
|
|
IF ( PRESENT(ecutwfc_pp) ) THEN
|
|
|
|
ecutwfc_pp = MAXVAL ( upf(1:ntyp)%ecutwfc )
|
|
|
|
END IF
|
|
|
|
IF ( PRESENT(ecutrho_pp) ) THEN
|
|
|
|
ecutrho_pp = MAXVAL ( upf(1:ntyp)%ecutrho )
|
|
|
|
END IF
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
end subroutine readpp
|
|
|
|
!-----------------------------------------------------------------------
|
2003-09-23 22:45:12 +08:00
|
|
|
integer function pseudo_type (psfile)
|
2003-01-20 05:58:50 +08:00
|
|
|
!-----------------------------------------------------------------------
|
2003-02-08 00:04:36 +08:00
|
|
|
implicit none
|
2003-09-23 22:45:12 +08:00
|
|
|
character (len=*) :: psfile
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: l
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-09-23 22:45:12 +08:00
|
|
|
l = len_trim (psfile)
|
2003-02-08 00:04:36 +08:00
|
|
|
pseudo_type = 0
|
2003-09-23 22:45:12 +08:00
|
|
|
if (psfile (l - 3:l) .eq.'.vdb'.or.psfile (l - 3:l) .eq.'.van') &
|
2003-01-20 05:58:50 +08:00
|
|
|
pseudo_type = 1
|
2015-06-12 16:24:39 +08:00
|
|
|
if (psfile (l - 3:l) .eq.'.gth') pseudo_type = 3
|
2003-01-20 05:58:50 +08:00
|
|
|
if (l > 5) then
|
2003-09-23 22:45:12 +08:00
|
|
|
if (psfile (l - 5:l) .eq.'.RRKJ3') pseudo_type = 2
|
2003-01-20 05:58:50 +08:00
|
|
|
end if
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
|
|
|
|
end function pseudo_type
|
|
|
|
|
2008-07-15 05:50:33 +08:00
|
|
|
!---------------------------------------------------------------
|
|
|
|
SUBROUTINE check_atwfc_norm(nt)
|
|
|
|
!---------------------------------------------------------------
|
2011-08-08 03:37:01 +08:00
|
|
|
! check for the presence of zero wavefunctions first
|
2008-07-15 05:50:33 +08:00
|
|
|
! check the normalization of the atomic wfc (only those with non-negative
|
|
|
|
! occupations) and renormalize them if the calculated norm is incorrect
|
2011-08-08 03:37:01 +08:00
|
|
|
! by more than eps6 (10^{-6})
|
2008-07-15 05:50:33 +08:00
|
|
|
!
|
|
|
|
USE kinds, ONLY : dp
|
2011-08-08 03:37:01 +08:00
|
|
|
USE constants, ONLY : eps6, eps8
|
2008-07-15 05:50:33 +08:00
|
|
|
USE io_global, ONLY : stdout
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
integer,intent(in) :: nt ! index of the pseudopotential to be checked
|
|
|
|
!
|
|
|
|
integer :: &
|
|
|
|
mesh, kkbeta, & ! auxiliary indices of integration limits
|
|
|
|
l, & ! orbital angular momentum
|
|
|
|
iwfc, ir, & ! counter on atomic wfcs and on radial mesh
|
|
|
|
ibeta, ibeta1, ibeta2 ! counters on betas
|
|
|
|
logical :: &
|
|
|
|
match ! a logical variable
|
|
|
|
real(DP) :: &
|
|
|
|
norm, & ! the norm
|
|
|
|
j ! total (spin+orbital) angular momentum
|
|
|
|
real(DP), allocatable :: &
|
|
|
|
work(:), gi(:) ! auxiliary variable for becp
|
2009-02-10 00:58:31 +08:00
|
|
|
character (len=80) :: renorm
|
2008-07-15 05:50:33 +08:00
|
|
|
!
|
|
|
|
allocate (work(upf(nt)%nbeta), gi(upf(nt)%grid%mesh) )
|
|
|
|
|
|
|
|
! define indices for integration limits
|
|
|
|
mesh = upf(nt)%grid%mesh
|
|
|
|
kkbeta = upf(nt)%kkbeta
|
|
|
|
!
|
2009-02-10 00:58:31 +08:00
|
|
|
renorm = ' '
|
2008-07-15 05:50:33 +08:00
|
|
|
DO iwfc = 1, upf(nt)%nwfc
|
|
|
|
l = upf(nt)%lchi(iwfc)
|
|
|
|
if ( upf(nt)%has_so ) j = upf(nt)%jchi(iwfc)
|
|
|
|
!
|
|
|
|
! the smooth part first ..
|
|
|
|
gi(1:mesh) = upf(nt)%chi(1:mesh,iwfc) * upf(nt)%chi(1:mesh,iwfc)
|
|
|
|
call simpson (mesh, gi, upf(nt)%grid%rab, norm)
|
|
|
|
!
|
2011-08-08 03:37:01 +08:00
|
|
|
IF ( norm < eps8 ) then
|
|
|
|
WRITE( stdout,'(5X,"WARNING: atomic wfc # ",i2, &
|
|
|
|
& " for atom type",i2," has zero norm")') iwfc, nt
|
|
|
|
!
|
|
|
|
! set occupancy to a small negative number so that this wfc
|
|
|
|
! is not going to be used for starting wavefunctions
|
|
|
|
!
|
|
|
|
upf(nt)%oc (iwfc) = -eps8
|
|
|
|
END IF
|
|
|
|
!
|
|
|
|
IF ( upf(nt)%oc(iwfc) < 0.d0) CYCLE ! only occupied states are normalized
|
|
|
|
!
|
2008-07-15 05:50:33 +08:00
|
|
|
if ( upf(nt)%tvanp ) then
|
|
|
|
!
|
|
|
|
! the US part if needed
|
|
|
|
do ibeta = 1, upf(nt)%nbeta
|
|
|
|
match = l.eq.upf(nt)%lll(ibeta)
|
2011-08-08 03:37:01 +08:00
|
|
|
if (upf(nt)%has_so) match=match.and.abs(j-upf(nt)%jjj(ibeta)) < eps6
|
2008-07-15 05:50:33 +08:00
|
|
|
if (match) then
|
|
|
|
gi(1:kkbeta)= upf(nt)%beta(1:kkbeta,ibeta) * &
|
|
|
|
upf(nt)%chi (1:kkbeta,iwfc)
|
|
|
|
call simpson (kkbeta, gi, upf(nt)%grid%rab, work(ibeta))
|
|
|
|
else
|
|
|
|
work(ibeta)=0.0_dp
|
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
do ibeta1=1,upf(nt)%nbeta
|
|
|
|
do ibeta2=1,upf(nt)%nbeta
|
|
|
|
norm=norm+upf(nt)%qqq(ibeta1,ibeta2)*work(ibeta1)*work(ibeta2)
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
end if
|
|
|
|
norm=sqrt(norm)
|
|
|
|
if (abs(norm-1.0_dp) > eps6 ) then
|
2009-02-10 00:58:31 +08:00
|
|
|
renorm = TRIM(renorm) // ' ' // upf(nt)%els(iwfc)
|
2008-07-15 05:50:33 +08:00
|
|
|
upf(nt)%chi(1:mesh,iwfc)=upf(nt)%chi(1:mesh,iwfc)/norm
|
|
|
|
end if
|
|
|
|
end do
|
|
|
|
deallocate (work, gi )
|
2011-08-08 03:37:01 +08:00
|
|
|
IF ( LEN_TRIM(renorm) > 0 ) WRITE( stdout, &
|
2011-05-26 20:37:10 +08:00
|
|
|
'(15x,"file ",a,": wavefunction(s) ",a," renormalized")') &
|
2011-08-08 03:37:01 +08:00
|
|
|
TRIM(psfile(nt)),TRIM(renorm)
|
|
|
|
RETURN
|
|
|
|
!
|
|
|
|
END SUBROUTINE check_atwfc_norm
|
|
|
|
|
2011-08-08 16:44:31 +08:00
|
|
|
SUBROUTINE check_order
|
|
|
|
! CP-specific check
|
|
|
|
INTEGER :: nt
|
2015-06-12 23:29:02 +08:00
|
|
|
IF ( ANY(upf(1:ntyp)%tpawp) ) CALL errore ('readpp','PAW not implemented',1)
|
2011-08-08 16:44:31 +08:00
|
|
|
DO nt =2, ntyp
|
|
|
|
IF ( (.NOT. upf(nt-1)%tvanp) .AND. upf(nt)%tvanp ) THEN
|
|
|
|
CALL errore ('readpp', 'ultrasoft PPs must precede norm-conserving',nt)
|
|
|
|
ENDIF
|
|
|
|
END DO
|
|
|
|
END SUBROUTINE check_order
|
2011-08-08 03:37:01 +08:00
|
|
|
END MODULE read_pseudo_mod
|