High-level Python library for MACE machine learning force field inference tasks
Project description
MACE Inference
High-level Python library for MACE machine learning force field inference tasks
🌟 Features
- 🚀 Simple API: High-level interface for common inference tasks
- 🔌 Flexible: Works with all MACE models (MACE-MP-0, MACE-MPA-0, MACE-OMAT-0, etc.)
- ⚡ GPU Support: Automatic device detection (CPU/CUDA)
- 🧪 Complete Workflow: Single-point energy, optimization, MD, phonon, adsorption, etc.
- 🔧 CLI Tools: Command-line interface for non-programmers
- 📦 Pure Python: Built on ASE and Phonopy - no extra software required
📦 Installation
Basic Installation (CPU)
pip install mace-inference
GPU Support
pip install mace-inference[gpu]
With D3 Dispersion Correction
pip install mace-inference[d3]
Development Installation
git clone https://github.com/lichman0405/mace-inference.git
cd mace-inference
pip install -e ".[all]"
🚀 Quick Start
Python API
from ase.io import read
from mace_inference import MACEInference
# Initialize MACE calculator
calc = MACEInference(model="medium", device="auto")
# Load structure
atoms = read("structure.cif")
# Single-point energy calculation
result = calc.single_point(atoms)
print(f"Energy: {result['energy']:.4f} eV")
print(f"Max Force: {result['max_force']:.4f} eV/Å")
# Structure optimization
optimized = calc.optimize(atoms, fmax=0.05) # Returns Atoms object
# Save with: from ase.io import write; write("optimized.cif", optimized)
# Molecular dynamics (NVT)
trajectory = calc.run_md(
atoms,
ensemble="nvt",
temperature_K=300,
steps=1000
)
# Phonon calculation
phonon_result = calc.phonon(atoms, supercell_matrix=[2, 2, 2])
# Adsorption energy
result = calc.adsorption_energy(
framework=mof,
adsorbate="CO2",
site_position=[10.0, 10.0, 10.0]
)
print(f"Adsorption Energy: {result['E_ads']:.3f} eV")
# Batch processing with progress callback
def progress(current, total):
print(f"Processing {current}/{total}")
results = calc.batch_single_point(
structures,
progress_callback=progress
)
Command Line Interface
# Single-point energy
mace-infer energy structure.cif --model medium
# Structure optimization
mace-infer optimize structure.cif --fmax 0.05 --output optimized.cif
# Molecular dynamics
mace-infer md structure.cif --ensemble nvt --temp 300 --steps 10000
# Phonon calculation
mace-infer phonon structure.cif --supercell 2 2 2 --temp-range 0 1000 10
# Bulk modulus
mace-infer bulk-modulus structure.cif
# Adsorption energy
mace-infer adsorption mof.cif --gas CO2 --site 10.0 10.0 10.0
📚 Documentation
Full documentation is available at lichman0405.github.io/mace-inference
- Installation Guide - Detailed installation instructions
- Quick Start - Getting started guide
- User Guide - Detailed usage guides
- API Reference - Complete API documentation
- Examples - Usage examples and tutorials
- Changelog - Version history and updates
Available Tasks
| Task | Method | Description |
|---|---|---|
| Single-Point Energy | single_point() |
Calculate energy, forces, stress |
| Structure Optimization | optimize() |
Minimize energy (atoms + cell) |
| Molecular Dynamics | run_md() |
NVT/NPT simulations |
| Phonon Calculation | phonon() |
Phonon dispersion & thermodynamics |
| Bulk Modulus | bulk_modulus() |
Equation of state fitting |
| Coordination Analysis | coordination() |
Metal-ligand bond lengths |
| Adsorption Energy | adsorption_energy() |
Gas molecule binding energy |
| Batch Single-Point | batch_single_point() |
Process multiple structures |
| Batch Optimize | batch_optimize() |
Batch structure optimization |
Supported MACE Models
- MACE-MP-0a/0b3 (Materials Project)
- MACE-MPA-0 (MPtraj + Alexandria)
- MACE-OMAT-0 (OMat24)
- MACE-MATPES-r2SCAN-0 (MatPES + MPtraj)
- Custom fine-tuned models
📖 Examples
See the examples/ directory for detailed usage:
- 01_basic_usage.py - Basic single-point and optimization
- 02_molecular_dynamics.py - NVT/NPT MD simulations
- 03_phonon_calculation.py - Phonon and thermal properties
- 04_adsorption_study.py - Gas adsorption in MOFs
- 05_high_throughput.py - Batch processing
- 06_d3_correction.py - Using D3 dispersion correction
- 07_batch_processing.py - Batch API and progress callbacks
🧪 Testing
# Run all tests
pytest
# Run with coverage
pytest --cov=mace_inference --cov-report=html
🤝 Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- MACE: ACEsuit/mace
- ASE: Atomic Simulation Environment
- Phonopy: Phonon calculations
📮 Citation
If you use this library in your research, please cite:
@software{mace_inference,
title = {MACE Inference: High-level Python library for MACE force field inference},
author = {Shibo Li},
year = {2026},
url = {https://github.com/lichman0405/mace-inference}
}
And the original MACE paper:
@inproceedings{Batatia2022mace,
title={{MACE}: Higher Order Equivariant Message Passing Neural Networks for Fast and Accurate Force Fields},
author={Ilyes Batatia and David Peter Kovacs and Gregor N. C. Simm and Christoph Ortner and Gabor Csanyi},
booktitle={Advances in Neural Information Processing Systems},
year={2022}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mace_inference-0.1.0.tar.gz.
File metadata
- Download URL: mace_inference-0.1.0.tar.gz
- Upload date:
- Size: 53.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d32a2d8f6b29bdf0bae788d7ec3d151bc296c82eb71e009c6809af8a86ff398f
|
|
| MD5 |
d495134422641fc295adcae05306fd18
|
|
| BLAKE2b-256 |
ce4dfecf7db26d02e042b16ce18c653f8312a8b37c3555dbb884e9a9b971c53a
|
File details
Details for the file mace_inference-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mace_inference-0.1.0-py3-none-any.whl
- Upload date:
- Size: 31.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d94d31cf3442ca225ed38ecd22e64cd8f1bf106d0e03c168c561942d4eb3ebf
|
|
| MD5 |
38565994d6702912dc25c0e74c635981
|
|
| BLAKE2b-256 |
7ad162adbe7cf088da6494c2a924c4660c9e07b18bf4c08186b45239ab045347
|