 1. Introduction
 2. Transformation to a target direction
 3. Transformation of basis vectors to a target lattice plane
 4. Simulation of the geometry of zone planes perpendicular to the target zone axis
 5. On the length of the vectors Ai
 6. Related literature
 7. Conclusions
 Supporting information
 References
 1. Introduction
 2. Transformation to a target direction
 3. Transformation of basis vectors to a target lattice plane
 4. Simulation of the geometry of zone planes perpendicular to the target zone axis
 5. On the length of the vectors Ai
 6. Related literature
 7. Conclusions
 Supporting information
 References
research papers
Algorithms for target transformations of lattice basis vectors
^{a}Department of Materials Science and Engineering, Tel Aviv University, Wolfson Building for Mechanical Engineering, Tel Aviv 6997801, Israel
^{*}Correspondence email: gorfman@tauex.tau.ac.il
Simple algorithms are proposed for the transformation of lattice basis vectors to a specific target. In the first case, one of the new basis vectors is aligned to a predefined lattice direction, while in the second case, two of the new basis vectors are brought to a lattice plane with predefined i.e. geometry of electron diffraction patterns) or transformation of a for surface or cleavage energy calculations. The most general multidimensional version of the algorithm may be useful for the analysis of quasiperiodic crystals or as an alternative method of calculating Bézout coefficients. The algorithms are demonstrated both graphically and numerically.
The multidimensional generalization of the algorithm is available in the supporting materials. The algorithms are useful for such crystallographic operations as simulation of zone planes (Keywords: crystal lattice; transformations; lattice planes; zones.
1. Introduction
The transformation of lattice basis vectors is a key mathematical operation in crystallography. It is expressed using a transformation matrix [S] (A_{i} = a_{j}S_{ji}) connecting old (a_{1}, a_{2}, a_{3}), and new (A_{1}, A_{2}, A_{3}) lattice basis vectors. If det[S] = ±1 and , then A_{i} and a_{i} are the bases of the same lattice/form the unit cells of the same Such unitcell transformations are useful for analysing the structures of polymorphs (Müller, 2013; de la Flor et al., 2016), twin laws (Nespolo & Ferraris, 2006; Zhang et al., 2010; Marzouki et al., 2014), phase transitions (Howard & Stokes, 2005), tilting of structural polyhedra (Glazer, 1972, 1975) and nanoscale stacking order (Biermanns et al., 2011). The ability to `view' the same using different unitcell settings is crucial for a skilful crystallographer.
This article introduces new algorithms for the transformation of basis vectors for a specific target. The first version of the algorithm enables the transformation (A_{i} = a_{j}S_{ji}, det[S] = ±1) such that A_{3} is parallel to a target lattice vector T. The second version results in A_{1}, A_{2} parallel to a target lattice plane (hkl) and A_{3} connecting lattice points of two adjacent planes. In this way the algorithm suggests an alternative approach to calculate the Bézout coefficients (Bézout, 1779).
In contrast with other numbertheoretical approaches [e.g. the extended Euclidean algorithm (Knuth, 1997)], the new algorithms are easily extendable to higherdimensional lattices. In addition, two and threedimensional versions allow for clear visualization using lattice directions and their stereographic projections. The algorithms are useful for the simulation of electron diffraction patterns or for exploring the twodimensional periodicity of crystal structures within a given lattice plane. It is necessary to follow the algorithms whenever the indices of a target direction or a plane are nontrivial. The output can be used in structure visualization programs [e.g. VESTA (Momma & Izumi, 2011)], for the structure utilities of the Bilbao Crystallographic Server (Aroyo, PerezMato et al., 2006; Aroyo, Kirov et al., 2006) and for the ab initio calculation of surface energy (Tran et al., 2016; Kresse & Furthmüller, 1996; Schwarz et al., 2002). The multidimensional version of the algorithm might be useful for the analysis of quasiperiodic materials. The algorithm is deposited as a MATLAB program.
2. Transformation to a target direction
The list of notations and relevant crystallographic relations are available in Appendix A. The names of the two, three and multidimensional algorithms are PARA, TRIO and MULDIN, respectively. PARA and TRIO are described here, while MULDIN is deposited in the supporting information.
2.1. PARA: twodimensional lattice
This algorithm transforms the basis vectors a_{1}, a_{2} to A_{1}, A_{2} such that A_{2} ∥ T = x_{1}a_{1} + x_{2}a_{2}. Table S1 and Fig. S1 (in the supporting information) provide a stepbystep illustration of the algorithm for the example target vector T = .
Iteration 0: We transform the basis vectors a_{i} to = ±a_{i} (`−' is taken if x_{i} is negative) and rearrange them so that det[S^{(0)}] = 1, where [S^{(0)}] is a 2×2 transformation matrix = [Fig. S1(a)]. According to equation (19) in Appendix A the new coordinates of T are [X^{(0)}] = [S^{(0)}]^{−1}[x]. All the components of [X^{(0)}] are nonnegative.
Iteration n: We replace one of the basis vectors by . This creates two transformation variants [ = ],
Because det[S] = 1, form the basis of the same lattice for both variants. The coordinates of T transform as
The exit condition of the algorithm is that one of X_{i}^{(n)} is zero. This happens if = . If valid, the exit condition holds for both transformation variants. We can choose variant (2) to ensure that . The final transformation a_{i} → A_{i} is given by the matrix product,
If the exit condition is not fulfilled, we select the variant m yielding all positive X_{i}^{(n)}: and force the choice of m = 1 [Fig. S1(c)] and m = 2 [Fig. S1(b)], respectively. The transformation is
The algorithm continues to the next iteration until the exit condition is reached [Fig. S1(d)].
2.2. TRIO: threedimensional lattice
This algorithm transforms the basis vectors of a threedimensional lattice a_{i} → A_{i} so that A_{3} ∥ T = x_{i}a_{i}. Table 1 and Fig. 1 support the explanations.

Iteration 0: We transform the basis vectors = ±a_{i} as in PARA, followed by their permutations ensuring the `righthandedness' of {det[S^{(0)}] = 1}, where [S^{(0)}] is a 3×3 transformation matrix between a_{i} and [Fig. 1(a)]. The new nonnegative coordinates of T become [X^{(0)}] = [S^{(0)}]^{−1}[x].
Iteration n: We replace one of the basis vectors by , creating three transformation variants [ = ]:
Because det[S] = 1, and a_{i} build the same lattice for all three variants. The new coordinates of T are
The exit condition (two of the new T coordinates are zero) is fulfilled if = = . If valid, it holds for all three variants but choosing [S_{3}] ensures . The transformation a_{i} → A_{i} is [S^{(f)}] = [S^{(n−1)}][S_{3}]. Otherwise, we select the variant m, which gives nonnegative X_{i}^{(n)}. According to equations (6)–(9), m is defined such that
If equation (10) is fulfilled only for one m then none of X_{i}^{(n)} is zero [Fig. 1(b), m = 2]. The transformation is
This moves the algorithm to the iteration n + 1.
However, equation (10) might be valid for two variants if e.g. = . Then either [S_{m1}] or [S_{m2}] could be selected for the next iteration, which yields X_{m2}^{(n)} = 0 or X_{m1}^{(n)} = 0, respectively. The transformation is described by equation (11) with m = max(m1, m2), which ensures X_{3}^{(n)} ≠ 0 [m = 3, X_{2}^{(n)} = 0 in Fig. 1(c)]. The algorithm will be completed by PARA with respect to the vectors a_{1} = and a_{2} = such that X_{j}^{(n)} ≠ 0 [Figs. 1(d) and 1(e)].
Table 1 and Fig. 1 show that the example of the TRIO algorithm where the target vector is T = results in
3. Transformation of basis vectors to a target lattice plane
We will show how TRIO helps transform the basis vectors a_{i} → A_{i} so that A_{1}, A_{2} are parallel to the reticular (lattice) planes with (hkl). Such planes are perpendicular to a reciprocallattice vector T* = , and the interplanar distance is the inverse length of T* [see e.g. De Graef & McHenry (2012) and Giacovazzo (1992)]. We apply TRIO to the reciprocal basis vectors with the target vector :
We can calculate the equivalent matrix of transformation of the directlattice vectors [equation (21) in Appendix A],
This will result in A_{1}, A_{2} ⊥ T*. Because A_{i} form the basis of the same lattice, A_{1}, A_{2} are the basis of the twodimensional lattice in the (hkl) planes and A_{3} connects two adjacent planes. This algorithm applies for twodimensional (Table S2/Fig. S2) and multidimensional cases alike. The threedimensional case is illustrated in the key application below and in Table S3/Fig. S3. The multidimensional version (supporting information) may be useful for the analysis of quasicrystals where projecting the multidimensional lattice onto one of its threedimensional sublattices is required.
Note that the coordinates of A_{3} (or vector A_{N} for the multidimensional case) are known as Bézout coefficients (Bézout, 1779). Therefore, the algorithm may be useful as an alternative method for finding such coefficients for any number of dimensions.
4. Simulation of the geometry of zone planes perpendicular to the target zone axis
The `zone axis' is the direction parallel to a lattice vector T = u_{i}a_{i} (). The reciprocity of direct and reciprocal lattices means that T is normal to the reciprocallattice planes with `Miller' indices u_{i}. Zones appear e.g. in electron diffraction as twodimensional sections of by a nearly flat (Vainshtein, 2013) or in Laue diffraction patterns (Helliwell et al., 1989; Ren et al., 1999; Send et al., 2009) as visually striking secondorder curves – ellipses, hyperbolas and parabolas.
Using T as a target of TRIO, we obtain the transformation matrix [S] for the directlattice vectors with A_{3} ∥ T. The corresponding reciprocallattice vectors = are transformed by [S*]^{T} = [S]^{−1}, with parallel to the zone plane. The twodimensional lattice parameters of a zone are obtained from the components of the reciprocal and equation (22):
followed by
Table 2 and Fig. 2 demonstrate four `zones' of a cubic lattice (a_{i}a_{j} = a^{2}δ_{ij}) with a = 4 Å.
Section S5 in the supporting information shows another application of the algorithm for the transformation of a (the LiNbO_{3} is considered). In particular, it demonstrates the extension of the algorithm for the case of a nonprimitive conventional unit cell.
5. On the length of the vectors A_{i}
The algorithms introduced here help in reaching one of infinitely many transformations to the specific target. However, the course of the algorithms does not depend on the matrix of dot products [G] or lattice parameters. Under these conditions, the transformed lattice parameters remain undefined and it is therefore impossible to choose one variant of the transformation over another. If [G] is known, the existing lattice reduction algorithms [e.g. Niggli (1928)] can be applied to transform the subset of A_{i} (e.g. A_{1} and A_{2}) without changing the target. For example, it is possible to apply the Minkowski algorithm to reduce the lengths of vectors A_{1} and A_{2} [e.g. Rote (1997) and Helfrich (1985)].
6. Related literature
The following references are cited in the supporting information: Abrahams et al. (1966), Ong et al. (2013), Weis & Gaylord (1985).
7. Conclusions
We have presented algorithms for the transformation of lattice basis vectors, so that one of the vectors is parallel to a target direction T, or alternatively two of the vectors are parallel to the target lattice planes (hkl). Such transformations are useful for e.g. the simulation of electron diffraction (presented here) and the transformation of crystal structures for exposing certain lattice planes (supporting information). We generalize the algorithm to the multidimensional case (MULDIN algorithm, supporting information), which may be useful for the analysis of quasiperiodic crystals or as an alternative approach for finding multidimensional Bézout coefficients.
APPENDIX A
Symbols, notation and important crystallographic relationships
The indices i, j run from 1 to N (N is the number of space dimensions). The Einstein summation rule applies to these indices but is abandoned for the index in brackets (m).
a_{i} are linearly independent basis vectors of an Ndimensional A_{i} are transformed basis vectors of the same We assume that both sets determine primitive unit cells, otherwise the transformation to such must be performed.
are the reciprocal basis vectors, such that their dot products with a_{i} are = δ_{ij} (here δ_{ij} is the Kronecker delta). are the reciprocals of the transformed basis vectors such that = δ_{ij}.
[g] and [g*] are the components of the direct and reciprocal metric tensors: g_{ij} = a_{i} · a_{j} and g_{ij}^{*} = . [G] and [G*] are the analogous components for the transformed basis vectors: G_{ij} = A_{i} · A_{j} and G_{ij}^{*} = .
x_{i} are the coordinates of a vector T = x_{i}a_{i}. X_{i} are the coordinates of the same vector relative to the transformed basis vectors: T = X_{i}A_{i}.
h_{i} (hk for two and hkl for threedimensional cases) are the reciprocallattice coordinates of a vector T* = . H_{i} are the transformed coordinates of the same vector: T* = .
[S] is the N×N matrix of the a_{i} → A_{i} transformation. The columns of [S] are the coordinates of A_{i} relative to a_{i}, so that A_{i} = a_{j}S_{ji}. For the threedimensional case, the formal matrix equation applies:
A_{i} form a primitive of the same lattice if and det[S] = ±1. (det[S] = −1 if the transformation changes the handedness of the coordinate system.)
[S*] is the N×N matrix of transformation for the reciprocallattice vectors:
[x], [X] are the N×1 columns of the numbers x_{i}, X_{i}, respectively. [h], [H] are the 1×N rows of the reciprocallattice coordinates h_{i}, H_{i}.
The following transformations are used in this paper (De Graef & McHenry, 2012; Hahn, 2005; Giacovazzo, 1992).
The transformation of the direct and reciprocallattice coordinates of a vector:
The relationship between [S] and [S*]:
The transformation of the matrix of the dot product:
If the transformations and are defined by the matrices [S_{1}] and [S_{2}], then the combined transformation is defined as a matrix product:
Supporting information
MATLAB script realizing the algorithm in the general multidimensional form. The number of space dimensions is determined by the size of the input vector. DOI: https://doi.org/10.1107/S2053273320012668/ae5090sup1.txt
Additional tables and figures. DOI: https://doi.org/10.1107/S2053273320012668/ae5090sup2.pdf
Acknowledgements
The author acknowledges Dr Alexei Entin (School of Mathematics, Tel Aviv University, Israel) for stimulating discussions and proofreading the manuscript.
Funding information
The following funding is acknowledged: Israel Science Foundation (grant No. 1561/18).
References
Abrahams, S. C., Hamilton, W. C. & Reddy, J. M. (1966). J. Phys. Chem. Solids, 27, 1013–1018. CrossRef ICSD CAS Web of Science Google Scholar
Aroyo, M. I., Kirov, A., Capillas, C., PerezMato, J. M. & Wondratschek, H. (2006). Acta Cryst. A62, 115–128. Web of Science CrossRef CAS IUCr Journals Google Scholar
Aroyo, M. I., PerezMato, J. M., Capillas, C., Kroumova, E., Ivantchev, S., Madariaga, G., Kirov, A. & Wondratschek, H. (2006). Z. Kristallogr. 221, 15–27. Web of Science CrossRef CAS Google Scholar
Bézout, E. (1779). Théorie générale des équations algébriques. Hachette LivreBNF. Google Scholar
Biermanns, A., Breuer, S., Davydok, A., Geelhaar, L. & Pietsch, U. (2011). Phys. Status Solidi RRL, 5, 156–158. Web of Science CrossRef CAS Google Scholar
De Graef, M. & McHenry, M. E. (2012). Structure of Materials: An Introduction to Crystallography, Diffraction and Symmetry. Cambridge University Press. Google Scholar
Flor, G. de la, Orobengoa, D., Tasci, E., PerezMato, J. M. & Aroyo, M. I. (2016). J. Appl. Cryst. 49, 653–664. Web of Science CrossRef IUCr Journals Google Scholar
Giacovazzo, C. (1992). Fundamentals of Crystallography. International Union of Crystallography/Oxford University Press. Google Scholar
Glazer, A. M. (1972). Acta Cryst. B28, 3384–3392. CrossRef CAS IUCr Journals Web of Science Google Scholar
Glazer, A. M. (1975). Acta Cryst. A31, 756–762. CrossRef CAS IUCr Journals Web of Science Google Scholar
Hahn, T. (2005). International Tables for Crystallography, Volume A, Space Group Symmetry. Heidelberg: Springer. Google Scholar
Helfrich, B. (1985). Theor. Comput. Sci. 41, 125–139. CrossRef Web of Science Google Scholar
Helliwell, J. R., Habash, J., Cruickshank, D. W. J., Harding, M. M., Greenhough, T. J., Campbell, J. W., Clifton, I. J., Elder, M., Machin, P. A., Papiz, M. Z. & Zurek, S. (1989). J. Appl. Cryst. 22, 483–497. CrossRef CAS Web of Science IUCr Journals Google Scholar
Howard, C. J. & Stokes, H. T. (2005). Acta Cryst. A61, 93–111. Web of Science CrossRef CAS IUCr Journals Google Scholar
Knuth, D. E. (1997). The Art of Computer Programming. London: Pearson Education. Google Scholar
Kresse, G. & Furthmüller, J. (1996). Phys. Rev. B, 54, 11169–11186. CrossRef CAS Web of Science Google Scholar
Marzouki, M. A., Souvignier, B. & Nespolo, M. (2014). IUCrJ, 1, 39–48. Web of Science CrossRef CAS PubMed IUCr Journals Google Scholar
Momma, K. & Izumi, F. (2011). J. Appl. Cryst. 44, 1272–1276. Web of Science CrossRef CAS IUCr Journals Google Scholar
Müller, U. (2013). Symmetry Relationships between Crystal Structures: Applications of Crystallographic Group Theory in Crystal Chemistry. Oxford University Press. Google Scholar
Nespolo, M. & Ferraris, G. (2006). Acta Cryst. A62, 336–349. Web of Science CrossRef CAS IUCr Journals Google Scholar
Niggli, P. (1928). Krystallographische und strukturtheoretische Grundbegriffe. Leipzig: Akademische Verlagsgesellschaft mbH. Google Scholar
Ong, S. P., Richards, W. D., Jain, A., Hautier, G., Kocher, M., Cholia, S., Gunter, D., Chevrier, V. L., Persson, K. A. & Ceder, G. (2013). Comput. Mater. Sci. 68, 314–319. Web of Science CrossRef CAS Google Scholar
Ren, Z., Bourgeois, D., Helliwell, J. R., Moffat, K., Šrajer, V. & Stoddard, B. L. (1999). J. Synchrotron Rad. 6, 891–917. Web of Science CrossRef CAS IUCr Journals Google Scholar
Rote, G. (1997). Theor. Comput. Sci. 172, 303–308. CrossRef Web of Science Google Scholar
Schwarz, K., Blaha, P. & Madsen, G. K. H. (2002). Comput. Phys. Commun. 147, 71–76. Web of Science CrossRef Google Scholar
Send, S., von Kozierowski, M., Panzner, T., Gorfman, S., Nurdan, K., Walenta, A. H., Pietsch, U., Leitenberger, W., Hartmann, R. & Strüder, L. (2009). J. Appl. Cryst. 42, 1139–1146. Web of Science CrossRef CAS IUCr Journals Google Scholar
Tran, R., Xu, Z., Radhakrishnan, B., Winston, D., Sun, W., Persson, K. A. & Ong, S. P. (2016). Sci Data, 3, 160080. Web of Science CrossRef PubMed Google Scholar
Vainshtein, B. K. (2013). Structure Analysis by Electron Diffraction. Amsterdam: Elsevier. Google Scholar
Weis, R. S. & Gaylord, T. K. (1985). Appl. Phys. A, 37, 191–203. CrossRef Web of Science Google Scholar
Zhang, Y., Li, Z., Esling, C., Muller, J., Zhao, X. & Zuo, L. (2010). J. Appl. Cryst. 43, 1426–1430. Web of Science CrossRef CAS IUCr Journals Google Scholar
This is an openaccess article distributed under the terms of the Creative Commons Attribution (CCBY) Licence, which permits unrestricted use, distribution, and reproduction in any medium, provided the original authors and source are cited.