Skip to content

setGrid()

Jasmin B. Maglic edited this page Sep 15, 2020 · 7 revisions
void Space::setGrid()

This method of the Space class fills the box containing all atoms, previously defined in setBoundaries(), with voxels. The number of voxels is chosen in every dimension so that the voxels fill the box, and if needed, extend outside the box. This means that generally, the total voxel volume will be larger than the cell volume. The voxels are stored in a vector of the space class.

Only top level voxels are initialised here. Since the volume calculation algorithm is based on an octree aproach, i.e., each voxel may be split into eight subvoxels if it cannot be holistically characterised, "top level voxel" refers to the voxels on the top of the respective octree.

Process

First, the number of top level voxels nsteps is determined along each spacial dimension i according to the following equation and then saved as an array in n_gridsteps.

f-steps

with the box size li, the grid size, i.e., the bottom level voxel size r, and the maximum octree depth d. The total number of voxels nvoxels is then simply obtained by multiplying the number of top level voxels for each spacial dimension:

f-nvoxel

Finally, the grid vector is initialised with nvoxels default instances of the Voxel class.

The resulting grid is displayed schematically for the 2D case in the following image. Subvoxels are marked as coloured squares, the tree depth is 2.

Clone this wiki locally