@@ -68,9 +68,9 @@ subroutine baoab (istep,dt)
6868 allocate (xold(n))
6969 allocate (yold(n))
7070 allocate (zold(n))
71- allocate (derivs(3 ,n))
7271 allocate (vfric(n))
7372 allocate (vrand(3 ,n))
73+ allocate (derivs(3 ,n))
7474c
7575c use a first B step to find the half-step velocities
7676c
@@ -96,20 +96,15 @@ subroutine baoab (istep,dt)
9696 if (use_rattle) then
9797 call rattle (dtr,xold,yold,zold)
9898 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
99104 end if
100105 end do
101106c
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
113108c
114109 call oprep (dt,vfric,vrand)
115110 do i = 1 , nuse
@@ -169,22 +164,19 @@ subroutine baoab (istep,dt)
169164 v(j,k) = v(j,k) + a(j,k)* dt_2
170165 end do
171166 end do
172- c
173- c find the constraint-corrected full-step velocities
174- c
175167 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
182168 call rattle2 (dt)
183169 do i = 1 , 3
184170 do j = 1 , 3
185171 vir(j,i) = vir(j,i) + virrat(j,i)
186172 end do
187173 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
188180 end if
189181c
190182c compute full-step kinetic energy and pressure correction;
@@ -203,9 +195,9 @@ subroutine baoab (istep,dt)
203195 deallocate (xold)
204196 deallocate (yold)
205197 deallocate (zold)
206- deallocate (derivs)
207198 deallocate (vfric)
208199 deallocate (vrand)
200+ deallocate (derivs)
209201c
210202c total energy is sum of kinetic and potential energies
211203c
@@ -281,21 +273,11 @@ subroutine obabo (istep,dt)
281273 allocate (xold(n))
282274 allocate (yold(n))
283275 allocate (zold(n))
284- allocate (derivs(3 ,n))
285276 allocate (vfric(n))
286277 allocate (vrand(3 ,n))
278+ allocate (derivs(3 ,n))
287279c
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
299281c
300282 call oprep (dt_2,vfric,vrand)
301283 do i = 1 , nuse
@@ -305,6 +287,11 @@ subroutine obabo (istep,dt)
305287 end do
306288 end do
307289 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
308295 call rattle2 (dt_2)
309296 do i = 1 , 3
310297 do j = 1 , 3
@@ -314,7 +301,7 @@ subroutine obabo (istep,dt)
314301 end do
315302 end if
316303c
317- c find half- step velocities via the Verlet recursion
304+ c use a first B step to find the half-step velocities
318305c
319306 do i = 1 , nuse
320307 k = iuse(i)
@@ -323,7 +310,7 @@ subroutine obabo (istep,dt)
323310 end do
324311 end do
325312c
326- c take first A step according to the BAOAB sequence
313+ c take full-step A step according to the BAOAB sequence
327314c
328315 do j = 1 , nrattle
329316 do i = 1 , nuse
@@ -355,8 +342,7 @@ subroutine obabo (istep,dt)
355342c
356343c call kinetic (eksum,ekin,temp)
357344c
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
360346c
361347 do i = 1 , nuse
362348 k = iuse(i)
@@ -365,12 +351,9 @@ subroutine obabo (istep,dt)
365351 v(j,k) = v(j,k) + a(j,k)* dt_2
366352 end do
367353 end do
368- c
369- c find the constraint-corrected full-step velocities
370- c
371354 if (use_rattle) call rattle2 (dt)
372355c
373- c update velocities with frictional and random components
356+ c use second O step for frictional and random components
374357c
375358 call oprep (dt_2,vfric,vrand)
376359 do i = 1 , nuse
@@ -379,23 +362,19 @@ subroutine obabo (istep,dt)
379362 v(j,k) = v(j,k)* vfric(k) + vrand(j,k)
380363 end do
381364 end do
382- if (use_rattle) call rattle2 (dt_2)
383- c
384- c find the constraint-corrected full-step velocities
385- c
386365 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
387372 do i = 1 , nuse
388373 k = iuse(i)
389374 xold(k) = x(k)
390375 yold(k) = y(k)
391376 zold(k) = z(k)
392377 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
399378 end if
400379c
401380c compute the kinetic energy and control the pressure
@@ -413,9 +392,9 @@ subroutine obabo (istep,dt)
413392 deallocate (xold)
414393 deallocate (yold)
415394 deallocate (zold)
416- deallocate (derivs)
417395 deallocate (vfric)
418396 deallocate (vrand)
397+ deallocate (derivs)
419398c
420399c total energy is sum of kinetic and potential energies
421400c
0 commit comments