pymatgen
Analyze crystal structures with pymatgen
Also available from: davila7
Work with crystal structures and materials data. Convert file formats, compute phase diagrams, analyze symmetry, and access the Materials Project database for computational materials science research.
Download the skill ZIP
Upload in Claude
Go to Settings → Capabilities → Skills → Upload skill
Toggle on and start using
Test it
Using "pymatgen". Read structure from POSCAR and show its properties
Expected outcome:
- Formula: Fe2O3 (hematite)
- Lattice: a=5.04 Å, b=5.04 Å, c=13.77 Å
- Space group: R-3c (#167)
- Crystal system: trigonal
- Density: 5.27 g/cm³
- Number of sites: 10
Using "pymatgen". Convert CIF to POSCAR format
Expected outcome:
- Successfully converted structure.cif to converted.POSCAR
- Structure contains 10 atoms (Fe4 O6)
- Format: POSCAR (VASP format)
Using "pymatgen". Query Materials Project for perovskites
Expected outcome:
- Found 23 stable perovskite structures
- Example: SrTiO3 (mp-5229) - band gap 3.2 eV
- Example: BaTiO3 (mp-2987) - band gap 2.8 eV
- Energy above hull: all < 0.01 eV/atom
Security Audit
SafeAll 537 static findings are false positives. The static analyzer incorrectly flagged markdown documentation syntax (code blocks, inline code formatting) as shell commands and cryptographic terms in documentation text as weak algorithms. The actual Python code uses secure patterns for API key management (environment variables) and performs legitimate materials science file I/O operations. No malicious code, data exfiltration, or security risks found.
Risk Factors
⚡ Contains scripts (6)
⚙️ External commands (447)
📁 Filesystem access (10)
🌐 Network access (14)
🔑 Env variables (23)
Quality Score
What You Can Build
Research stable compounds
Build phase diagrams and identify stable materials using data from the Materials Project database.
Convert structure formats
Convert crystal structure files between CIF, POSCAR, XYZ and other formats for different simulation codes.
Analyze crystal symmetry
Determine space groups, symmetry operations, and coordination environments from structure files.
Try These Prompts
Read the structure from file 'POSCAR' and show its composition, lattice parameters, and space group.
Convert 'structure.cif' to POSCAR format and save as 'converted.POSCAR'.
Build a phase diagram for the Li-Fe-O system and identify stable compounds.
Search the Materials Project for stable perovskite structures with band gap between 1.5 and 3.0 eV.
Best Practices
- Always use environment variables (MP_API_KEY) for API credentials, never hardcode keys
- Validate structures after reading to check for overlapping atoms or unrealistic bond lengths
- Use SpacegroupAnalyzer to reduce structures to primitive cells before analysis
Avoid
- Do not hardcode API keys in scripts - use environment variables instead
- Do not skip symmetry analysis when comparing structures - different space groups may look similar
- Do not assume automatic format detection always works - specify format when unsure
Frequently Asked Questions
What file formats does pymatgen support?
How do I get a Materials Project API key?
Can pymatgen analyze molecular dynamics trajectories?
How do I generate a supercell?
Does pymatgen work with other simulation codes?
How do I analyze coordination environments?
Developer Details
Author
K-Dense-AILicense
MIT license
Repository
https://github.com/K-Dense-AI/claude-scientific-skills/tree/main/scientific-skills/pymatgenRef
main