Generating a Voronoi Tessellation (-T)#
Note
This tutorial presents the -n, -id, -dim, -format and -tesrsize options of the Tessellation Module (-T). For details on the use of the Visualization Module (-V) in this tutorial, see Visualizing a Tessellation (-V).
To reproduce exactly the images below, add the following line to your $HOME/.neperrc file (or to a local configuration file to be loaded with --rcfile):
neper -V -imagesize 800:400
Tessellations are generated using the Tessellation Module (-T). Voronoi tessellations are generated by default [CMAME2011], and the only required input is the number of cells.
Specifying the Number of Cells (-n)#
The number of cells can be specified using -n. A Voronoi tessellation containing 100 cells can be generated as follows:
$ neper -T -n 100
This produces a Tessellation File (.tess) named n100-id1.tess.
The tessellation can be visualized using the Visualization Module (-V):
$ neper -V n100-id1.tess -print img1
This produces a PNG file named img1.png where cells are colored by their ids (1, 2, etc.) according to the Color Map for Integer Values.
Generating Different Tessellations (-id)#
Given a number of cells, different tessellations can be obtained using -id (the default value is 1). The specified value initializes the random number generator, which is then used to determine the seed coordinates. This can be done as follows:
$ neper -T -n 100 -id 2
This produces a Tessellation File (.tess) named n100-id2.tess.
The new tessellation can be visualized as before:
$ neper -V n100-id2.tess -print img1b
Those who prefer non-deterministic tessellation generation can use -id -1, which selects a new random seed on each run. For example, to generate three different tessellations:
$ neper -T -n 100 -id -1 -o tess1
$ neper -T -n 100 -id -1 -o tess2
$ neper -T -n 100 -id -1 -o tess3
The new tessellations can be visualized as before, using ImageMagick’s convert to assemble the images:
$ neper -V tess1.tess -print img1c
$ neper -V tess2.tess -print img1d
$ neper -V tess3.tess -print img1e
$ convert img1c.png img1d.png img1e.png -trim +repage -resize x300 -extent x300 -bordercolor white -border 10x0 +append -resize 780x -background white -gravity center -extent 800x img1f.png
Note that, because the generation is non-deterministic, you (or anyone else) won’t be able to exactly reproduce these images.
Switching to 2D (-dim)#
The tessellation dimension can be specified using -dim (the default value is 3). A 2D tessellation can be generated as follows:
$ neper -T -n 100 -dim 2
This produces a Tessellation File (.tess) named n100-id1.tess.
The tessellation can be visualized as before:
$ neper -V n100-id1.tess -print img2
Writing a Raster Tessellation (-format)#
A tessellation can be written in raster format (as a Raster Tessellation File (.tesr)), i.e. as an image made of voxels, as typically used in fast Fourier transform (FFT)-based simulations, using -format tesr. The number of voxels along each direction can be specified using -tesrsize (the default value is 20). For example, to write a tessellation in both scalar and raster formats, on a raster of \(64 \times 64 \times 64\) voxels:
$ neper -T -n 100 -format tess,tesr -tesrsize 64
This produces a Tessellation File (.tess) named n100-id1.tess and a Raster Tessellation File (.tesr) named n100-id1.tesr.
The raster tessellation can be visualized as before:
$ neper -V n100-id1.tesr -print img3