This example script demonstrates the ability of the code to handle polydisperse packings using the Voronoi radical tessellation. The code makes use of two sample particle packings in a cube of side length 6: “pack_six_cube” contains 216 monodisperse particles of diameter 1, and “pack_six_cube_poly” contains 159 polydisperse particles with diameters ranging from 0.5 to 1.5. These packings were generated from a DEM pouring simulation using LAMMPS.

On lines 26 to 31, the code creates a container class, and uses it to compute a normal Voronoi tessellation for the monodisperse packing, that is shown on the left above – this section of the code is essentially identical to the previous import.cc demonstration.

On lines 37 to 42, the code makes use of the container_poly to compute the radical Voronoi tessellation. This class is a variant of the container class, that has the same functionality, except that a radius is stored for each particle. The import() routine requires an additional radius entry, so that the lines in “pack_six_cube_poly” have the form:

<Numerical ID label> <x coordinate> <y coordinate> <z coordinate> <Radius>

The radical Voronoi tessellation is shown on the right above. The weighting introduced by the radical tessellation ensures that each particle is exactly within its Voronoi cell.

## Code listing

1: // Radical Voronoi tessellation example code
2: //
3: // Author   : Chris H. Rycroft (LBL / UC Berkeley)
4: // Email    : chr@alum.mit.edu
5: // Date     : August 30th 2011
6:
7: #include "voro++.hh"
8: using namespace voro;
9:
10: // Set up constants for the container geometry
11: const double x_min=-3,x_max=3;
12: const double y_min=-3,y_max=3;
13: const double z_min=0,z_max=6;
14:
15: // Set up the number of blocks that the container is divided
16: // into.
17: const int n_x=3,n_y=3,n_z=3;
18:
19: int main() {
20:
21:         // Create a container with the geometry given above, and make it
22:         // non-periodic in each of the three coordinates. Allocate space for
23:         // eight particles within each computational block. Import
24:         // the monodisperse test packing and output the Voronoi
25:         // tessellation in gnuplot and POV-Ray formats.
26:         container con(x_min,x_max,y_min,y_max,z_min,z_max,n_x,n_y,n_z,
27:                         false,false,false,8);
28:         con.import("pack_six_cube");
29:         con.draw_cells_gnuplot("pack_six_cube.gnu");
30:         con.draw_cells_pov("pack_six_cube_v.pov");
31:         con.draw_particles_pov("pack_six_cube_p.pov");
32:
33:         // Create a container for polydisperse particles using the same
34:         // geometry as above. Import the polydisperse test packing and
35:         // output the Voronoi radical tessellation in gnuplot and POV-Ray
36:         // formats.
37:         container_poly conp(x_min,x_max,y_min,y_max,z_min,z_max,n_x,n_y,n_z,
38:                         false,false,false,8);
39:         conp.import("pack_six_cube_poly");
40:         conp.draw_cells_gnuplot("pack_six_cube_poly.gnu");
41:         conp.draw_cells_pov("pack_six_cube_poly_v.pov");
42:         conp.draw_particles_pov("pack_six_cube_poly_p.pov");
43: }