Skip to main content

MACE Inference

CI PyPI version Python 3.9+ License: MIT

High-level Python library for MACE machine learning force field inference tasks

Documentation • Installation • Quick Start • Examples


🌟 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

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:


🧪 Testing

# Run all tests
pytest

# Run with coverage
pytest --cov=mace_inference --cov-report=html

🤝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


🙏 Acknowledgments


📮 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}
}

Metadata

Release files for mace-inference 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mace-inference 0.1.0
File Size Uploaded Provenance Actions
mace_inference-0.1.0.tar.gz 53.7 kB Without provenance Details for mace_inference-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mace-inference 0.1.0
File Interpreter ABI Platform Actions
mace_inference-0.1.0-py3-none-any.whl Python 3 none any Details for mace_inference-0.1.0-py3-none-any.whl

Total release size: 85.2 kB

Release files / mace_inference-0.1.0.tar.gz

Download URL mace_inference-0.1.0.tar.gz
Size 53.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d32a2d8f6b29bdf0bae788d7ec3d151bc296c82eb71e009c6809af8a86ff398f
BLAKE2b-256 checksum
How to use checksums
ce4dfecf7db26d02e042b16ce18c653f8312a8b37c3555dbb884e9a9b971c53a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.19

Release files / mace_inference-0.1.0-py3-none-any.whl

Download URL mace_inference-0.1.0-py3-none-any.whl
Size 31.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d94d31cf3442ca225ed38ecd22e64cd8f1bf106d0e03c168c561942d4eb3ebf
BLAKE2b-256 checksum
How to use checksums
7ad162adbe7cf088da6494c2a924c4660c9e07b18bf4c08186b45239ab045347
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.19

Security for mace-inference 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page