2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-09-17 01:17:53 +08:00
|
|
|
! Copyright (C) 2001-2004 PWSCF 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 .
|
|
|
|
!
|
2004-06-26 01:25:37 +08:00
|
|
|
#include "f_defs.h"
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
!----------------------------------------------------------------------------
|
2004-01-21 22:41:25 +08:00
|
|
|
SUBROUTINE setup()
|
2003-10-29 19:34:53 +08:00
|
|
|
!----------------------------------------------------------------------------
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-09-14 23:25:27 +08:00
|
|
|
! ... This routine
|
|
|
|
! ... 1) determines various parameters of the calculation
|
|
|
|
! ... 2) finds actual crystal symmetry, determine lattice
|
|
|
|
! ... 3) generates k-points corresponding to the crystal symmetry
|
|
|
|
!
|
|
|
|
! ... Calculated parameters:
|
|
|
|
! ... msh mesh point (atomic grid) for which R(msh) > Rcut = 10a.u.
|
|
|
|
! ... zv charge of each atomic type
|
|
|
|
! ... nelec total number of electrons
|
|
|
|
! ... nbnd total number of bands
|
|
|
|
! ... nbndx max number of bands used in iterative diagonalization
|
|
|
|
! ... tpiba 2 pi / a (a = lattice parameter)
|
|
|
|
! ... tpiba2 square of tpiba
|
|
|
|
! ... gcutm cut-off in g space
|
|
|
|
! ... gcutms cut-off in g space for smooth functions
|
|
|
|
! ... ethr convergence limit of iterative diagonalization
|
|
|
|
! ... at direct lattice vectors
|
|
|
|
! ... omega volume of the unit cell
|
|
|
|
! ... bg reciprocal lattice vectors
|
|
|
|
! ... s symmetry matrices in the direct lattice vectors basis
|
|
|
|
! ... nsym total number of symmetry operations
|
|
|
|
! ... ftau fractionary translations
|
|
|
|
! ... irt for each atom gives the corresponding symmetric
|
|
|
|
! ... invsym if true the system has inversion symmetry
|
|
|
|
! ... + non-collinear related quantities
|
|
|
|
! ... + spin-orbit related quantities
|
|
|
|
! ... + LDA+U-related quantities
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-06-12 21:44:18 +08:00
|
|
|
USE kinds, ONLY : DP
|
2004-09-14 23:25:27 +08:00
|
|
|
USE constants, ONLY : eps8
|
2004-06-12 21:44:18 +08:00
|
|
|
USE parameters, ONLY : npsx, nchix, npk
|
|
|
|
USE io_global, ONLY : stdout
|
|
|
|
USE constants, ONLY : pi, degspin
|
|
|
|
USE cell_base, ONLY : at, bg, alat, tpiba, tpiba2, ibrav, symm_type
|
|
|
|
USE ions_base, ONLY : nat, tau, ntyp => nsp, ityp, zv
|
2004-12-10 23:20:46 +08:00
|
|
|
USE basis, ONLY : startingpot, natomwfc
|
2004-06-12 21:44:18 +08:00
|
|
|
USE gvect, ONLY : gcutm, ecutwfc, dual, nr1, nr2, nr3
|
|
|
|
USE gsmooth, ONLY : doublegrid, gcutms
|
|
|
|
USE klist, ONLY : xk, wk, xqq, nks, nelec, degauss, lgauss, &
|
2005-03-17 22:47:46 +08:00
|
|
|
lxkcry, nkstot, b_length, lcart, &
|
|
|
|
nelup, neldw, two_fermi_energies
|
2004-09-14 23:25:27 +08:00
|
|
|
USE lsda_mod, ONLY : lsda, nspin, current_spin, isk, &
|
|
|
|
starting_magnetization
|
2004-06-12 21:44:18 +08:00
|
|
|
USE ktetra, ONLY : nk1, nk2, nk3, k1, k2, k3, tetra, ntetra, ltetra
|
|
|
|
USE symme, ONLY : s, irt, ftau, nsym, invsym
|
|
|
|
USE atom, ONLY : r, oc, chi, nchi, lchi, jchi, mesh, msh
|
2005-03-28 21:55:19 +08:00
|
|
|
USE pseud, ONLY : zp
|
2005-05-11 23:28:23 +08:00
|
|
|
USE wvfct, ONLY : nbnd, nbndx, gamma_only
|
2004-12-10 23:20:46 +08:00
|
|
|
USE control_flags, ONLY : tr2, ethr, alpha0, beta0, lscf, &
|
2005-05-25 01:17:27 +08:00
|
|
|
lmd, lpath, lphonon, david, isolve, &
|
2004-12-10 23:20:46 +08:00
|
|
|
niter, noinv, nosym, modenum, lraman
|
2004-06-12 21:44:18 +08:00
|
|
|
USE relax, ONLY : dtau_ref, starting_diag_threshold
|
|
|
|
USE cellmd, ONLY : calc
|
|
|
|
USE uspp_param, ONLY : psd, betar, nbeta, dion, jjj, lll, tvanp
|
2005-03-28 21:55:19 +08:00
|
|
|
USE uspp, ONLY : okvan
|
2004-06-12 21:44:18 +08:00
|
|
|
USE ldaU, ONLY : d1, d2, d3, lda_plus_u, Hubbard_U, Hubbard_l, &
|
|
|
|
Hubbard_alpha, Hubbard_lmax
|
|
|
|
USE bp, ONLY : gdir, lberry, nppstr
|
|
|
|
USE fixed_occ, ONLY : f_inp, tfixed_occ
|
|
|
|
USE char, ONLY : sname
|
2004-11-04 21:35:00 +08:00
|
|
|
USE mp_global, ONLY : nimage, kunit
|
2004-09-14 23:25:27 +08:00
|
|
|
USE spin_orb, ONLY : lspinorb, domag
|
|
|
|
USE noncollin_module, ONLY : noncolin, npol, m_loc, i_cons, mcons, &
|
2005-03-18 18:42:56 +08:00
|
|
|
angle1, angle2, bfield
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IMPLICIT NONE
|
|
|
|
!
|
|
|
|
! ... local variables
|
|
|
|
!
|
|
|
|
REAL(KIND=DP), PARAMETER :: &
|
|
|
|
rcut = 10.D0, &! cut-off radius for radial integrations
|
2004-09-14 23:25:27 +08:00
|
|
|
eps = 1.0D-12 ! small number
|
2003-10-29 19:34:53 +08:00
|
|
|
INTEGER :: &
|
|
|
|
na, &!
|
|
|
|
ir, &!
|
|
|
|
nt, &!
|
|
|
|
input_nks, &!
|
|
|
|
nrot, &!
|
|
|
|
iter, &!
|
|
|
|
ierr, &!
|
|
|
|
irot, &!
|
|
|
|
isym, &!
|
|
|
|
ipol, &!
|
|
|
|
jpol, &!
|
|
|
|
tipo, &!
|
|
|
|
is, &!
|
2004-05-03 16:08:59 +08:00
|
|
|
nb, &!
|
2005-01-31 23:04:50 +08:00
|
|
|
nbe, &!
|
|
|
|
ind, ind1, &!
|
2004-05-03 16:08:59 +08:00
|
|
|
l, &!
|
2003-10-29 19:34:53 +08:00
|
|
|
ibnd !
|
|
|
|
LOGICAL :: &
|
2004-09-14 23:25:27 +08:00
|
|
|
so(npsx), &!
|
2004-01-24 01:00:45 +08:00
|
|
|
minus_q, &!
|
|
|
|
ltest !
|
2003-10-29 19:34:53 +08:00
|
|
|
REAL(KIND=DP) :: &
|
2004-05-03 16:08:59 +08:00
|
|
|
vionl, & !
|
2004-01-24 01:00:45 +08:00
|
|
|
iocc !
|
2003-10-29 19:34:53 +08:00
|
|
|
INTEGER, EXTERNAL :: &
|
|
|
|
n_atom_wfc, &!
|
|
|
|
set_Hubbard_l
|
|
|
|
LOGICAL, EXTERNAL :: &
|
2004-05-22 00:19:20 +08:00
|
|
|
lchk_tauxk ! tests that atomic coordinates do not overlap
|
2003-10-29 19:34:53 +08:00
|
|
|
!
|
|
|
|
!
|
2004-09-14 23:25:27 +08:00
|
|
|
ALLOCATE( m_loc( 3, nat ) )
|
2003-10-29 19:34:53 +08:00
|
|
|
!
|
2004-08-23 14:51:19 +08:00
|
|
|
IF ( nimage > 1 .AND. .NOT. lpath ) &
|
2004-03-24 17:36:50 +08:00
|
|
|
CALL errore( 'setup', 'images parallelization not permitted', 1 )
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
DO nt = 1, ntyp
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
DO ir = 1, mesh(nt)
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
IF ( r(ir,nt) > rcut ) THEN
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
msh(nt) = ir
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
GO TO 5
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END IF
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END DO
|
|
|
|
!
|
|
|
|
msh(nt) = mesh(nt)
|
|
|
|
!
|
|
|
|
! ... force msh to be odd for simpson integration
|
|
|
|
!
|
2004-09-14 23:25:27 +08:00
|
|
|
5 msh(nt) = 2 * ( ( msh(nt) + 1 ) / 2 ) - 1
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END DO
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2005-03-18 18:42:56 +08:00
|
|
|
! ... Compute the ionic charge for each atom type
|
|
|
|
!
|
|
|
|
zv(1:ntyp) = zp(1:ntyp)
|
|
|
|
!
|
|
|
|
! ... Set the number of electrons equal to the total ionic charge
|
|
|
|
!
|
|
|
|
IF ( nelec == 0.D0 ) THEN
|
|
|
|
!
|
|
|
|
#if defined (__PGI)
|
|
|
|
!
|
|
|
|
DO na = 1, nat
|
|
|
|
nelec = nelec + zv( ityp(na) )
|
|
|
|
END DO
|
|
|
|
!
|
|
|
|
#else
|
|
|
|
!
|
|
|
|
nelec = SUM( zv(ityp(1:nat)) )
|
|
|
|
!
|
|
|
|
#endif
|
|
|
|
!
|
|
|
|
END IF
|
|
|
|
!
|
|
|
|
! ... If the occupations are from input, check the consistency with the
|
|
|
|
! ... number of electrons
|
2004-09-14 23:25:27 +08:00
|
|
|
IF ( noncolin ) THEN
|
|
|
|
!
|
2005-05-11 23:28:23 +08:00
|
|
|
! gamma_only and noncollinear not allowed
|
|
|
|
!
|
|
|
|
if (gamma_only) call errore('setup', &
|
|
|
|
'gamma_only and noncolin not allowed',1)
|
|
|
|
!
|
2004-09-14 23:25:27 +08:00
|
|
|
! ... wavefunctions are spinors with 2 components
|
|
|
|
!
|
|
|
|
npol = 2
|
|
|
|
!
|
|
|
|
! ... transform angles to radiants
|
|
|
|
!
|
|
|
|
DO nt = 1, ntyp
|
|
|
|
!
|
|
|
|
angle1(nt) = pi * angle1(nt) / 180.D0
|
|
|
|
angle2(nt) = pi * angle2(nt) / 180.D0
|
|
|
|
!
|
|
|
|
END DO
|
|
|
|
!
|
|
|
|
! ... Set the nomag variable to make a spin-orbit calculation with zero
|
|
|
|
! ... magnetization
|
|
|
|
!
|
|
|
|
IF ( lspinorb ) THEN
|
|
|
|
!
|
|
|
|
domag = .FALSE.
|
|
|
|
!
|
|
|
|
DO nt = 1, ntyp
|
|
|
|
!
|
|
|
|
domag = domag .OR. ( ABS( starting_magnetization(nt) ) > 1.D-6 )
|
|
|
|
!
|
|
|
|
END DO
|
|
|
|
!
|
|
|
|
ELSE
|
|
|
|
!
|
|
|
|
domag = .TRUE.
|
|
|
|
!
|
|
|
|
END IF
|
|
|
|
!
|
|
|
|
DO na = 1, nat
|
|
|
|
!
|
|
|
|
m_loc(1,na) = starting_magnetization(ityp(na)) * &
|
|
|
|
SIN( angle1(ityp(na)) ) * COS( angle2(ityp(na)) )
|
|
|
|
m_loc(2,na) = starting_magnetization(ityp(na)) * &
|
|
|
|
SIN( angle1(ityp(na)) ) * SIN( angle2(ityp(na)) )
|
|
|
|
m_loc(3,na) = starting_magnetization(ityp(na)) * &
|
|
|
|
COS( angle1(ityp(na)) )
|
|
|
|
END DO
|
|
|
|
!
|
2005-03-18 18:42:56 +08:00
|
|
|
bfield=0.d0
|
2004-09-14 23:25:27 +08:00
|
|
|
IF ( i_cons == 2 ) THEN
|
|
|
|
!
|
|
|
|
! ... angle theta between the magnetic moments and the z-axis is
|
|
|
|
! ... constrained. Transform theta to radiants
|
|
|
|
!
|
|
|
|
DO na = 1, ntyp
|
|
|
|
!
|
|
|
|
mcons(1,na) = pi * mcons(1,na) / 180.D0
|
|
|
|
!
|
|
|
|
END DO
|
|
|
|
!
|
2005-03-18 18:42:56 +08:00
|
|
|
ELSE IF (i_cons == 4) THEN
|
|
|
|
bfield(:)=mcons(:,1)
|
2004-09-14 23:25:27 +08:00
|
|
|
END IF
|
|
|
|
!
|
|
|
|
ELSE
|
|
|
|
!
|
|
|
|
! wavefunctions are scalars
|
|
|
|
!
|
|
|
|
npol = 1
|
|
|
|
!
|
2005-03-18 18:42:56 +08:00
|
|
|
IF (i_cons==5) THEN
|
|
|
|
nelup= (nelec+mcons(3,1))*0.5d0
|
|
|
|
neldw= (nelec-mcons(3,1))*0.5d0
|
|
|
|
ENDIF
|
|
|
|
|
2005-03-18 18:52:01 +08:00
|
|
|
IF (i_cons.NE.0.AND.i_cons.NE.5) &
|
|
|
|
call errore('setup','this i_cons requires a non colinear run',1)
|
2005-03-18 18:42:56 +08:00
|
|
|
IF (i_cons==5.AND.nspin.NE.2) &
|
|
|
|
call errore('setup','i_cons can be 5 only with nspin=2',1)
|
2004-09-14 23:25:27 +08:00
|
|
|
END IF
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( tfixed_occ ) THEN
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
iocc = 0
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
IF ( noncolin ) THEN
|
|
|
|
!
|
|
|
|
#if defined (__PGI)
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
DO ibnd = 1, nbnd
|
2004-09-15 23:30:27 +08:00
|
|
|
iocc = iocc + f_inp(ibnd,1)
|
2003-10-29 19:34:53 +08:00
|
|
|
END DO
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
#else
|
|
|
|
!
|
2004-09-20 19:02:54 +08:00
|
|
|
iocc = iocc + SUM( f_inp(1:nbnd,1) )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
#endif
|
|
|
|
!
|
|
|
|
ELSE
|
|
|
|
!
|
|
|
|
DO is = 1, nspin
|
|
|
|
!
|
|
|
|
#if defined (__PGI)
|
|
|
|
!
|
|
|
|
DO ibnd = 1, nbnd
|
|
|
|
iocc = iocc + f_inp(ibnd,is)
|
|
|
|
END DO
|
|
|
|
!
|
|
|
|
#else
|
|
|
|
!
|
2004-09-20 18:51:04 +08:00
|
|
|
iocc = iocc + SUM( f_inp(1:nbnd,is) )
|
2004-09-20 19:02:54 +08:00
|
|
|
!
|
2004-09-14 23:25:27 +08:00
|
|
|
#endif
|
|
|
|
!
|
|
|
|
END DO
|
|
|
|
!
|
|
|
|
END IF
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( ABS( iocc - nelec ) > 1D-5 ) &
|
|
|
|
CALL errore( 'setup', 'strange occupations', 1 )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END IF
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-09-14 23:25:27 +08:00
|
|
|
! ... For metals: check whether Gaussian broadening or Tetrahedron method
|
|
|
|
! ... is used
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
lgauss = ( ( degauss /= 0.D0 ) .AND. ( .NOT. tfixed_occ ) )
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... Check: if there is an odd number of electrons, the crystal is a metal
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-09-14 23:25:27 +08:00
|
|
|
IF ( lscf .AND. ABS( NINT( nelec / 2.D0 ) - nelec / 2.D0 ) > eps8 &
|
2003-10-29 19:34:53 +08:00
|
|
|
.AND. .NOT. lgauss .AND. .NOT. ltetra .AND. .NOT. tfixed_occ ) &
|
|
|
|
CALL errore( 'setup', 'the system is metallic, specify occupations', 1 )
|
2004-11-23 21:22:47 +08:00
|
|
|
!
|
|
|
|
! ... Check: spin-polarized calculations require tetrahedra or broadening
|
|
|
|
! or fixed occupation - the simple filling of levels is not
|
|
|
|
! implemented right now (it will yield an unpolarized system)
|
|
|
|
!
|
|
|
|
IF ( lscf .AND. lsda &
|
2005-03-17 22:47:46 +08:00
|
|
|
.AND. .NOT. lgauss .AND. .NOT. ltetra &
|
|
|
|
.AND. .NOT. tfixed_occ .AND. .NOT. two_fermi_energies ) &
|
2004-11-23 21:22:47 +08:00
|
|
|
CALL errore( 'setup', 'spin-polarized system, specify occupations', 1 )
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... Set the number of occupied bands if not given in input
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( nbnd == 0 ) THEN
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2005-03-17 22:47:46 +08:00
|
|
|
nbnd = MAX ( NINT( nelec / degspin ), NINT(nelup), NINT(neldw) )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( lgauss .OR. ltetra ) THEN
|
|
|
|
!
|
|
|
|
! ... metallic case: add 20% more bands, with a minimum of 4
|
|
|
|
!
|
2005-03-17 22:47:46 +08:00
|
|
|
nbnd = MAX( NINT( 1.2D0 * nelec / degspin ), &
|
|
|
|
NINT( 1.2D0 * nelup), NINT( 1.2d0 * neldw ), &
|
|
|
|
( nbnd + 4 ) )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END IF
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
! ... In the case of noncollinear magnetism, bands are NOT
|
|
|
|
! ... twofold degenerate :
|
|
|
|
!
|
2004-09-17 14:03:02 +08:00
|
|
|
IF ( noncolin ) nbnd = INT( degspin ) * nbnd
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
ELSE
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-05-22 00:19:20 +08:00
|
|
|
IF ( nbnd < NINT( nelec / degspin ) .AND. lscf ) &
|
2003-10-29 19:34:53 +08:00
|
|
|
CALL errore( 'setup', 'too few bands', 1 )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2005-03-17 22:47:46 +08:00
|
|
|
IF ( nbnd < NINT( nelup ) .AND. lscf ) &
|
|
|
|
CALL errore( 'setup', 'too few spin up bands', 1 )
|
|
|
|
IF ( nbnd < NINT( neldw ) .AND. lscf ) &
|
|
|
|
CALL errore( 'setup', 'too few spin dw bands', 1 )
|
|
|
|
!
|
2004-09-14 23:25:27 +08:00
|
|
|
IF ( nbnd < NINT( nelec ) .AND. lscf .AND. noncolin ) &
|
|
|
|
CALL errore( 'setup', 'too few bands', 1 )
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END IF
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-01-21 22:41:25 +08:00
|
|
|
! ... Here we set the precision of the diagonalization for the first scf
|
|
|
|
! ... iteration of for the first ionic step
|
|
|
|
! ... for subsequent steps ethr is automatically updated in electrons
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-01-24 01:00:45 +08:00
|
|
|
ltest = ( ethr == 0.D0 )
|
|
|
|
!
|
2004-09-14 23:25:27 +08:00
|
|
|
IF ( lphonon .or. lraman ) THEN
|
2004-01-21 22:41:25 +08:00
|
|
|
!
|
2004-01-23 17:50:00 +08:00
|
|
|
! ... in the case of a phonon calculation ethr can not be specified
|
|
|
|
! ... in the input file
|
|
|
|
!
|
2004-01-24 01:00:45 +08:00
|
|
|
IF ( .NOT. ltest ) &
|
2004-01-23 17:50:00 +08:00
|
|
|
WRITE( UNIT = stdout, &
|
2004-01-24 01:00:45 +08:00
|
|
|
& FMT = '(5X,"diago_thr_init overwritten ", &
|
|
|
|
& "with conv_thr / nelec")' )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2005-05-25 01:17:27 +08:00
|
|
|
ethr = 0.1D0 * MIN( 1.D-2, tr2 / nelec )
|
2004-01-23 17:50:00 +08:00
|
|
|
!
|
|
|
|
ELSE IF ( .NOT. lscf ) THEN
|
|
|
|
!
|
2004-01-24 01:00:45 +08:00
|
|
|
IF ( ltest ) THEN
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2005-05-25 01:17:27 +08:00
|
|
|
ethr = 0.1D0 * MIN( 1.D-2, tr2 / nelec )
|
2004-01-21 22:41:25 +08:00
|
|
|
!
|
2004-01-23 17:50:00 +08:00
|
|
|
END IF
|
|
|
|
!
|
|
|
|
ELSE
|
|
|
|
!
|
2004-01-24 01:00:45 +08:00
|
|
|
IF ( ltest ) THEN
|
2003-10-29 19:34:53 +08:00
|
|
|
!
|
2004-01-23 17:50:00 +08:00
|
|
|
IF ( startingpot == 'file' ) THEN
|
|
|
|
!
|
|
|
|
! ... if you think that the starting potential is good
|
|
|
|
! ... do not spoil it with a lousy first diagonalization :
|
|
|
|
! ... set a strict ethr in the input file (diago_thr_init)
|
|
|
|
!
|
2005-05-25 01:17:27 +08:00
|
|
|
ethr = 1.D-5
|
2004-01-23 17:50:00 +08:00
|
|
|
!
|
|
|
|
ELSE
|
|
|
|
!
|
|
|
|
! ... starting atomic potential is probably far from scf
|
|
|
|
! ... do not waste iterations in the first diagonalizations
|
|
|
|
!
|
2005-05-25 01:17:27 +08:00
|
|
|
ethr = 1.0D-2
|
2004-01-23 17:50:00 +08:00
|
|
|
!
|
|
|
|
END IF
|
2004-01-21 22:41:25 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END IF
|
2004-01-21 22:41:25 +08:00
|
|
|
!
|
2004-01-23 17:50:00 +08:00
|
|
|
END IF
|
2003-10-29 19:34:53 +08:00
|
|
|
!
|
|
|
|
IF ( .NOT. lscf ) niter = 1
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
starting_diag_threshold = ethr
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
! check if spin-orbit is possible
|
|
|
|
!
|
|
|
|
lspinorb = lspinorb .AND. noncolin
|
|
|
|
!
|
|
|
|
! ... if this is not a spin-orbit calculation, all spin-orbit pseudopotentials
|
|
|
|
! ... are transformed into standard pseudopotentials
|
|
|
|
!
|
|
|
|
DO nt = 1, ntyp
|
|
|
|
!
|
|
|
|
so(nt) = .TRUE.
|
|
|
|
!
|
|
|
|
DO nb = 1, nbeta(nt)
|
|
|
|
!
|
|
|
|
so(nt) = so(nt) .AND. ( ABS( jjj(nb,nt) ) > 1.D-7 )
|
|
|
|
!
|
|
|
|
END DO
|
|
|
|
!
|
|
|
|
END DO
|
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
IF ( .NOT. lspinorb ) THEN
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
DO nt = 1, ntyp
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
IF ( so(nt) ) THEN
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
IF ( tvanp(nt) ) &
|
|
|
|
CALL errore( 'setup', 'US j-average not yet implemented', 1 )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
nbe = 0
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
DO nb = 1, nbeta(nt)
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
nbe = nbe + 1
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
IF ( lll(nb,nt) /= 0 .AND. &
|
|
|
|
ABS( jjj(nb,nt) - lll(nb,nt) - 0.5D0 ) < 1.D-7 ) nbe = nbe - 1
|
|
|
|
END DO
|
|
|
|
!
|
|
|
|
nbeta(nt) = nbe
|
|
|
|
!
|
|
|
|
nbe = 0
|
|
|
|
!
|
|
|
|
DO nb = 1, nbeta(nt)
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
nbe = nbe + 1
|
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
l = lll(nbe,nt)
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
IF ( l /= 0 ) THEN
|
|
|
|
!
|
2005-01-31 23:04:50 +08:00
|
|
|
IF (ABS(jjj(nbe,nt)-lll(nbe,nt)+0.5d0).LT.1.d-7) THEN
|
|
|
|
IF (ABS(jjj(nbe+1,nt)-lll(nbe+1,nt)-0.5d0).GT.1.d-7) &
|
|
|
|
call errore('setup','wrong beta functions',1)
|
|
|
|
ind=nbe+1
|
|
|
|
ind1=nbe
|
|
|
|
ELSE
|
|
|
|
IF (ABS(jjj(nbe+1,nt)-lll(nbe+1,nt)+0.5d0).GT.1.d-7) &
|
|
|
|
call errore('setup','wrong beta functions',1)
|
|
|
|
ind=nbe
|
|
|
|
ind1=nbe+1
|
|
|
|
ENDIF
|
|
|
|
!
|
|
|
|
vionl = ( ( l + 1.D0 ) * dion(ind,ind,nt) + &
|
|
|
|
l * dion(ind1,ind1,nt) ) / ( 2.D0 * l + 1.D0 )
|
2004-09-17 14:35:36 +08:00
|
|
|
!
|
|
|
|
betar(1:mesh(nt),nb,nt) = 1.D0 / ( 2.D0 * l + 1.D0 ) * &
|
2005-01-31 23:04:50 +08:00
|
|
|
( ( l + 1.D0 ) * SQRT( dion(ind,ind,nt) / vionl ) * &
|
|
|
|
betar(1:mesh(nt),ind,nt) + &
|
|
|
|
l * SQRT( dion(ind1,ind1,nt) / vionl ) * &
|
|
|
|
betar(1:mesh(nt),ind1,nt) )
|
2004-09-17 14:35:36 +08:00
|
|
|
!
|
|
|
|
dion(nb,nb,nt) = vionl
|
|
|
|
!
|
|
|
|
nbe = nbe + 1
|
|
|
|
!
|
|
|
|
ELSE
|
|
|
|
!
|
|
|
|
betar(1:mesh(nt),nb,nt) = betar(1:mesh(nt),nbe,nt)
|
|
|
|
!
|
|
|
|
dion(nb,nb,nt) = dion(nbe,nbe,nt)
|
|
|
|
!
|
|
|
|
END IF
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2005-01-31 23:04:50 +08:00
|
|
|
lll(nb,nt)=lll(nbe,nt)
|
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
END DO
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
nbe = 0
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
DO nb = 1, nchi(nt)
|
|
|
|
!
|
|
|
|
nbe = nbe + 1
|
|
|
|
!
|
|
|
|
IF ( lchi(nb,nt) /= 0 .AND. &
|
2005-01-31 23:04:50 +08:00
|
|
|
ABS(jchi(nb,nt)-lchi(nb,nt)-0.5D0 ) < 1.D-7 ) nbe = nbe - 1
|
2004-09-17 14:35:36 +08:00
|
|
|
!
|
|
|
|
END DO
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
nchi(nt) = nbe
|
|
|
|
!
|
|
|
|
nbe = 0
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
do nb = 1, nchi(nt)
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
nbe = nbe + 1
|
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
l = lchi(nbe,nt)
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
IF ( l /= 0 ) THEN
|
|
|
|
!
|
2005-01-31 23:04:50 +08:00
|
|
|
IF (ABS(jchi(nbe,nt)-lchi(nbe,nt)+0.5d0).LT.1.d-7) THEN
|
|
|
|
IF (ABS(jchi(nbe+1,nt)-lchi(nbe+1,nt)-0.5d0).GT.1.d-7) &
|
|
|
|
call errore('setup','wrong chi functions',1)
|
|
|
|
ind=nbe+1
|
|
|
|
ind1=nbe
|
|
|
|
ELSE
|
|
|
|
IF (ABS(jchi(nbe+1,nt)-lchi(nbe+1,nt)+0.5d0).GT.1.d-7) &
|
|
|
|
call errore('setup','wrong chi functions',1)
|
|
|
|
ind=nbe
|
|
|
|
ind1=nbe+1
|
|
|
|
END IF
|
|
|
|
!
|
|
|
|
chi(1:mesh(nt),nb,nt)=((l+1.D0) * chi(1:mesh(nt),ind,nt)+ &
|
|
|
|
l * chi(1:mesh(nt),ind1,nt)) / ( 2.D0 * l + 1.D0 )
|
2004-09-17 14:35:36 +08:00
|
|
|
|
|
|
|
nbe = nbe + 1
|
|
|
|
!
|
|
|
|
ELSE
|
|
|
|
!
|
|
|
|
chi(1:mesh(nt),nb,nt) = chi(1:mesh(nt),nbe,nt)
|
|
|
|
!
|
|
|
|
END IF
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2005-01-31 23:04:50 +08:00
|
|
|
lchi(nb,nt)= lchi(nbe,nt)
|
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
END DO
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
END IF
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
END DO
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-09-17 14:35:36 +08:00
|
|
|
END IF
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... set number of atomic wavefunctions
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-09-14 23:25:27 +08:00
|
|
|
natomwfc = n_atom_wfc( nat, npsx, ityp, nchix, nchi, oc, lchi, jchi )
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... set the max number of bands used in iterative diagonalization
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
nbndx = nbnd
|
|
|
|
!
|
2004-09-14 23:25:27 +08:00
|
|
|
IF ( isolve == 0 ) nbndx = david * nbnd
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... Set the units in real and reciprocal space
|
|
|
|
!
|
2004-09-14 23:25:27 +08:00
|
|
|
tpiba = 2.D0 * pi / alat
|
2003-01-20 05:58:50 +08:00
|
|
|
tpiba2 = tpiba**2
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... Compute the cut-off of the G vectors
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
gcutm = dual * ecutwfc / tpiba2
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
doublegrid = ( dual > 4.D0 )
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( doublegrid ) THEN
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
gcutms = 4.D0 * ecutwfc / tpiba2
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
ELSE
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-01-20 05:58:50 +08:00
|
|
|
gcutms = gcutm
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END IF
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... Generate the reciprocal lattice vectors
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
CALL recips( at(1,1), at(1,2), at(1,3), bg(1,1), bg(1,2), bg(1,3) )
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... If lxkcry = .TRUE. , the input k-point components in crystal
|
|
|
|
! ... axis are transformed in cartesian coordinates
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( lxkcry ) CALL cryst_to_cart( nks, xk, bg, 1 )
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... Test that atoms do not overlap
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( .NOT. ( lchk_tauxk( nat, tau, bg ) ) ) &
|
|
|
|
CALL errore( 'setup', 'Wrong atomic coordinates ', 1 )
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... set dtau_ref for relaxation and dynamics
|
|
|
|
! ... this is done here because dtau_ref is updated in cg
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
dtau_ref = 0.2D0
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... calculate dimensions of the FFT grid
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
CALL set_fft_dim()
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... generate transformation matrices for the crystal point group
|
|
|
|
! ... First we generate all the symmetry matrices of the Bravais lattice
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( ibrav == 4 .OR. ibrav == 5 ) THEN
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... here the hexagonal or trigonal bravais lattice
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
CALL hexsym( at, s, sname, nrot )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
tipo = 2
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
ELSE IF ( ibrav >=1 .AND. ibrav <= 14 ) THEN
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... here for the cubic bravais lattice
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
CALL cubicsym( at, s, sname, nrot )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
tipo = 1
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
ELSE IF ( ibrav == 0 ) THEN
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( symm_type == 'cubic' ) THEN
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
tipo = 1
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
CALL cubicsym( at, s, sname, nrot )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
ELSE IF ( symm_type == 'hexagonal' ) THEN
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
tipo = 2
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
CALL hexsym( at, s, sname, nrot )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END IF
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
ELSE
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
CALL errore( 'setup', 'wrong ibrav', 1 )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END IF
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... if noinv is .TRUE. eliminate all symmetries which exchange z with -z
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( noinv ) THEN
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
irot = 0
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
DO isym = 1, nrot
|
|
|
|
IF ( s(1,3,isym) == 0 .AND. s(3,1,isym) == 0 .AND. &
|
|
|
|
s(2,3,isym) == 0 .AND. s(3,2,isym) == 0 .AND. &
|
|
|
|
s(3,3,isym) == 1) THEN
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
irot = irot + 1
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
s(:,:,irot) = s(:,:,isym)
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
sname(irot) = sname(isym)
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END IF
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END DO
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
nrot = irot
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END IF
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... If nosym is true do not use any point-group symmetry
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( nosym ) nrot = 1
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... Automatic generation of k-points (if required)
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( nks < 0 ) THEN
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
CALL setupkpoint( s, nrot, xk, wk, nks, npk, nk1, &
|
|
|
|
nk2, nk3, k1, k2, k3, at, bg, tipo )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
ELSE IF ( nks == 0 ) THEN
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( lberry ) THEN
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
CALL kp_strings( nppstr, gdir, nrot, s, bg, npk, &
|
|
|
|
k1, k2, k3, nk1, nk2, nk3, nks, xk, wk )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
nosym = .TRUE.
|
|
|
|
nrot = 1
|
|
|
|
nsym = 1
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
ELSE
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
CALL kpoint_grid( nrot, s, bg, npk, k1, k2, k3, &
|
|
|
|
nk1, nk2, nk3, nks, xk, wk )
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END IF
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END IF
|
|
|
|
!
|
|
|
|
! ... allocate space for irt
|
|
|
|
!
|
|
|
|
ALLOCATE( irt( 48, nat ) )
|
|
|
|
!
|
|
|
|
! ... "sgama" eliminates rotations that are not symmetry operations
|
|
|
|
! ... Input k-points are assumed to be given in the IBZ of the Bravais
|
|
|
|
! ... lattice, with the full point symmetry of the lattice.
|
|
|
|
! ... If some symmetries are missing in the crystal, "sgama" computes
|
|
|
|
! ... the missing k-points. If nosym is true (see above) we do not use
|
|
|
|
! ... any point-group symmetry and leave k-points unchanged.
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-07-23 20:18:52 +08:00
|
|
|
input_nks = nks
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
CALL sgama( nrot, nat, s, sname, at, bg, tau, ityp, nsym, nr1, &
|
2004-09-14 23:25:27 +08:00
|
|
|
nr2, nr3, irt, ftau, npk, nks, xk, wk, invsym, minus_q, &
|
2004-12-10 23:20:46 +08:00
|
|
|
xqq, modenum, noncolin, m_loc )
|
2003-10-29 19:34:53 +08:00
|
|
|
!
|
2004-09-14 23:25:27 +08:00
|
|
|
CALL checkallsym( nsym, s, nat, tau, ityp, at, &
|
|
|
|
bg, nr1, nr2, nr3, irt, ftau )
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... if dynamics is done the system should have no symmetries
|
|
|
|
! ... (inversion symmetry alone is allowed)
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-03-15 17:43:02 +08:00
|
|
|
IF ( lmd .AND. ( nsym == 2 .AND. .NOT. invsym .OR. nsym > 2 ) &
|
2003-10-29 19:34:53 +08:00
|
|
|
.AND. .NOT. ( calc == 'mm' .OR. calc == 'nm' ) ) &
|
|
|
|
CALL errore( 'setup', 'Dynamics, you should have no symmetries', -1 )
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... Calculate quantities used in tetrahedra method
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( ltetra ) THEN
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-01-20 05:58:50 +08:00
|
|
|
ntetra = 6 * nk1 * nk2 * nk3
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
ALLOCATE( tetra( 4, ntetra ) )
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
CALL tetrahedra( nsym, s, minus_q, at, bg, npk, k1, k2, k3, &
|
|
|
|
nk1, nk2, nk3, nks, xk, wk, ntetra, tetra )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
ELSE
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-04-22 04:42:34 +08:00
|
|
|
ntetra = 0
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END IF
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-09-14 23:25:27 +08:00
|
|
|
! ... non scf calculation: do not change the number of k-points
|
2005-02-11 23:47:00 +08:00
|
|
|
! ... to account for reduced symmetry, unless you need to
|
|
|
|
! ... (as in phonon or raman or DOS calculations, or whenever the
|
|
|
|
! ... Fermi energy has to be calculated)
|
2003-07-23 20:18:52 +08:00
|
|
|
!
|
2005-02-11 23:47:00 +08:00
|
|
|
ltest = ( nks /= input_nks ) .AND. &
|
|
|
|
( .NOT. ( ltetra .OR. lgauss ) ) .AND. &
|
|
|
|
( .NOT. lscf ) .AND. ( .NOT. ( lphonon .OR. lraman ) )
|
2004-09-15 20:06:19 +08:00
|
|
|
IF ( ltest ) THEN
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-09-15 20:06:19 +08:00
|
|
|
WRITE( stdout, '(/,5X,"Only input k-points are used ", &
|
|
|
|
& "(inequivalent points not generated)",/)' )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
nks = input_nks
|
|
|
|
!
|
|
|
|
END IF
|
2003-07-23 20:18:52 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... phonon calculation: add k+q to the list of k
|
2003-07-23 20:18:52 +08:00
|
|
|
!
|
2004-12-10 23:20:46 +08:00
|
|
|
IF ( lphonon ) CALL set_kplusq( xk, wk, xqq, nks, npk )
|
2003-07-23 20:18:52 +08:00
|
|
|
!
|
2004-05-25 22:22:43 +08:00
|
|
|
! ... raman calculation: add k+b to the list of k
|
|
|
|
!
|
|
|
|
IF ( lraman ) CALL set_kplusb(ibrav, xk, wk, b_length, nks, npk, lcart)
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( lsda ) THEN
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... LSDA case: two different spin polarizations,
|
|
|
|
! ... each with its own kpoints
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2005-03-24 01:20:26 +08:00
|
|
|
if (nspin /= 2) call errore ('setup','nspin should be 2; check iosys',1)
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
CALL set_kup_and_kdw( xk, wk, isk, nks, npk )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
ELSE IF ( noncolin ) THEN
|
|
|
|
!
|
|
|
|
! ... noncolinear magnetism: potential and charge have dimension 4 (1+3)
|
|
|
|
!
|
2005-03-24 01:20:26 +08:00
|
|
|
if (nspin /= 4) call errore ('setup','nspin should be 4; check iosys',1)
|
2004-09-14 23:25:27 +08:00
|
|
|
current_spin = 1
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
ELSE
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... LDA case: the two spin polarizations are identical
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-09-14 23:25:27 +08:00
|
|
|
wk(1:nks) = wk(1:nks) * degspin
|
2003-02-08 00:04:36 +08:00
|
|
|
current_spin = 1
|
2005-03-24 01:20:26 +08:00
|
|
|
if (nspin /= 1) call errore ('setup','nspin should be 1; check iosys',1)
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END IF
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( nks > npk ) CALL errore( 'setup', 'too many k points', nks )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-02-21 22:57:00 +08:00
|
|
|
#ifdef __PARA
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... set the granularity for k-point distribution
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( ( ABS( xqq(1) ) < eps .AND. ABS( xqq(2) ) < eps .AND. &
|
2004-12-10 23:20:46 +08:00
|
|
|
ABS( xqq(3) ) < eps) .OR. ( .NOT. lphonon ) ) THEN
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
kunit = 1
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
ELSE
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
kunit = 2
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
ENDIF
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
IF ( lraman ) THEN
|
|
|
|
!
|
|
|
|
IF( lcart ) THEN
|
|
|
|
!
|
2004-05-25 22:22:43 +08:00
|
|
|
kunit = 7
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
ELSE
|
|
|
|
!
|
|
|
|
IF ( ibrav == 1 ) kunit = 7
|
|
|
|
IF ( ibrav == 2 ) kunit = 9
|
|
|
|
IF ( ibrav == 3 ) kunit = 13
|
|
|
|
!
|
|
|
|
END IF
|
|
|
|
!
|
|
|
|
END IF
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... distribute the k-points (and their weights and spin indices)
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
CALL divide_et_impera( xk, wk, isk, lsda, nkstot, nks )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-01-20 05:58:50 +08:00
|
|
|
#else
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... set nkstot which is used to write results for all k-points
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
nkstot = nks
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-01-20 05:58:50 +08:00
|
|
|
#endif
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... okvan = .TRUE. : at least one pseudopotential is US
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-09-14 23:25:27 +08:00
|
|
|
okvan = ANY( tvanp(:) )
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... initialize parameters for charge density extrapolation during dynamics
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
alpha0 = 1.D0
|
|
|
|
beta0 = 0.D0
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... Needed for LDA+U
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
! ... initialize d1 and d2 to rotate the spherical harmonics
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( lda_plus_u ) THEN
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-02-10 16:58:33 +08:00
|
|
|
Hubbard_lmax = -1
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
DO nt = 1, ntyp
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
IF ( Hubbard_U(nt) /= 0.D0 .OR. Hubbard_alpha(nt) /= 0.D0 ) THEN
|
|
|
|
!
|
2003-02-10 16:58:33 +08:00
|
|
|
Hubbard_l(nt) = set_Hubbard_l( psd(nt) )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
Hubbard_lmax = MAX( Hubbard_lmax, Hubbard_l(nt) )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
WRITE( UNIT = stdout, &
|
|
|
|
FMT = * ) ' HUBBARD L FOR TYPE ',psd(nt),' IS ', Hubbard_l(nt)
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END IF
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END DO
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
WRITE( UNIT = stdout, &
|
|
|
|
FMT = * ) ' MAXIMUM HUBBARD L IS ', Hubbard_lmax
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
IF ( Hubbard_lmax == -1 ) &
|
|
|
|
CALL errore( 'setup', &
|
|
|
|
& 'lda_plus_u calculation but Hubbard_l not set', 1 )
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
CALL d_matrix( d1, d2, d3 )
|
|
|
|
!
|
2004-01-06 02:11:01 +08:00
|
|
|
ELSE
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2004-01-06 02:11:01 +08:00
|
|
|
Hubbard_lmax = 0
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END IF
|
|
|
|
!
|
|
|
|
RETURN
|
|
|
|
!
|
|
|
|
END SUBROUTINE setup
|
|
|
|
!
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
!----------------------------------------------------------------------------
|
2004-09-14 23:25:27 +08:00
|
|
|
FUNCTION n_atom_wfc( nat, npsx, ityp, nchix, nchi, oc, lchi, jchi )
|
2003-10-29 19:34:53 +08:00
|
|
|
!----------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! ... Find max number of bands needed
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-09-14 23:25:27 +08:00
|
|
|
USE kinds, ONLY : DP
|
|
|
|
use noncollin_module, ONLY : noncolin
|
|
|
|
use spin_orb, ONLY : lspinorb
|
2003-10-29 19:34:53 +08:00
|
|
|
!
|
|
|
|
IMPLICIT NONE
|
|
|
|
!
|
|
|
|
INTEGER :: n_atom_wfc
|
2004-09-17 01:17:53 +08:00
|
|
|
INTEGER :: nat, npsx, ityp(nat), nchix, nchi(npsx), lchi(nchix,npsx)
|
|
|
|
REAL(KIND=DP) :: oc(nchix,npsx), jchi(nchix,npsx)
|
2003-10-29 19:34:53 +08:00
|
|
|
INTEGER :: na, nt, n
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-04-22 04:42:34 +08:00
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
n_atom_wfc = 0
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
DO na = 1, nat
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
nt = ityp(na)
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
DO n = 1, nchi(nt)
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
|
|
|
IF ( oc(n,nt) >= 0.D0 ) THEN
|
|
|
|
!
|
|
|
|
IF ( noncolin ) THEN
|
|
|
|
!
|
|
|
|
IF ( lspinorb ) THEN
|
|
|
|
!
|
|
|
|
n_atom_wfc = n_atom_wfc + 2 * lchi(n,nt)
|
|
|
|
!
|
|
|
|
IF ( ABS( jchi(n,nt) - lchi(n,nt) - 0.5D0 ) < 1.D-6 ) &
|
|
|
|
n_atom_wfc = n_atom_wfc + 2
|
|
|
|
!
|
|
|
|
ELSE
|
|
|
|
!
|
|
|
|
n_atom_wfc = n_atom_wfc + 2 * ( 2 * lchi(n,nt) + 1 )
|
|
|
|
!
|
|
|
|
END IF
|
|
|
|
!
|
|
|
|
ELSE
|
|
|
|
!
|
|
|
|
n_atom_wfc = n_atom_wfc + 2 * lchi(n,nt) + 1
|
|
|
|
!
|
|
|
|
END IF
|
|
|
|
!
|
|
|
|
END IF
|
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END DO
|
2004-09-14 23:25:27 +08:00
|
|
|
!
|
2003-10-29 19:34:53 +08:00
|
|
|
END DO
|
|
|
|
!
|
|
|
|
RETURN
|
|
|
|
!
|
|
|
|
END FUNCTION n_atom_wfc
|