-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcell_list.cpp
98 lines (78 loc) · 2.76 KB
/
cell_list.cpp
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
#include <math.h>
#include <cstdlib>
#include "cell_list.h"
#include "global.h"
void update_cell_list() {
double imcx, imcy, imcz, jmcx, jmcy, jmcz;
double cdistx, cdisty, cdistz;
int ibead, jbead, itype, jtype;
nnl_att = 0;
nnl_rep = 0;
for (int i=1; i<=ncon_att; i++) {
ibead = ibead_lj_nat[i];
jbead = jbead_lj_nat[i];
itype = itype_lj_nat[i];
jtype = jtype_lj_nat[i];
// get vector index from coordinates
imcx = floor(unc_pos[ibead].x / lcell);
imcy = floor(unc_pos[ibead].y / lcell);
imcz = floor(unc_pos[ibead].z / lcell);
// get vector index from coordinates
jmcx = floor(unc_pos[jbead].x / lcell);
jmcy = floor(unc_pos[jbead].y / lcell);
jmcz = floor(unc_pos[jbead].z / lcell);
cdistx = imcx - jmcx;
cdisty = imcy - jmcy;
cdistz = imcz - jmcz;
cdistx -= ncell*rnd(cdistx/ncell);
cdisty -= ncell*rnd(cdisty/ncell);
cdistz -= ncell*rnd(cdistz/ncell);
// check whether beads are in neighboring cells
if (cdistx >= -1.0 && cdistx <= 1.0 &&
cdisty >= -1.0 && cdisty <= 1.0 &&
cdistz >= -1.0 && cdistz <= 1.0) {
// add ibead and jbead to neighbor list
nnl_att++;
ibead_neighbor_list_att[nnl_att] = ibead;
jbead_neighbor_list_att[nnl_att] = jbead;
itype_neighbor_list_att[nnl_att] = itype;
jtype_neighbor_list_att[nnl_att] = jtype;
nl_lj_nat_pdb_dist[nnl_att] = lj_nat_pdb_dist[i];
nl_lj_nat_pdb_dist2[nnl_att] = lj_nat_pdb_dist2[i];
nl_lj_nat_pdb_dist6[nnl_att] = lj_nat_pdb_dist6[i];
nl_lj_nat_pdb_dist12[nnl_att] = lj_nat_pdb_dist12[i];
}
}
for (int i=1; i<=ncon_rep; i++) {
ibead = ibead_lj_non_nat[i];
jbead = jbead_lj_non_nat[i];
itype = itype_lj_non_nat[i];
jtype = jtype_lj_non_nat[i];
// get vector index from coordinates
imcx = floor(unc_pos[ibead].x / lcell);
imcy = floor(unc_pos[ibead].y / lcell);
imcz = floor(unc_pos[ibead].z / lcell);
// get vector index from coordinates
jmcx = floor(unc_pos[jbead].x / lcell);
jmcy = floor(unc_pos[jbead].y / lcell);
jmcz = floor(unc_pos[jbead].z / lcell);
cdistx = imcx - jmcx;
cdisty = imcy - jmcy;
cdistz = imcz - jmcz;
// apply minimum image convention so cells wrap
cdistx -= ncell*rnd(cdistx/ncell);
cdisty -= ncell*rnd(cdisty/ncell);
cdistz -= ncell*rnd(cdistz/ncell);
// check whether beads are in neighboring cells
if (cdistx >= -1.0 && cdistx <= 1.0 &&
cdisty >= -1.0 && cdisty <= 1.0 &&
cdistz >= -1.0 && cdistz <= 1.0) {
// add ibead and jbead to neighbor list
nnl_rep++;
ibead_neighbor_list_rep[nnl_rep] = ibead;
jbead_neighbor_list_rep[nnl_rep] = jbead;
itype_neighbor_list_rep[nnl_rep] = itype;
jtype_neighbor_list_rep[nnl_rep] = jtype;
}
}
}