-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathrestart_sub.f90
184 lines (180 loc) · 5.79 KB
/
restart_sub.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
!
! Copyright (C) 2002-2005 Quantum ESPRESSO group
! 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 .
!
!
SUBROUTINE from_restart( )
!
USE kinds, ONLY : DP
USE control_flags, ONLY : tbeg, taurdr, tfor, tsdp, iverbosity, &
tsde, tzeroe, tzerop, nbeg, tranp, amprp,&
thdyn, tzeroc, force_pairing, trhor, &
ampre, trane, tpre, dt_old
USE wavefunctions_module, ONLY : c0_bgrp, cm_bgrp
USE electrons_module, ONLY : occn_info
USE electrons_base, ONLY : nspin, iupdwn, nupdwn, f, nbsp, nbsp_bgrp
USE io_global, ONLY : ionode, ionode_id, stdout
USE cell_base, ONLY : ainv, h, hold, deth, r_to_s, s_to_r, &
velh, at, alat
USE ions_base, ONLY : na, nsp, iforce, vel_srt, nat, randpos
USE time_step, ONLY : tps, delt
USE ions_positions, ONLY : taus, tau0, tausm, taum, vels, fion, fionm, set_velocities
USE ions_nose, ONLY : xnhp0, xnhpm
USE gvect, ONLY : mill, eigts1, eigts2, eigts3
USE printout_base, ONLY : printout_pos
USE gvecs, ONLY : ngms
USE gvecw, ONLY : ngw
USE cp_interfaces, ONLY : phfacs, strucf, prefor, calbec_bgrp, caldbec_bgrp
USE energies, ONLY : eself, dft_energy_type
USE wave_base, ONLY : rande_base
USE efield_module, ONLY : efield_berry_setup, tefield, &
efield_berry_setup2, tefield2
USE uspp, ONLY : okvan, vkb, nkb, nlcc_any
USE cp_main_variables, ONLY : ht0, htm, lambdap, lambda, lambdam, eigr, &
sfac, taub, irb, eigrb, edft, bec_bgrp, dbec, descla
USE time_step, ONLY : delt
USE fft_base, ONLY : dfftp
USE matrix_inversion
!
IMPLICIT NONE
INTEGER :: iss
CALL start_clock( 'from_restart' )
!
! ... We are restarting from file recompute ainv
!
CALL invmat( 3, h, ainv, deth )
!
! ... Reset total time counter if the run is not strictly 'restart'
!
IF ( nbeg < 1 ) tps = 0.D0
!
IF ( taurdr ) THEN
!
! ... Input positions read from input file and stored in tau0
! ... in readfile, only scaled positions are read
!
CALL r_to_s( tau0, taus, na, nsp, ainv )
!
END IF
!
IF ( ANY( tranp(1:nsp) ) ) THEN
!
! ... Input positions are randomized
!
CALL randpos( taus, na, nsp, tranp, amprp, ainv, iforce )
!
END IF
!
IF ( tzerop .AND. tfor ) THEN
!
vel_srt(:,:) = 0.0_dp
vels(:,:) = 0.0_dp
CALL set_velocities( tausm, taus, vels, iforce, nat, delt )
WRITE( stdout, '(" Ionic velocities set to zero")' )
!
END IF
!
CALL s_to_r( taus, tau0, na, nsp, h )
!
!CALL s_to_r( tausm, taum, na, nsp, h )
!BS: tausm to taum conversion should use hold in variable cell calculations...
CALL s_to_r( tausm, taum, na, nsp, hold )
!
IF ( tzeroc ) THEN
!
hold = h
velh = 0.D0
!
htm = ht0
ht0%hvel = 0.D0
!
END IF
!
fion = 0.D0
!
IF( force_pairing ) THEN
cm_bgrp(:,iupdwn(2):nbsp) = cm_bgrp(:,1:nupdwn(2))
c0_bgrp(:,iupdwn(2):nbsp) = c0_bgrp(:,1:nupdwn(2))
lambdap( :, :, 2) = lambdap( :, :, 1)
lambda( :, :, 2) = lambda( :, :, 1)
lambdam( :, :, 2) = lambdam( :, :, 1)
END IF
!
IF ( tzeroe ) THEN
!
lambdam = lambda
!
cm_bgrp = c0_bgrp
!
WRITE( stdout, '(" Electronic velocities set to zero")' )
!
END IF
!
! ... computes form factors and initializes nl-pseudop. according
! ... to starting cell (from ndr or again standard input)
!
IF ( okvan .or. nlcc_any ) THEN
CALL initbox( tau0, alat, at, ainv, taub, irb )
CALL phbox( taub, iverbosity, eigrb )
END IF
!
CALL phfacs( eigts1, eigts2, eigts3, eigr, mill, taus, dfftp%nr1, dfftp%nr2, dfftp%nr3, nat )
!
CALL strucf( sfac, eigts1, eigts2, eigts3, mill, ngms )
!
CALL prefor( eigr, vkb )
!
CALL formf( .TRUE. , eself )
!
IF ( trane ) THEN
!
WRITE( stdout, 515 ) ampre
!
515 FORMAT( 3X,'Initial random displacement of el. coordinates',/ &
3X,'Amplitude = ',F10.6 )
!
CALL rande_base( c0_bgrp, ampre )
!
CALL gram_bgrp( vkb, bec_bgrp, nkb, c0_bgrp, ngw )
!
IF( force_pairing ) c0_bgrp(:,iupdwn(2):nbsp) = c0_bgrp(:,1:nupdwn(2))
!
cm_bgrp = c0_bgrp
!
END IF
!
CALL calbec_bgrp( 1, nsp, eigr, c0_bgrp, bec_bgrp )
!
IF ( tpre ) CALL caldbec_bgrp( eigr, c0_bgrp, dbec, descla )
!
IF ( tefield ) CALL efield_berry_setup( eigr, tau0 )
IF ( tefield2 ) CALL efield_berry_setup2( eigr, tau0 )
!
CALL plugin_init_ions( tau0 )
!
edft%eself = eself
!
IF( tzerop .or. tzeroe .or. tzeroc ) THEN
IF( .not. ( tzerop .and. tzeroe .and. ( tzeroc .or. .not. thdyn ) ) ) THEN
IF( ionode ) THEN
WRITE( stdout, * ) 'WARNING setting to ZERO ions, electrons and cell velocities without '
WRITE( stdout, * ) 'setting to ZERO all velocities could generate meaningles trajectories '
END IF
END IF
END IF
!
! dt_old should be -1.0 here if untouched ...
!
if ( dt_old > 0.0d0 ) then
tausm = taus - (taus-tausm)*delt/dt_old
xnhpm = xnhp0 - (xnhp0-xnhpm)*delt/dt_old
WRITE( stdout, '(" tausm & xnhpm were rescaled ")' )
endif
CALL stop_clock( 'from_restart' )
!
RETURN
!
END SUBROUTINE from_restart