# Polyhedral template matching

This modifier classifies the local structural environment of particles using the Polyhedral Template Matching (PTM) method [P.M. Larsen et al., Modelling Simul. Mater. Sci. Eng. 24, 055007] (preprint available) and allows identifying the local crystalline structure of simple condensed phases (FCC, BCC, etc.) formed by atoms.

The PTM approach promises greater reliability than e.g. Common Neighbor Analysis (CNA) in the presence of strong thermal fluctuations and strain. Furthermore, it provides a direct calculation of the local (per-atom) orientation, elastic deformation, strain and alloy type.

The modifier assigns the `Structure Type` property to each particle with the assigned structural type encoded as an integer value:

- 0 = Other, unknown coordination structure

- 1 = FCC, face-centered cubic

- 2 = HCP, hexagonal close-packed

- 3 = BCC, body-centered cubic

- 4 = ICO, icosahedral coordination

- 5 = SC, simple cubic

The structural types to be searched for can be changed by checking/unchecking the tick box for each type.

## Root-Mean-Square Deviation (RMSD)

For each input particle, the PTM tries to determine a mapping of the local neighborhood to each active candidate structure. If such a mapping exists, a RMSD value is calculated, which is a measure of the spatial deviation from the ideal structure template (the quality of the match). The structural type with the lowest RMSD value is finally assigned to the particle. A histogram of the RMSD values for all structures and all particles is shown in the side panel.

The modifier allows to set a global RMSD cutoff, which limits the assignment of structural types to a range of RMSD values. Particles whose RMSD exceeds the threshold are assigned the Other structure type. By adjusting the RMSD cutoff, the level of robustness can be adjusted. A higher RMSD cutoff will lead to more identifications (and fewer 'defect' atoms), though possibly at the expense of false positives. A lower RMSD cutoff will result in fewer structural identifications (and more 'defect' atoms and greater sensitivity to perturbations of the lattice), though possibly at the expense of false negatives. The role of the RMSD cutoff is discussed in section 5.1 of the PTM paper.

A resonable value for the RMSD cutoff parameter is 0.1, which works well for identifying defects in crystalline solids. Note that, for the sake of reproducibility, the chosen RMSD cutoff value should typically be reported in a publication if you use the PTM method to gain quantitative results (e.g. measure crystal defect fractions).

## Interatomic distance

The internal scale factor computed by the PTM method (see the paper) is the amount by which the atom coordinates are scaled in order to minimize the RMSD between the atom and template coordinates, after translation and rotation. It is proportional to the reciprocal local interatomic distance (including hydrostatic strain components).

The PTM modifier provides an option to output the local interatomic distance (or nearest neighbor distance) as a new particle property, which is computed from the internal scale factor for those atoms that match one of the known structure types. Note that you can compute a local lattice constant (including hydrostatic strain) from the interatomic distance by dividing it by the factor `sqrt(1/2)` (for FCC,HCP) or `sqrt(3/4)` (for BCC) using, e.g., the Compute property modifier

## Local lattice orientation

The PTM modifier can calculate the local lattice orientation for atoms that match one of the structural types. The computed orientation is stored as a quaternion in the `Orientation` particle property. You can switch the particle display shape to Cube/Box to visualize the computed per-particle orientations or apply this custom Python modifier to color particles according to their local lattice orientation. Lattice orientations are calculated such that they lie in the fundamental zone of the symmetry group for each structural type. This means that two atoms with very similar orientations can have large misorientations if they lie close to the boundaries of the fundamental zone. For atoms that do not match any of the known structure types, no local lattice orientation can be computed. They are assigned the invalid quaternion (0,0,0,0).

## Elastic deformation gradient

The local elastic deformation gradient is calculated as the affine transformation of the ideal template which minimizes the sum of squared distances from the actual atomic coordinates.

## Alloy structures

Atom types are generally ignored by the PTM when identifying the structural type (e.g. FCC, BCC, etc.). However, the algorithm can additionally identify the local alloy type by taking into account the chemical species of atoms (given by the `Particle Type` property, which must be defined). The binary alloy types currently identified by the PTM algorithm are A2 and B2 for BCC, and A1, L10 and L12 for FCC.

The local alloy type is output as an additional integer particle property named `Alloy Type`:

- 0 = Other, unknown alloy type

- 1 = Pure (all neighbors like central atom)

- 2 = L10

- 3 = L12 (Cu-type)

- 4 = L12 (Au-type)

- 5 = B2

The alloy type of a lattice atom is found by comparing the types of its neighbors to its own type. See the paper for details. You can subsequently use the Expression select modifier to select atoms of a certain alloy type to give them a distinct color, for example.

## Notes

In addition to the PTM, OVITO provides alternative structure identification tools like the Common Neighbor Analysis modifier or the Bond-Angle Analysis modifier. Furthermore, the Identify Diamond Structure analysis modifier can be used for identifying diamond lattice structures.

Note that this modifier requires access to the complete set of input particles to perform the analysis. It should therefore be placed at the beginning of the processing pipeline, preceding any modifiers that delete particles.

The Use only selected particles option restricts the analysis to the currently selected particles. If this option is checked, unselected particles will be ignored (as if they did not exist) and will be assigned the structure type "Other". This option can be useful if you want to identify defects in a crystal structure that is not directly supported by the PTM algorithm, but which possesses a known sublattice.

## Technical notes

A few changes have been made to the PTM method since publication of the article:

- The reference templates are now scaled such that the mean distance of the neighbors is 1. The central atom is no longer included in this calculation.

- The Voronoi cell calculation is now performed using the Voro++ library [].

- The polar decomposition now uses a fast NR-QCP method instead of the SVD.