7
subroutine new_dm( auxchanged )
11
use atomlist, only: datm, no_s, iaorb, lasto, no_u, no_l
12
use m_steps, only: istp
13
use m_spin, only: nspin
14
use m_extrapol, only: extrapol
18
logical:: auxchanged ! Has auxiliary supercell changed?
20
logical:: dminit ! Initialize density matrix?
21
integer:: iord ! Order of DM extrapolation between geom. steps
22
integer:: istpsave ! Temporary to save and restore istp when reading DM from file
23
logical:: itest ! Temporary used to check if DM have just been read
26
! Initialize density matrix
27
! Set density matrix for first step
30
if (istp .eq. 1) dminit = .true.
31
if (istp .ne. 1 .and. harrisfun) dminit = .true.
32
if (istp .ne. 1 .and. (idyn .eq. 6)
33
$ .and. usesavedm .and. writedm) dminit = .true.
34
if (istp .ne. 1 .and. (idyn .eq. 7)
35
$ .and. usesavedm) dminit = .true.
37
! If auxiliary cell has changed, optionally reset density matrix
38
! and set usesavedata to false to avoid reading back saved copy
39
if (initdmaux.and.auxchanged) then
41
usesavedmloc = .false.
43
usesavedmloc = usesavedm
47
. call initdm(Datm, Dscf, Dold, lasto, na_s,
48
. maxnh, no_s, no_l, nspin, na_u, no_l, nspin,
49
. numh, numhold, listhptr, listhptrold,
50
. listh, listhold, iaorb, found, inspn,
54
! Initialize energy-density matrix to zero for first call to overfsm
55
Escf(1:maxnh,1:nspin) = 0.0_dp
57
! Extrapolate density matrix between steps
61
if (idyn .eq. 0) iord = 0
62
if (idyn .eq. 6) iord = 0
63
if (idyn .eq. 7) iord = 0
64
! If DM has just been read from disk,
65
! call extrapol with istep = 2 and iord = 0
66
! to make it update the structure of DM, if needed
67
if (found .and. ((istp .eq. 1) .or. (idyn .eq. 6)
68
. .or. (idyn .eq. 7))) then
75
. call extrapol(istp, iord, nspin, no_s, no_l, maxnh,
76
. numh, listhptr, listh, numhold, listhptrold,
77
. listhold, Dscfsave, Dscf)
78
! If DM have just been read, restore istp
79
if (itest) istp = istpsave