2004-11-25 22:51:47 +08:00
|
|
|
!
|
2005-05-17 03:19:04 +08:00
|
|
|
! Copyright (C) 2002-2005 FPMD-CPV groups
|
2004-11-25 22:51:47 +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 .
|
|
|
|
!
|
|
|
|
! ---------------------------------------------------------------------- !
|
|
|
|
MODULE runsd_module
|
|
|
|
! ---------------------------------------------------------------------- !
|
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
USE kinds, ONLY: DP
|
2004-11-25 22:51:47 +08:00
|
|
|
|
|
|
|
IMPLICIT NONE
|
|
|
|
SAVE
|
|
|
|
|
|
|
|
PRIVATE
|
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
REAL(DP), PRIVATE :: old_clock_value = 0.0d0
|
2004-11-25 22:51:47 +08:00
|
|
|
|
|
|
|
PUBLIC :: runsd
|
|
|
|
|
|
|
|
! ---------------------------------------------------------------------- !
|
|
|
|
CONTAINS
|
|
|
|
! ---------------------------------------------------------------------- !
|
|
|
|
|
|
|
|
|
|
|
|
! -----------------------------------------------------------------------
|
|
|
|
! BEGIN manual
|
|
|
|
|
2006-06-26 15:51:38 +08:00
|
|
|
SUBROUTINE runsd &
|
|
|
|
( tortho, tprint, tforce, rhoe, atoms_0, bec, becdr, eigr, &
|
|
|
|
vkb, ei1, ei2, ei3, sfac, c0, cm, cp, cdesc, tcel, ht0, &
|
2006-08-04 01:47:35 +08:00
|
|
|
fi, ei, vpot, doions, edft, maxnstep, sdthr )
|
2004-11-25 22:51:47 +08:00
|
|
|
|
|
|
|
! this routine computes the electronic ground state via steepest descent
|
|
|
|
! END manual
|
|
|
|
|
|
|
|
! ... declare modules
|
2005-04-22 23:23:19 +08:00
|
|
|
USE energies, ONLY: dft_energy_type, print_energies
|
|
|
|
USE check_stop, ONLY: check_stop_now
|
|
|
|
USE io_global, ONLY: ionode
|
|
|
|
USE io_global, ONLY: stdout
|
2006-10-07 01:21:32 +08:00
|
|
|
USE cell_base, ONLY: boxdimensions
|
2005-04-22 23:23:19 +08:00
|
|
|
USE wave_types, ONLY: wave_descriptor
|
2006-08-11 16:29:52 +08:00
|
|
|
USE cp_interfaces, ONLY: kspotential
|
2005-04-22 23:23:19 +08:00
|
|
|
USE atoms_type_module, ONLY: atoms_type
|
2006-08-04 01:47:35 +08:00
|
|
|
USE cp_interfaces, ONLY: runcp, update_wave_functions, strucf, phfacs
|
2005-04-22 23:23:19 +08:00
|
|
|
USE control_flags, ONLY: force_pairing
|
|
|
|
use grid_dimensions, only: nr1, nr2, nr3
|
|
|
|
USE reciprocal_vectors, ONLY: mill_l
|
|
|
|
USE gvecp, ONLY: ngm
|
2004-11-25 22:51:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
IMPLICIT NONE
|
|
|
|
|
|
|
|
! ... declare subroutine arguments
|
2005-03-31 02:08:01 +08:00
|
|
|
LOGICAL :: tortho, tprint, tforce, tcel, doions
|
2004-11-25 22:51:47 +08:00
|
|
|
TYPE (atoms_type), INTENT(INOUT) :: atoms_0
|
2006-07-17 17:15:34 +08:00
|
|
|
COMPLEX(DP), INTENT(INOUT) :: c0(:,:), cm(:,:), cp(:,:)
|
2004-11-25 22:51:47 +08:00
|
|
|
TYPE (wave_descriptor) :: cdesc
|
2006-01-10 22:04:13 +08:00
|
|
|
REAL(DP) :: rhoe(:,:)
|
2005-08-28 22:09:42 +08:00
|
|
|
COMPLEX(DP) :: sfac(:,:)
|
|
|
|
COMPLEX(DP) :: eigr(:,:)
|
2006-06-26 15:51:38 +08:00
|
|
|
COMPLEX(DP) :: vkb(:,:)
|
2005-08-28 22:09:42 +08:00
|
|
|
COMPLEX(DP) :: ei1(:,:)
|
|
|
|
COMPLEX(DP) :: ei2(:,:)
|
|
|
|
COMPLEX(DP) :: ei3(:,:)
|
2004-11-25 22:51:47 +08:00
|
|
|
TYPE (boxdimensions), INTENT(INOUT) :: ht0
|
2006-08-04 01:47:35 +08:00
|
|
|
REAL(DP) :: fi(:)
|
2005-08-28 22:09:42 +08:00
|
|
|
REAL(DP) :: bec(:,:)
|
|
|
|
REAL(DP) :: becdr(:,:,:)
|
2004-11-25 22:51:47 +08:00
|
|
|
TYPE (dft_energy_type) :: edft
|
|
|
|
|
2006-06-01 18:51:33 +08:00
|
|
|
REAL(DP) :: ei(:,:)
|
2006-01-10 22:04:13 +08:00
|
|
|
REAL(DP) :: vpot(:,:)
|
2004-11-25 22:51:47 +08:00
|
|
|
|
|
|
|
INTEGER :: maxnstep ! maximum number of iteration
|
2005-08-28 22:09:42 +08:00
|
|
|
REAL(DP) :: sdthr ! threshold for convergence
|
2004-11-25 22:51:47 +08:00
|
|
|
|
|
|
|
! ... declare other variables
|
|
|
|
LOGICAL :: ttsde, ttprint, ttforce, ttstress, gzero, ttortho
|
|
|
|
LOGICAL :: gammasym
|
|
|
|
|
2006-06-26 15:51:38 +08:00
|
|
|
REAL(DP) :: s0, s1, s2, s3, s4, s5, s6, seconds_per_iter
|
|
|
|
REAL(DP) :: eold, ekinc, fccc
|
2005-08-28 22:09:42 +08:00
|
|
|
REAL(DP) :: ekinc_old, emin, demin
|
2004-11-25 22:51:47 +08:00
|
|
|
|
|
|
|
INTEGER :: ispin, nspin, iter, ierr
|
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
REAL(DP), EXTERNAL :: cclock
|
2004-11-25 22:51:47 +08:00
|
|
|
|
|
|
|
! ... end of declarations
|
|
|
|
! ----------------------------------------------
|
|
|
|
|
|
|
|
nspin = cdesc%nspin
|
|
|
|
doions = .FALSE.
|
|
|
|
eold = 1.0d10 ! a large number
|
|
|
|
ttsde = .TRUE.
|
|
|
|
ttprint = .FALSE.
|
|
|
|
ttforce = .FALSE.
|
|
|
|
ttstress = .FALSE.
|
|
|
|
ttortho = .TRUE.
|
2005-12-13 19:50:36 +08:00
|
|
|
fccc = 1.0d0
|
2004-11-25 22:51:47 +08:00
|
|
|
gzero = cdesc%gzero
|
|
|
|
gammasym = cdesc%gamma
|
|
|
|
|
|
|
|
IF( force_pairing ) &
|
|
|
|
CALL errore( ' runsd ', ' force pairing not implemented ', 1 )
|
|
|
|
|
|
|
|
IF( ionode ) THEN
|
|
|
|
WRITE( stdout,'(/,12X,"Steepest Descent Optimizations for electron, starting ...")' )
|
|
|
|
WRITE( stdout,'( 12X,"iter erho derho ekinc seconds")' )
|
|
|
|
END IF
|
|
|
|
|
|
|
|
old_clock_value = cclock()
|
|
|
|
|
2005-04-22 23:23:19 +08:00
|
|
|
CALL phfacs( ei1, ei2, ei3, eigr, mill_l, atoms_0%taus, nr1, nr2, nr3, atoms_0%nat )
|
|
|
|
CALL strucf( sfac, ei1, ei2, ei3, mill_l, ngm )
|
2006-06-26 15:51:38 +08:00
|
|
|
CALL prefor( eigr, vkb )
|
2004-11-25 22:51:47 +08:00
|
|
|
|
|
|
|
STEEPEST_DESCENT: DO iter = 1, maxnstep
|
|
|
|
|
|
|
|
s1 = cclock()
|
|
|
|
|
2006-01-10 22:04:13 +08:00
|
|
|
CALL kspotential( 1, ttprint, ttforce, ttstress, rhoe, atoms_0, &
|
- FPMD: pseudopotential variable wsg, wnl, fnl substituted with
dion, beta, bec everyware.
- subroutines formfn, compute_beta, nlsm1, nlsm2, ecc ... now are common
between FPMD and CPV, a lot of clean ups!
- Changes in stdout: relevant physical quantities ( positions velocities an cell )
are now printed with the seme format of the corresponding input card,
like in PW, as was suggested by SdG.
- exemple23 updated to reflect the new input namelist "wannier"
- Subroutine init_run now is used in FPMD too.
- WARNING in the stress computed with CP, for a pseudo with core-corrections,
a contribution is missing! Not yet fixed, I need to talk with PG for the
box staff.
- WARNING the examples reference are not updated, I'm on the IBM sp, and
I prefer to update them from a linux machine.
git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@2110 c92efa57-630b-4861-b058-cf58834340f0
2005-08-22 22:14:13 +08:00
|
|
|
bec, becdr, eigr, ei1, ei2, ei3, sfac, c0, cdesc, tcel, ht0, &
|
2006-08-04 01:47:35 +08:00
|
|
|
fi, vpot, edft )
|
2004-11-25 22:51:47 +08:00
|
|
|
|
|
|
|
s2 = cclock()
|
|
|
|
|
2006-08-04 01:47:35 +08:00
|
|
|
CALL runcp( ttprint, ttortho, ttsde, cm, c0, cp, vpot, vkb, fi, ekinc, ht0, ei, bec, fccc)
|
2004-11-25 22:51:47 +08:00
|
|
|
|
|
|
|
emin = edft%etot
|
|
|
|
demin = eold - emin
|
|
|
|
eold = emin
|
|
|
|
|
|
|
|
s0 = cclock()
|
|
|
|
seconds_per_iter = ( s0 - old_clock_value )
|
|
|
|
old_clock_value = s0
|
|
|
|
|
|
|
|
IF( ionode ) THEN
|
|
|
|
WRITE( stdout,113) iter, emin, demin, ekinc, seconds_per_iter
|
|
|
|
113 FORMAT(10X,I5,2X,F14.6,2X,3D12.4)
|
|
|
|
END IF
|
|
|
|
|
2006-07-17 17:15:34 +08:00
|
|
|
CALL update_wave_functions( cm, c0, cp )
|
2004-11-25 22:51:47 +08:00
|
|
|
|
|
|
|
s6 = cclock()
|
|
|
|
|
|
|
|
! ... check for exit
|
|
|
|
IF (check_stop_now()) THEN
|
|
|
|
EXIT STEEPEST_DESCENT
|
|
|
|
END IF
|
|
|
|
IF( ekinc .LT. sdthr ) THEN
|
|
|
|
IF(ionode) WRITE( stdout,fmt="(12X,'runsd: convergence achieved succesfully')")
|
|
|
|
doions = .TRUE.
|
|
|
|
EXIT STEEPEST_DESCENT
|
|
|
|
END IF
|
|
|
|
ekinc_old = ekinc
|
|
|
|
END DO STEEPEST_DESCENT
|
|
|
|
|
|
|
|
! ... set wave functions velocity to 0
|
|
|
|
cm = c0
|
|
|
|
|
|
|
|
IF( tforce ) THEN
|
|
|
|
atoms_0%for = 0.0d0
|
2006-01-10 22:04:13 +08:00
|
|
|
CALL kspotential( 1, ttprint, tforce, ttstress, rhoe, &
|
2006-08-04 01:47:35 +08:00
|
|
|
atoms_0, bec, becdr, eigr, ei1, ei2, ei3, sfac, c0, cdesc, tcel, ht0, fi, vpot, edft )
|
2004-11-25 22:51:47 +08:00
|
|
|
IF(ionode ) THEN
|
|
|
|
WRITE( stdout,fmt="(12X,'runsd: fion and edft calculated = ',F14.6)") edft%etot
|
|
|
|
END IF
|
|
|
|
END IF
|
|
|
|
|
|
|
|
IF( (iter .GT. maxnstep) .AND. ionode) THEN
|
|
|
|
WRITE( stdout,fmt= &
|
|
|
|
"(12X,'runsd: convergence not achieved, maximum number of iteration exceeded')")
|
|
|
|
END IF
|
|
|
|
|
|
|
|
RETURN
|
2005-05-18 17:38:45 +08:00
|
|
|
END SUBROUTINE runsd
|
2004-11-25 22:51:47 +08:00
|
|
|
|
|
|
|
! ---------------------------------------------------------------------- !
|
2005-05-18 22:24:56 +08:00
|
|
|
END MODULE runsd_module
|
2004-11-25 22:51:47 +08:00
|
|
|
! ---------------------------------------------------------------------- !
|