Minkowski test code.
[voro++.git] / trunk / examples / no_release / import_rahman.cc
blob2a0b86f0319112f9d53228cb7ed822b34756e3a0
1 // Voronoi method to generate nanocrystalline grain boundaries
2 // Oct 18, 2011
3 #include "voro++.hh"
4 using namespace voro;
6 // Box geometry
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;}
22 int main() {
23 int i;
24 double x,y,z;
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
32 particle_order po;
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);
39 con.put(po,i,x,y,z);
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);
48 fclose(fp);