pymatgen

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

Updated Aug 12, 2026
One-click install
npx skills add https://github.com/littlt-momo-c-yfc/skills --skill pymatgen-littlt-momo-c-yfc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pymatgen
Source: https://github.com/littlt-momo-c-yfc/skills/tree/main/skills/scientific-toolkit-skill/references/scientific-skills/pymatgen
Command: npx skills add https://github.com/littlt-momo-c-yfc/skills --skill pymatgen-littlt-momo-c-yfc

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 manipulating crystal structures across dozens of file formats, assessing thermodynamic stability, and analyzing electronic structure data, all of which involve complex library APIs and multi-step workflows that are error-prone when done manually. ## Core Features & Use Cases - Structure Handling and Conversion: Read, create, and convert crystal structures across 100+ formats (CIF, POSCAR, XYZ) with automatic format detection, symmetry analysis, and coordination environment analysis. - Phase Diagrams and Stability: Build phase diagrams from Materials Project data, compute energy above hull, and determine decomposition products for any composition. - Electronic Structure and Surfaces: Analyze band structures and DOS from VASP outputs, generate slabs and adsorption sites, and construct Wulff shapes. - Use Case: A researcher screening Li-Fe-O cathode candidates queries the Materials Project for stable phases, generates a phase diagram, and produces VASP input files for the most promising structures in one workflow. ## Quick Start Ask the agent to analyze the crystal structure in your POSCAR file, including its space group, density, and coordination environments.

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 supported format with automatic detection, then call struct.to(filename="output.cif") to write the target format. The bundled 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("Li-Fe-O"), then pass them to pymatgen's PhaseDiagram class. You need a free API key from materialsproject.org set as the MP_API_KEY environment variable.

Does pymatgen support VASP input and output files?

Yes, pymatgen has comprehensive VASP integration including Poscar, Incar, Kpoints, and Potcar input classes, Vasprun and Outcar output parsers, and pre-configured input sets like MPRelaxSet and MPStaticSet for common calculation types.

Why does symmetry analysis fail on my structure?

Symmetry detection usually fails due to numerical precision issues in atomic coordinates. Increase the tolerance by creating SpacegroupAnalyzer(struct, symprec=0.1) instead of using the default precision.

Can pymatgen analyze band structures and density of states?

Yes, Vasprun("vasprun.xml").get_band_structure() returns a band structure object with methods for band gap, VBM, and CBM, while complete_dos provides total and element-projected DOS. Both have built-in plotters for visualization.