pymatgen
Installation
SKILL.md
pymatgen
Overview
pymatgen is the standard Python library for materials science computation. Its core data model — Structure (periodic crystalline materials) and Molecule (non-periodic) — provides a unified representation for input/output across 30+ file formats (CIF, POSCAR/CONTCAR, XYZ, PDB, Gaussian, VASP). The library integrates with the Materials Project REST API (mp_api) to retrieve 150,000+ DFT-computed structures with band gaps, formation energies, and elastic constants. pymatgen is the foundation of the atomate2 and Custodian workflow frameworks for high-throughput DFT.
When to Use
- Parsing and converting crystal structure files between CIF, POSCAR, XYZ, and other formats
- Querying the Materials Project API for computed band gaps, formation energies, and stability data
- Constructing and analyzing phase diagrams and Pourbaix diagrams for thermodynamic stability
- Generating VASP, Quantum ESPRESSO, or CP2K input files from structure objects
- Computing X-ray diffraction (XRD) and neutron diffraction patterns for comparison with experiment
- Analyzing symmetry, space groups, and Wyckoff positions of crystal structures
- Use ASE when running molecular dynamics or interfacing with multiple MD/DFT codes via a unified runner