materials-databases
Skill19 starsChanged 10 months agoMITView on GitHub
Expert assistant for accessing materials databases (AFLOW and Materials Project) - query crystal structures, materials properties, thermodynamic data, and computational results from comprehensive databases
- Reads credentials
- Installs packages
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
No API key required for basic access
- Distinctive: line 250
Paginate large results: - Use chunk_size for large queries
- Distinctive: line 354
Always specify fields in MP queries for efficiency
- Distinctive: line 355
Use pymatgen for structure manipulation and analysis
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Materials Databases Access Skill
You are an expert assistant for accessing and querying materials science databases, specifically AFLOW and Materials Project. Help users retrieve crystal structures, materials properties, and computational data efficiently.
Overview
This skill enables access to two major materials databases:
- AFLOW (Automatic Flow for Materials Discovery)
- 3.5+ million calculated materials
- Crystal structures, thermodynamic properties, elastic properties
- No API key required for basic access
- REST API with simple URL-based queries
- Materials Project (MP)
- 150,000+ inorganic compounds
- Electronic structure, phonons, elasticity, surfaces, batteries
- Requires free API key
- Python client library (mp-api) with rich functionality
Installation Requirements
Materials Project (mp-api)
# Install the Materials Project API client
pip install mp-api
# Alternative: with conda
conda install -c conda-forge mp-apiAFLOW
AFLOW uses REST API - no Python package installation required. However, for convenience:
# Optional: Install requests for API calls
pip install requests
# Optional: Install aflow Python package (community-maintained)
pip install aflowAdditional Recommended Packages
# For structure manipulation and visualization
pip install pymatgen ase
# For data analysis
pip install pandas numpy matplotlibAPI Key Setup
Materials Project API Key
- Get an API key:
- Visit: https://next-gen.materialsproject.org/api
- Click "Generate API Key" (requires login with ORCID or email)
- Copy your API key (format: long alphanumeric string)
Set up authentication:
Option A: Environment variable (recommended)
export MP_API_KEY="your_api_key_here"Option B: Configuration file
# Create ~/.config/.mpapi.json or ~/.pmgrc.yaml echo '{"MAPI_KEY": "your_api_key_here"}' > ~/.config/.mpapi.jsonOption C: Pass directly in code
from mp_api.client import MPRester with MPRester("your_api_key_here") as mpr: # Your code here pass
AFLOW
No API key required - AFLOW API is publicly accessible.
Core Functionality
Materials Project - Common Queries
Search by formula:
from mp_api.client import MPRester
with MPRester(api_key="YOUR_API_KEY") as mpr:
# Search for all Silicon entries
docs = mpr.materials.summary.search(formula="Si")
# Get specific properties
docs = mpr.materials.summary.search(
formula="Fe2O3",
fields=["material_id", "formula_pretty", "band_gap", "energy_per_atom"]
)Search by material ID:
with MPRester() as mpr: # Uses env var or config file
structure = mpr.get_structure_by_material_id("mp-149")
doc = mpr.materials.summary.get_data_by_id("mp-149")Search by criteria:
with MPRester() as mpr:
# Find materials with band gap between 1-3 eV
docs = mpr.materials.summary.search(
band_gap=(1, 3),
elements=["O", "Ti"],
num_elements=2
)
# Find stable materials
docs = mpr.materials.summary.search(
energy_above_hull=(0, 0.01), # Nearly stable
fields=["material_id", "formula_pretty", "energy_above_hull"]
)Available data types:
materials.summary- General materials propertiesmaterials.thermo- Thermodynamic datamaterials.electronic_structure- Band structures, DOSmaterials.phonon- Phonon band structuresmaterials.elasticity- Elastic tensorsmaterials.surface_properties- Surface energiesmolecules- Molecular structures and properties
AFLOW - REST API Queries
Basic URL structure:
http://aflowlib.duke.edu/AFLOWDATA/ICSD_WEB/<system>/<file>?<directives>Common queries using REST:
import requests
# Get all keywords for a material
url = "http://aflowlib.duke.edu/AFLOWDATA/ICSD_WEB/FCC/Ag1/?keywords"
response = requests.get(url)
data = response.text
# Get specific property (e.g., enthalpy)
url = "http://aflowlib.duke.edu/AFLOWDATA/ICSD_WEB/FCC/Ag1/?enthalpy_formation_atom"
response = requests.get(url)
# Search using AFLUX (AFLOW search language)
url = "http://aflowlib.duke.edu/search/API/?species(Au),Egap(5*),catalog(ICSD)"
response = requests.get(url)Using aflow Python package (optional):
import aflow
# Search for materials
results = aflow.search(filter='species(Au),Egap(5*)')
for result in results:
print(result.enthalpy_formation_atom)
print(result.Egap)
structure = result.atoms # Get ASE Atoms objectCommon AFLOW directives:
?keywords- List all available properties?enthalpy_formation_atom- Formation enthalpy per atom?Egap- Band gap?volume_cell- Unit cell volume?geometry- Crystal structure (POSCAR format)?files- List all available files
AFLUX search syntax:
species(element1,element2) # Chemical system
Egap(min*,max*) # Band gap range (eV)
enthalpy_formation_atom(min*,max*) # Formation enthalpy range
catalog(ICSD) # Database catalogWorkflow Guidance
When to Use Materials Project
- You need electronic structure data (band structures, DOS, Fermi surfaces)
- Battery materials research (voltage, capacity calculations)
- Surface properties and adsorption energies
- Detailed phonon calculations
- Integration with pymatgen workflows
- Phase stability analysis (phase diagrams, energy above hull)
When to Use AFLOW
- Large-scale materials screening (millions of entries)
- Elastic properties and mechanical data
- No API key setup possible/desired
- ICSD-based structures (experimental references)
- Quick property lookups (simple REST calls)
Combining Both Databases
# Example: Cross-reference findings
from mp_api.client import MPRester
import requests
# Find in Materials Project
with MPRester() as mpr:
mp_docs = mpr.materials.summary.search(
formula="TiO2",
fields=["material_id", "band_gap", "energy_per_atom"]
)
# Cross-check with AFLOW
aflow_url = "http://aflowlib.duke.edu/search/API/?species(Ti,O),nspecies(2)"
aflow_data = requests.get(aflow_url).json()Best Practices
- Use specific queries - Request only needed fields to reduce data transfer
docs = mpr.materials.summary.search( formula="Li", fields=["material_id", "formula_pretty", "band_gap"] # Specify fields ) - Paginate large results - Use chunk_size for large queries
docs = mpr.materials.summary.search( elements=["O"], num_chunks=10, # Fetch in chunks chunk_size=1000 ) - Cache results locally - Save API results to avoid repeated queries
import pickle # Save results with open("mp_results.pkl", "wb") as f: pickle.dump(docs, f) - Handle structures properly - Convert between formats as needed
from pymatgen.io.ase import AseAtomsAdaptor # MP Structure → ASE Atoms atoms = AseAtomsAdaptor.get_atoms(structure) # ASE Atoms → MP Structure structure = AseAtomsAdaptor.get_structure(atoms) - Check API status - Materials Project has rate limits (typically generous)
Error Handling
from mp_api.client import MPRester
from mp_api.client.core import MPRestError
try:
with MPRester() as mpr:
docs = mpr.materials.summary.search(formula="InvalidFormula")
except MPRestError as e:
print(f"API Error: {e}")
except Exception as e:
print(f"Unexpected error: {e}")Common Tasks
Task 1: Find Band Gap of a Material
# Materials Project
with MPRester() as mpr:
docs = mpr.materials.summary.search(
formula="GaN",
fields=["material_id", "band_gap", "is_gap_direct"]
)
for doc in docs:
print(f"{doc.material_id}: {doc.band_gap} eV (direct: {doc.is_gap_direct})")
# AFLOW
import requests
url = "http://aflowlib.duke.edu/search/API/?species(Ga,N),Egap"
response = requests.get(url)Task 2: Get Crystal Structure
# Materials Project - returns pymatgen Structure
with MPRester() as mpr:
structure = mpr.get_structure_by_material_id("mp-149")
structure.to(filename="POSCAR")
# AFLOW - returns POSCAR format text
url = "http://aflowlib.duke.edu/AFLOWDATA/ICSD_WEB/FCC/Ag1/?geometry"
poscar = requests.get(url).textTask 3: Screen for Stable Materials
# Find thermodynamically stable oxides with specific properties
with MPRester() as mpr:
docs = mpr.materials.summary.search(
elements=["O"],
energy_above_hull=(0, 0.05), # Stable or nearly stable
band_gap=(1.0, 4.0), # Semiconducting
num_elements=(2, 3), # Binary or ternary
fields=["material_id", "formula_pretty", "band_gap", "energy_above_hull"]
)References
- See
references/materials-project.mdfor detailed MP API documentation - See
references/aflow.mdfor AFLOW REST API and AFLUX syntax - See
examples/for complete working scripts
Key Points
- Materials Project requires API key (free); AFLOW does not
- MP has better Python integration; AFLOW uses REST API
- MP: 150k materials, rich electronic/phonon data; AFLOW: 3.5M materials, elastic properties
- Always specify fields in MP queries for efficiency
- Use pymatgen for structure manipulation and analysis
- Both databases are continuously updated with new calculations
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- jkitchin/knowhow★ 42100% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository48 other files it gives its agents.
- astropySkill
- brainstormingSkill
- causal-inference-root-causeSkill
- decision-matrixSkill
- decomposition-reconstructionSkill
- design-of-experimentsSkill
- docxSkill
- equivariant-architecture-designerSkill
- estimation-fermiSkill
- fairchemSkill
- fluidsimSkill
- latex-postersSkill
- markitdownSkill
- materials-propertiesSkill
- memorySkill
- meta-prompt-engineeringSkill
- model-equivariance-auditorSkill
- openmxSkill
- pdfSkill
- planningSkill
- postmortemSkill
- pptxSkill
- pymatgen-analysisSkill
- pymatgen-coreSkill
- pymatgen-electronic-structureSkill
- pymatgen-extSkill
- pymatgen-ioSkill
- pymatgen-io-vaspSkill
- pymatgen-phononSkill
- pymatgen-symmetrySkill
- python-aseSkill
- python-jaxSkill
- python-multiobjective-optimizationSkill
- python-optimizationSkill
- python-plottingSkill
- python-regression-statisticsSkill
- pytorch-lightningSkill
- scikit-learnSkill
- skill-creatorSkill
- symmetry-discovery-questionnaireSkill
- symmetry-group-identifierSkill
- symmetry-validation-suiteSkill
- sympySkill
- systems-thinking-leverageSkill
- torch-geometricSkill
- transformersSkill
- vaspSkill
- xlsxSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

