MaterialVis calculates defect values of atoms for each type of defect. They are calcu- lated using the local neighborhood of atoms; any defect in the local neighborhood of an atom contributes to the atom’s defect. In this way, the defects are represented and visu- alized properly because a large volumetric region is affected. The defect quantification is described in Algorithm 14.
Defect quantification starts by determining the boundaries of the local neighbor- hood. We define the local neighborhood as the sphere around the atom whose radius is the length of largest primitive vector, called local neighborhood radius (LNR). Using small LNR values will reduce the size of the local neighborhood, thus any defect will be represented in a small part of the crystal. Using large LNR values will make any defect to be represented in a large part of the crystal, which increases the computa- tional cost. The trade-off between the computational cost and the visualization quality is controlled with a user-specified parameter.
The next step is to construct the feature vectors for each basis vector. The feature vector is a sample that represents the appearance of the perfect crystal. The createFea- tureVector function takes a basis vector, translates it to the origin and identifies all the atoms around it within the distance LNR or closer from the perfect crystal. The algo- rithm continues by determining the local neighborhood of each atom from the actual crystal and comparing it to the feature vector. However, determining the local neigh- borhood of atoms is not a trivial task. The brute-force approach is to scan all the atoms and extract the ones that lie in the local neighborhood. This leads to quadratic com- putational cost and it is very time consuming for large datasets. Octrees storing range data could be utilized to speed up the process. Because of the overhead of construct- ing and maintaining the octree, we use regular grids to speed up the process, whose
construction and maintenance is simple.
DefectQuantification(Atoms A, UnitCellInfo uci) begin
//Define the local neighborhood radius; the distance that an atom is affected from defects within
LNR=LengthOfLargestPrimitiveVector;
//Compute the feature vectors; the type and relative position of atoms to each basis vector within LNR distance in the perfect crystal
for (i = 0 upto NumOfBasisVectors) do FV[i]=createFeatureVector(i, uci, LNR); //Construct the grids
atom QueryGrid[32][32][32]; atom RefGrid[32][32][32];
CreateGrid(A, LNR, QueryGrid, RefGrid);
//Compare the feature vector and local neighborhood vector for each atom using grid approach
for (i = 0 upto 32) do for ( j = 0 upto 32) do
for (k = 0 upto 32) do
foreach (Atom atomR in RefGrid[i][j][k]) do LNV=NULL;
//Extract the local neighborhood vector foreach (Atom atomQ in QueryGrid[i][j][k]) do
if (distance(atomR, atomQ) ≤ LNR) then LNV+=atomQ;
//Assign defect upon feature comparisons atomR.defect=compareFeatures(FV[atomR.type], LNV); end
Algorithm 14: Defect quantification algorithm
Figure A.2 illustrates a simple 2D cubic lattice with 64 atoms mapped by a 2 × 2 grid. Query grids have the exact dimensions of 4 × 4. Thus the lattice is divided equally into four query grids. For each query grid, there is a corresponding reference
grid. The reference grid contains every atom that is within maximum feature vector length distance to any atom in the query grid for any dimension. To find the feature vector of any atom in a query grid, only searching the atoms in the corresponding reference grid is sufficient.
QueryGrid[0,1] QueryGrid[1,1]
QueryGrid[1,0]
RefGrid[0,0]
QueryGrid[0,0]
Figure A.2: The illustration of the query and reference grids
The algorithm constructs regular grids to speed-up the local neighborhood extrac- tion process. The regular grid divides the volume into 32 × 32 × 32 = 32, 768 cells (sub-volumes). Then atoms are inserted into one of these cells of the reference grid (RefGrid) according to their coordinates. The query grid (QueryGrid) is constructed in a different way. Any atom whose coordinate values differ by at most LNR at each axis from the boundaries of a cell of the QueryGrid is inserted into that cell. In other words, for any atom a in the cell RefGrid[x][y][z], we identify all the atoms within LNR distance to a in QueryGrid[x][y][z]. This process is repeated for each cell in the regular grid. The local neighborhood vectors, LNV, for each atom in RefGrid[x][y][z], are found using the query grid cell QueryGrid[x][y][z]. Although the algorithm still have quadratic time complexity, the number of comparisons are significantly reduced with the regular grid approach.
The compareFeatures function compares the feature and local neighborhood vec- tors of an atom and assigns the defect value. The first step is to match the elements of the feature and local neighborhood vectors. Two atoms are matched only if their atom types are identical and their positions relative to their origin differ less than a
pre-specified threshold. After matchings are completed, the squares of the relative distance differences between matched atoms are added. This value multiplied with a constant depending on the unit cell size and assigned to the atom as the positional defect, or simply defect. The number of atoms left unmatched in the feature vector is assigned as the missing atom defect, and the number of atoms left unmatched in the local neighborhood vector is assigned as the extra atom defect.
There are also some special cases that compareFeatures function should handle. First of all, near the boundaries of vectors, the positional defects can cause false miss- ing and extra atom defects. For example, an atom that matches to an atom near the boundaries of the feature vector (FV) might be left out of the local neighborhood vec- tor (LNV) due to some positional defect, leading to a false missing atom defect. Simi- larly, some atoms that must have been left out of the local neighborhood vector (LNV) could be included, leading to a false extra atom defect. In order to avoid these cases, unmatched atoms near the boundaries of the feature vector and the local neighborhood vectors are not counted as defects. Secondly, atoms very close to the surface will cause significant missing atom defects. Because such missing atoms are caused by the topol- ogy of the crystal, they should not be treated as missing atoms. The algorithm simply ignores missing atom defects very close to the surface.