Skip to content

Commit cde9bf0

Browse files
committed
assign atoms to default group 0 when groups are not specified
1 parent fc1f226 commit cde9bf0

File tree

2 files changed

+64
-41
lines changed

2 files changed

+64
-41
lines changed

source/cluster.f

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ subroutine cluster
2424
use inform
2525
use iounit
2626
use keys
27-
use limits
2827
use molcul
2928
implicit none
3029
integer i,j,k
@@ -154,37 +153,67 @@ subroutine cluster
154153
c
155154
c pack atoms of each group into a contiguous indexed list
156155
c
157-
do i = 1, n
158-
list(i) = grplist(i)
159-
end do
160-
call sort3 (n,list,kgrp)
156+
if (use_group) then
157+
do i = 1, n
158+
list(i) = grplist(i)
159+
end do
160+
call sort3 (n,list,kgrp)
161161
c
162162
c find the first and last atom in each of the groups
163163
c
164-
k = list(1)
165-
igrp(1,k) = 1
166-
do i = 1, n
167-
j = list(i)
168-
if (j .ne. k) then
169-
igrp(2,k) = i - 1
170-
igrp(1,j) = i
171-
k = j
172-
end if
173-
ngrp = max(j,ngrp)
174-
end do
175-
igrp(2,j) = n
164+
k = list(1)
165+
igrp(1,k) = 1
166+
do i = 1, n
167+
j = list(i)
168+
if (j .ne. k) then
169+
igrp(2,k) = i - 1
170+
igrp(1,j) = i
171+
k = j
172+
end if
173+
ngrp = max(j,ngrp)
174+
end do
175+
igrp(2,j) = n
176176
c
177177
c sort the list of atoms in each group by atom number
178178
c
179-
do i = 0, ngrp
180-
size = igrp(2,i) - igrp(1,i) + 1
181-
if (igrp(1,i) .ne. 0) call sort (size,kgrp(igrp(1,i)))
182-
end do
179+
do i = 0, ngrp
180+
size = igrp(2,i) - igrp(1,i) + 1
181+
if (igrp(1,i) .ne. 0) call sort (size,kgrp(igrp(1,i)))
182+
end do
183+
c
184+
c if groups are not used, put full system in default group
185+
c
186+
else
187+
ngrp = 0
188+
igrp(1,0) = 1
189+
igrp(2,0) = n
190+
do i = 1, n
191+
kgrp(i) = i
192+
grplist(i) = 0
193+
end do
194+
end if
183195
c
184196
c perform deallocation of some local arrays
185197
c
186198
deallocate (list)
187199
c
200+
c compute the total mass of all atoms in each group
201+
c
202+
do i = 0, ngrp
203+
grpmass(i) = 0.0d0
204+
do j = igrp(1,i), igrp(2,i)
205+
grpmass(i) = grpmass(i) + mass(kgrp(j))
206+
end do
207+
end do
208+
c
209+
c turn off bounds and replicas for intragroup calculations
210+
c
211+
if (use_intra) then
212+
use_bounds = .false.
213+
use_replica = .false.
214+
call cutoffs
215+
end if
216+
c
188217
c use only intragroup or intergroup interactions if selected
189218
c
190219
if (use_intra) then
@@ -204,7 +233,7 @@ subroutine cluster
204233
end do
205234
end if
206235
c
207-
c disable consideration of interactions with any empty groups
236+
c disable consideration of interactions with empty groups
208237
c
209238
do i = 0, ngrp
210239
size = igrp(2,i) - igrp(1,i) + 1
@@ -216,27 +245,10 @@ subroutine cluster
216245
end if
217246
end do
218247
c
219-
c turn off bounds and replicas for intragroup calculations
220-
c
221-
if (use_intra) then
222-
use_bounds = .false.
223-
use_replica = .false.
224-
call cutoffs
225-
end if
226-
c
227-
c compute the total mass of all atoms in each group
228-
c
229-
do i = 0, ngrp
230-
grpmass(i) = 0.0d0
231-
do j = igrp(1,i), igrp(2,i)
232-
grpmass(i) = grpmass(i) + mass(kgrp(j))
233-
end do
234-
end do
235-
c
236248
c output the final list of atoms in each group
237249
c
238250
if (use_group .and. debug) then
239-
do i = 0, ngrp
251+
do i = 1, ngrp
240252
size = igrp(2,i) - igrp(1,i) + 1
241253
if (size .ne. 0) then
242254
write (iout,50) i

source/diffuse.f

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ program diffuse
3737
integer nframe,iframe
3838
integer iarc,start,stop
3939
integer step,skip,size
40+
integer nave,nstart,nstop
4041
integer, allocatable :: list(:)
4142
integer, allocatable :: ntime(:)
4243
real*8 xmid,ymid,zmid
@@ -45,7 +46,8 @@ program diffuse
4546
real*8 xr,yr,zr,weigh
4647
real*8 tstep,dunits,delta
4748
real*8 xvalue,yvalue,zvalue
48-
real*8 rvalue,dvalue,counts
49+
real*8 rvalue,counts
50+
real*8 dvalue,dave
4951
real*8, allocatable :: xmsd(:)
5052
real*8, allocatable :: ymsd(:)
5153
real*8, allocatable :: zmsd(:)
@@ -332,16 +334,25 @@ program diffuse
332334
& 7x,'R MSD',4x,'Diff Const',
333335
& /,7x,'(ps)',9x,'(/2)',8x,'(/2)',8x,'(/2)',8x,'(/6)',
334336
& 5x,'(x 10^5)',/)
337+
nstart = nint(dble(nframe-1)/3.0d0)
338+
nstop = 2 * nstart
339+
nave = nstop - nstart + 1
340+
dave = 0.0d0
335341
do i = 1, nframe-1
336342
delta = tstep * dble(i)
337343
xvalue = xmsd(i) / 2.0d0
338344
yvalue = ymsd(i) / 2.0d0
339345
zvalue = zmsd(i) / 2.0d0
340346
rvalue = (xmsd(i) + ymsd(i) + zmsd(i)) / 6.0d0
341347
dvalue = rvalue / delta
348+
if (i.ge.nstart .and. i.le.nstop) dave = dave + dvalue/nave
342349
write (iout,190) delta,xvalue,yvalue,zvalue,rvalue,dvalue
343350
190 format (f12.2,4f12.2,f12.4)
344351
end do
352+
if (nave .ge. 8) then
353+
write (iout,200) dave
354+
200 format (/,' Self-Diffusion Constant :',f12.4,' x 10^-5 cm^2/s')
355+
end if
345356
c
346357
c perform deallocation of some local arrays
347358
c

0 commit comments

Comments
 (0)