Examples¶
This section contains practical examples demonstrating how to use MACE Inference for various computational tasks.
Example Files¶
All examples are available in the examples/ directory of the repository.
| Example | Description |
|---|---|
| Basic Usage | Single-point, optimization, basic workflow |
| Molecular Dynamics | NVT and NPT simulations |
| Phonon Calculation | Phonon DOS and thermal properties |
| Adsorption Study | Gas adsorption in frameworks |
| High Throughput | Screening multiple structures |
| D3 Correction | Using DFT-D3 dispersion |
| Batch Processing | Processing multiple files |
Running Examples¶
Option 1: Using Installed Package¶
If you installed via PyPI:
# Install the package
pip install mace-inference
# Download examples
git clone https://github.com/lichman0405/mace-inference.git
cd mace-inference
# Run an example
python examples/01_basic_usage.py
Option 2: From Source¶
If you want to modify and develop:
# Clone the repository
git clone https://github.com/lichman0405/mace-inference.git
cd mace-inference
# Install in development mode
pip install -e .
# Run an example
python examples/01_basic_usage.py
Structure Files¶
Examples use CIF structure files from examples/structures/:
cu_fcc.cif- FCC Coppercu_paddlewheel.cif- Cu paddlewheel cluster (MOF building block)si_diamond.cif- Diamond cubic Silicon
Output¶
Examples that generate output save files to examples/output/.
Quick Start Example¶
Here's a minimal working example:
from mace_inference import MACEInference
from ase.io import read
# Initialize
calc = MACEInference(model="medium", device="auto")
# Load structure
atoms = read("structure.cif")
# Calculate
result = calc.single_point(atoms)
print(f"Energy: {result['energy']:.4f} eV")
# Optimize
opt = calc.optimize(atoms, fmax=0.01)
print(f"Optimized energy: {opt['energy']:.4f} eV")