pymatgen
Materials science toolkit. Crystal structures (CIF, POSCAR), phase diagrams, band structure, DOS, Materials Project integration, format conversion, for computational materials science.
Author
Category
Product DesignInstall
Download and extract to your skills directory
Copy command and send to AI Agent for auto-install:
Pymatgen - The Python flagship tool for materials science data analysis
Skills overview
Pymatgen (Python Materials Genomics) is a powerful Python library for materials science. It provides core support for the Materials Project and can analyze, transform, and visualize a wide range of materials data, including crystal structures, molecules, electronic structures, and phase diagrams. It supports 100+ types of computational software file formats.
Use cases
Core features
FAQ
What is pymatgen? Who is it for?
Pymatgen is an open-source Python library for materials science, mainly used to process and analyze materials data such as crystal structures, electronic structures, and phase diagrams. It is especially suitable for graduate students, postdocs, and researchers working in computational materials science, condensed matter physics, and materials informatics. If you frequently handle VASP results, need to query the Materials Project database, or want to perform high-throughput materials screening, pymatgen will significantly improve your workflow efficiency.
How do I install and configure pymatgen?
You can install the core library with pip install pymatgen or uv pip install pymatgen. If you want to access the Materials Project database, you also need to install the mp-api package and configure an API key (register at https://next-gen.materialsproject.org/ ). After setting the environment variable export MP_API_KEY="your_key", you can use MPRester in your code to query the database. For advanced analysis features (such as band plotting), it is recommended to install the pymatgen[vis] extension package.
What file formats does pymatgen support? How do I convert files?
Pymatgen supports 100+ file formats from computational software, including:
Conversion is straightforward:
# Automatically detect and read formats
struct = Structure.from_file("input.cif")
# Save to another format
struct.to("POSCAR") # Convert to VASP formatIt also provides command-line scripts for batch conversion:
python scripts/structure_converter.py *.cif --output-dir ./poscar_files --format poscar