Should "compute contact/atom" and "compute pair/gran/local" give the same number of contacts per particle/atom ?

Submitted by limone on Thu, 01/25/2018 - 18:08

Dear All,

I would like to compare the output of compute contact/atom for the contacts count of each particle/atom (to calculate the number of contacts for each atom in a group) and compute pair/gran/local for the number of pairwise interactions or particle-wall interactions in the system.

compute contact/atom
compute atomtrack all contact/atom
dump collide all custom 100 CSVs/dump*.doll.csv c_atomtrack

compute pair/gran/local
compute fc all pair/gran/local id pos force
dump cforce all local 100 post/dump.fc.*.liggghts c_fc[1] c_fc[2] c_fc[3] c_fc[4] c_fc[5] c_fc[6] c_fc[7] c_fc[8] c_fc[9] c_fc[10] c_fc[11] c_fc[12]

With the output of compute pair/gran/local, you can print/see the id of the interacting pairwise (id of both particles which collide) and therefore derive the number of contacts for each particle involved in the interactions (contacts detection).

The idea is that both compute contact/atom and compute pair/gran/local outputs should give the same number of contacts for each particle ( compute contact/atom directly, while compute pair/gran/local indirectly). Right or not ?

Here an example where the number of contacts for each particle is compared between dump.fc.10000.liggghts (compute pair/gran/local) and dump10000.doll.csv (compute contact/atom) - for the same time-step of course!

dump.fc.10000.liggghts


ITEM: TIMESTEP
10000
ITEM: NUMBER OF ENTRIES
57
ITEM: BOX BOUNDS mm mm mm
-0.12 0.12
-0.12 0.12
-0.001 0.57
ITEM: ENTRIES c_fc[1] c_fc[2] c_fc[3] c_fc[4] c_fc[5] c_fc[6] c_fc[7] c_fc[8] c_fc[9] c_fc[10] c_fc[11] c_fc[12]
-0.0119791 -0.0372214 0.00808775 -0.00274904 -0.0399211 0.0108293 39 85 0 -0.000100644 -0.000184731 -0.000235928
-0.0279946 -0.0275802 0.00895708 -0.0273477 -0.0184194 0.00499989 64 51 0 0.000543664 0.0011043 0.00262464
-0.0279946 -0.0275802 0.00895708 -0.0249331 -0.0272672 0.0184717 64 61 0 0.000293425 0.000381684 -7.0334e-05
-0.0201895 -0.0324198 0.00499982 -0.0208617 -0.0354904 0.0144927 95 80 0 0.00167992 -0.00127885 -0.000361249
-0.00440136 -0.031473 0.00500006 -0.00367668 -0.0214994 0.00499991 76 88 0 -0.000723488 0.000120806 0.00145762
-0.0273477 -0.0184194 0.00499989 -0.0358132 -0.0130963 0.00499995 51 31 0 -0.0001302 -0.000213634 0.000573923
-0.00367668 -0.0214994 0.00499991 0.00189059 -0.0198818 0.0131478 88 34 0 3.84608e-07 2.04164e-05 -9.16127e-06
-0.0358132 -0.0130963 0.00499995 -0.0396077 -0.0062695 0.0112446 31 82 0 7.68826e-06 8.44941e-06 -1.64976e-05
-0.00274904 -0.0399211 0.0108293 0.00511357 -0.0378726 0.00499991 85 8 0 -3.21344e-05 9.14682e-06 8.94728e-06
-0.00276775 -0.00533035 0.0144356 -0.0110374 1.3488e-05 0.0126873 74 73 0 9.57456e-05 0.000147521 -0.000109827
-0.00276775 -0.00533035 0.0144356 0.00635899 -0.00187714 0.0166214 74 68 0 2.70978e-05 1.09398e-05 6.09679e-06
-0.0174327 6.80009e-05 0.00499991 -0.022111 0.00102588 0.013786 69 96 0 3.20189e-06 -9.65264e-07 -1.73104e-05
-0.0174327 6.80009e-05 0.00499991 -0.0110374 1.3488e-05 0.0126873 69 73 0 1.23903e-05 -8.69348e-07 1.72145e-05
-0.0174327 6.80009e-05 0.00499991 -0.0166066 0.00869152 0.0099951 69 3 0 0.000797963 0.00161688 -0.00292904
-0.0323319 0.0198639 0.0049999 -0.0367224 0.0181406 0.0138176 90 7 0 3.10341e-07 2.93293e-07 -2.17524e-06
-0.0323319 0.0198639 0.0049999 -0.0299198 0.0268056 0.0117817 90 57 0 -2.25115e-06 -8.15439e-06 -1.5263e-05
-0.0221187 0.0202346 0.0049999 -0.0233785 0.0301549 0.00499993 105 41 0 -0.000375073 -8.65646e-05 0.00201354
-0.0221187 0.0202346 0.0049999 -0.0265597 0.0174887 0.0135285 105 52 0 -0.00301984 -0.000632578 -0.00180448
-0.0128304 0.0164882 0.00499991 -0.0166066 0.00869152 0.0099951 42 3 0 -0.000352924 -0.000351054 -0.00080909
-0.0128304 0.0164882 0.00499991 -0.0167636 0.0195161 0.0136809 42 13 0 -2.1436e-06 2.10349e-06 4.84231e-06
-0.00207699 0.0260532 0.00499992 -0.00774801 0.026673 0.013213 20 4 0 2.89533e-06 -2.511e-07 -6.98219e-06
-0.0233785 0.0301549 0.00499993 -0.0299198 0.0268056 0.0117817 41 57 0 -0.000919615 -0.000669283 -0.00121318
-0.0135464 0.027697 0.00499994 -0.0140269 0.0368204 0.00906588 104 99 0 -0.000351642 0.00183002 -0.00416098
-0.0140269 0.0368204 0.00906588 -0.00494966 0.0378548 0.00499991 99 93 0 -2.14499e-05 7.73808e-07 1.00233e-05
-0.0140269 0.0368204 0.00906588 -0.0174307 0.0294227 0.0148699 99 38 0 5.9377e-06 1.68836e-06 -5.05459e-06
-0.00494966 0.0378548 0.00499991 -0.000451576 0.0404762 0.0135377 93 33 0 -0.000445521 0.010205 -0.00291241
-0.0167636 0.0195161 0.0136809 -0.0174307 0.0294227 0.0148699 13 38 0 -0.000196053 -2.39771e-07 -8.95674e-05
-0.00774801 0.026673 0.013213 -0.00178252 0.0226735 0.0201712 4 81 0 0.0049332 -0.00305771 -0.00598846
0.00511357 -0.0378726 0.00499991 0.0115262 -0.0388562 0.0126098 8 75 0 -1.81612e-05 -1.00921e-06 -8.00849e-06
0.00431631 -0.0288069 0.00914989 0.0133517 -0.0277445 0.00499958 32 54 0 0.000335424 2.08415e-05 -0.000141562
0.0133517 -0.0277445 0.00499958 0.0227801 -0.0309897 0.00575233 54 100 0 0.000330542 -0.000121624 9.13611e-05
0.0133517 -0.0277445 0.00499958 0.0125685 -0.0215804 0.0128348 54 56 0 0.000147395 -0.000482757 -0.000654966
0.0227801 -0.0309897 0.00575233 0.0255832 -0.0321823 0.0152767 100 79 0 -0.000379985 -0.00278225 7.21469e-05
0.0302391 -0.0254775 0.00949902 0.0307166 -0.0165596 0.00499991 86 87 0 2.14335e-05 5.8538e-05 0.0001689
0.0302391 -0.0254775 0.00949902 0.0264575 -0.0204731 0.017287 86 70 0 -2.47332e-05 3.15473e-05 2.72307e-05
0.00751333 -0.0179666 0.00499992 0.0125685 -0.0215804 0.0128348 28 56 0 -8.35805e-06 1.38234e-05 1.9204e-05
0.0207036 -0.0211208 0.00644715 0.022173 -0.0113359 0.00499986 58 16 0 0.00367002 0.00111896 0.011348
0.0307166 -0.0165596 0.00499991 0.0346382 -0.0133332 0.0136145 87 17 0 -1.45026e-06 -9.00725e-07 -3.28957e-06
0.022173 -0.0113359 0.00499986 0.020063 -0.0132771 0.0145799 16 14 0 0.000213597 -0.00377383 -0.000729664
0.0371571 -0.0089096 0.00499988 0.0404706 -0.00384042 0.0129574 45 60 0 3.71194e-05 5.37303e-05 0.000106851
0.0115262 -0.0388562 0.0126098 0.0157608 -0.0305306 0.0161807 75 67 0 -0.00178494 0.00154805 -0.00154129
0.020063 -0.0132771 0.0145799 0.0264575 -0.0204731 0.017287 14 70 0 -5.15014e-05 1.0534e-05 0.000189155
0.0357242 0.000987224 0.00499993 0.0315037 0.00119108 0.0140633 22 12 0 0.000100515 3.70987e-05 -2.32105e-06
0.0133112 0.00800893 0.00499988 0.012354 0.00589985 0.0147279 53 36 0 0.000219238 -1.40937e-05 0.000101751
0.0133112 0.00800893 0.00499988 0.0213078 0.00918205 0.0108884 53 62 0 0.000191065 3.94844e-05 6.19779e-05
0.0366148 0.0109476 0.00499973 0.0401897 0.00615543 0.0130157 49 101 0 -0.000716901 0.000160093 0.000334624
0.0366148 0.0109476 0.00499973 0.0308361 0.0111976 0.0131569 49 10 0 -4.03327e-05 4.28977e-05 0.000123138
0.0184678 0.0167928 0.00499992 0.022153 0.0223938 0.0124193 6 91 0 -1.20301e-05 -1.30391e-05 3.80838e-06
0.0284678 0.0168261 0.00499994 0.0272481 0.0267514 0.00499989 65 78 0 0.000668158 9.74035e-05 -0.00106092
0.0272481 0.0267514 0.00499989 0.022153 0.0223938 0.0124193 78 91 0 -8.04279e-06 7.87038e-06 2.34027e-05
0.0272481 0.0267514 0.00499989 0.0245962 0.0323254 0.0128674 78 66 0 -7.54178e-06 -2.20315e-05 -1.99092e-05
0.0213078 0.00918205 0.0108884 0.0308361 0.0111976 0.0131569 62 10 0 0.000131339 5.6036e-05 0.000233534
0.0401897 0.00615543 0.0130157 0.0404706 -0.00384042 0.0129574 101 60 0 0.000290889 2.0559e-05 -0.000495695
0.0308361 0.0111976 0.0131569 0.0348781 0.020258 0.0119046 10 98 0 0.000323099 -0.000308534 -0.00235972
0.0308361 0.0111976 0.0131569 0.0267986 0.00999968 0.0222267 10 44 0 -2.44847e-05 -1.74375e-05 0.000187432
0.022153 0.0223938 0.0124193 0.0153457 0.0257279 0.0189419 91 97 0 -7.19461e-06 -4.06512e-06 5.55833e-06
0.0245962 0.0323254 0.0128674 0.0168508 0.0355937 0.0182826 66 11 0 -2.13036e-05 0.00047883 -0.000328189

From this file we can extract c_fc[7] and c_fc[8], which are the id of the colliding particles (from Matlab):


id =

39 85
64 51
64 61
95 80
76 88
51 31
88 34
31 82
85 8
74 73
74 68
69 96
69 73
69 3
90 7
90 57
105 41
105 52
42 3
42 13
20 4
41 57
104 99
99 93
99 38
93 33
13 38
4 81
8 75
32 54
54 100
54 56
100 79
86 87
86 70
28 56
58 16
87 17
16 14
45 60
75 67
14 70
22 12
53 36
53 62
49 101
49 10
6 91
65 78
78 91
78 66
62 10
101 60
10 98
10 44
91 97
66 11

...and see how many times each particle is colliding (from Matlab):


maxid = max(max(id));

for i = 1 : maxid
contacts_per_particle(i) = length(find(id==i));
end

contacts_per_particle =

0
0
2
2
0
1
1
2
0
4
1
1
2
2
0
2
1
0
0
1
0
1
0
0
0
0
0
1
0
0
2
1
1
1
0
1
0
2
1
0
2
2
0
1
1
0
0
0
2
0
2
1
2
3
0
2
2
1
0
2
1
2
0
2
1
2
1
1
3
2
0
0
2
2
2
1
0
3
1
1
1
1
0
0
2
2
2
2
0
2
3
0
2
0
1
1
1
1
3
2
2
0
0
1
2

Now, If we compare the contacts_per_particle vector (extracted from compute pair/gran/local output) to the output of
compute contact/atom, we can see they are different:

dump10000.doll.csv


ITEM: TIMESTEP
10000
ITEM: NUMBER OF ATOMS
106
ITEM: BOX BOUNDS mm mm mm
-0.12 0.12
-0.12 0.12
-0.001 0.57
ITEM: ATOMS c_1
1
2
1
1
0
2
2
2
0
0
0
0
2
1
0
0
0
1
0
0
2
1
0
0
3
0
0
0
2
2
2
1
2
1
3
2
1
2
0
0
2
1
1
2
0
2
2
1
0
2
0
0
1
2
1
3
2
2
1
1
2
2
0
1
2
1
2
2
1
0
0
2
1
1
2
0
1
0
0
0
1
2
0
2
1
1
0
3
0
1
0
1
2
2
4
0
1
3
0
2
0
0
0
1
1
1

Should the dump10000.doll.csv (compute contact/atom) and dump.fc.10000.liggghts (compute pair/gran/local) give the same number of contacts per partice/atom ???

Best,
Limone

jsams | Tue, 02/27/2018 - 06:03

Hi Limone,

What you're writing sounds logical and makes sense to me, so I copied the two columns (the calculated contacts from compute pair/gran/local and the computed contacts from the compute contact/atom command) into an editor and did some simple comparison. Apart from the fact that the calculated contacts contain 105 entries and the contact /atom output 106 entries, the data looks quite similar.

I checked how many 0, 1, 2, 3, 4 contacts were detected and the result is the same for both methods, except for 0 contacts which has a difference of 1 (due to the different number of entries).

0 contacts: 36/37
1 contact: 31
2 contacts: 32
3 contacts: 5
4 contacts: 1

total: 105/106

You could also dump the particle id for the compute contact/atom method to better compare the two outputs.

limone | Wed, 03/14/2018 - 12:05

Many thanks jsams and sorry for a late reply (I was sick) !!

Yes it works! ...And dumping the particle id, as you suggested, I checked that the outputs match!

Thanks a lot,
Limo