Materials Science Adsorption Agent
A Python agent for automated materials science workflows, focusing on surface adsorption analysis using Materials Project data, ASE/pymatgen tools, and FairChem UMA machine learning potentials.
Features
- Materials Project Integration: Retrieve crystal structures using MP API
- Structure Conversion: Convert pymatgen structures to ASE Atoms objects
- Surface Cleaving: Generate surface slabs with user-specified Miller indices and terminations
- Adsorbate Selection: Choose from common adsorbates (H, O, CO, OH, N, etc.)
- Adsorption Site Analysis: Find optimal adsorption sites using pymatgen algorithms
- ML-Accelerated DFT: Calculate adsorption energies using FairChem UMA models
- Results Export: Generate CIF files and comprehensive JSON reports
Installation
Requires Python 3.11–3.13 (driven by fairchem-core 2.x).
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# or: venv\Scripts\activate # Windows
pip install agent-materials-science
# Install the package (geometry workflow: slabs + adsorption sites)
pip install .
# Optional: ML adsorption energies (installs torch ~=2.8, large download)
pip install ".[ml]"
# Optional: AdsorbML production workflows
pip install ".[adsorbml]"
# Set up Materials Project API key
export MP_API_KEY="your_api_key_here"
# Or create a .env file with: MP_API_KEY=your_api_key_here
UMA checkpoints are gated on Hugging Face: request access to
facebook/UMA and run
huggingface-cli login once.
Quick Start
Command Line Interface
# Basic usage - analyze silicon (111) surface with H adsorbate
python -m agent_materials_science.cli --material Si --miller 1,1,1 --adsorbate H
# Using Materials Project ID
python -m agent_materials_science.cli --mp-id mp-149 --miller 1,1,0 --adsorbate CO
# Full workflow with relaxed energy calculations
agent-materials-science \
--material SrTiO3 \
--miller 1,0,0 \
--adsorbate O \
--layers 6 \
--vacuum 15 \
--supercell 2,2 \
--calculate-energies \
--relax --fix-layers 2 \
--device auto \
--output-dir outputs/srtio3_analysis
The agent-materials-science console script is installed with the package;
python -m agent_materials_science.cli works too.
Python API
from agent_materials_science import MaterialsScienceAgent, AgentConfig
# Create agent configuration
config = AgentConfig(
material="Si",
miller_indices=(1, 1, 1),
adsorbate="H",
n_layers=6,
vacuum=15.0,
supercell=(2, 2),
calculate_energies=True,
output_dir="outputs"
)
# Run agent
agent = MaterialsScienceAgent(config)
result = agent.run()
# Access results
print(f"Material: {result.formula} ({result.material_id})")
print(f"Best adsorption site: {result.best_site}")
print(f"Output files: {result.output_files}")
Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
MP_API_KEY |
Materials Project API key | Required |
FAIRCHEM_MODEL |
FairChem model name | uma-s-1p2 |
FAIRCHEM_TASK |
UMA task head (oc20, omat, omol, …) |
oc20 |
FAIRCHEM_DEVICE |
Device: auto, cpu, cuda |
auto |
Explicit constructor/CLI arguments always take precedence over environment variables.
Supported Adsorbates
27 species, including atoms (H, O, N, C, S, F, Cl), diatomics (H2, O2, N2,
CO/OC, OH/HO, NO/ON, HF, HCl) and molecules (H2O, CO2, N2O, NH3, CH4, C2H2,
C2H4, HCOO, CH3OH). Run agent-materials-science --list-adsorbates for the
authoritative list with descriptions.
FairChem Models
UMA models require FairChem v2 and a Hugging Face account with access
granted to the UMA model repository (huggingface-cli login).
uma-s-1p2- UMA small v1.2 (latest small model; recommended, default)uma-s-1p1- UMA small v1.1uma-m-1p1- UMA medium v1.1 (higher accuracy, slower)esen-*- eSEN models
uma-s-1was removed from the FairChem registry and can no longer be downloaded. Runagent-materials-science --list-modelsto query the live registry when fairchem-core is installed. A local checkpoint file path can be passed via--model /path/to/checkpoint.pt.
Pick the task head to match the problem: oc20 for surface adsorption /
catalysis (the default here), omat for bulk inorganic materials, omol for
isolated molecules. Mixing task heads between the slab and the reference makes
adsorption energies meaningless.
Adsorption-site backend
Site finding uses pymatgen's AdsorbateSiteFinder when pymatgen is
installed (--site-finder auto, the default). It is symmetry-aware, so it
returns only the distinct sites and avoids redundant energy evaluations. A
self-contained, periodicity-correct geometric finder is used as a fallback
(--site-finder builtin). Pass --no-symm-reduce to keep every site.
Project Structure
agent_materials_science/
├── __init__.py # Package exports
├── agent.py # Main agent orchestration
├── cli.py # Command line interface
├── config.py # Configuration management
├── core/
│ ├── __init__.py
│ ├── adsorption.py # Adsorption site finding
│ ├── surface.py # Surface/slab generation
│ └── workflow.py # Workflow orchestration
├── tools/
│ ├── __init__.py
│ ├── materials_project.py # MP API wrapper
│ ├── ase_tools.py # ASE utilities
│ ├── fairchem_calc.py # FairChem calculator
│ └── converters.py # Structure converters
├── outputs/ # Default output directory
├── requirements.txt
└── README.md
Output Files
The agent generates the following output files:
{material_id}_slab_{hkl}.cif- Clean slab structure{material_id}_slab_{hkl}.vasp- VASP POSCAR format{material_id}_sites.json- Adsorption sites data{material_id}_best_site.cif- Structure with adsorbate at best site{material_id}_results.json- Complete analysis results
Methodology notes & limitations
- Adsorption-energy convention.
E_ads = E(slab+ads) − E(slab) − E_gas(ads), whereE_gasfollows the OC20 convention: a linear combination of per-element reference energies (H −3.477, C −7.282, O −7.204, N −8.083 eV, from the OC20 paper) that pairs consistently with UMAoc20total energies — this is the scheme recommended by the FairChem documentation. Adsorbates containing other elements fall back to relative energies (site ranking is still valid) unless you provide per-element overrides viaget_adsorbate_reference_energy(..., overrides=...). - Consistent relaxation. With
--relax, the clean slab is relaxed once (before site finding) and each slab+adsorbate system is relaxed, so both totals inE_adscome from relaxed geometries. Use--fix-layers 2(or more) to hold the bottom layers bulk-like during relaxations. - ML accuracy. Energies come from a machine-learned potential (UMA); expect ~0.1 eV-scale deviations from explicit DFT depending on the system.
- Single initial placement per site. Each site is evaluated from one
initial geometry (optionally relaxed). The state-of-the-art recipe is
AdsorbML: generate many
initial configurations, ML-relax each, and take the minimum — available via
pip install "fairchem-core[adsorbml]"(or higher-level libraries such asquaccslab_to_ads_flowandatomate2) for production studies. - Surface-normal assumption. Site finding assumes the surface lies in the xy-plane with vacuum along z (the convention produced by the slab builder).
License
MIT License
Metadata
Release files for agent-materials-science 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| agent_materials_science-0.2.2.tar.gz | 51.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agent_materials_science-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 104.0 kB
Release files / agent_materials_science-0.2.2.tar.gz
| Download URL | agent_materials_science-0.2.2.tar.gz |
|---|---|
| Size | 51.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
de14bc4d41ac58ef41ffdebee7643cd8e99125a0d4307c74fde4bc2f384e124f
|
|
BLAKE2b-256 checksum How to use checksums |
bd1e0996b97d5c27a03d38ffd0f7b5f4b4db3370d81870ca9e4e4eea29909eb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / agent_materials_science-0.2.2-py3-none-any.whl
| Download URL | agent_materials_science-0.2.2-py3-none-any.whl |
|---|---|
| Size | 52.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0971018d67d5aff294ea21b3b3c4e3768163b353b2861d784d8248d295a9d7ea
|
|
BLAKE2b-256 checksum How to use checksums |
4e3f6a467165bd7a2e2e322acc36a94d7ac311b5fd7d95d77abe6236fd29bdfa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|