mirror of https://gitlab.com/QEF/q-e.git
Small speed-up of the first diagonalisation (this at each ionic step).
C.S. git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@1639 c92efa57-630b-4861-b058-cf58834340f0
This commit is contained in:
parent
159d490f48
commit
059ffd302b
|
@ -196,52 +196,52 @@
|
|||
!
|
||||
!
|
||||
REAL(KIND=DP), PUBLIC :: &
|
||||
mixing_beta, &! the mixing parameter
|
||||
tr2, &! the convergence threshold for potential
|
||||
upscale, &! maximum reduction of convergence threshold
|
||||
ethr, &! the convergence threshold for eigenvalues
|
||||
alpha0, &! the mixing parameters for the extrapolation
|
||||
beta0 ! of the starting potential
|
||||
mixing_beta, &! the mixing parameter
|
||||
tr2, &! the convergence threshold for potential
|
||||
upscale, &! maximum reduction of convergence threshold
|
||||
ethr, &! the convergence threshold for eigenvalues
|
||||
alpha0, &! the mixing parameters for the extrapolation
|
||||
beta0 ! of the starting potential
|
||||
!
|
||||
INTEGER, PUBLIC :: &
|
||||
ngm0, &! used in mix_rho
|
||||
niter, &! the maximum number of iteration
|
||||
nmix, &! the number of iteration kept in the history
|
||||
imix, &! the type of mixing (0=plain,1=TF,2=local-TF)
|
||||
! iprint, &! the interval between full writing of results
|
||||
iverbosity, &! type of printing ( 0 few, 1 all )
|
||||
david, &! used on Davidson diagonalization
|
||||
nstep, &! number of minimization steps
|
||||
istep, &! current minimization step
|
||||
isolve, &! Davidson or CG diagonalization
|
||||
modenum, &! for single mode phonon calculation
|
||||
max_cg_iter, &! maximum number of iterations in a CG di
|
||||
diis_buff, &! dimension of the buffer in diis
|
||||
diis_ndim, &! dimension of reduced basis in DIIS
|
||||
history, &! number of old steps available for potential updating
|
||||
pot_order, &! type of potential updating ( see update_pot )
|
||||
wfc_order ! type of wavefunctions updating ( see update_pot )
|
||||
ngm0, &! used in mix_rho
|
||||
niter, &! the maximum number of iteration
|
||||
nmix, &! the number of iteration kept in the history
|
||||
imix, &! the type of mixing (0=plain,1=TF,2=local-TF)
|
||||
iverbosity, &! type of printing ( 0 few, 1 all )
|
||||
david, &! used on Davidson diagonalization
|
||||
nstep, &! number of minimization steps
|
||||
istep, &! current minimization step
|
||||
isolve, &! Davidson or CG diagonalization
|
||||
modenum, &! for single mode phonon calculation
|
||||
max_cg_iter, &! maximum number of iterations in a CG di
|
||||
diis_buff, &! dimension of the buffer in diis
|
||||
diis_ndim, &! dimension of reduced basis in DIIS
|
||||
history, &! number of old steps available for potential updating
|
||||
pot_order, &! type of potential updating ( see update_pot )
|
||||
wfc_order ! type of wavefunctions updating ( see update_pot )
|
||||
!
|
||||
LOGICAL, PUBLIC :: &
|
||||
lfixatom, &! if .TRUE. some atom is kept fixed
|
||||
lscf, &! if .TRUE. the calculation is selfconsistent
|
||||
lbfgs, &! if .TRUE. the calculation is a relaxation based on new BFGS scheme
|
||||
loldbfgs, &! if .TRUE. the calculation is a bfgs-type relaxation based on the old scheme
|
||||
lmd, &! if .TRUE. the calculation is a dynamics
|
||||
lpath, &! if .TRUE. the calculation is a path optimizations
|
||||
lneb, &! if .TRUE. the calculation is NEB dynamics
|
||||
lsmd, &! if .TRUE. the calculation is string dynamics
|
||||
lwf, &! if .TRUE. the calculation is with wannier functions
|
||||
lphonon, &! if .TRUE. the calculation is phonon
|
||||
lraman, &! if .TRUE. the calculation is raman
|
||||
lconstrain, &! if .TRUE. the calculation is constraint
|
||||
ldamped, &! if .TRUE. the calculation is a damped dynamics
|
||||
conv_elec, &! if .TRUE. electron convergence has been reached
|
||||
conv_ions, &! if .TRUE. ionic convergence has been reached
|
||||
nosym, &! if .TRUE. no symmetry is used
|
||||
noinv = .FALSE., &! if .TRUE. eliminates inversion symmetry
|
||||
restart, &! if .TRUE. restart from results of a preceding run
|
||||
reduce_io ! if .TRUE. reduce the I/O to the strict minimum
|
||||
lfixatom, &! if .TRUE. some atom is kept fixed
|
||||
lscf, &! if .TRUE. the calculation is selfconsistent
|
||||
lbfgs, &! if .TRUE. the calculation is a relaxation based on new BFGS scheme
|
||||
loldbfgs, &! if .TRUE. the calculation is a bfgs-type relaxation based on the old scheme
|
||||
lmd, &! if .TRUE. the calculation is a dynamics
|
||||
lpath, &! if .TRUE. the calculation is a path optimizations
|
||||
lneb, &! if .TRUE. the calculation is NEB dynamics
|
||||
lsmd, &! if .TRUE. the calculation is string dynamics
|
||||
lwf, &! if .TRUE. the calculation is with wannier functions
|
||||
lphonon, &! if .TRUE. the calculation is phonon
|
||||
lraman, &! if .TRUE. the calculation is raman
|
||||
lconstrain, &! if .TRUE. the calculation is constraint
|
||||
ldamped, &! if .TRUE. the calculation is a damped dynamics
|
||||
conv_elec, &! if .TRUE. electron convergence has been reached
|
||||
conv_ions, &! if .TRUE. ionic convergence has been reached
|
||||
nosym, &! if .TRUE. no symmetry is used
|
||||
noinv = .FALSE., &! if .TRUE. eliminates inversion symmetry
|
||||
restart, &! if .TRUE. restart from results of a preceding run
|
||||
reduce_io, &! if .TRUE. reduce the I/O to the strict minimum
|
||||
wg_setted = .FALSE.
|
||||
!
|
||||
|
||||
INTEGER :: ortho_max = 0 ! maximum number of iterations in routine ortho
|
||||
|
|
178
PW/c_bands.f90
178
PW/c_bands.f90
|
@ -34,7 +34,7 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
USE wvfct, ONLY : g2kin, wg, nbndx, et, nbnd, npwx, igk, &
|
||||
npw
|
||||
USE control_flags, ONLY : diis_ndim, istep, ethr, lscf, max_cg_iter, &
|
||||
isolve, reduce_io
|
||||
isolve, reduce_io, wg_setted
|
||||
USE ldaU, ONLY : lda_plus_u, swfcatom
|
||||
USE scf, ONLY : vltot
|
||||
USE lsda_mod, ONLY : current_spin, lsda, isk
|
||||
|
@ -86,15 +86,19 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
!
|
||||
! ... allocate arrays
|
||||
!
|
||||
IF (noncolin) THEN
|
||||
ALLOCATE( h_diag_nc( npwx, npol ) )
|
||||
ALLOCATE( s_diag_nc( npwx, npol ) )
|
||||
IF ( noncolin ) THEN
|
||||
!
|
||||
ALLOCATE( h_diag_nc( npwx, npol ) )
|
||||
ALLOCATE( s_diag_nc( npwx, npol ) )
|
||||
!
|
||||
ELSE
|
||||
ALLOCATE( h_diag( npwx ) )
|
||||
ALLOCATE( s_diag( npwx ) )
|
||||
!
|
||||
ALLOCATE( h_diag( npwx ) )
|
||||
ALLOCATE( s_diag( npwx ) )
|
||||
!
|
||||
END IF
|
||||
|
||||
ALLOCATE( btype( nbnd ) )
|
||||
!
|
||||
ALLOCATE( btype( nbnd ) )
|
||||
!
|
||||
IF ( gamma_only ) THEN
|
||||
!
|
||||
|
@ -108,13 +112,17 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
!
|
||||
! ... deallocate arrays
|
||||
!
|
||||
IF (noncolin) THEN
|
||||
IF ( noncolin ) THEN
|
||||
!
|
||||
DEALLOCATE( s_diag_nc )
|
||||
DEALLOCATE( h_diag_nc )
|
||||
!
|
||||
ELSE
|
||||
!
|
||||
DEALLOCATE( s_diag )
|
||||
DEALLOCATE( h_diag )
|
||||
ENDIF
|
||||
!
|
||||
END IF
|
||||
!
|
||||
DEALLOCATE( btype )
|
||||
!
|
||||
|
@ -216,8 +224,10 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
IF ( qcutz > 0.D0 ) THEN
|
||||
!
|
||||
DO ig = 1, npw
|
||||
!
|
||||
g2kin(ig) = g2kin(ig) + qcutz * &
|
||||
( 1.D0 + erf( (g2kin(ig) - ecfixed ) / q2sigma ) )
|
||||
!
|
||||
END DO
|
||||
!
|
||||
END IF
|
||||
|
@ -227,7 +237,7 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
! ... a band is considered empty when its occupation is less
|
||||
! ... than 1.0 % ( the occupation is known after the first step )
|
||||
!
|
||||
IF ( iter > 1 ) WHERE( wg(:,ik) < 0.01D0 ) btype(:) = 0
|
||||
IF ( wg_setted ) WHERE( wg(:,ik) < 0.01D0 ) btype(:) = 0
|
||||
!
|
||||
IF ( isolve == 2 ) THEN
|
||||
!
|
||||
|
@ -328,8 +338,7 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
!
|
||||
RETURN
|
||||
!
|
||||
END SUBROUTINE c_bands_gamma
|
||||
!
|
||||
END SUBROUTINE c_bands_gamma
|
||||
!
|
||||
!-----------------------------------------------------------------------
|
||||
SUBROUTINE c_bands_k()
|
||||
|
@ -353,16 +362,20 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
! ... here the local variables
|
||||
!
|
||||
REAL(KIND=DP) :: cg_iter
|
||||
! number of iteration in CG
|
||||
! number of iteration in DIIS
|
||||
! number of iteration in CG
|
||||
! number of iteration in DIIS
|
||||
INTEGER :: ipol
|
||||
!
|
||||
! ... becp contains <beta|psi> - used in h_psi and s_psi
|
||||
!
|
||||
IF (noncolin) THEN
|
||||
IF ( noncolin ) THEN
|
||||
!
|
||||
ALLOCATE( becp_nc( nkb, npol, nbnd ) )
|
||||
!
|
||||
ELSE
|
||||
!
|
||||
ALLOCATE( becp( nkb, nbnd ) )
|
||||
!
|
||||
END IF
|
||||
!
|
||||
! ... allocate specific array for DIIS
|
||||
|
@ -423,12 +436,16 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
!
|
||||
! ... read in wavefunctions from the previous iteration
|
||||
!
|
||||
IF (noncolin) THEN
|
||||
IF ( noncolin ) THEN
|
||||
!
|
||||
IF ( nks > 1 .OR. .NOT. reduce_io ) &
|
||||
CALL davcio( evc_nc, nwordwfc, iunwfc, ik, -1 )
|
||||
!
|
||||
ELSE
|
||||
!
|
||||
IF ( nks > 1 .OR. .NOT. reduce_io ) &
|
||||
CALL davcio( evc, nwordwfc, iunwfc, ik, -1 )
|
||||
!
|
||||
END IF
|
||||
!
|
||||
! ... Needed for LDA+U
|
||||
|
@ -441,12 +458,15 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
( xk(2,ik) + g(2,igk(1:npw)) )**2 + &
|
||||
( xk(3,ik) + g(3,igk(1:npw)) )**2 ) * tpiba2
|
||||
!
|
||||
!
|
||||
IF ( qcutz > 0.D0 ) THEN
|
||||
!
|
||||
DO ig = 1, npw
|
||||
g2kin (ig) = g2kin(ig) + qcutz * &
|
||||
( 1.D0 + erf( ( g2kin(ig) - ecfixed ) / q2sigma ) )
|
||||
!
|
||||
g2kin(ig) = g2kin(ig) + qcutz * &
|
||||
( 1.D0 + erf( ( g2kin(ig) - ecfixed ) / q2sigma ) )
|
||||
!
|
||||
END DO
|
||||
!
|
||||
END IF
|
||||
!
|
||||
btype(:) = 1
|
||||
|
@ -454,7 +474,7 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
! ... a band is considered empty when its occupation is less
|
||||
! ... than 1.0 % ( the occupation is known after the first step )
|
||||
!
|
||||
IF ( iter > 1 ) WHERE( wg(:,ik) < 0.01D0 ) btype(:) = 0
|
||||
IF ( wg_setted ) WHERE( wg(:,ik) < 0.01D0 ) btype(:) = 0
|
||||
!
|
||||
IF ( isolve == 1 ) THEN
|
||||
!
|
||||
|
@ -462,13 +482,19 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
!
|
||||
! ... h_diag is the precondition matrix
|
||||
!
|
||||
IF (noncolin) THEN
|
||||
DO ipol=1,npol
|
||||
IF ( noncolin ) THEN
|
||||
!
|
||||
DO ipol = 1, npol
|
||||
!
|
||||
h_diag_nc(1:npw,ipol) = MAX( 1.D0, g2kin(1:npw) )
|
||||
ENDDO
|
||||
!
|
||||
END DO
|
||||
!
|
||||
ELSE
|
||||
!
|
||||
h_diag(1:npw) = MAX( 1.D0, g2kin(1:npw) )
|
||||
ENDIF
|
||||
!
|
||||
END IF
|
||||
!
|
||||
ntry = 0
|
||||
!
|
||||
|
@ -476,23 +502,33 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
!
|
||||
IF ( iter /= 1 .OR. istep /= 1 .OR. ntry > 0 ) THEN
|
||||
!
|
||||
IF (noncolin) THEN
|
||||
CALL cinitcgg_nc(npwx,npw,nbnd,nbnd,evc_nc, &
|
||||
evc_nc,et(1,ik),okvan,npol)
|
||||
IF ( noncolin ) THEN
|
||||
!
|
||||
CALL cinitcgg_nc( npwx, npw, nbnd, nbnd, evc_nc, &
|
||||
evc_nc, et(1,ik), okvan, npol )
|
||||
!
|
||||
ELSE
|
||||
!
|
||||
CALL cinitcgg( npwx, npw, nbnd, nbnd, evc, evc, et(1,ik) )
|
||||
!
|
||||
END IF
|
||||
!
|
||||
avg_iter = avg_iter + 1.D0
|
||||
!
|
||||
END IF
|
||||
!
|
||||
IF (noncolin) THEN
|
||||
CALL ccgdiagg_nc(npwx,npw,nbnd,evc_nc,et(1,ik),h_diag_nc, &
|
||||
ethr,max_cg_iter,.NOT.lscf,notconv,cg_iter,npol)
|
||||
IF ( noncolin ) THEN
|
||||
!
|
||||
CALL ccgdiagg_nc( npwx, npw, nbnd, evc_nc, et(1,ik), &
|
||||
h_diag_nc, ethr, max_cg_iter, &
|
||||
.NOT. lscf, notconv, cg_iter, npol )
|
||||
!
|
||||
ELSE
|
||||
CALL ccgdiagg( npwx, npw, nbnd, evc, et(1,ik), h_diag, &
|
||||
ethr,max_cg_iter,.NOT.lscf,notconv,cg_iter )
|
||||
!
|
||||
CALL ccgdiagg( npwx, npw, nbnd, evc, et(1,ik), &
|
||||
h_diag, ethr, max_cg_iter, .NOT. lscf, &
|
||||
notconv, cg_iter )
|
||||
!
|
||||
END IF
|
||||
!
|
||||
avg_iter = avg_iter + cg_iter
|
||||
|
@ -501,12 +537,16 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
! ... iterative diagonalization of the next scf iteration
|
||||
! ... and for rho calculation
|
||||
!
|
||||
IF (noncolin) THEN
|
||||
IF ( noncolin ) THEN
|
||||
!
|
||||
IF ( nks > 1 .OR. .NOT. reduce_io ) &
|
||||
CALL davcio( evc_nc, nwordwfc, iunwfc, ik, 1 )
|
||||
!
|
||||
ELSE
|
||||
!
|
||||
IF ( nks > 1 .OR. .NOT. reduce_io ) &
|
||||
CALL davcio( evc, nwordwfc, iunwfc, ik, 1 )
|
||||
!
|
||||
END IF
|
||||
!
|
||||
ntry = ntry + 1
|
||||
|
@ -521,12 +561,18 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
!
|
||||
! ... RMM-DIIS method
|
||||
!
|
||||
IF (noncolin) THEN
|
||||
DO ipol=1,npol
|
||||
IF ( noncolin ) THEN
|
||||
!
|
||||
DO ipol = 1, npol
|
||||
!
|
||||
h_diag_nc(1:npw,ipol) = g2kin(1:npw) + v_of_0
|
||||
ENDDO
|
||||
!
|
||||
END DO
|
||||
!
|
||||
ELSE
|
||||
!
|
||||
h_diag(1:npw) = g2kin(1:npw) + v_of_0
|
||||
!
|
||||
END IF
|
||||
!
|
||||
CALL usnldiag( h_diag_nc, s_diag_nc )
|
||||
|
@ -535,13 +581,17 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
!
|
||||
RMMDIIS_loop: DO
|
||||
!
|
||||
IF (noncolin) THEN
|
||||
CALL cdiisg_nc( npw, npwx, nbnd, diis_ndim, evc_nc, &
|
||||
et(1,ik), ethr, btype, notconv, diis_iter, iter, npol)
|
||||
!
|
||||
IF ( noncolin ) THEN
|
||||
!
|
||||
CALL cdiisg_nc( npw, npwx, nbnd, diis_ndim, &
|
||||
evc_nc, et(1,ik), ethr, btype, &
|
||||
notconv, diis_iter, iter, npol )
|
||||
!
|
||||
ELSE
|
||||
!
|
||||
CALL cdiisg( npw, npwx, nbnd, evc, &
|
||||
et(1,ik), btype, notconv, diis_iter, iter )
|
||||
et(1,ik), btype, notconv, diis_iter, iter )
|
||||
!
|
||||
END IF
|
||||
!
|
||||
avg_iter = avg_iter + diis_iter
|
||||
|
@ -550,12 +600,16 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
! ... iterative diagonalization of the next scf iteration
|
||||
! ... and for rho calculation
|
||||
!
|
||||
IF (noncolin) THEN
|
||||
IF ( noncolin ) THEN
|
||||
!
|
||||
IF ( nks > 1 .OR. .NOT. reduce_io ) &
|
||||
CALL davcio( evc_nc, nwordwfc, iunwfc, ik, 1 )
|
||||
!
|
||||
ELSE
|
||||
!
|
||||
IF ( nks > 1 .OR. .NOT. reduce_io ) &
|
||||
CALL davcio( evc, nwordwfc, iunwfc, ik, 1 )
|
||||
!
|
||||
END IF
|
||||
!
|
||||
ntry = ntry + 1
|
||||
|
@ -574,27 +628,38 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
! ... hamiltonian used in g_psi to evaluate the correction
|
||||
! ... to the trial eigenvectors
|
||||
!
|
||||
IF (noncolin) THEN
|
||||
DO ipol=1,npol
|
||||
IF ( noncolin ) THEN
|
||||
!
|
||||
DO ipol = 1, npol
|
||||
!
|
||||
h_diag_nc(1:npw,ipol) = g2kin(1:npw) + v_of_0
|
||||
ENDDO
|
||||
!
|
||||
END DO
|
||||
!
|
||||
CALL usnldiag_nc( h_diag_nc, s_diag_nc )
|
||||
!
|
||||
ELSE
|
||||
!
|
||||
h_diag(1:npw) = g2kin(1:npw) + v_of_0
|
||||
!
|
||||
CALL usnldiag( h_diag, s_diag )
|
||||
!
|
||||
END IF
|
||||
!
|
||||
!
|
||||
ntry = 0
|
||||
!
|
||||
david_loop: DO
|
||||
!
|
||||
IF (noncolin) THEN
|
||||
IF ( noncolin ) THEN
|
||||
!
|
||||
CALL cegterg_nc( npw, npwx, nbnd, nbndx, evc_nc, ethr, &
|
||||
okvan, et(1,ik), notconv, dav_iter, npol )
|
||||
okvan, et(1,ik), notconv, dav_iter, npol )
|
||||
!
|
||||
ELSE
|
||||
!
|
||||
CALL cegterg( npw, npwx, nbnd, nbndx, evc, ethr, &
|
||||
okvan, et(1,ik), btype, notconv, dav_iter )
|
||||
okvan, et(1,ik), btype, notconv, dav_iter )
|
||||
!
|
||||
END IF
|
||||
!
|
||||
avg_iter = avg_iter + dav_iter
|
||||
|
@ -603,12 +668,16 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
! ... iterative diagonalization of the next scf iteration
|
||||
! ... and for rho calculation
|
||||
!
|
||||
IF (noncolin) THEN
|
||||
IF ( noncolin ) THEN
|
||||
!
|
||||
IF ( nks > 1 .OR. .NOT. reduce_io ) &
|
||||
CALL davcio( evc_nc, nwordwfc, iunwfc, ik, 1 )
|
||||
!
|
||||
ELSE
|
||||
!
|
||||
IF ( nks > 1 .OR. .NOT. reduce_io ) &
|
||||
CALL davcio( evc, nwordwfc, iunwfc, ik, 1 )
|
||||
!
|
||||
END IF
|
||||
!
|
||||
ntry = ntry + 1
|
||||
|
@ -646,17 +715,20 @@ SUBROUTINE c_bands( iter, ik_, dr2 )
|
|||
!
|
||||
! ... deallocate work space
|
||||
!
|
||||
IF (noncolin) THEN
|
||||
IF ( noncolin ) THEN
|
||||
!
|
||||
DEALLOCATE( becp_nc )
|
||||
!
|
||||
ELSE
|
||||
!
|
||||
DEALLOCATE( becp )
|
||||
!
|
||||
END IF
|
||||
!
|
||||
RETURN
|
||||
!
|
||||
END SUBROUTINE c_bands_k
|
||||
!
|
||||
!
|
||||
!-----------------------------------------------------------------------
|
||||
FUNCTION test_exit_cond()
|
||||
!-----------------------------------------------------------------------
|
||||
|
|
|
@ -39,6 +39,7 @@ SUBROUTINE sum_band()
|
|||
USE noncollin_module, ONLY : noncolin, npol
|
||||
USE spin_orb, ONLY : lspinorb, domag, fcoef
|
||||
USE wvfct, ONLY : nbnd, npwx, npw, igk, wg, et
|
||||
USE control_flags, ONLY : wg_setted
|
||||
USE mp_global, ONLY : intra_image_comm, me_image, &
|
||||
root_image, npool, my_pool_id
|
||||
USE mp, ONLY : mp_bcast
|
||||
|
@ -117,6 +118,8 @@ SUBROUTINE sum_band()
|
|||
!
|
||||
END IF
|
||||
!
|
||||
wg_setted = .TRUE.
|
||||
!
|
||||
! ... Needed for LDA+U
|
||||
!
|
||||
IF ( lda_plus_u ) CALL new_ns()
|
||||
|
|
Loading…
Reference in New Issue