-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcycles.f90
365 lines (290 loc) · 9.41 KB
/
cycles.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
program cycles
use routines
use f90nautyinterf
implicit none
integer :: nsites, &
ievt, nevt, n_in_map, n_color, &
hash_val1, hash_val2, hash_val3, kart_hash
integer :: i, j, k, isite, idx
real :: Rcut, dum, rnd
real, dimension(3,3) :: bases
integer, dimension(3) :: bases_indices
real, allocatable :: coords(:,:), map_coords(:,:), color_cutoff(:,:), &
map_ordered_coords(:,:), all_prob(:), prob_M(:)
integer, allocatable :: types(:), map_indices(:), map_types(:), &
connect(:,:), lab(:), color(:),&
global_from_sorted_color(:), sorted_from_global_color(:),&
site_hash(:), all_hash(:), event_nat(:), ev_site(:), ev_tag(:)
open(unit=111,file='site.in',status='old')
open(unit=444,file='events.in',status='old')
call set_random_seed()
!!!----------------------------
!!! set up color cutoff matrix
!!!----------------------------
call set_color_cutoff(color_cutoff)
!!! cutoff to create a map - is not the same as color cutoff matrix, should be larger
Rcut = 1.1
!!!-------------------------
!!! read sites
!!!-------------------------
call get_nsites(111,nsites)
allocate(coords(1:nsites,1:3))
allocate(types(1:nsites))
allocate(site_hash(1:nsites))
call read_sites3D_new(111,nsites,types,coords)
! do i = 1, nsites
! write(*,*) types(i), coords(i,:)
! end do
!!!------------------------------
!!!
!!! loop on all sites, get hash, store it
!!!
!!!------------------------------
DO isite = 1, nsites
!isite = 5
!!!---------------------------------
!!! construct connectivity matrix from site map
!!!---------------------------------
call map_site(isite,Rcut,coords,types,map_coords,map_types,map_indices,n_in_map)
!write(*,*) isite,'/',nsites
!write(*,*) 'typ,coord as read'
!do i = 1, nsites
! write(*,*) map_types(i),map_coords(i,:)
!end do
allocate(connect(1:n_in_map,1:n_in_map))
connect(:,:) = 0
allocate(lab(1:n_in_map))
lab(:) = 0
allocate(color(1:n_in_map))
color(:) = 0
allocate(sorted_from_global_color(1:n_in_map))
allocate(global_from_sorted_color(1:n_in_map))
call sort_property(n_in_map, map_types, color, global_from_sorted_color,&
sorted_from_global_color)
! write(*,*)'sorted map_types',map_types
! write(*,*) 'global_from_sorted_color',global_from_sorted_color
! write(*,*) 'sorted_color_from_global',sorted_from_global_color
! write(*,*) 'color is',color
do i=1, n_in_map
do j=i+1, n_in_map
dum=0.0
do k=1,3
dum= dum+(map_coords(j,k)-map_coords(i,k))**2
enddo
dum=sqrt(dum)
connect(i,j)= NINT(0.5*erfc(dum-color_cutoff(map_types(i),map_types(j))))
connect(j,i)= NINT(0.5*erfc(dum-color_cutoff(map_types(j),map_types(i))))
! write(*,*) i,j,dij, connect(i,j), connect(j,i)
enddo
enddo
! write(*,*) "connect"
! do i=1, n_in_map
! write(*,"(15i4)") (connect(i,j), j=1,n_in_map)
! enddo
! write(*,*) "lab"
do i=1,n_in_map
lab(i)=global_from_sorted_color(i)-1
! write(*,*) lab(i)
enddo
!!!---------------------------
!!! get canon, hash
!!!---------------------------
! write(*,*) 'coords before canon11'
! do i =1,n_in_map
! write(*,*) map_types(i), map_coords(i,:)
! end do
hash_val1=0
hash_val2=0
hash_val3=0
call c_ffnautyex1_sestic(n_in_map, connect,lab,color, hash_val1,hash_val2,hash_val3)
kart_hash= modulo (modulo (hash_val1,104729)+ modulo(hash_val2, 15485863)+ &
modulo(hash_val3, 882377) - 1, 1299709)+1
write(*,*) "config hash is",isite,'/',nsites
write(*,*) kart_hash
site_hash(isite) = kart_hash
do i=1,n_in_map
lab(i) = lab(i) + 1
end do
deallocate(connect)
deallocate(lab)
deallocate(color)
deallocate(sorted_from_global_color)
deallocate(global_from_sorted_color)
ENDDO
!!!--------------------------------
!!!
!!! at this point, all site hashes are known
!!!
!!!--------------------------------
open(unit=323,file='ordered_events.dat',status='old')
call get_hash_prob_new(323,all_hash,all_prob,event_nat)
write(*,*) 'events info'
write(*,*) all_hash
write(*,*) all_prob
!! vector to fill probabilities
nevt = size(all_hash)
write(*,*) 'nevt',nevt
allocate(prob_M(1:nsites*nevt))
allocate(ev_site(1:nsites*nevt))
allocate(ev_tag(1:nsites*nevt))
prob_M(:) = 0.0
ev_site(:) = 0
k=1
do isite =1,nsites
do ievt=1,nevt
if ( all_hash(ievt)==site_hash(isite) ) then
prob_M(k) = all_prob(ievt)
ev_site(k) = isite
ev_tag(k) = ievt
k = k+1
endif
end do
end do
do i=1,size(prob_M)
write(*,'(A4,F5.2)') 'prob',prob_M(i)
write(*,'(A2,I2)') 'on',ev_site(i)
end do
call random_number(rnd)
call choose_p(prob_M,size(prob_M),rnd,idx)
write(*,*) 'chosen event',idx,'with',prob_M(idx),'which is ev@',ev_tag(idx)
write(*,*) 'which should be at site',ev_site(idx)
!!!------------------
!!! the event is chosen at this point 'idx', on site 'ev_site(idx)'
!!!------------------
!!!!!!!!! get again all info of that site
!!!---------------------------------
!!! construct connectivity matrix from site map
!!!---------------------------------
call map_site(ev_site(idx),Rcut,coords,types,map_coords,map_types,map_indices,n_in_map)
!write(*,*) isite,'/',nsites
!write(*,*) 'typ,coord as read'
!do i = 1, nsites
! write(*,*) map_types(i),map_coords(i,:)
!end do
allocate(connect(1:n_in_map,1:n_in_map))
connect(:,:) = 0
allocate(lab(1:n_in_map))
lab(:) = 0
allocate(color(1:n_in_map))
color(:) = 0
allocate(sorted_from_global_color(1:n_in_map))
allocate(global_from_sorted_color(1:n_in_map))
call sort_property(n_in_map, map_types, color, global_from_sorted_color,&
sorted_from_global_color)
write(*,*)'sorted map_types',map_types
write(*,*) 'global_from_sorted_color',global_from_sorted_color
write(*,*) 'sorted_color_from_global',sorted_from_global_color
write(*,*) 'color is',color
do i=1, n_in_map
do j=i+1, n_in_map
dum=0.0
do k=1,3
dum= dum+(map_coords(j,k)-map_coords(i,k))**2
enddo
dum=sqrt(dum)
connect(i,j)= NINT(0.5*erfc(dum-color_cutoff(map_types(i),map_types(j))))
connect(j,i)= NINT(0.5*erfc(dum-color_cutoff(map_types(j),map_types(i))))
! write(*,*) i,j,dij, connect(i,j), connect(j,i)
enddo
enddo
! write(*,*) "connect"
! do i=1, n_in_map
! write(*,"(15i4)") (connect(i,j), j=1,n_in_map)
! enddo
! write(*,*) "lab"
do i=1,n_in_map
lab(i)=global_from_sorted_color(i)-1
! write(*,*) lab(i)
enddo
!!!---------------------------
!!! get canon, hash
!!!---------------------------
! write(*,*) 'coords before canon11'
! do i =1,n_in_map
! write(*,*) map_types(i), map_coords(i,:)
! end do
hash_val1=0
hash_val2=0
hash_val3=0
call c_ffnautyex1_sestic(n_in_map, connect,lab,color, hash_val1,hash_val2,hash_val3)
kart_hash= modulo (modulo (hash_val1,104729)+ modulo(hash_val2, 15485863)+ &
modulo(hash_val3, 882377) - 1, 1299709)+1
! write(*,*) "config hash is",isite,'/',nsites
write(*,*) kart_hash
do i=1,n_in_map
lab(i) = lab(i) + 1
end do
! write(*,*) "canon order, canon typ, and pos in such order"
! do i=1,n_in_map
! write(*,*) lab(i), map_types(sorted_from_global_color(lab(i))),&
! map_coords(lab(i),:)
! enddo
! write(*,*) 'coords before canon'
! do i =1,n_in_map
! write(*,*) map_types(i), map_coords(i,:)
! end do
!write(*,*) 'canon order',lab
!! reorder cluster into canon
! call sort_to_canon(n_in_map,map_coords,map_ordered_coords,lab)
! write(*,*) 'coords after canon'
! do i =1,n_in_map
! write(*,*) map_types(i), map_ordered_coords(i,:)
! end do
!! get the basis of cluster in canon order
call find_noncollinear_vectors(n_in_map,map_ordered_coords,bases,bases_indices)
call gram_schmidt(bases)
! do i =1,3
! write(*,*) bases(i,:)
! end do
!! replace involved vectors with final event positions
!!!! first get final positions from ordered_events.dat
!! crist_to_cart( basis found before )
deallocate(connect)
deallocate(lab)
deallocate(color)
deallocate(sorted_from_global_color)
deallocate(global_from_sorted_color)
!write(*,*) 'coords before canon22'
!do i =1,n_in_map
! write(*,*) map_types(i), map_coords(i,:)
!end do
! write(*,*) "canon order, canon typ, and pos in such order"
! do i=1,n_in_map
! write(*,*) lab(i), map_types(sorted_from_global_color(lab(i))),&
! map_coords(lab(i),:)
! enddo
!
! write(*,*) 'coords before canon'
! do i =1,n_in_map
! write(*,*) map_types(i), map_coords(i,:)
! end do
! !write(*,*) 'canon order',lab
!
! !! reorder cluster into canon
! call sort_to_canon(n_in_map,map_coords,map_ordered_coords,lab)
! write(*,*) 'coords after canon'
! do i =1,n_in_map
! write(*,*) map_types(i), map_ordered_coords(i,:)
! end do
!
! !! get the basis of cluster in canon order
!
! !! find possible events
!
! ! probably this loop should end here
!
! !! replace involved vectors with final event positions
!
! !! crist_to_cart( basis found before )
!
! !!!---------------
! !!! deallocate for next site
! !!!---------------
! deallocate(connect)
! deallocate(lab)
! deallocate(color)
! deallocate(sorted_from_global_color)
! deallocate(global_from_sorted_color)
!
! end do
end program cycles