1
1
!
2
- ! Copyright (C) 2001-2009 Quantum ESPRESSO group
2
+ ! Copyright (C) 2001-2011 Quantum ESPRESSO group
3
3
! This file is distributed under the terms of the
4
4
! GNU General Public License. See the file `License'
5
5
! in the root directory of the present distribution,
6
6
! or http://www.gnu.org/copyleft/gpl.txt .
7
7
!
8
8
!
9
- #define __BFGS
10
- ! #define __NPT
11
- !
9
+ #undef __NPT
12
10
#if defined (__NPT)
13
11
#define RELAXTIME 2000.D0
14
12
#define TARGPRESS 2.39D0
@@ -133,14 +131,15 @@ SUBROUTINE verlet()
133
131
REAL (DP) :: total_mass, temp_new, temp_av, elapsed_time
134
132
REAL (DP) :: delta(3 ), ml(3 ), mlt
135
133
INTEGER :: na
134
+ ! istep0 counts MD steps done during this run
135
+ ! (istep counts instead all MD steps, including those of previous runs)
136
+ INTEGER , SAVE :: istep0 = 0
136
137
#if defined (__NPT)
137
138
REAL (DP) :: chi, press_new
138
139
#endif
139
140
LOGICAL :: file_exists, leof
140
- !
141
141
REAL (DP), EXTERNAL :: dnrm2
142
142
!
143
- !
144
143
! ... the number of degrees of freedom
145
144
!
146
145
IF ( any ( if_pos(:,:) == 0 ) ) THEN
@@ -198,7 +197,7 @@ SUBROUTINE verlet()
198
197
!
199
198
ENDIF
200
199
!
201
- IF ( istep >= nstep ) THEN
200
+ IF ( istep0 >= nstep ) THEN
202
201
!
203
202
conv_ions = .true.
204
203
!
@@ -215,6 +214,7 @@ SUBROUTINE verlet()
215
214
!
216
215
elapsed_time = elapsed_time + dt* 2.D0 * au_ps
217
216
!
217
+ istep0= istep0+ 1
218
218
istep = istep + 1
219
219
!
220
220
WRITE ( UNIT = stdout, &
@@ -434,8 +434,17 @@ SUBROUTINE md_init()
434
434
CASE ( ' andersen' , ' Andersen' )
435
435
!
436
436
WRITE ( UNIT = stdout, &
437
- FMT = ' (/,5X,"temperature is ", &
438
- & "controlled by Andersen thermostat"/)' )
437
+ FMT = ' (/,5X,"temperature is controlled by Andersen ", &
438
+ & "thermostat",/,5x,"Collision frequency =",&
439
+ & f7.4,"/timestep")' ) 1.0_dp / nraise
440
+ !
441
+ CASE ( ' berendsen' , ' Berendsen' )
442
+ !
443
+ WRITE ( UNIT = stdout, &
444
+ FMT = ' (/,5X,"temperature is controlled by soft ", &
445
+ & "(Berendsen) velocity rescaling",/,5x,&
446
+ & "Characteristic time =",i3,"*timestep")' ) &
447
+ nraise
439
448
!
440
449
CASE ( ' initial' , ' Initial' )
441
450
!
@@ -514,6 +523,7 @@ SUBROUTINE apply_thermostat()
514
523
!
515
524
IMPLICIT NONE
516
525
!
526
+ INTEGER :: nat_moved
517
527
REAL (DP) :: sigma, kt
518
528
!
519
529
IF (.not. vel_defined)THEN
@@ -574,25 +584,20 @@ SUBROUTINE apply_thermostat()
574
584
CASE ( ' berendsen' , ' Berendsen' )
575
585
!
576
586
WRITE ( UNIT = stdout, &
577
- FMT = ' (/,5X,"Soft velocity rescaling with tau=",i3, &
578
- & "*time step: T_new = ",F6.1,"K ")' ) nraise,temp_new
587
+ FMT = ' (/,5X,"Soft (Berendsen) velocity rescaling")' )
579
588
!
580
589
CALL thermalize( nraise, temp_new, temperature )
581
590
!
582
591
CASE ( ' andersen' , ' Andersen' )
583
592
!
584
593
kt = temperature / ry_to_kelvin
585
- !
586
- WRITE ( UNIT = stdout, &
587
- FMT = ' (/,5X,"Andersen thermostat with acceptance rate ",&
588
- & f6.3,": T_new = ",F6.1,"K ")' ) temp_new
589
- !
590
- CALL thermalize( nraise, temp_new, temperature )
594
+ nat_moved = 0
591
595
!
592
596
DO na = 1 , nat
593
597
!
594
598
IF ( randy() < 1.D0 / dble ( nraise ) ) THEN
595
599
!
600
+ nat_moved = nat_moved + 1
596
601
sigma = sqrt ( kt / mass(na) )
597
602
!
598
603
! ... N.B. velocities must in a.u. units of alat and are zero
@@ -605,6 +610,10 @@ SUBROUTINE apply_thermostat()
605
610
!
606
611
ENDDO
607
612
!
613
+ IF ( nat_moved > 0 ) WRITE ( UNIT = stdout, &
614
+ FMT = ' (/,5X,"Andersen thermostat: ",I4," collisions")' ) &
615
+ nat_moved
616
+ !
608
617
CASE ( ' initial' , ' Initial' )
609
618
!
610
619
CONTINUE
@@ -629,14 +638,17 @@ SUBROUTINE start_therm()
629
638
USE control_flags, ONLY : lfixatom
630
639
USE cell_base, ONLY : alat
631
640
USE ions_base, ONLY : nat, if_pos
632
- USE random_numbers, ONLY : gauss_dist
641
+ USE random_numbers, ONLY : gauss_dist, set_random_seed
633
642
!
634
643
IMPLICIT NONE
635
644
!
636
645
INTEGER :: na, nb
637
646
REAL (DP) :: total_mass, kt, sigma, ek, ml(3 ), system_temp
638
647
!
648
+ ! ... next command prevents different MD runs to start
649
+ ! ... with exactly the same "random" velocities
639
650
!
651
+ call set_random_seed ( )
640
652
kt = temperature / ry_to_kelvin
641
653
!
642
654
! ... starting velocities have a Maxwell-Boltzmann distribution
@@ -1290,8 +1302,6 @@ SUBROUTINE force_precond( istep, force, etotold )
1290
1302
REAL (DP), INTENT (inout ) :: force(:,:)
1291
1303
REAL (DP), INTENT (in ) :: etotold
1292
1304
!
1293
- #if defined (__BFGS)
1294
- !
1295
1305
REAL (DP), ALLOCATABLE :: pos(:), pos_p(:)
1296
1306
REAL (DP), ALLOCATABLE :: grad(:), grad_p(:), precond_grad(:)
1297
1307
REAL (DP), ALLOCATABLE :: inv_hess(:,:)
@@ -1403,8 +1413,6 @@ SUBROUTINE force_precond( istep, force, etotold )
1403
1413
DEALLOCATE ( y, s )
1404
1414
DEALLOCATE ( Hy, yH )
1405
1415
!
1406
- #endif
1407
- !
1408
1416
END SUBROUTINE force_precond
1409
1417
!
1410
1418
!- ----------------------------------------------------------------------
0 commit comments