Authors: Xin Zhu | Jian‐Min Zuo
Source: Microscopy and Microanalysis (article, 2023-07-22)
Field: Materials Science — Materials Chemistry

PyEMAPS: An Open Source Python Package for Transmission Electron Diffraction Simulations and Crystallographic Computing Transmission electron diffraction is a powerful technique for analyzing the structure of materials at the nanometer scale.Computer simulations play a critical role in interpreting and quantifying electron diffraction patterns, bridging the gap between crystallography, electron diffraction theory, and electron microscopy practices.Simulating large diffraction datasets can also benefit data-driven electron microscopy, particularly for machine learning applications using four-dimensional scanning transmission electron microscopy (4D-STEM).Several solutions have been developed to meet the needs of electron diffraction simulations [1][2][3][4][5].In this session, we introduce PyEMAPS, an integrated Python package for electron diffraction and crystallography computation that is freely available for education and research.Python is a high-level programming language with an array of numerical functions and modules for scientific computing.By providing a user-friendly and accessible interface for electron diffraction simulation and crystallographic computation in a popular scripting language, we aim to accelerate research and education in electron diffraction and microscopy (Fig. 1).The implementation in Python also allows access to a large repository of packages in its opensource communities for advanced computing, such as parallel computing and machine learning.PyEMAPS implements the kinematical and dynamical electron diffraction theories described by Spence and Zuo in the book "Electron Microdiffraction" [1].The Python package is built from well-tested electron diffraction simulation algorithms written in Fortran/C, which have been converted into Python modules using f2py [6], a part of the Python numpy package for fundamental scientific computing.This combination of approaches takes advantage of both the performance and memory efficiency of traditional Fortran/C scientific computation and the versatility and productivity of Python.PyEMAPS features crystal construction Python classes capable of loading data from various sources, such as CIF files and PyEMAPS' built-in libraries.All simulations are implemented as crystal class methods and interfaces, including simulations of selected area diffraction, convergent beam diffraction, Kikuchi and high-order laue zone line geometry display.Dynamic (Bloch) diffractions, powder diffraction simulations, electron dispersion, and scattering matrix calculations are also included in this free and open-source package.PyEMAPS is available on Python's free and open-source package repository and can be easily installed using Python's pip package install utility.Documentation with tutorials is available, along with a set of sample codes.A significant improvement made in PyEMAPS over previous implementations (WebEMPAS and CloudEMAPS) is the acceleration of dynamical diffraction simulation using the Bloch wave method (Fig. 2).This acceleration is achieved by optimizing code and code generation with Intel ® classic Fortran compiler and Intel® Math Kernel Library in Intel ® oneAPI toolkits.Users can realize even more simulation speed-up with parallel processing in Python.In this presentation, we introduce the architecture of PyEMAPS, its classes, and methods.We will provide tutorials on how to set up PyEMAPS in a Python environment, load real crystal data, create Python crystal objects, and show kinematic and dynamic simulations.To promote microscopy education and research, we will illustrate the advanced PyEMAPS usages and applications in generating diffraction databases for image analysis and index matching. Python (programming language) ; Crystallography ; Materials science ; Open source ; Computational science ; Electron diffraction ; Computer science ; Diffraction ; Physics ; Chemistry ; Operating system ; Optics Machine Learning in Materials Science ; Advanced Materials Characterization Techniques ; Electronic and Structural Properties of Oxides