1 // Voronoi calculation example code
3 // Author : Chris H. Rycroft (LBL / UC Berkeley)
4 // Email : chr@alum.mit.edu
5 // Date : August 30th 2011
10 // Set up constants for the container geometry
11 const double x_min
=-1,x_max
=1;
12 const double y_min
=-1,y_max
=1;
13 const double z_min
=-1,z_max
=1;
14 const double cvol
=(x_max
-x_min
)*(y_max
-y_min
)*(x_max
-x_min
);
16 // Set up the number of blocks that the container is divided into
17 const int n_x
=3,n_y
=3,n_z
=3;
19 // Set the number of particles that are going to be randomly introduced
20 const int particles
=1000;
22 // This function returns a random double between 0 and 1
23 double rnd() {return double(rand())/RAND_MAX
;}
27 double pos
[particles
*4],*posp
=pos
;
29 for(i
=0;i
<particles
;i
++) {
30 *(posp
++)=x_min
+rnd()*(x_max
-x_min
);
31 *(posp
++)=y_min
+rnd()*(y_max
-y_min
);
32 *(posp
++)=z_min
+rnd()*(z_max
-z_min
);
38 int j
;double x
,y
,z
,r
,mul
=i
*0.01,vol
=0;
40 container_poly
con(x_min
,x_max
,y_min
,y_max
,z_min
,z_max
,n_x
,n_y
,n_z
,
44 for(int j
=0;j
<particles
;j
++) {
45 x
=*(posp
++);y
=*(posp
++);z
=*(posp
++);r
=*(posp
++)*mul
;
49 sprintf(buf
,"rad_test_out/fr%d.pov",i
);
50 // FILE *pf=safe_fopen(buf,"w");
56 if(con
.compute_cell(c
,cl
)) {
59 // c.draw_pov(x,y,z,pf);
64 printf("%g %d %g %g\n",mul
,j
,vol
,vol
-8);