1 // Voronoi method to generate nanocrystalline grain boundaries
7 const double x_min
=-10,x_max
=10;
8 const double y_min
=-10,y_max
=10;
9 const double z_min
=-10,z_max
=10;
10 const double cvol
=(x_max
-x_min
)*(y_max
-y_min
)*(x_max
-x_min
);
12 // Number of blocks that the Box is divided into
13 const int n_x
=5,n_y
=5,n_z
=4;
15 // Total no of particles
17 const int particles
=10000;
19 // Function for random double between 0 and 1
20 double rnd() {return double(rand())/RAND_MAX
;}
26 // Creating Box and allcating 100 particles within each block
28 container
con(x_min
,x_max
,y_min
,y_max
,z_min
,z_max
,n_x
,n_y
,n_z
,
29 false,false,false,100);
31 // Set up particle order class
34 // Add particles into the Box
35 for(i
=1;i
<particles
;i
++) {
36 x
=x_min
+rnd()*(x_max
-x_min
);
37 y
=y_min
+rnd()*(y_max
-y_min
);
38 z
=z_min
+rnd()*(z_max
-z_min
);
42 // Setup an ordered loop class
43 c_loop_order
cl(con
,po
);
45 // Customize output for LAMMPS, preserving ordering
46 FILE *fp
=safe_fopen("lammps_input","w");
47 con
.print_custom(cl
,"%i 1 %x %y %z",fp
);