Pymatgen
K-Dense-AI/scientific-agent-skills
Analyzes, validates, converts, and transforms materials structures and computed materials data with pymatgen.
Materials science toolkit. An agent skill from zLanqing/codex-claude-academic-skills.
$ npx skills add zLanqing/codex-claude-academic-skills --skill pymatgen -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install zLanqing/codex-claude-academic-skills pymatgen --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/zLanqing/codex-claude-academic-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/scientific-toolkit-skill/references/scientific-skills/pymatgen .claude/skills/pymatgen && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "pymatgen" agent skill from https://github.com/zLanqing/codex-claude-academic-skills/tree/main/scientific-toolkit-skill/references/scientific-skills/pymatgen into .claude/skills/pymatgen/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "pymatgen", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/zLanqing/codex-claude-academic-skills/tree/main/scientific-toolkit-skill/references/scientific-skills/pymatgenType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add zLanqing/codex-claude-academic-skills --skill pymatgen -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install zLanqing/codex-claude-academic-skills pymatgen --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/zLanqing/codex-claude-academic-skills.git skills-src && mkdir -p .agents/skills && cp -r skills-src/scientific-toolkit-skill/references/scientific-skills/pymatgen .agents/skills/pymatgen && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "pymatgen" agent skill from https://github.com/zLanqing/codex-claude-academic-skills/tree/main/scientific-toolkit-skill/references/scientific-skills/pymatgen into .agents/skills/pymatgen/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "pymatgen", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add zLanqing/codex-claude-academic-skills --skill pymatgen -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install zLanqing/codex-claude-academic-skills pymatgen --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/zLanqing/codex-claude-academic-skills.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/scientific-toolkit-skill/references/scientific-skills/pymatgen .cursor/skills/pymatgen && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "pymatgen" agent skill from https://github.com/zLanqing/codex-claude-academic-skills/tree/main/scientific-toolkit-skill/references/scientific-skills/pymatgen into .cursor/skills/pymatgen/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "pymatgen", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/zLanqing/codex-claude-academic-skills.git --path scientific-toolkit-skill/references/scientific-skills/pymatgen--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add zLanqing/codex-claude-academic-skills --skill pymatgen -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install zLanqing/codex-claude-academic-skills pymatgen --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/zLanqing/codex-claude-academic-skills.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/scientific-toolkit-skill/references/scientific-skills/pymatgen .gemini/skills/pymatgen && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "pymatgen" agent skill from https://github.com/zLanqing/codex-claude-academic-skills/tree/main/scientific-toolkit-skill/references/scientific-skills/pymatgen into .gemini/skills/pymatgen/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "pymatgen", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install zLanqing/codex-claude-academic-skills pymatgenInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add zLanqing/codex-claude-academic-skills --skill pymatgen -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/zLanqing/codex-claude-academic-skills.git skills-src && mkdir -p .github/skills && cp -r skills-src/scientific-toolkit-skill/references/scientific-skills/pymatgen .github/skills/pymatgen && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "pymatgen" agent skill from https://github.com/zLanqing/codex-claude-academic-skills/tree/main/scientific-toolkit-skill/references/scientific-skills/pymatgen into .github/skills/pymatgen/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "pymatgen", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add zLanqing/codex-claude-academic-skills --skill pymatgen -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install zLanqing/codex-claude-academic-skills pymatgen --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/zLanqing/codex-claude-academic-skills.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/scientific-toolkit-skill/references/scientific-skills/pymatgen .opencode/skills/pymatgen && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "pymatgen" agent skill from https://github.com/zLanqing/codex-claude-academic-skills/tree/main/scientific-toolkit-skill/references/scientific-skills/pymatgen into .opencode/skills/pymatgen/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "pymatgen", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
pymatgenMaterials science toolkit. An agent skill from zLanqing/codex-claude-academic-skills.
Pymatgen is an agent skill from zLanqing/codex-claude-academic-skills. Materials science toolkit. Crystal structures (CIF, POSCAR), phase diagrams, band structure, DOS, Materials Project integration, format conversion, for computational materials science.
Its SKILL.md is about 5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 10 other files, including scripts and reference files (for example `references/analysis_modules.md`, `references/core_classes.md` and `references/io_formats.md`).
It sits in Research & Science, covering Physical and earth sciences and Diagrams. The repository describes itself as: 本仓库包含三个面向学术科研人员的Skills,覆盖从文献阅读、论文写作到科学计算的完整研究工作流。office-academic-skill 负责论文阅读报告与学术 PPT/Word 文档生成;research-writing-skill 提供论文写作、润色与审稿回复辅助;scientific-toolkit-skill 整合 MATLAB/Python… The licence is MIT.
9 steps, taken from the step headings in SKILL.md.
Read from SKILL.md and the folder at commit 7ed6377. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
Ships 3 files in scripts/ (Python), which the agent can run.
Shell commands in SKILL.md call:
pythonuvFrom the folder's file list and the shell code blocks in SKILL.md.
Links to these hosts (documentation or services it may open):
next-gen.materialsproject.orgpymatgen.orgmaterialsproject.orggithub.commatsci.orgmatgenb.materialsvirtuallab.orgFrom URLs in SKILL.md, links to its own repository left out.
Names these keys or tokens, usually read from environment variables:
MP_API_KEYFrom names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Pymatgen loads about 5k tokens when it runs, and up to ~21k if it reads all its reference files. Until then it costs about 48 tokens; SKILL.md has 906 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.
The full file from zLanqing/codex-claude-academic-skills at commit 7ed6377, republished under its MIT licence (© zLanqing). 906 words, ~5,006 tokens.
.claude/skills/pymatgen/SKILL.md (or your agent's skills folder). This skill also uses 8 other files; get the full folder from GitHub.Pymatgen is a comprehensive Python library for materials analysis that powers the Materials Project. Create, analyze, and manipulate crystal structures and molecules, compute phase diagrams and thermodynamic properties, analyze electronic structure (band structures, DOS), generate surfaces and interfaces, and access Materials Project's database of computed materials. Supports 100+ file formats from various computational codes.
This skill should be used when:
# Core pymatgen
uv pip install pymatgen
# With Materials Project API access
uv pip install pymatgen mp-api
# Optional dependencies for extended functionality
uv pip install pymatgen[analysis] # Additional analysis tools
uv pip install pymatgen[vis] # Visualization toolsfrom pymatgen.core import Structure, Lattice
# Read structure from file (automatic format detection)
struct = Structure.from_file("POSCAR")
# Create structure from scratch
lattice = Lattice.cubic(3.84)
struct = Structure(lattice, ["Si", "Si"], [[0,0,0], [0.25,0.25,0.25]])
# Write to different format
struct.to(filename="structure.cif")
# Basic properties
print(f"Formula: {struct.composition.reduced_formula}")
print(f"Space group: {struct.get_space_group_info()}")
print(f"Density: {struct.density:.2f} g/cm³")# Set up API key
export MP_API_KEY="your_api_key_here"from mp_api.client import MPRester
with MPRester() as mpr:
# Get structure by material ID
struct = mpr.get_structure_by_material_id("mp-149")
# Search for materials
materials = mpr.materials.summary.search(
formula="Fe2O3",
energy_above_hull=(0, 0.05)
)Create structures using various methods and perform transformations.
From files:
# Automatic format detection
struct = Structure.from_file("structure.cif")
struct = Structure.from_file("POSCAR")
mol = Molecule.from_file("molecule.xyz")From scratch:
from pymatgen.core import Structure, Lattice
# Using lattice parameters
lattice = Lattice.from_parameters(a=3.84, b=3.84, c=3.84,
alpha=120, beta=90, gamma=60)
coords = [[0, 0, 0], [0.75, 0.5, 0.75]]
struct = Structure(lattice, ["Si", "Si"], coords)
# From space group
struct = Structure.from_spacegroup(
"Fm-3m",
Lattice.cubic(3.5),
["Si"],
[[0, 0, 0]]
)Transformations:
from pymatgen.transformations.standard_transformations import (
SupercellTransformation,
SubstitutionTransformation,
PrimitiveCellTransformation
)
# Create supercell
trans = SupercellTransformation([[2,0,0],[0,2,0],[0,0,2]])
supercell = trans.apply_transformation(struct)
# Substitute elements
trans = SubstitutionTransformation({"Fe": "Mn"})
new_struct = trans.apply_transformation(struct)
# Get primitive cell
trans = PrimitiveCellTransformation()
primitive = trans.apply_transformation(struct)Reference: See references/core_classes.md for comprehensive documentation of Structure, Lattice, Molecule, and related classes.
Convert between 100+ file formats with automatic format detection.
Using convenience methods:
# Read any format
struct = Structure.from_file("input_file")
# Write to any format
struct.to(filename="output.cif")
struct.to(filename="POSCAR")
struct.to(filename="output.xyz")Using the conversion script:
# Single file conversion
python scripts/structure_converter.py POSCAR structure.cif
# Batch conversion
python scripts/structure_converter.py *.cif --output-dir ./poscar_files --format poscarReference: See references/io_formats.md for detailed documentation of all supported formats and code integrations.
Analyze structures for symmetry, coordination, and other properties.
Symmetry analysis:
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
sga = SpacegroupAnalyzer(struct)
# Get space group information
print(f"Space group: {sga.get_space_group_symbol()}")
print(f"Number: {sga.get_space_group_number()}")
print(f"Crystal system: {sga.get_crystal_system()}")
# Get conventional/primitive cells
conventional = sga.get_conventional_standard_structure()
primitive = sga.get_primitive_standard_structure()Coordination environment:
from pymatgen.analysis.local_env import CrystalNN
cnn = CrystalNN()
neighbors = cnn.get_nn_info(struct, n=0) # Neighbors of site 0
print(f"Coordination number: {len(neighbors)}")
for neighbor in neighbors:
site = struct[neighbor['site_index']]
print(f" {site.species_string} at {neighbor['weight']:.3f} Å")Using the analysis script:
# Comprehensive analysis
python scripts/structure_analyzer.py POSCAR --symmetry --neighbors
# Export results
python scripts/structure_analyzer.py structure.cif --symmetry --export jsonReference: See references/analysis_modules.md for detailed documentation of all analysis capabilities.
Construct phase diagrams and analyze thermodynamic stability.
Phase diagram construction:
from mp_api.client import MPRester
from pymatgen.analysis.phase_diagram import PhaseDiagram, PDPlotter
# Get entries from Materials Project
with MPRester() as mpr:
entries = mpr.get_entries_in_chemsys("Li-Fe-O")
# Build phase diagram
pd = PhaseDiagram(entries)
# Check stability
from pymatgen.core import Composition
comp = Composition("LiFeO2")
# Find entry for composition
for entry in entries:
if entry.composition.reduced_formula == comp.reduced_formula:
e_above_hull = pd.get_e_above_hull(entry)
print(f"Energy above hull: {e_above_hull:.4f} eV/atom")
if e_above_hull > 0.001:
# Get decomposition
decomp = pd.get_decomposition(comp)
print("Decomposes to:", decomp)
# Plot
plotter = PDPlotter(pd)
plotter.show()Using the phase diagram script:
# Generate phase diagram
python scripts/phase_diagram_generator.py Li-Fe-O --output li_fe_o.png
# Analyze specific composition
python scripts/phase_diagram_generator.py Li-Fe-O --analyze "LiFeO2" --showReference: See references/analysis_modules.md (Phase Diagrams section) and references/transformations_workflows.md (Workflow 2) for detailed examples.
Analyze band structures, density of states, and electronic properties.
Band structure:
from pymatgen.io.vasp import Vasprun
from pymatgen.electronic_structure.plotter import BSPlotter
# Read from VASP calculation
vasprun = Vasprun("vasprun.xml")
bs = vasprun.get_band_structure()
# Analyze
band_gap = bs.get_band_gap()
print(f"Band gap: {band_gap['energy']:.3f} eV")
print(f"Direct: {band_gap['direct']}")
print(f"Is metal: {bs.is_metal()}")
# Plot
plotter = BSPlotter(bs)
plotter.save_plot("band_structure.png")Density of states:
from pymatgen.electronic_structure.plotter import DosPlotter
dos = vasprun.complete_dos
# Get element-projected DOS
element_dos = dos.get_element_dos()
for element, element_dos_obj in element_dos.items():
print(f"{element}: {element_dos_obj.get_gap():.3f} eV")
# Plot
plotter = DosPlotter()
plotter.add_dos("Total DOS", dos)
plotter.show()Reference: See references/analysis_modules.md (Electronic Structure section) and references/io_formats.md (VASP section).
Generate slabs, analyze surfaces, and study interfaces.
Slab generation:
from pymatgen.core.surface import SlabGenerator
# Generate slabs for specific Miller index
slabgen = SlabGenerator(
struct,
miller_index=(1, 1, 1),
min_slab_size=10.0, # Å
min_vacuum_size=10.0, # Å
center_slab=True
)
slabs = slabgen.get_slabs()
# Write slabs
for i, slab in enumerate(slabs):
slab.to(filename=f"slab_{i}.cif")Wulff shape construction:
from pymatgen.analysis.wulff import WulffShape
# Define surface energies
surface_energies = {
(1, 0, 0): 1.0,
(1, 1, 0): 1.1,
(1, 1, 1): 0.9,
}
wulff = WulffShape(struct.lattice, surface_energies)
print(f"Surface area: {wulff.surface_area:.2f} Ų")
print(f"Volume: {wulff.volume:.2f} ų")
wulff.show()Adsorption site finding:
from pymatgen.analysis.adsorption import AdsorbateSiteFinder
from pymatgen.core import Molecule
asf = AdsorbateSiteFinder(slab)
# Find sites
ads_sites = asf.find_adsorption_sites()
print(f"On-top sites: {len(ads_sites['ontop'])}")
print(f"Bridge sites: {len(ads_sites['bridge'])}")
print(f"Hollow sites: {len(ads_sites['hollow'])}")
# Add adsorbate
adsorbate = Molecule("O", [[0, 0, 0]])
ads_struct = asf.add_adsorbate(adsorbate, ads_sites["ontop"][0])Reference: See references/analysis_modules.md (Surface and Interface section) and references/transformations_workflows.md (Workflows 3 and 9).
Programmatically access the Materials Project database.
Setup:
export MP_API_KEY="your_key_here"Search and retrieve:
from mp_api.client import MPRester
with MPRester() as mpr:
# Search by formula
materials = mpr.materials.summary.search(formula="Fe2O3")
# Search by chemical system
materials = mpr.materials.summary.search(chemsys="Li-Fe-O")
# Filter by properties
materials = mpr.materials.summary.search(
chemsys="Li-Fe-O",
energy_above_hull=(0, 0.05), # Stable/metastable
band_gap=(1.0, 3.0) # Semiconducting
)
# Get structure
struct = mpr.get_structure_by_material_id("mp-149")
# Get band structure
bs = mpr.get_bandstructure_by_material_id("mp-149")
# Get entries for phase diagram
entries = mpr.get_entries_in_chemsys("Li-Fe-O")Reference: See references/materials_project_api.md for comprehensive API documentation and examples.
Set up calculations for various electronic structure codes.
VASP input generation:
from pymatgen.io.vasp.sets import MPRelaxSet, MPStaticSet, MPNonSCFSet
# Relaxation
relax = MPRelaxSet(struct)
relax.write_input("./relax_calc")
# Static calculation
static = MPStaticSet(struct)
static.write_input("./static_calc")
# Band structure (non-self-consistent)
nscf = MPNonSCFSet(struct, mode="line")
nscf.write_input("./bandstructure_calc")
# Custom parameters
custom = MPRelaxSet(struct, user_incar_settings={"ENCUT": 600})
custom.write_input("./custom_calc")Other codes:
# Gaussian
from pymatgen.io.gaussian import GaussianInput
gin = GaussianInput(
mol,
functional="B3LYP",
basis_set="6-31G(d)",
route_parameters={"Opt": None}
)
gin.write_file("input.gjf")
# Quantum ESPRESSO
from pymatgen.io.pwscf import PWInput
pwin = PWInput(struct, control={"calculation": "scf"})
pwin.write_file("pw.in")Reference: See references/io_formats.md (Electronic Structure Code I/O section) and references/transformations_workflows.md for workflow examples.
Diffraction patterns:
from pymatgen.analysis.diffraction.xrd import XRDCalculator
xrd = XRDCalculator()
pattern = xrd.get_pattern(struct)
# Get peaks
for peak in pattern.hkls:
print(f"2θ = {peak['2theta']:.2f}°, hkl = {peak['hkl']}")
pattern.plot()Elastic properties:
from pymatgen.analysis.elasticity import ElasticTensor
# From elastic tensor matrix
elastic_tensor = ElasticTensor.from_voigt(matrix)
print(f"Bulk modulus: {elastic_tensor.k_voigt:.1f} GPa")
print(f"Shear modulus: {elastic_tensor.g_voigt:.1f} GPa")
print(f"Young's modulus: {elastic_tensor.y_mod:.1f} GPa")Magnetic ordering:
from pymatgen.transformations.advanced_transformations import MagOrderingTransformation
# Enumerate magnetic orderings
trans = MagOrderingTransformation({"Fe": 5.0})
mag_structs = trans.apply_transformation(struct, return_ranked_list=True)
# Get lowest energy magnetic structure
lowest_energy_struct = mag_structs[0]['structure']Reference: See references/analysis_modules.md for comprehensive analysis module documentation.
scripts/)Executable Python scripts for common tasks:
structure_converter.py: Convert between structure file formats
python scripts/structure_converter.py POSCAR structure.cifstructure_analyzer.py: Comprehensive structure analysis
python scripts/structure_analyzer.py structure.cif --symmetry --neighborsphase_diagram_generator.py: Generate phase diagrams from Materials Project
python scripts/phase_diagram_generator.py Li-Fe-O --analyze "LiFeO2"All scripts include detailed help: python scripts/script_name.py --help
references/)Comprehensive documentation loaded into context as needed:
core_classes.md: Element, Structure, Lattice, Molecule, Composition classesio_formats.md: File format support and code integration (VASP, Gaussian, etc.)analysis_modules.md: Phase diagrams, surfaces, electronic structure, symmetrymaterials_project_api.md: Complete Materials Project API guidetransformations_workflows.md: Transformations framework and common workflowsLoad references when detailed information is needed about specific modules or workflows.
from pymatgen.transformations.standard_transformations import SubstitutionTransformation
from pymatgen.io.vasp.sets import MPRelaxSet
# Generate doped structures
base_struct = Structure.from_file("POSCAR")
dopants = ["Mn", "Co", "Ni", "Cu"]
for dopant in dopants:
trans = SubstitutionTransformation({"Fe": dopant})
doped_struct = trans.apply_transformation(base_struct)
# Generate VASP inputs
vasp_input = MPRelaxSet(doped_struct)
vasp_input.write_input(f"./calcs/Fe_{dopant}")# 1. Relaxation
relax = MPRelaxSet(struct)
relax.write_input("./1_relax")
# 2. Static (after relaxation)
relaxed = Structure.from_file("1_relax/CONTCAR")
static = MPStaticSet(relaxed)
static.write_input("./2_static")
# 3. Band structure (non-self-consistent)
nscf = MPNonSCFSet(relaxed, mode="line")
nscf.write_input("./3_bandstructure")
# 4. Analysis
from pymatgen.io.vasp import Vasprun
vasprun = Vasprun("3_bandstructure/vasprun.xml")
bs = vasprun.get_band_structure()
bs.get_band_gap()# 1. Get bulk energy
bulk_vasprun = Vasprun("bulk/vasprun.xml")
bulk_E_per_atom = bulk_vasprun.final_energy / len(bulk)
# 2. Generate and calculate slabs
slabgen = SlabGenerator(bulk, (1,1,1), 10, 15)
slab = slabgen.get_slabs()[0]
MPRelaxSet(slab).write_input("./slab_calc")
# 3. Calculate surface energy (after calculation)
slab_vasprun = Vasprun("slab_calc/vasprun.xml")
E_surf = (slab_vasprun.final_energy - len(slab) * bulk_E_per_atom) / (2 * slab.surface_area)
E_surf *= 16.021766 # Convert eV/Ų to J/m²More workflows: See references/transformations_workflows.md for 10 detailed workflow examples.
Structure.from_file() handles most formatsIStructure when structure shouldn't changeSpacegroupAnalyzer to reduce to primitive cellfrom_file() and to() are preferredas_dict()/from_dict() for version-safe storagewith MPRester() as mpr:MPRelaxSet, MPStaticSet over manual INCARTransformedStructure for provenancePymatgen uses atomic units throughout:
Convert units using pymatgen.core.units when needed.
Pymatgen integrates seamlessly with:
Import errors: Install missing dependencies
uv pip install pymatgen[analysis,vis]API key not found: Set MP_API_KEY environment variable
export MP_API_KEY="your_key_here"Structure read failures: Check file format and syntax
# Try explicit format specification
struct = Structure.from_file("file.txt", fmt="cif")Symmetry analysis fails: Structure may have numerical precision issues
# Increase tolerance
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
sga = SpacegroupAnalyzer(struct, symprec=0.1)This skill is designed for pymatgen 2024.x and later. For the Materials Project API, use the mp-api package (separate from legacy pymatgen.ext.matproj).
Requirements:
© zLanqing, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
SKILL.md and 8 other files (scripts, references) in scientific-toolkit-skill/references/scientific-skills/pymatgen of zLanqing/codex-claude-academic-skills.
Open the folder on GitHubat commit 7ed6377
We found 13 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 11 other GitHub owners. This page covers the copy in zLanqing/codex-claude-academic-skills, which our catalogue first saw on October 7, 2026.
Pymatgen next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Pymatgen this skillzLanqing/codex-claude-academic-skills | 4.7k | 11 repos | ~5k | Automated safety check: Pass | MIT | |
| PymatgenK-Dense-AI/scientific-agent-skills | 48k | 1 repos | ~4.6k | Automated safety check: Notes | MIT | |
| Mat Defect Energy Dftlearningmatter-mit/AtomisticSkills | 176 | — | ~1.6k | Automated safety check: Pass | MIT | |
| MolecodeAtomFlow-AI/MoleCode | 306 | — | ~1.9k | Automated safety check: Pass | MIT | |
| Engineering Figure Agentheyu-233/engineering-figure-agent | 305 | — | ~1.1k | Automated safety check: Pass | MIT | |
| Cantera Ignition DelayK-Dense-AI/scientific-agent-skills | 48k | 1 repos | ~2.2k | Automated safety check: Pass | MIT |
K-Dense-AI/scientific-agent-skills
Analyzes, validates, converts, and transforms materials structures and computed materials data with pymatgen.
learningmatter-mit/AtomisticSkills
Calculate charged defect formation energies and transition level diagrams using pymatgen-analysis-defects and atomate2 VASP workflows.
AtomFlow-AI/MoleCode
A skill your agent uses for deterministic molecule understanding, graph-level editing, generation, and validation with MoleCode — an explicit Mermaid graph in which every atom and bond is a typed…
heyu-233/engineering-figure-agent
A skill your agent uses when the user needs engineering or research-paper figures: system architecture diagrams, algorithm workflows, hardware schematics, benchmark charts, ablation plots, figure…
K-Dense-AI/scientific-agent-skills
Runs Cantera constant-volume or constant-pressure ignition simulations and reports temperature-based ignition delay with mechanism provenance and checks.
trpc-group/trpc-agent-go
Get current weather and forecasts via wttr.in or Open-Meteo.
zLanqing/codex-claude-academic-skills
Low-level plotting library for full customization. An agent skill from zLanqing/codex-claude-academic-skills.
zLanqing/codex-claude-academic-skills
Machine learning in Python with scikit-learn. An agent skill from zLanqing/codex-claude-academic-skills.
zLanqing/codex-claude-academic-skills
Process-based discrete-event simulation framework in Python.
zLanqing/codex-claude-academic-skills
Comprehensive toolkit for creating, analyzing, and visualizing complex networks and graphs in Python.
zLanqing/codex-claude-academic-skills
Statistical visualization with pandas integration. An agent skill from zLanqing/codex-claude-academic-skills.
zLanqing/codex-claude-academic-skills
Statistical models library for Python. An agent skill from zLanqing/codex-claude-academic-skills.
Categories
Materials science toolkit. An agent skill from zLanqing/codex-claude-academic-skills. Pymatgen is an agent skill from zLanqing/codex-claude-academic-skills. Materials science toolkit.
Pymatgen fits situations like: tasks that involve Physical and earth sciences; tasks that involve Diagrams.
Run `npx skills add zLanqing/codex-claude-academic-skills --skill pymatgen -a claude-code`. Or copy the skill folder (scientific-toolkit-skill/references/scientific-skills/pymatgen in zLanqing/codex-claude-academic-skills) into .claude/skills/pymatgen in your project. Claude Code loads it when a task matches its description.
Run `npx skills add zLanqing/codex-claude-academic-skills --skill pymatgen -a codex`. Or copy the skill folder (scientific-toolkit-skill/references/scientific-skills/pymatgen in zLanqing/codex-claude-academic-skills) into .agents/skills/pymatgen in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add zLanqing/codex-claude-academic-skills --skill pymatgen -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/pymatgen, .gemini/skills/pymatgen, .github/skills/pymatgen and .opencode/skills/pymatgen in your project.
Going by SKILL.md and its folder, Pymatgen needs Python for the scripts in its folder, the command-line tools its instructions call (python and uv) and credentials named MP_API_KEY. Our summary lists: Python 3; A credential in MP_API_KEY.
SKILL.md names 6 domains. As links in the text: next-gen.materialsproject.org, pymatgen.org, materialsproject.org, github.com, matsci.org and matgenb.materialsvirtuallab.org. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.
Pymatgen is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.
About 5k tokens (SKILL.md is roughly 20k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 16k tokens, read only when the agent opens those files.
Skills that share tags, products or a category with Pymatgen: Pymatgen (K-Dense-AI/scientific-agent-skills, 48k stars), Mat Defect Energy Dft (learningmatter-mit/AtomisticSkills, 176 stars), Molecode (AtomFlow-AI/MoleCode, 306 stars) and Engineering Figure Agent (heyu-233/engineering-figure-agent, 305 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
zLanqing (a GitHub user) maintains it in zLanqing/codex-claude-academic-skills, which has 4,671 GitHub stars. The repository holds 17 skills in this directory. The repository was last updated on May 14, 2026.
Source: zLanqing/codex-claude-academic-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.