High-performance Python for crystallographic computing - Archive ouverte HAL Accéder directement au contenu
Article Dans Une Revue Journal of Applied Crystallography Année : 2019

High-performance Python for crystallographic computing

Résumé

The Python programming language, combined with the numerical computing library NumPy, and the scientific computing library SciPy, has become the de facto standard for scientific computing in a variety of fields. This popularity is mainly due to the ease with which a Python program can be written and executed (easy syntax, dynamical typing, no compilation, etc.) coupled with the existence of a large amount of specialized third-party libraries that aim to lift all the limitations of the raw Python language. NumPy introduces vector programming improving execution speeds, whereas SciPy brings a wealth of highly optimized and reliable scientific functions. There are cases however, where vector programming alone is not sufficient to reach optimal performances. This issue is addressed with dedicated compilers that aim to translate Python code into native and statically typed code with support for the multi-core architectures of modern processors. In the present article we show how these approaches can be efficiently used to tackle different problems, with increasing complexity, that are relevant to crystallography: the 2-dimensional (2D) Laue function, the scattering from a strained 2D crystal, the scattering from three-dimensional nanocrystals and, finally, the diffraction from films and multilayers. For each case we provide detailed implementations and explications on the functioning of the algorithms. Different Python compilers (namely NumExpr, Numba, Pythran and Cython) are presented and used to improve performances and are benchmarked against state-of-the-art NumPy implementations. All examples are also provided as commented and didactic Python (Jupyter) notebooks that can be used as starting points for crystallographers curious to enter the Python ecosystem or willing to accelerate their existing codes.
Fichier principal
Vignette du fichier
Preprint.pdf (1.76 Mo) Télécharger le fichier
Notebooks.zip (1.42 Mo) Télécharger le fichier
Origine : Fichiers produits par l'(les) auteur(s)
Loading...

Dates et versions

hal-02194025 , version 1 (25-07-2019)
hal-02194025 , version 2 (25-07-2019)

Identifiants

Citer

Alexandre Boulle, Jérôme Kieffer. High-performance Python for crystallographic computing. Journal of Applied Crystallography, 2019, 52, pp.882-897. ⟨10.1107/S1600576719008471⟩. ⟨hal-02194025v2⟩
875 Consultations
985 Téléchargements

Altmetric

Partager

Gmail Facebook X LinkedIn More