agent-materials-science 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent_materials_science-0.2.1/LICENSE +21 -0
- agent_materials_science-0.2.1/PKG-INFO +266 -0
- agent_materials_science-0.2.1/README.md +227 -0
- agent_materials_science-0.2.1/agent_materials_science/__init__.py +26 -0
- agent_materials_science-0.2.1/agent_materials_science/__main__.py +12 -0
- agent_materials_science-0.2.1/agent_materials_science/agent.py +384 -0
- agent_materials_science-0.2.1/agent_materials_science/cli.py +377 -0
- agent_materials_science-0.2.1/agent_materials_science/config.py +318 -0
- agent_materials_science-0.2.1/agent_materials_science/core/__init__.py +15 -0
- agent_materials_science-0.2.1/agent_materials_science/core/adsorption.py +752 -0
- agent_materials_science-0.2.1/agent_materials_science/core/surface.py +383 -0
- agent_materials_science-0.2.1/agent_materials_science/core/workflow.py +662 -0
- agent_materials_science-0.2.1/agent_materials_science/py.typed +0 -0
- agent_materials_science-0.2.1/agent_materials_science/tools/__init__.py +29 -0
- agent_materials_science-0.2.1/agent_materials_science/tools/ase_tools.py +347 -0
- agent_materials_science-0.2.1/agent_materials_science/tools/converters.py +365 -0
- agent_materials_science-0.2.1/agent_materials_science/tools/fairchem_calc.py +536 -0
- agent_materials_science-0.2.1/agent_materials_science/tools/materials_project.py +275 -0
- agent_materials_science-0.2.1/agent_materials_science.egg-info/PKG-INFO +266 -0
- agent_materials_science-0.2.1/agent_materials_science.egg-info/SOURCES.txt +28 -0
- agent_materials_science-0.2.1/agent_materials_science.egg-info/dependency_links.txt +1 -0
- agent_materials_science-0.2.1/agent_materials_science.egg-info/entry_points.txt +2 -0
- agent_materials_science-0.2.1/agent_materials_science.egg-info/requires.txt +19 -0
- agent_materials_science-0.2.1/agent_materials_science.egg-info/top_level.txt +1 -0
- agent_materials_science-0.2.1/pyproject.toml +79 -0
- agent_materials_science-0.2.1/setup.cfg +4 -0
- agent_materials_science-0.2.1/tests/test_adsorption.py +79 -0
- agent_materials_science-0.2.1/tests/test_config.py +93 -0
- agent_materials_science-0.2.1/tests/test_references.py +70 -0
- agent_materials_science-0.2.1/tests/test_surface.py +79 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Raghavendra Meena
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agent-materials-science
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: A Python agent for automated materials science workflows, focusing on surface adsorption analysis
|
|
5
|
+
Author-email: Raghavendra Meena <raghavendra.ip2020@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/raghavendram3/agent_materials_science
|
|
8
|
+
Project-URL: Repository, https://github.com/raghavendram3/agent_materials_science
|
|
9
|
+
Project-URL: Issues, https://github.com/raghavendram3/agent_materials_science/issues
|
|
10
|
+
Keywords: materials-science,computational-chemistry,adsorption,DFT,machine-learning
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: mp-api>=0.45
|
|
23
|
+
Requires-Dist: pymatgen>=2024.11.13
|
|
24
|
+
Requires-Dist: ase>=3.26.0
|
|
25
|
+
Requires-Dist: numpy<2.5,>=2.0
|
|
26
|
+
Requires-Dist: scipy>=1.11.0
|
|
27
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
28
|
+
Provides-Extra: ml
|
|
29
|
+
Requires-Dist: fairchem-core>=2.21.0; extra == "ml"
|
|
30
|
+
Provides-Extra: adsorbml
|
|
31
|
+
Requires-Dist: fairchem-core[adsorbml]>=2.21.0; extra == "adsorbml"
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
35
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
36
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
|
|
40
|
+
# Materials Science Adsorption Agent
|
|
41
|
+

|
|
42
|
+
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.
|
|
43
|
+
|
|
44
|
+
## Features
|
|
45
|
+
|
|
46
|
+
1. **Materials Project Integration**: Retrieve crystal structures using MP API
|
|
47
|
+
2. **Structure Conversion**: Convert pymatgen structures to ASE Atoms objects
|
|
48
|
+
3. **Surface Cleaving**: Generate surface slabs with user-specified Miller indices and terminations
|
|
49
|
+
4. **Adsorbate Selection**: Choose from common adsorbates (H, O, CO, OH, N, etc.)
|
|
50
|
+
5. **Adsorption Site Analysis**: Find optimal adsorption sites using pymatgen algorithms
|
|
51
|
+
6. **ML-Accelerated DFT**: Calculate adsorption energies using FairChem UMA models
|
|
52
|
+
7. **Results Export**: Generate CIF files and comprehensive JSON reports
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
Requires **Python 3.11–3.13** (driven by fairchem-core 2.x).
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Create virtual environment
|
|
60
|
+
python -m venv venv
|
|
61
|
+
source venv/bin/activate # Linux/Mac
|
|
62
|
+
# or: venv\Scripts\activate # Windows
|
|
63
|
+
|
|
64
|
+
# Install from PyPI (after release)
|
|
65
|
+
pip install agent-materials-science
|
|
66
|
+
|
|
67
|
+
# Install the package (geometry workflow: slabs + adsorption sites)
|
|
68
|
+
pip install .
|
|
69
|
+
|
|
70
|
+
# Optional: ML adsorption energies (installs torch ~=2.8, large download)
|
|
71
|
+
pip install ".[ml]"
|
|
72
|
+
|
|
73
|
+
# Optional: AdsorbML production workflows
|
|
74
|
+
pip install ".[adsorbml]"
|
|
75
|
+
|
|
76
|
+
# Set up Materials Project API key
|
|
77
|
+
export MP_API_KEY="your_api_key_here"
|
|
78
|
+
# Or create a .env file with: MP_API_KEY=your_api_key_here
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
UMA checkpoints are gated on Hugging Face: request access to
|
|
82
|
+
[facebook/UMA](https://huggingface.co/facebook/UMA) and run
|
|
83
|
+
`huggingface-cli login` once.
|
|
84
|
+
|
|
85
|
+
## Releasing to PyPI
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Build source and wheel distributions
|
|
89
|
+
python -m pip install --upgrade build twine
|
|
90
|
+
python -m build
|
|
91
|
+
python -m twine check dist/*
|
|
92
|
+
|
|
93
|
+
# Upload to TestPyPI (recommended first)
|
|
94
|
+
python -m twine upload --repository testpypi dist/*
|
|
95
|
+
|
|
96
|
+
# Upload to PyPI
|
|
97
|
+
python -m twine upload dist/*
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Quick Start
|
|
101
|
+
|
|
102
|
+
### Command Line Interface
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Basic usage - analyze silicon (111) surface with H adsorbate
|
|
106
|
+
python -m agent_materials_science.cli --material Si --miller 1,1,1 --adsorbate H
|
|
107
|
+
|
|
108
|
+
# Using Materials Project ID
|
|
109
|
+
python -m agent_materials_science.cli --mp-id mp-149 --miller 1,1,0 --adsorbate CO
|
|
110
|
+
|
|
111
|
+
# Full workflow with relaxed energy calculations
|
|
112
|
+
agent-materials-science \
|
|
113
|
+
--material SrTiO3 \
|
|
114
|
+
--miller 1,0,0 \
|
|
115
|
+
--adsorbate O \
|
|
116
|
+
--layers 6 \
|
|
117
|
+
--vacuum 15 \
|
|
118
|
+
--supercell 2,2 \
|
|
119
|
+
--calculate-energies \
|
|
120
|
+
--relax --fix-layers 2 \
|
|
121
|
+
--device auto \
|
|
122
|
+
--output-dir outputs/srtio3_analysis
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The `agent-materials-science` console script is installed with the package;
|
|
126
|
+
`python -m agent_materials_science.cli` works too.
|
|
127
|
+
|
|
128
|
+
### Python API
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from agent_materials_science import MaterialsScienceAgent, AgentConfig
|
|
132
|
+
|
|
133
|
+
# Create agent configuration
|
|
134
|
+
config = AgentConfig(
|
|
135
|
+
material="Si",
|
|
136
|
+
miller_indices=(1, 1, 1),
|
|
137
|
+
adsorbate="H",
|
|
138
|
+
n_layers=6,
|
|
139
|
+
vacuum=15.0,
|
|
140
|
+
supercell=(2, 2),
|
|
141
|
+
calculate_energies=True,
|
|
142
|
+
output_dir="outputs"
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
# Run agent
|
|
146
|
+
agent = MaterialsScienceAgent(config)
|
|
147
|
+
result = agent.run()
|
|
148
|
+
|
|
149
|
+
# Access results
|
|
150
|
+
print(f"Material: {result.formula} ({result.material_id})")
|
|
151
|
+
print(f"Best adsorption site: {result.best_site}")
|
|
152
|
+
print(f"Output files: {result.output_files}")
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Configuration
|
|
156
|
+
|
|
157
|
+
### Environment Variables
|
|
158
|
+
|
|
159
|
+
| Variable | Description | Default |
|
|
160
|
+
|----------|-------------|---------|
|
|
161
|
+
| `MP_API_KEY` | Materials Project API key | Required |
|
|
162
|
+
| `FAIRCHEM_MODEL` | FairChem model name | `uma-s-1p2` |
|
|
163
|
+
| `FAIRCHEM_TASK` | UMA task head (`oc20`, `omat`, `omol`, …) | `oc20` |
|
|
164
|
+
| `FAIRCHEM_DEVICE` | Device: `auto`, `cpu`, `cuda` | `auto` |
|
|
165
|
+
|
|
166
|
+
Explicit constructor/CLI arguments always take precedence over environment
|
|
167
|
+
variables.
|
|
168
|
+
|
|
169
|
+
### Supported Adsorbates
|
|
170
|
+
|
|
171
|
+
27 species, including atoms (H, O, N, C, S, F, Cl), diatomics (H2, O2, N2,
|
|
172
|
+
CO/OC, OH/HO, NO/ON, HF, HCl) and molecules (H2O, CO2, N2O, NH3, CH4, C2H2,
|
|
173
|
+
C2H4, HCOO, CH3OH). Run `agent-materials-science --list-adsorbates` for the
|
|
174
|
+
authoritative list with descriptions.
|
|
175
|
+
|
|
176
|
+
### FairChem Models
|
|
177
|
+
|
|
178
|
+
UMA models require **FairChem v2** and a Hugging Face account with access
|
|
179
|
+
granted to the UMA model repository (`huggingface-cli login`).
|
|
180
|
+
|
|
181
|
+
- `uma-s-1p2` - UMA small v1.2 (latest small model; recommended, default)
|
|
182
|
+
- `uma-s-1p1` - UMA small v1.1
|
|
183
|
+
- `uma-m-1p1` - UMA medium v1.1 (higher accuracy, slower)
|
|
184
|
+
- `esen-*` - eSEN models
|
|
185
|
+
|
|
186
|
+
> `uma-s-1` was **removed** from the FairChem registry and can no longer be
|
|
187
|
+
> downloaded. Run `agent-materials-science --list-models` to query the live
|
|
188
|
+
> registry when fairchem-core is installed. A local checkpoint file path can
|
|
189
|
+
> be passed via `--model /path/to/checkpoint.pt`.
|
|
190
|
+
|
|
191
|
+
Pick the **task head** to match the problem: `oc20` for surface adsorption /
|
|
192
|
+
catalysis (the default here), `omat` for bulk inorganic materials, `omol` for
|
|
193
|
+
isolated molecules. Mixing task heads between the slab and the reference makes
|
|
194
|
+
adsorption energies meaningless.
|
|
195
|
+
|
|
196
|
+
### Adsorption-site backend
|
|
197
|
+
|
|
198
|
+
Site finding uses **pymatgen's `AdsorbateSiteFinder`** when pymatgen is
|
|
199
|
+
installed (`--site-finder auto`, the default). It is symmetry-aware, so it
|
|
200
|
+
returns only the distinct sites and avoids redundant energy evaluations. A
|
|
201
|
+
self-contained, periodicity-correct geometric finder is used as a fallback
|
|
202
|
+
(`--site-finder builtin`). Pass `--no-symm-reduce` to keep every site.
|
|
203
|
+
|
|
204
|
+
## Project Structure
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
agent_materials_science/
|
|
208
|
+
├── __init__.py # Package exports
|
|
209
|
+
├── agent.py # Main agent orchestration
|
|
210
|
+
├── cli.py # Command line interface
|
|
211
|
+
├── config.py # Configuration management
|
|
212
|
+
├── core/
|
|
213
|
+
│ ├── __init__.py
|
|
214
|
+
│ ├── adsorption.py # Adsorption site finding
|
|
215
|
+
│ ├── surface.py # Surface/slab generation
|
|
216
|
+
│ └── workflow.py # Workflow orchestration
|
|
217
|
+
├── tools/
|
|
218
|
+
│ ├── __init__.py
|
|
219
|
+
│ ├── materials_project.py # MP API wrapper
|
|
220
|
+
│ ├── ase_tools.py # ASE utilities
|
|
221
|
+
│ ├── fairchem_calc.py # FairChem calculator
|
|
222
|
+
│ └── converters.py # Structure converters
|
|
223
|
+
├── outputs/ # Default output directory
|
|
224
|
+
├── requirements.txt
|
|
225
|
+
└── README.md
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Output Files
|
|
229
|
+
|
|
230
|
+
The agent generates the following output files:
|
|
231
|
+
|
|
232
|
+
- `{material_id}_slab_{hkl}.cif` - Clean slab structure
|
|
233
|
+
- `{material_id}_slab_{hkl}.vasp` - VASP POSCAR format
|
|
234
|
+
- `{material_id}_sites.json` - Adsorption sites data
|
|
235
|
+
- `{material_id}_best_site.cif` - Structure with adsorbate at best site
|
|
236
|
+
- `{material_id}_results.json` - Complete analysis results
|
|
237
|
+
|
|
238
|
+
## Methodology notes & limitations
|
|
239
|
+
|
|
240
|
+
- **Adsorption-energy convention.** `E_ads = E(slab+ads) − E(slab) −
|
|
241
|
+
E_gas(ads)`, where `E_gas` follows the **OC20 convention**: a linear
|
|
242
|
+
combination of per-element reference energies (H −3.477, C −7.282,
|
|
243
|
+
O −7.204, N −8.083 eV, from the OC20 paper) that pairs consistently with
|
|
244
|
+
UMA `oc20` total energies — this is the scheme recommended by the FairChem
|
|
245
|
+
documentation. Adsorbates containing other elements fall back to relative
|
|
246
|
+
energies (site ranking is still valid) unless you provide per-element
|
|
247
|
+
overrides via `get_adsorbate_reference_energy(..., overrides=...)`.
|
|
248
|
+
- **Consistent relaxation.** With `--relax`, the clean slab is relaxed once
|
|
249
|
+
(before site finding) and each slab+adsorbate system is relaxed, so both
|
|
250
|
+
totals in `E_ads` come from relaxed geometries. Use `--fix-layers 2` (or
|
|
251
|
+
more) to hold the bottom layers bulk-like during relaxations.
|
|
252
|
+
- **ML accuracy.** Energies come from a machine-learned potential (UMA);
|
|
253
|
+
expect ~0.1 eV-scale deviations from explicit DFT depending on the system.
|
|
254
|
+
- **Single initial placement per site.** Each site is evaluated from one
|
|
255
|
+
initial geometry (optionally relaxed). The state-of-the-art recipe is
|
|
256
|
+
[AdsorbML](https://www.nature.com/articles/s41524-023-01121-5): generate many
|
|
257
|
+
initial configurations, ML-relax each, and take the minimum — available via
|
|
258
|
+
`pip install "fairchem-core[adsorbml]"` (or higher-level libraries such as
|
|
259
|
+
[`quacc`](https://quacc.readthedocs.io) `slab_to_ads_flow` and `atomate2`)
|
|
260
|
+
for production studies.
|
|
261
|
+
- **Surface-normal assumption.** Site finding assumes the surface lies in the
|
|
262
|
+
xy-plane with vacuum along z (the convention produced by the slab builder).
|
|
263
|
+
|
|
264
|
+
## License
|
|
265
|
+
|
|
266
|
+
MIT License
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# Materials Science Adsorption Agent
|
|
2
|
+

|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
1. **Materials Project Integration**: Retrieve crystal structures using MP API
|
|
8
|
+
2. **Structure Conversion**: Convert pymatgen structures to ASE Atoms objects
|
|
9
|
+
3. **Surface Cleaving**: Generate surface slabs with user-specified Miller indices and terminations
|
|
10
|
+
4. **Adsorbate Selection**: Choose from common adsorbates (H, O, CO, OH, N, etc.)
|
|
11
|
+
5. **Adsorption Site Analysis**: Find optimal adsorption sites using pymatgen algorithms
|
|
12
|
+
6. **ML-Accelerated DFT**: Calculate adsorption energies using FairChem UMA models
|
|
13
|
+
7. **Results Export**: Generate CIF files and comprehensive JSON reports
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Requires **Python 3.11–3.13** (driven by fairchem-core 2.x).
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Create virtual environment
|
|
21
|
+
python -m venv venv
|
|
22
|
+
source venv/bin/activate # Linux/Mac
|
|
23
|
+
# or: venv\Scripts\activate # Windows
|
|
24
|
+
|
|
25
|
+
# Install from PyPI (after release)
|
|
26
|
+
pip install agent-materials-science
|
|
27
|
+
|
|
28
|
+
# Install the package (geometry workflow: slabs + adsorption sites)
|
|
29
|
+
pip install .
|
|
30
|
+
|
|
31
|
+
# Optional: ML adsorption energies (installs torch ~=2.8, large download)
|
|
32
|
+
pip install ".[ml]"
|
|
33
|
+
|
|
34
|
+
# Optional: AdsorbML production workflows
|
|
35
|
+
pip install ".[adsorbml]"
|
|
36
|
+
|
|
37
|
+
# Set up Materials Project API key
|
|
38
|
+
export MP_API_KEY="your_api_key_here"
|
|
39
|
+
# Or create a .env file with: MP_API_KEY=your_api_key_here
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
UMA checkpoints are gated on Hugging Face: request access to
|
|
43
|
+
[facebook/UMA](https://huggingface.co/facebook/UMA) and run
|
|
44
|
+
`huggingface-cli login` once.
|
|
45
|
+
|
|
46
|
+
## Releasing to PyPI
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Build source and wheel distributions
|
|
50
|
+
python -m pip install --upgrade build twine
|
|
51
|
+
python -m build
|
|
52
|
+
python -m twine check dist/*
|
|
53
|
+
|
|
54
|
+
# Upload to TestPyPI (recommended first)
|
|
55
|
+
python -m twine upload --repository testpypi dist/*
|
|
56
|
+
|
|
57
|
+
# Upload to PyPI
|
|
58
|
+
python -m twine upload dist/*
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Quick Start
|
|
62
|
+
|
|
63
|
+
### Command Line Interface
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Basic usage - analyze silicon (111) surface with H adsorbate
|
|
67
|
+
python -m agent_materials_science.cli --material Si --miller 1,1,1 --adsorbate H
|
|
68
|
+
|
|
69
|
+
# Using Materials Project ID
|
|
70
|
+
python -m agent_materials_science.cli --mp-id mp-149 --miller 1,1,0 --adsorbate CO
|
|
71
|
+
|
|
72
|
+
# Full workflow with relaxed energy calculations
|
|
73
|
+
agent-materials-science \
|
|
74
|
+
--material SrTiO3 \
|
|
75
|
+
--miller 1,0,0 \
|
|
76
|
+
--adsorbate O \
|
|
77
|
+
--layers 6 \
|
|
78
|
+
--vacuum 15 \
|
|
79
|
+
--supercell 2,2 \
|
|
80
|
+
--calculate-energies \
|
|
81
|
+
--relax --fix-layers 2 \
|
|
82
|
+
--device auto \
|
|
83
|
+
--output-dir outputs/srtio3_analysis
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The `agent-materials-science` console script is installed with the package;
|
|
87
|
+
`python -m agent_materials_science.cli` works too.
|
|
88
|
+
|
|
89
|
+
### Python API
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from agent_materials_science import MaterialsScienceAgent, AgentConfig
|
|
93
|
+
|
|
94
|
+
# Create agent configuration
|
|
95
|
+
config = AgentConfig(
|
|
96
|
+
material="Si",
|
|
97
|
+
miller_indices=(1, 1, 1),
|
|
98
|
+
adsorbate="H",
|
|
99
|
+
n_layers=6,
|
|
100
|
+
vacuum=15.0,
|
|
101
|
+
supercell=(2, 2),
|
|
102
|
+
calculate_energies=True,
|
|
103
|
+
output_dir="outputs"
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
# Run agent
|
|
107
|
+
agent = MaterialsScienceAgent(config)
|
|
108
|
+
result = agent.run()
|
|
109
|
+
|
|
110
|
+
# Access results
|
|
111
|
+
print(f"Material: {result.formula} ({result.material_id})")
|
|
112
|
+
print(f"Best adsorption site: {result.best_site}")
|
|
113
|
+
print(f"Output files: {result.output_files}")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Configuration
|
|
117
|
+
|
|
118
|
+
### Environment Variables
|
|
119
|
+
|
|
120
|
+
| Variable | Description | Default |
|
|
121
|
+
|----------|-------------|---------|
|
|
122
|
+
| `MP_API_KEY` | Materials Project API key | Required |
|
|
123
|
+
| `FAIRCHEM_MODEL` | FairChem model name | `uma-s-1p2` |
|
|
124
|
+
| `FAIRCHEM_TASK` | UMA task head (`oc20`, `omat`, `omol`, …) | `oc20` |
|
|
125
|
+
| `FAIRCHEM_DEVICE` | Device: `auto`, `cpu`, `cuda` | `auto` |
|
|
126
|
+
|
|
127
|
+
Explicit constructor/CLI arguments always take precedence over environment
|
|
128
|
+
variables.
|
|
129
|
+
|
|
130
|
+
### Supported Adsorbates
|
|
131
|
+
|
|
132
|
+
27 species, including atoms (H, O, N, C, S, F, Cl), diatomics (H2, O2, N2,
|
|
133
|
+
CO/OC, OH/HO, NO/ON, HF, HCl) and molecules (H2O, CO2, N2O, NH3, CH4, C2H2,
|
|
134
|
+
C2H4, HCOO, CH3OH). Run `agent-materials-science --list-adsorbates` for the
|
|
135
|
+
authoritative list with descriptions.
|
|
136
|
+
|
|
137
|
+
### FairChem Models
|
|
138
|
+
|
|
139
|
+
UMA models require **FairChem v2** and a Hugging Face account with access
|
|
140
|
+
granted to the UMA model repository (`huggingface-cli login`).
|
|
141
|
+
|
|
142
|
+
- `uma-s-1p2` - UMA small v1.2 (latest small model; recommended, default)
|
|
143
|
+
- `uma-s-1p1` - UMA small v1.1
|
|
144
|
+
- `uma-m-1p1` - UMA medium v1.1 (higher accuracy, slower)
|
|
145
|
+
- `esen-*` - eSEN models
|
|
146
|
+
|
|
147
|
+
> `uma-s-1` was **removed** from the FairChem registry and can no longer be
|
|
148
|
+
> downloaded. Run `agent-materials-science --list-models` to query the live
|
|
149
|
+
> registry when fairchem-core is installed. A local checkpoint file path can
|
|
150
|
+
> be passed via `--model /path/to/checkpoint.pt`.
|
|
151
|
+
|
|
152
|
+
Pick the **task head** to match the problem: `oc20` for surface adsorption /
|
|
153
|
+
catalysis (the default here), `omat` for bulk inorganic materials, `omol` for
|
|
154
|
+
isolated molecules. Mixing task heads between the slab and the reference makes
|
|
155
|
+
adsorption energies meaningless.
|
|
156
|
+
|
|
157
|
+
### Adsorption-site backend
|
|
158
|
+
|
|
159
|
+
Site finding uses **pymatgen's `AdsorbateSiteFinder`** when pymatgen is
|
|
160
|
+
installed (`--site-finder auto`, the default). It is symmetry-aware, so it
|
|
161
|
+
returns only the distinct sites and avoids redundant energy evaluations. A
|
|
162
|
+
self-contained, periodicity-correct geometric finder is used as a fallback
|
|
163
|
+
(`--site-finder builtin`). Pass `--no-symm-reduce` to keep every site.
|
|
164
|
+
|
|
165
|
+
## Project Structure
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
agent_materials_science/
|
|
169
|
+
├── __init__.py # Package exports
|
|
170
|
+
├── agent.py # Main agent orchestration
|
|
171
|
+
├── cli.py # Command line interface
|
|
172
|
+
├── config.py # Configuration management
|
|
173
|
+
├── core/
|
|
174
|
+
│ ├── __init__.py
|
|
175
|
+
│ ├── adsorption.py # Adsorption site finding
|
|
176
|
+
│ ├── surface.py # Surface/slab generation
|
|
177
|
+
│ └── workflow.py # Workflow orchestration
|
|
178
|
+
├── tools/
|
|
179
|
+
│ ├── __init__.py
|
|
180
|
+
│ ├── materials_project.py # MP API wrapper
|
|
181
|
+
│ ├── ase_tools.py # ASE utilities
|
|
182
|
+
│ ├── fairchem_calc.py # FairChem calculator
|
|
183
|
+
│ └── converters.py # Structure converters
|
|
184
|
+
├── outputs/ # Default output directory
|
|
185
|
+
├── requirements.txt
|
|
186
|
+
└── README.md
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Output Files
|
|
190
|
+
|
|
191
|
+
The agent generates the following output files:
|
|
192
|
+
|
|
193
|
+
- `{material_id}_slab_{hkl}.cif` - Clean slab structure
|
|
194
|
+
- `{material_id}_slab_{hkl}.vasp` - VASP POSCAR format
|
|
195
|
+
- `{material_id}_sites.json` - Adsorption sites data
|
|
196
|
+
- `{material_id}_best_site.cif` - Structure with adsorbate at best site
|
|
197
|
+
- `{material_id}_results.json` - Complete analysis results
|
|
198
|
+
|
|
199
|
+
## Methodology notes & limitations
|
|
200
|
+
|
|
201
|
+
- **Adsorption-energy convention.** `E_ads = E(slab+ads) − E(slab) −
|
|
202
|
+
E_gas(ads)`, where `E_gas` follows the **OC20 convention**: a linear
|
|
203
|
+
combination of per-element reference energies (H −3.477, C −7.282,
|
|
204
|
+
O −7.204, N −8.083 eV, from the OC20 paper) that pairs consistently with
|
|
205
|
+
UMA `oc20` total energies — this is the scheme recommended by the FairChem
|
|
206
|
+
documentation. Adsorbates containing other elements fall back to relative
|
|
207
|
+
energies (site ranking is still valid) unless you provide per-element
|
|
208
|
+
overrides via `get_adsorbate_reference_energy(..., overrides=...)`.
|
|
209
|
+
- **Consistent relaxation.** With `--relax`, the clean slab is relaxed once
|
|
210
|
+
(before site finding) and each slab+adsorbate system is relaxed, so both
|
|
211
|
+
totals in `E_ads` come from relaxed geometries. Use `--fix-layers 2` (or
|
|
212
|
+
more) to hold the bottom layers bulk-like during relaxations.
|
|
213
|
+
- **ML accuracy.** Energies come from a machine-learned potential (UMA);
|
|
214
|
+
expect ~0.1 eV-scale deviations from explicit DFT depending on the system.
|
|
215
|
+
- **Single initial placement per site.** Each site is evaluated from one
|
|
216
|
+
initial geometry (optionally relaxed). The state-of-the-art recipe is
|
|
217
|
+
[AdsorbML](https://www.nature.com/articles/s41524-023-01121-5): generate many
|
|
218
|
+
initial configurations, ML-relax each, and take the minimum — available via
|
|
219
|
+
`pip install "fairchem-core[adsorbml]"` (or higher-level libraries such as
|
|
220
|
+
[`quacc`](https://quacc.readthedocs.io) `slab_to_ads_flow` and `atomate2`)
|
|
221
|
+
for production studies.
|
|
222
|
+
- **Surface-normal assumption.** Site finding assumes the surface lies in the
|
|
223
|
+
xy-plane with vacuum along z (the convention produced by the slab builder).
|
|
224
|
+
|
|
225
|
+
## License
|
|
226
|
+
|
|
227
|
+
MIT License
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Materials Science Adsorption Agent
|
|
3
|
+
|
|
4
|
+
A Python agent for automated materials science workflows, focusing on
|
|
5
|
+
surface adsorption analysis using Materials Project data, ASE/pymatgen
|
|
6
|
+
tools, and FairChem UMA machine learning potentials.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from .config import AgentConfig
|
|
10
|
+
from .agent import (
|
|
11
|
+
MaterialsScienceAgent,
|
|
12
|
+
AgentResult,
|
|
13
|
+
InteractiveAgent,
|
|
14
|
+
run_analysis,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
__version__ = "0.2.1"
|
|
18
|
+
__author__ = "Materials Science Agent"
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
"MaterialsScienceAgent",
|
|
22
|
+
"AgentConfig",
|
|
23
|
+
"AgentResult",
|
|
24
|
+
"InteractiveAgent",
|
|
25
|
+
"run_analysis",
|
|
26
|
+
]
|