Skip to content

assignTypeInGrid()

Jasmin B. Maglic edited this page Jun 18, 2021 · 1 revision
void Space::assignTypeInGrid(std::vector<Atom> atomlist, double r_probe1, double r_probe2, bool probe_mode, bool cavities_exceeded)

Method of the Space group. Manages the type assignment algorithm. Calls functions corresponding to different steps of the algorithm. After this function has been called, all voxels stored inside the Space instance will have been assigned a type and identity (if applicable).

The cavities_exceeded value is used to mark an overflow error that may occur during the identity assignment.

Implementation

The type assignment algorithm is performed in multiple steps. In each step, each individual voxel is evaluated to determine its type and identity.

Single probe mode

In single probe mode, the first step evaluates the relation between voxels and atoms. By comparing the distance between voxel and all atoms, it is possible to determine whether a voxel is entirely inside an atom, or whether the voxel is part of space accessible by the probe core. The latter is true if the voxel is far enough from all atoms. If neither case can be assured, then the type of the voxel remains uncertain since it may be part of the probe shell or inaccessible by the probe.

Before evaluating the remaining voxels, an intermediate step is performed. Here, a flood fill algorithm is used to assign each core type voxel an identity. This is required to identify individual cavities. This step is performed before evaluating potential shell voxels, so that shell voxels may obtain identity and type in the same step.

In the final step, all remaining unassigned voxels are evaluated. This step evaluates the relation of voxels with each other. In order to determine whether a voxel is probe accessible or inaccessible, it searches for the nearest core voxel within a distance equal to the probe radius. If it finds a core voxel then it is accessible and it is assigned the shell type and the identity of the closest core voxel. If there is no core voxel close enough then the voxel is probe inaccessible.

Two probe mode

In two probe mode, the same steps as described above are performed. However, two additional steps are performed before the other steps. These two steps are functionally analogous to the first and last step of the type assignment in single probe mode. The only important difference is that in two probe mode, these two steps are performed with the large probe radius. All voxels accessible by the large probe are assigned a core or shell type and will not be evaluated further. Therefore, the large probe "blocks" part of space for the small probe.