WorksPhysics and Astronomy
interface_master: Python package building CSL and approximate CSL interfaces of any two lattices – an effective tool for interface engineers
Abstract
Crystalline interfaces are of highly importance in many practical applications. To conduct effective simulation and analysis for coincident site lattice (CSL) interfaces, effective programmes are of high demand in building their CSL bicrystal models to apply periodic boundary condition. The existing reported programmes capable suffer from problems including limitation of available lattice, poor capability for making heterogeneous interfaces and requirement of none-intuitive input parameters which cannot be directly obtained from an experimental observation result for an interface. This work presents a python programme to construct bicrystal model of interfaces consisting of any two lattices, including tilt, twist, mixed, and hetero interfaces and surfaces, which will support in effective simulation and analysis of crystalline interfaces.
Program Summary
Program title: interface_master
This program aims to construct bicrystal model of interfaces consisting of any two lattices which will support in effective simulation and analysis of interfaces.
Licensing provisions: MIT license (MIT)
Programming language: Python
Nature of problem: Atomistic computational simulation is an effective way to study crystalline interfaces where one often needs to construct a coincident site lattice (CSL) interface to apply periodic boundary condition. While there have been reported packages for building CSL interfaces[1, 2, 3, 4], none of them are capable to build an arbitrary CSL interface by simply knowing the geometric information of the disorientation of the two crystals forming this interface and the interface plane orientation. The main difficulty in making a general program to do so is to compute the approximate CSL which is to slightly deform one of the two crystals to make them three-dimensionally or two-dimensionally coincident given an arbitrary disorientation.
Solution method: In this work, applying two effective algorithms[5, 6, 7] we generated a python programme capable to build both CSL and approximate CSL interfaces. By inputting simply two CIF files (better of conventional cells), and some intuitive geometric parameters, users can build any desired CSL interface.
Introduction
Crystalline interfaces play significant roles in modern materials science. Homogeneous crystalline interfaces known as grain boundaries (GBs) can dominate the performances of many important engineering materials existing as polycrystallines which has bred the concept of GB engineering to promote the performance of polycrystalline materials by tailoring the distribution of distinguishable GBs [8, 9]. On the other hand, heterogeneous crystalline interfaces are ubiquitous in modern functional devices and play key roles in device performances. Examples of these significant interfaces include not only those in the devices which are already commercialized like electrode/electrolyte interface in solid-state lithium batteries[10], and the semiconductor/electrode interface in thin-film transistors[11]. Exploring the interface physics like interface superconductivity[12] is also a key aspect to achieve well-controlled novel quantum materials.
Computational simulation is an effective way to study the interfaces. In most cases, one needs to construct a coincident site lattice (CSL) interface for simulation. A CSL interface comprises two coincident crystalline surfaces and it is desired by most atomic simulation methods to allow use of two-dimensional periodic boundary condition in the interface plane. Of course, CSL interface is not simply a mathematical concept supporting in simulation and it is of practical importance. CSL GBs exist in many important engineering materials and the main objective of GB engineering is often to increase the composition of certain CSL GB to achieve desired performance. CSL heterogeneous interfaces are the most important structures for all the epitaxial thin-film devices where the substrate and deposited film were desired to keep coincident for a good thin-film performance.
Exploration of CSL interfaces can be done in two ways. Firstly, one can apply numerical searching for any two lattices to find two coincident surfaces. Secondly, one can find a CSL interface from the geometric information by the overlapping diffraction patterns of the two crystals forming the interface. Among all the reported computer programs for constructing CSL interfaces, only one named MPInterfaces[3] applying a lattice-matching method is capable to explore CSL interfaces of any two materials and is available for those combined by crystals of any the 14 Bravais lattices. However, although it provides an effective tool to determine the interface structure by high-throughput simulation, it does not provide a straightforward usage to construct a specific CSL interface given its geometric information including the disorientation of the two lattices and the interface plane orientation (five-dimensional macroscopic parameters). This usage is demanding both for engineers who desire to simulate the interfaces observed by experiments without conducting crystallographic computation manually, and for one needing to explore the structure-property relationship of the interfaces in the five-dimensional space of macroscopic parameters. Some previous studies have been conducted to investigate the structure-property relationship in this five-dimensional space for GBs of cubic lattice systems[13, 14] while such studies are still rare for interfaces involving non-cubic crystals due to lacking in effective code to construct interface models. Considering the general cases to simulate interfaces, given two arbitrary crystals defined by two cif files and an arbitrary disorientation which can be measured from experiment or pre-determined by sampling a point in the 5-dimensional space, one often needs to slightly deform one of the two crystals to make them coincident forming a three-dimensional or two-dimensional CSL. However, none of the previously reported programmes provide this application. Another shortage of the MPInterfaces package is that it cannot be applied to search for three-dimensional CSL. For those applying periodic boundary condition in all the three dimensions of the supercell, there always exist two interfaces in the supercell. In this case, applying a supercell consisting of two three-dimensionally coincident crystals where the two crystals coincide not only in the interface plane but also in the direction crossing the interface is a convenient way to make the two interfaces identical. Such convention has been applied in many first-principles simulation for symmetric tilt GBs[15, 16] of cubic lattices. Lacking in capability to automatically build such three-dimensional CSL interfaces for non-cubic lattice systems has become a main limitation to extend such studies to more general cases. Here, we provide a python package which is capable to achieve a convenient usage satisfying all these purposes above. This package is capable to make approximate CSL interfaces of any two crystalline materials by inputting two Cif files and geometric parameters with good intuition. This code outputs a structure file of the constructed interface with format as VASP or LAMMPS data file, as well as generates a ‘Structure’ object of this interface corresponding to usages for packages like Pymatgen[17] and Atomic Simulation Environment[18]. It also provides computation of cell of non-identical displacement (CNID) of the constructed CSL interface to accelerate the exploration of interface structures by rigid body translation (RBT). Although we have published a brute-force method for computing CNID [19], in this code we applied an analytical algorithm which is more effective and reliable. In this article we will briefly review the most important algorithms, and present the application of this code in building some experimentally observed interfaces. This package is now available from github: https://github.com/nmdl-mizo/interface_master/tree/master.
Algorithms
Algorithm generating approximate CSL for any two lattices
Here we present the algorithm finding an approximate CSL for any two lattices with certain initial disorientation. The algorithm was proposed by Bonnet et al. 5–7 and we did some modifications. Given two lattices 1 and 2 expressed by basis vectors and () as column vectors, where is related to basis vectors of rotated lattice 2 by a rotation operation , denominate an operation relating and as:
where is a matrix representing the set of basis vectors of lattice .
If lattice 1 and 2 form an approximate CSL with basis vector sets , we have
where slightly deforms and can be decomposed as using with small enough eigenvalues; and execute linear combinations extracting supercells of and . and have only integer elements. Denominate the ratio of the volume of to , as , .
Note that in the original literature by Bonnet et al. 5–7, were all applied as left-operations, while we found that their following discussions indicated that they should all be right-operations if the basic vectors were column vectors. (*Applying a right-operation supports the fact that , have only integer elements because CSL vectors should be linear combination of lattice 1 & 2 both with only integer coefficients. On the other hand, the equivalent left-operation is a linear transformation with and can have non-integer elements.)
To find the relationship between the approximate CSL and the two original lattices, rewrite 2.1.2 as
Comparing 2.1.3 with 2.1.1, , should be close to , . Therefore, the process finding an approximate CSL of lattice 1 and 2 is to find a rational matrix close to so that the matrix to hold 2.1.3 is close to a unit matrix. Note that is a rational matrix and its elements can be written as where at least one of the nine s is prime to . To control the extend of approximation, defining parameters , and denominating elements of , , (a unit matrix) as , , we make some inequalities:
As , can be determined by
where .
Now we present the algorithm.
Input , , rotation axis , angle , , , , , and ;
while :
while :
compute by 2.1.5
if :
compute by 2.1.3
if
compute and using algorithm in 2.2
if :
Output , and . end if
end if
end if
end while
end while
In more general cases the two crystals can form a 2-D CSL without simultaneously forming a 3-D CSL. Our programme is also available for this case. The process is as follows.
Input: , , , , a target disorientation .
Rotate by so that the normal vector of is collinear with the normal vector of ;
Rotate along the by so that ;
Applying the method by Banadaki & Patala[20] find two primitive plane bases of and , denominated as , .
Define two lattices , as , .
Execute the algorithm searching for the 3-D approximate CSL lattice with substituting , , by , , with keeping the third column of the matrix always being .
Output: , , , . The two vectors of or perpendicular to form a primitive basis of the 2-D CSL lattice.
Algorithm generating a 3-D DSC basis and a 3-D CSL basis for two arbitrary coincident lattices
Here we review the method to compute , mentioned in 2.1 and to compute CNID (two-dimensional DSC) and CSL[6]. Considering two arbitrary lattices with basic vectors as and forming an exact CSL lattice , we have
Similar with that in 2.1, and have only integer elements with , , and elements of have can be written as , where .
As lattice 1 is a sub-lattice of DSC [21], a basis of DSC can be parameterized as:
where are all non-negative integers.
To verify that such a DSC basis is primitive, the six non-negative integer parameters should satisfy that:
Then, the DSC bases can be determined by find the six integer parameters. The method solving the integer equations of the six parameters is presented in [6]. In this way, we obtain a DSC basis here.
As discussed in 2.1, we need to compute and to find a CSL basis. According to the literature, a CSL basis can be computed by repeating the routine computing a DSC basis of an ‘auxiliary’ lattice . The process is
Denominate a matrix related to by a symmetry operation along the second diagonal:
For and the ‘auxiliary’ lattice where , using the method above compute a DSC basis .
expressing as , where has elements as , and is determined as:
Then
Computation of CNID
After obtaining a CSL basis, we can specify an interface lying in a CSL lattice plane. Then the CNID of this interface can be found the following routine:
Specify an interface with miller indices expressed in the CSL lattice’s frame;
Use the method in [19] to convert to be expressed in lattice 1’s & lattice 2’s frame as & ;
Use the method in [20] to find the two plane bases of & denominated as & ;
Compute a DSC basis of & . Then the two of the basic DSC vectors lying in the interface is the desired CNID.
Bonnet’s algorithm is both effective and generally available. It is effective because the only numerical searching aspect involved is to solve two equations under inspection in a small range of unknown integer parameters. It is generally available because once two lattices form an exact CSL lattice, this algorithm can be applied for them, no matter what lattice species the two lattices are and no matter whether they are identical or not.
Generation of bicrystal model and examples of application
The Cif files of the crystals making these example interfaces were provided by Materials Project [22]. Visualization is down using VESTA[23] and OVITO[24].
Generating non-cubic CSL GBs with known geometric information
Here we show an example of CuInSe twinning GB [25] generated using our code. In this example, we input a cif file of a conventional cell of CuInSe, and output a bicrystal of a well-known twinning structure of this material as showed in the Figure 1.

Figure 1. Unit cell and twinning GB of CuInSe; all the vectors expressed in the conventional cell’s frame. (a) conventional cell; (b) primitive cell; (c) part of the final output bicrystal.
The process generating this GB is: 1) read the cif file of the conventional cell; 2) obtain the primitive cell and generate two identical lattices as and ; 3) according to the known geometry information, rotate to a close orientation (in this case rotate along axis by 180 degrees); 4) near the orientation, using the algorithm in 2.1 find an approximate 3-D CSL and determine parameters ; 5) specify the interface to lie in a CSL lattice plane ; 6) find a CSL plane basis of using the method in [20]; 7) find a CSL primitive basic vector which is closely normal to the plane; 8) get the integer indices matrix so that and ; 9) generate two slabs with basis as column vectors of and ; 10) translate the second slab by and the GB is generated. Some of the mentioned parameters of practical interests are shown in Table 1.
Table 1. Parameters involved generating the CuInSe twinning GB
As can be seen, because of some slight difference between the structure of a real material observed in the experiment and the structure provided by a cif file, the original crystals often cannot form an exact CSL by inputting geometry information obtained from experiment, which means that this CSL interfaces are not capable to be built with the existing programs without manual computation. For example, in Pymatgen, users need to adjust the lattice shape by their own to make this CSL structure while here we help users to find this deformation information automatically within allowed approximation. Our program also automatically computes the CNID cell which is output as two vectors (in this example as and ).
Here we show another example where this package can be applied to make an three-dimensional CSL interface by directly using the result from a diffraction experiment. Londoño-Calderon, A. et al.[26] has identified a Tellurium twinning GB by the diffraction pattern showing that two grains formed this GB comprising the and planes of the conventional hexagonal lattice, and that they have their and directions to be collinear. Our package can help to compute the corresponding target disorientation () by input the three-element miller indices of these two crystal planes and the indices of the two collinear directions, and a cif file of a conventional Tellurium unit cell. After determining this disorientation, this twinning GB can be constructed following the same routine for the last example of the CuInSe twinning GB. Table 2 shows the involved parameters. Also, as shown in Figure 2, one can change the chirality of one of the crystals by the command:
Table 2. Parameters involved generating the Tellurium twinning GB

Figure 2. Bicrystals of the Tellurium twinning GBs with difference in chirality
my_interface.atoms_2 = [1,1,1] – my_interface.atoms_2
This should be down before building this interface. In this way, one can investigate the effects of the chirality of the two crystals on the physical properties of this twinning grain boundary.
Generating two-dimensional CSL interfaces – -SiN(0001)/Si(111)
In 2.1 we explained the process to find a two-dimensional CSL lattice when a three-dimensional CSL lattice does not exist but a two-dimensional CSL lattice appears. Here we show an example of this case, which is the interface -SiN(0001)/Si(111) reported in [27], as shown in Figure 3. The involved parameters making this interface is shown in Table 3.
| <br><br><br> | <br> | ||
| <br> |
Table 3. Parameters involved generating the -SiN(0001)/Si(111) interface

Figure 3. Bicrystal of the -SiN(0001)/Si(111) interface
Using this code, users can also adjust the termination of the two slabs at the interface as well as adjust the size of each slab. They can also adjust the vacuum size between the two interfaces and that at the end of the supercell. We also provide functions to make supercells sampling the RBT in the CNID. With the supercells generated by these operations, one can flexibly conduct effective high-throughput simulation for any conceptual or experimentally observed interface.
Conclusion
In this work, applying two effective algorithms we generated a python programme capable to build CSL and approximate CSL interfaces and compute their CNIDs. By inputting simply two cif files (better of conventional cells), and some intuitive parameters, users can build any desired near CSL interface. Our programme provides a convenient tool supporting in research on interfaces.
Acknowledgements
Yaoshu Xie is supported by Ministry of Education, Culture,Sports, Science and Technology (MEXT) Scholarship with Embassy Recommendation for Chinese students. This study is supported by JST-CREST (JPMJCR1993) and the (MEXT); Nos 19H00818, and 19H05787, and Tenkai special funding in Institute of Industrial Science.
References
- [1]Ogawa, H. GBstudio: A builder software on periodic models of CSL boundaries for molecular simulation. Mater. Trans. 47, 2706–2710 (2006).
- [2]Cheng, J., Luo, J. & Yang, K. Aimsgb: An algorithm and open-source python library to generate periodic grain boundary structures. Comput. Mater. Sci. 155, 92–103 (2018).
- [3]Mathew, K. et al. MPInterfaces: A Materials Project based Python tool for high-throughput computational screening of interfacial systems. Comput. Mater. Sci. 122, 183–190 (2016).
- [4]Hadian, R., Grabowski, B. & Neugebauer, J. GB code: A grain boundary generation code Software • Review • Repository • Archive. (2018) doi:10.21105/joss.00900.DOI
- [5]Bonnet, R. & Durand, F. A general analytical method to find a basis for the DSC lattice. Scr. Metall. 9, 935–939 (1975).
- [6]Bonnet, R. Note on a general analytical method to find a basis for the DSC lattice. Derivation of a basis for the CSL. Scr. Metall. 10, 801–803 (1976).
- [7]Bonnet, R. & Cousineau, E. Computation of coincident and near-coincident cells for any two lattices – related DSC-1 and DSC-2 lattices. Acta Crystallogr. Sect. A 33, 850–856 (1977).
- [8]SUTTON & P., A. Interfaces in Crystalline Materials. Monogr. Physice Chem. Mater. 414–423 (1995).
- [9]Watanabe, T. Grain boundary engineering: Historical perspective and future prospects. in Journal of Materials Science vol. 46 4095–4115 (Springer, 2011).
- [10]Pervez, S. A., Cambaz, M. A., Thangadurai, V. & Fichtner, M. Interface in Solid-State Lithium Battery: Challenges, Progress, and Outlook. ACS Appl. Mater. Interfaces 11, 22029–22050 (2019).
- [11]Chen, H., Zhang, W., Li, M., He, G. & Guo, X. Interface Engineering in Organic Field-Effect Transistors: Principles, Applications, and Perspectives. Chem. Rev. 120, 2879–2949 (2020).
- [12]Gariglio, S., Gabay, M., Mannhart, J. & Triscone, J. M. Interface superconductivity. Phys. C Supercond. its Appl. 514, 189–198 (2015).DOI
- [13]Banadaki, A. D. & Patala, S. A simple faceting model for the interfacial and cleavage energies of Σ3 grain boundaries in the complete boundary plane orientation space. Comput. Mater. Sci. 112, 147–160 (2016).
- [14]Huber, L., Hadian, R., Grabowski, B. & Neugebauer, J. ARTICLE OPEN A machine learning approach to model solute grain boundary segregation. npj Comput. Mater. 4, 64 (2018).
- [15]Zheng, H. et al. Grain boundary properties of elemental metals. Acta Mater. 186, 40–49 (2020).arxiv.org/abs/1907.08905
- [16]Ziebarth, B., Mrovec, M., Elsässer, C. & Gumbsch, P. Interstitial iron impurities at grain boundaries in silicon: A first-principles study. Phys. Rev. B - Condens. Matter Mater. Phys. 91, 035309 (2015).DOI
- [17]Ong, S. P. et al. Python Materials Genomics (pymatgen): A robust, open-source python library for materials analysis. Comput. Mater. Sci. 68, 314–319 (2013).DOI
- [18]Hjorth Larsen, A. et al. The atomic simulation environment—a Python library for working with atoms. J. Phys. Condens. Matter 29, 273002 (2017).DOI
- [19]Xie, Y., Shibata, K. & Mizoguchi, T. A brute-force code searching for cell of non-identical displacement for CSL grain boundaries and interfaces. Comput. Phys. Commun. 273, 108260 (2022).DOI
- [20]Banadaki, A. D. & Patala, S. An efficient algorithm for computing the primitive bases of a general lattice plane. J. Appl. Crystallogr. 48, 585–588 (2015).DOI
- [21]Bollmann, W. General Geometrical Theory of Crystalline Interfaces. in Crystal Defects and Crystalline Interfaces 143–185 (Springer Berlin Heidelberg, 1970). doi:10.1007/978-3-642-49173-3_12.DOI
- [22]Lambert, H., Fekete, A., Kermode, J. R. & Vita, A. De. Imeall: A computational framework for the calculation of the atomistic properties of grain boundaries. Comput. Phys. Commun. 232, 256–263 (2018).DOI
- [23]Momma, K. & Izumi, F. VESTA: a three-dimensional visualization system for electronic and structural analysis. urn:issn:0021-8898 41, 653–658 (2008).DOI
- [24]Stukowski, A. Visualization and analysis of atomistic simulation data with OVITO-the Open Visualization Tool. Model. Simul. Mater. Sci. Eng. 18, (2010).DOI
- [25]Yamaguchi, H., Hiramatsu, H., Hosono, H. & Mizoguchi, T. The atomic structure, band gap, and electrostatic potential at the (112)[11̄0] twin grain boundary of CuInSe2. Appl. Phys. Lett. 104, 153904 (2014).
- [26]Londoño-Calderon, A. et al. Local lattice deformation of tellurene grain boundaries by four-dimensional electron microscopy. J. Phys. Chem. C 125, 3396–3405 (2021).
- [27]Wu, C. L., Wang, J. C., Chan, M. H., Chen, T. T. & Gwo, S. Heteroepitaxy of GaN on Si(111) realized with a coincident-interface AlN/ β-Si3N4(0001) double-buffer structure. Appl. Phys. Lett. 83, 4530–4532 (2003).DOI