$ show materialsproject/pymatgen
pymatgen (Python Materials Genomics) is a robust, open-source Python library for materials analysis, primarily used for high-throughput computational materials science. It provides core object representations for crystal structures, molecules, and computational outputs (VASP, Q-Chem, Gaussian, etc.), and extends into analysis modules for phase diagrams, battery electrodes, coordination environments, magnetism, elasticity, surface science, diffraction, and spectroscopy. The library powers the Materials Project database and includes CLI tools for structure manipulation, POTCAR generation, and plotting. It features extensive use of MSONable serialization, abstract base classes, and a correction scheme pattern for DFT energy adjustments. While heavily integrated with the Materials Project ecosystem, its modular design allows reuse of individual analysis components in other materials research pipelines.
The LLM identified 5 files worth highlighting for reuse:
Provides a clean, extensible abstract base class `EOSBase` with concrete implementations for multiple equation-of-state models (Murnaghan, Birch-Murnaghan, Vinet, etc.). The `EOS` wrapper class auto-selects the best fit. Each model is a small, self-contained class implementing `fit()` and `func()`, making it easy to add new EOS forms. The module is isolated (depends only on numpy/scipy) and could be extracted as a standalone EOS fitting utility for any pressure-volume data.
Implements the Zur & McGill (1984) lattice matching algorithm (ZSL) for identifying commensurate interfaces between two crystal lattices. Uses numba `@njit` for performance-critical loops and provides a clean API through `ZSLGenerator`. The algorithm is self-contained (requires only numpy, numba) and can be reused in any interface analysis project, including strain calculations and heterostructure design.
Implements the ChemEnv method for identifying coordination geometries around a central atom using continuous symmetry measures and separation-plane algorithms. The `LocalGeometryFinder` class encapsulates the full pipeline (Voronoi neighbor identification, symmetry measure computation, geometry ranking) with configurable optimization levels. The underlying `AbstractGeometry` class and symmetry measure functions are self-contained and reusable for any point-cloud shape analysis task beyond coordination chemistry.
Provides an abstract `Compatibility` base class with concrete implementations for applying DFT energy corrections (e.g., MaterialsProject2020Compatibility, MITCompatibility). Each correction is defined in YAML files and applied via a chain-of-responsibility pattern through `CorrectionsList`. The architecture is extensible: new correction schemes can be added by subclassing and providing a YAML configuration. This pattern is reusable for any domain requiring versioned correction schemes applied to computational entries.
Provides `CollinearMagneticStructureAnalyzer` for detecting magnetic ordering types and `MagneticStructureEnumerator` for generating collinear magnetic configurations. Uses symmetry analysis to reduce enumeration space and integrates with pymatgen's structure matching for deduplication. The analyzer's magnetic moment assignment and ordering classification logic is reusable for any collinear magnetic structure analysis, independent of the DFT code used.