@@ -68,9 +68,9 @@ subroutine baoab (istep,dt)
68
68
allocate (xold(n))
69
69
allocate (yold(n))
70
70
allocate (zold(n))
71
- allocate (derivs(3 ,n))
72
71
allocate (vfric(n))
73
72
allocate (vrand(3 ,n))
73
+ allocate (derivs(3 ,n))
74
74
c
75
75
c use a first B step to find the half-step velocities
76
76
c
@@ -96,20 +96,15 @@ subroutine baoab (istep,dt)
96
96
if (use_rattle) then
97
97
call rattle (dtr,xold,yold,zold)
98
98
call rattle2 (dtr)
99
+ do i = 1 , 3
100
+ do k = 1 , 3
101
+ vir(k,i) = 0.0d0
102
+ end do
103
+ end do
99
104
end if
100
105
end do
101
106
c
102
- c initialize virial for stochastic and constraint forces
103
- c
104
- if (use_rattle) then
105
- do i = 1 , 3
106
- do j = 1 , 3
107
- vir(j,i) = 0.0d0
108
- end do
109
- end do
110
- end if
111
- c
112
- c next an O step to get frictional and random components
107
+ c use an O step to get frictional and random components
113
108
c
114
109
call oprep (dt,vfric,vrand)
115
110
do i = 1 , nuse
@@ -169,22 +164,19 @@ subroutine baoab (istep,dt)
169
164
v(j,k) = v(j,k) + a(j,k)* dt_2
170
165
end do
171
166
end do
172
- c
173
- c find the constraint-corrected full-step velocities
174
- c
175
167
if (use_rattle) then
176
- do i = 1 , nuse
177
- k = iuse(i)
178
- xold(k) = x(k)
179
- yold(k) = y(k)
180
- zold(k) = z(k)
181
- end do
182
168
call rattle2 (dt)
183
169
do i = 1 , 3
184
170
do j = 1 , 3
185
171
vir(j,i) = vir(j,i) + virrat(j,i)
186
172
end do
187
173
end do
174
+ do i = 1 , nuse
175
+ k = iuse(i)
176
+ xold(k) = x(k)
177
+ yold(k) = y(k)
178
+ zold(k) = z(k)
179
+ end do
188
180
end if
189
181
c
190
182
c compute full-step kinetic energy and pressure correction;
@@ -203,9 +195,9 @@ subroutine baoab (istep,dt)
203
195
deallocate (xold)
204
196
deallocate (yold)
205
197
deallocate (zold)
206
- deallocate (derivs)
207
198
deallocate (vfric)
208
199
deallocate (vrand)
200
+ deallocate (derivs)
209
201
c
210
202
c total energy is sum of kinetic and potential energies
211
203
c
@@ -281,21 +273,11 @@ subroutine obabo (istep,dt)
281
273
allocate (xold(n))
282
274
allocate (yold(n))
283
275
allocate (zold(n))
284
- allocate (derivs(3 ,n))
285
276
allocate (vfric(n))
286
277
allocate (vrand(3 ,n))
278
+ allocate (derivs(3 ,n))
287
279
c
288
- c initialize virial for stochastic and constraint forces
289
- c
290
- if (use_rattle) then
291
- do i = 1 , 3
292
- do j = 1 , 3
293
- vir(j,i) = 0.0d0
294
- end do
295
- end do
296
- end if
297
- c
298
- c update velocities with frictional and random components
280
+ c take first O step for frictional and random components
299
281
c
300
282
call oprep (dt_2,vfric,vrand)
301
283
do i = 1 , nuse
@@ -305,6 +287,11 @@ subroutine obabo (istep,dt)
305
287
end do
306
288
end do
307
289
if (use_rattle) then
290
+ do i = 1 , 3
291
+ do j = 1 , 3
292
+ vir(j,i) = 0.0d0
293
+ end do
294
+ end do
308
295
call rattle2 (dt_2)
309
296
do i = 1 , 3
310
297
do j = 1 , 3
@@ -314,7 +301,7 @@ subroutine obabo (istep,dt)
314
301
end do
315
302
end if
316
303
c
317
- c find half- step velocities via the Verlet recursion
304
+ c use a first B step to find the half-step velocities
318
305
c
319
306
do i = 1 , nuse
320
307
k = iuse(i)
@@ -323,7 +310,7 @@ subroutine obabo (istep,dt)
323
310
end do
324
311
end do
325
312
c
326
- c take first A step according to the BAOAB sequence
313
+ c take full-step A step according to the BAOAB sequence
327
314
c
328
315
do j = 1 , nrattle
329
316
do i = 1 , nuse
@@ -355,8 +342,7 @@ subroutine obabo (istep,dt)
355
342
c
356
343
c call kinetic (eksum,ekin,temp)
357
344
c
358
- c use Newton's second law to get the next accelerations;
359
- c find the full-step velocities using the Verlet recursion
345
+ c second B step for accelerations and full-step velocities
360
346
c
361
347
do i = 1 , nuse
362
348
k = iuse(i)
@@ -365,12 +351,9 @@ subroutine obabo (istep,dt)
365
351
v(j,k) = v(j,k) + a(j,k)* dt_2
366
352
end do
367
353
end do
368
- c
369
- c find the constraint-corrected full-step velocities
370
- c
371
354
if (use_rattle) call rattle2 (dt)
372
355
c
373
- c update velocities with frictional and random components
356
+ c use second O step for frictional and random components
374
357
c
375
358
call oprep (dt_2,vfric,vrand)
376
359
do i = 1 , nuse
@@ -379,23 +362,19 @@ subroutine obabo (istep,dt)
379
362
v(j,k) = v(j,k)* vfric(k) + vrand(j,k)
380
363
end do
381
364
end do
382
- if (use_rattle) call rattle2 (dt_2)
383
- c
384
- c find the constraint-corrected full-step velocities
385
- c
386
365
if (use_rattle) then
366
+ call rattle2 (dt_2)
367
+ do i = 1 , 3
368
+ do j = 1 , 3
369
+ vir(j,i) = vir(j,i) + virrat(j,i)
370
+ end do
371
+ end do
387
372
do i = 1 , nuse
388
373
k = iuse(i)
389
374
xold(k) = x(k)
390
375
yold(k) = y(k)
391
376
zold(k) = z(k)
392
377
end do
393
- call rattle2 (dt)
394
- do i = 1 , 3
395
- do j = 1 , 3
396
- vir(j,i) = vir(j,i) + virrat(j,i)
397
- end do
398
- end do
399
378
end if
400
379
c
401
380
c compute the kinetic energy and control the pressure
@@ -413,9 +392,9 @@ subroutine obabo (istep,dt)
413
392
deallocate (xold)
414
393
deallocate (yold)
415
394
deallocate (zold)
416
- deallocate (derivs)
417
395
deallocate (vfric)
418
396
deallocate (vrand)
397
+ deallocate (derivs)
419
398
c
420
399
c total energy is sum of kinetic and potential energies
421
400
c
0 commit comments