Minkowski test code.
[voro++.git] / trunk / examples / no_release / period.cc
blob7653c3ee03d48fc0a4eb7a72e59ac7d645216375
1 #include "voro++.hh"
2 using namespace voro;
4 // Set up constants for the container geometry
5 const double bx=10;
6 const double by=10;
7 const double bz=10;
8 const double bxy=0;
9 const double bxz=5;
10 const double byz=0;
12 // Set up the number of blocks that the container is divided
13 // into
14 const int n_x=3,n_y=3,n_z=3;
16 // Set the number of particles to add
17 const int particles=20;
19 // This function returns a 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 // Create a container with the geometry given above, and make it
27 // non-periodic in each of the three coordinates. Allocate space for
28 // eight particles within each computational block.
29 container_periodic con(bx,bxy,by,bxz,byz,bz,n_x,n_y,n_z,8);
31 // Add particles into the container at random positions
32 for(i=0;i<particles;i++) {
33 x=bx*rnd();
34 y=by*rnd();
35 z=bz*rnd();
36 con.put(i,x,y,z);
40 // Output volume
41 double vvol=con.sum_cell_volumes();
42 printf("Container volume : %g\n"
43 "Voronoi volume : %g\n",bx*by*bz,vvol);
45 // Output particle positions, Voronoi cells, and the domain
46 con.draw_particles("particles_periodic.gnu");
47 con.draw_cells_gnuplot("cells_periodic.gnu");
48 con.draw_domain_gnuplot("domain_periodic.gnu");