pymatgen

Analyze crystal structures, phase diagrams, and electronic properties with pymatgen and Materials Project.

Updated Sep 2, 2026
One-click install
npx skills add https://github.com/ricfulop/cba-agentic-engineering-bootstrap --skill pymatgen-ricfulop
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pymatgen
Source: https://github.com/ricfulop/cba-agentic-engineering-bootstrap/tree/main/skills/pymatgen
Command: npx skills add https://github.com/ricfulop/cba-agentic-engineering-bootstrap --skill pymatgen-ricfulop

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pymatgen, mp-api, and includes scripts (resource) and references (resource) components.

What problem does it solve? Computational materials science requires juggling dozens of structure file formats, symmetry analysis, thermodynamic stability checks, and electronic structure post-processing. This Skill provides ready-to-use pymatgen workflows, scripts, and references so you can analyze materials and query the Materials Project without writing boilerplate from scratch. ## Core Features & Use Cases - Structure Handling and Conversion: Read, create, and convert between 100+ formats (CIF, POSCAR, XYZ) with automatic format detection and batch conversion scripts. - Thermodynamic and Electronic Analysis: Build phase diagrams, compute energy above hull, analyze band structures and DOS, and generate surfaces, slabs, and adsorption sites. - Materials Project Integration: Query the Materials Project database programmatically via mp-api to retrieve structures, entries, and computed properties. - Use Case: Given a POSCAR file, run the structure analyzer script to get symmetry, coordination environments, and lattice parameters, then generate a Li-Fe-O phase diagram and check whether LiFeO2 is stable against decomposition. ## Quick Start Ask the assistant to analyze the attached POSCAR file for symmetry and coordination environment using the pymatgen skill.

Frequently Asked Questions about pymatgen

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert between CIF and POSCAR files in Python?

Use pymatgen's Structure.from_file() to read any format with automatic detection, then call struct.to(filename="output.cif") to write the target format. The included structure_converter.py script also handles single and batch conversions from the command line.

How do I generate a phase diagram from Materials Project data?

Use MPRester from the mp-api package to fetch entries with get_entries_in_chemsys, then pass them to pymatgen's PhaseDiagram class. The phase_diagram_generator.py script automates this and reports energy above hull and decomposition products.

Does pymatgen require a Materials Project API key?

Only for database queries through mp-api; local structure analysis, format conversion, and file I/O work without any key. Set the MP_API_KEY environment variable after registering at next-gen.materialsproject.org to enable database access.

Can pymatgen read VASP output files like vasprun.xml?

Yes, pymatgen's Vasprun class parses vasprun.xml to extract final structures, energies, band structures, and density of states. It also supports OUTCAR, OSZICAR, and input generation via input sets like MPRelaxSet and MPStaticSet.

Why does symmetry analysis fail on my structure?

Symmetry detection usually fails due to numerical precision issues in atomic coordinates. Increase the tolerance by passing a larger symprec value, such as SpacegroupAnalyzer(struct, symprec=0.1), to resolve the issue.