
Pymatgen
Wire materials-science analysis—phase diagrams, hull stability, Pourbaix plots—into agent or Python workflows with pymatgen APIs.
Install
npx skills add https://github.com/k-dense-ai/scientific-agent-skills --skill pymatgenWhat is this skill?
- Phase diagram construction from ComputedEntry lists with stability, energy-above-hull, and decomposition lookups
- PDPlotter export to interactive views and PNG via write_image
- Chemical potential diagrams with configurable element limits and stability domains
- Pourbaix and extended thermodynamics modules documented in the full reference
- Copy-paste Python patterns for equilibrium reaction energy and hull diagnostics
Adoption & trust: 512 installs on skills.sh; 27.6k GitHub stars; 2/3 security scanners passed (skills.sh audits).
Recommended Skills
Paper Context Resolverlllllllama/ai-paper-reproduction-skill
Repo Intake And Planlllllllama/ai-paper-reproduction-skill
Env And Assets Bootstraplllllllama/ai-paper-reproduction-skill
Minimal Run And Auditlllllllama/ai-paper-reproduction-skill
Analyze Projectlllllllama/rigorpilot-skills
Ai Research Reproductionlllllllama/rigorpilot-skills
Journey fit
Primary fit
Canonical shelf is Build because the skill is procedural reference for implementing computational materials features, not early market research. Integrations fits library API wiring (PhaseDiagram, PDPlotter, ChemicalPotentialDiagram) into backends, CLIs, or scientific agents.
Common Questions / FAQ
Is Pymatgen safe to install?
skills.sh reports 2 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Pymatgen
# Pymatgen Analysis Modules Reference This reference documents pymatgen's extensive analysis capabilities for materials characterization, property prediction, and computational analysis. ## Phase Diagrams and Thermodynamics ### Phase Diagram Construction ```python from pymatgen.analysis.phase_diagram import PhaseDiagram, PDPlotter from pymatgen.entries.computed_entries import ComputedEntry # Create entries (composition and total energy) entries = [ ComputedEntry("Fe", -8.4), ComputedEntry("O2", -4.9), ComputedEntry("FeO", -6.7), ComputedEntry("Fe2O3", -8.3), ComputedEntry("Fe3O4", -9.1), ] # Build phase diagram pd = PhaseDiagram(entries) # Get stable entries stable_entries = pd.stable_entries # Get energy above hull (stability) entry_to_test = ComputedEntry("Fe2O3", -8.0) energy_above_hull = pd.get_e_above_hull(entry_to_test) # Get decomposition products decomp = pd.get_decomposition(entry_to_test.composition) # Returns: {entry1: fraction1, entry2: fraction2, ...} # Get equilibrium reaction energy rxn_energy = pd.get_equilibrium_reaction_energy(entry_to_test) # Plot phase diagram plotter = PDPlotter(pd) plotter.show() plotter.write_image("phase_diagram.png") ``` ### Chemical Potential Diagrams ```python from pymatgen.analysis.phase_diagram import ChemicalPotentialDiagram # Create chemical potential diagram cpd = ChemicalPotentialDiagram(entries, limits={"O": (-10, 0)}) # Get domains (stability regions) domains = cpd.domains ``` ### Pourbaix Diagrams Electrochemical phase diagrams with pH and potential axes. ```python from pymatgen.analysis.pourbaix_diagram import PourbaixDiagram, PourbaixPlotter from pymatgen.entries.computed_entries import ComputedEntry # Create entries with corrections for aqueous species entries = [...] # Include solids and ions # Build Pourbaix diagram pb = PourbaixDiagram(entries) # Get stable entry at specific pH and potential stable_entry = pb.get_stable_entry(pH=7, V=0) # Plot plotter = PourbaixPlotter(pb) plotter.show() ``` ## Structure Analysis ### Structure Matching and Comparison ```python from pymatgen.analysis.structure_matcher import StructureMatcher matcher = StructureMatcher() # Check if structures match is_match = matcher.fit(struct1, struct2) # Get mapping between structures mapping = matcher.get_mapping(struct1, struct2) # Group similar structures grouped = matcher.group_structures([struct1, struct2, struct3, ...]) ``` ### Ewald Summation Calculate electrostatic energy of ionic structures. ```python from pymatgen.analysis.ewald import EwaldSummation ewald = EwaldSummation(struct) total_energy = ewald.total_energy # In eV forces = ewald.forces # Forces on each site ``` ### Symmetry Analysis ```python from pymatgen.symmetry.analyzer import SpacegroupAnalyzer sga = SpacegroupAnalyzer(struct) # Get space group information spacegroup_symbol = sga.get_space_group_symbol() # e.g., "Fm-3m" spacegroup_number = sga.get_space_group_number() # e.g., 225 crystal_system = sga.get_crystal_system() # e.g., "cubic" # Get symmetrized structure sym_struct = sga.get_symmetrized_structure() equivalent_sites = sym_struct.equivalent_sites # Get conventional/primitive cells conventional = sga.get_conventional_standard_structure() primitive = sga.get_primitive_standard_structure() # Get symmetry operations symmetry_ops = sga.get_symmetry_operations() ``` ## Local Environment Analysis ### Coordination Environment ```python from pymatgen.analysis.local_env import ( VoronoiNN, # Voronoi tessellation CrystalNN, # Crystal-based MinimumDistanceNN, # Distance cutoff BrunnerNN_real, # Brunner method ) # Voronoi nearest neighbors voronoi = VoronoiNN() neighbors = voronoi.get_nn_info(struct, n=0) # Neighbors of site 0 # CrystalNN (recommended for most cases) crystalnn = CrystalNN() neighbors = crystalnn.get_nn_info(struct, n=0) # Analyze all sites for i, site in enumerate(struct): neighbors = voro