pymatgen

Automate materials analysis, structure manipulation, and thermodynamics with Python.

Updated Dec 17, 2025
One-click install
npx skills add https://github.com/robotlearning123/claude-scientific-skills --skill pymatgen-robotlearning123
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pymatgen
Source: https://github.com/robotlearning123/claude-scientific-skills/tree/main/scientific-skills/pymatgen
Command: npx skills add https://github.com/robotlearning123/claude-scientific-skills --skill pymatgen-robotlearning123

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill simplifies materials analysis, allowing users to create, analyze, and manipulate crystal structures, compute phase diagrams, and access Materials Project data.

Core Features & Use Cases

  • Structure Creation and Manipulation: Create structures from scratch or from files, perform transformations, and analyze symmetry and coordination.
  • File Format Conversion: Convert between 100+ file formats with automatic detection.
  • Structure Analysis: Analyze structures for symmetry, coordination, and other properties.
  • Phase Diagrams and Thermodynamics: Construct phase diagrams and analyze thermodynamic stability.
  • Electronic Structure Analysis: Analyze band structures, density of states, and electronic properties.
  • Surface and Interface Analysis: Generate slabs, analyze surfaces, and study interfaces.
  • Materials Project Database Access: Programatically access the Materials Project database for structure and property data.
  • Computational Workflow Setup: Set up calculations for various electronic structure codes.
  • Advanced Analysis: Perform diffraction, elasticity, magnetism, and reaction analysis.
  • Use Case: Imagine you need to analyze the crystal structure of a new material. Use this Skill to create the structure, compute its phase diagram, and analyze its electronic properties.

Quick Start

Install the skill using the following command:

uv pip install pymatgen

Then, you can create a new structure and write it to a CIF file:

from pymatgen.core import Structure
lattice = Lattice.cubic(3.84)
struct = Structure(lattice, ["Si", "Si"], [[0, 0, 0], [0.25, 0.25, 0.25]])
struct.to(filename="structure.cif")

Frequently Asked Questions about pymatgen

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

FAQPage Schema
How do I construct a phase diagram and analyze thermodynamic stability for a set of compounds?

You can construct a phase diagram and analyze thermodynamic stability by providing structural data, which the Skill processes using pymatgen to map phase boundaries and compute stability metrics. It outputs visual and analytical thermodynamic data.

Can I convert between different crystal structure file formats automatically?

Yes, you can convert between 100+ crystal structure file formats with automatic detection. The Skill uses pymatgen to parse input files and export them to your desired format, streamlining structural data interoperability for computational workflows.

How do I generate slabs and analyze surfaces for interface studies?

You can generate slabs and analyze surfaces by defining the miller indices and slab thickness, which the Skill processes using pymatgen to output the required surface structures. It enables detailed interface analysis and surface property computation for computational materials science.

Does this Skill support accessing the Materials Project database for structure and property data?

Yes, this Skill supports accessing the Materials Project database programmatically via the mp-api dependency. It allows you to query and retrieve crystal structure and material property data directly for downstream analysis and manipulation.

What Python environment and libraries are required to compute electronic structures and band structures?

Computing electronic structures and band structures requires a Python environment with pymatgen, mp-api, and ASE installed. These dependencies provide the foundational framework for parsing outputs and analyzing density of states and electronic properties.

How do I create a crystal structure from scratch and write it to a CIF file?

To create a crystal structure from scratch and write it to a CIF file, you define the lattice and atomic coordinates using pymatgen, then use the built-in file writing functions to export the structure to CIF format.