Fast building, analysis, simulation and visualization of atomistic systems, in Python.
Documentation · Quick tour · Lessons · Examples · Install · Tests · Cite
MDAPY 2.0 is a complete rewrite and is not compatible with MDAPY 1.x. It brings many more features, and we recommend upgrading. The code of 1.x stays on the branch
1.x.
If you like MDAPY, please give it a ⭐ star.
- Light. NumPy and polars are its only requirements. Packages such as matplotlib or ASE are optional, and it carries no other third-party code.
- Robust. Tests cover more than 99 % of the code and compare each feature with analytic results and with mature software. All of them run automatically on Linux, macOS and Windows. Results are the same for any number of threads, and damaged files or impossible inputs give a clear error, not a crash.
- Fast. The heavy parts run in C++, on a parallel engine of MDAPY's own. See the benchmarks.
- Predictable. Names say what the code does:
minimize,elastic_constants,CommonNeighborAnalysis. ASystemnever changes in place, every analysis has the formcompute(system)and returns NumPy arrays, and one unit system, Å, eV and ps, runs through everything. - Integrated. One package and one
System, from the first structure to the last picture. It converts systems to and from ASE, OVITO, pymatgen and freud, takes any ASE calculator or LAMMPS interaction, shares a process with PyTorch, and works as one step of high-throughput calculations. - Documented. Every feature has its own page, with an example, its parameters, its results and its references, and lessons lead from the first structure on.
| Area | What is in it |
|---|---|
| Build | Crystals, polycrystals, alloys, defects and dislocations |
| Analyze | More than 40 analyses of structure, local order, defects and dynamics |
| Simulate | Native EAM and NEP, interfaces to LAMMPS and ASE; relaxation and dynamics; elastic constants, phonons, free energies, melting points and phase diagrams |
| MLIP | Training sets from VASP, descriptors, errors of a model, the frames worth computing |
| Visualize | Ray-traced pictures on the processor or the graphics card, movies and plots |
| Exchange | Eight file formats, and systems shared with ASE, OVITO, pymatgen and freud |
One copper polycrystal, from nothing to a movie.
See A movie that flies through a crystal for the whole script.
pip install --pre mdapyThe first release of 2.0 is a preview, and --pre asks pip for it: without it, pip
installs 1.x. MDAPY needs Python 3.11 or newer. Installation
describes the other ways to install it, from a source archive or from git, what those need,
and the optional packages.
git clone https://github.com/mushroomfire/mdapy.git
cd mdapy
pip install -e ".[dev]"
pytestTests that need another program are skipped where it is missing. Contributing lists what a complete run needs.
If MDAPY contributes to a publication, please cite:
Yong-Chao Wu and Jian-Li Shao, mdapy: A flexible and efficient analysis software for molecular dynamics simulations, Computer Physics Communications 290, 108764 (2023). doi:10.1016/j.cpc.2023.108764
Mozilla Public License 2.0, see LICENSE: MDAPY may be used in any software, open or closed, and changes to its own files are shared under the same license.
MDAPY has been written three times.
| Series | Years | How it was built | Code |
|---|---|---|---|
| 0.x | 2022–2025 | Python, with Taichi for the kernels | Branch mdapy_old, last release 0.11.5 |
| 1.x | 2025–2026 | Rewritten with every kernel in C++, and with NumPy and polars as its only requirements | Branch 1.x, last release 1.0.10, documentation |
| 2.x | 2026– | Rewritten again from scratch, for the reasons below | This branch |
Taichi was no longer updated, which also limited the versions of Python that 0.x could run on. 1.x was rewritten to be easy to update and maintain, and it needs only NumPy and polars, no longer SciPy and Taichi.
2.x goes further: it is easier to maintain, more stable and more consistent, lighter without external code, with many more features and a clearer organization. In particular:
- OpenMP. The OpenMP runtime of 1.x could clash with those of other packages. 2.x runs a thread pool of its own, so it shares a process with PyTorch and LAMMPS.
- Third-party code. 1.x carried ten third-party codes to build and keep working. 2.x carries none.
- The API. In 1.x an analysis was a method that changed the system. In 2.x a
Systemnever changes and every analysis is a class with one form. - Tests. Tests cover more than 99 % of the code and compare each feature with analytic results and with mature software, which makes 2.x more stable.
- Many small calculations. The threads can be limited for each process, so thousands of small calculations side by side do not fight for cores.
- Graphical interfaces. Long computations report their progress, can be cancelled and leave Python running, so a graphical interface is easy to build on 2.x.




