Calculators
The calculator module provides a unified interface to MLIP and classical backends.
Calculator factory
- amorphgen.utils.calculators.get_calculator(model='mace-mpa-0', device='auto', model_path=None, **kwargs)[source]
Build and return an ASE calculator for the given foundation model.
This is the unified entry point for all supported MLFF backends. The returned object is always a standard ASE calculator that can be attached to any
ase.Atomsobject.- Parameters:
model (str) –
Short name identifying the model. Examples:
MACE:
"mace-mpa-0","mace-mh-1","mace-omat-0"CHGNet:
"chgnet"SevenNet:
"sevennet","7net-mf-ompa","7net-l3i5"Classical:
"lennard-jones","buckingham"
Use
list_models()or--list-modelsto see all options. Ignored if model_path is provided (defaults to MACE backend).device (str) –
"cuda"or"cpu".model_path (str, optional) – Path to a local
.modelfile (e.g. a fine-tuned MACE model). Takes priority over model. Currently only MACE.modelfiles are supported for custom paths.**kwargs – Extra keyword arguments forwarded to the backend-specific calculator constructor.
- Returns:
A ready-to-use ASE calculator.
- Return type:
- Raises:
ValueError – If the model name is not recognised by any backend.
ImportError – If the required backend package is not installed.
FileNotFoundError – If model_path points to a non-existent file.
Examples
>>> calc = get_calculator("mace-mpa-0", device="cuda") >>> calc = get_calculator("chgnet", device="cpu") >>> calc = get_calculator("7net-mf-ompa", device="cuda") >>> calc = get_calculator(model_path="/data/my_finetuned.model") >>> calc = get_calculator("buckingham", classical_params={...})
Backend detection
MACE models
The following MACE foundation models are available via get_calculator():
Key |
Variant |
|---|---|
|
MP-0a (initial release) |
|
MP-0b (improved pair repulsion) |
|
MP-0b2 (high-pressure stability) |
|
MP-0b3 (fixed phonons) |
|
Latest MPA model |
SevenNet models
Key |
Variant |
|---|---|
|
Multi-fidelity foundation (OMat+MPtrj+Alexandria) — recommended |
|
Multi-fidelity baseline |
|
OMat-only |
|
Improved equivariant features |
|
Original release (Jul 2024) |
|
Multi-task |
Multi-fidelity (mf) variants accept a modal kwarg ('mpa' default, or 'omat24'):
calc = get_calculator("7net-mf-ompa", device="auto") # PBE
calc = get_calculator("7net-mf-ompa", device="auto", modal="omat24") # PBE+U
Use amorphgen --list-models or list_models() for the complete list.
Classical potentials
Built-in pair potentials for initial structure preparation. No extra install needed.
Model name |
Potential |
Parameters required |
|---|---|---|
|
4eps[(sig/r)^12 - (sig/r)^6] |
|
|
A*exp(-r/rho) - C/r^6 + Coulomb |
|
Parameters are passed via classical_params in YAML config or Python API:
calc = get_calculator("buckingham", classical_params={
"params": {("Si", "O"): {"A": 18003.76, "rho": 0.2052, "C": 133.54}},
"charges": {"Si": 2.4, "O": -1.2},
"cutoff": 10.0,
})
- class amorphgen.utils.classical.LennardJonesCalculator(*args, **kwargs)[source]
Bases:
CalculatorLennard-Jones pair potential calculator (vectorized).
V(r) = 4 * epsilon * [(sigma/r)^12 - (sigma/r)^6]
- Parameters:
- implemented_properties = ['energy', 'forces']
- class amorphgen.utils.classical.BuckinghamCalculator(*args, **kwargs)[source]
Bases:
CalculatorBuckingham + Coulomb pair potential calculator (rigid-ion, vectorized).
V(r) = A * exp(-r/rho) - C/r^6 + q_i * q_j / (4*pi*eps0*r)
The Coulomb term uses a Wolf summation for convergence under PBC. This is an approximation to full Ewald – accurate for amorphous structures but not for crystalline long-range order.
- Parameters:
params (dict) – Per-pair Buckingham parameters, e.g. {(“Si”, “O”): {“A”: 13702.905, “rho”: 0.193817, “C”: 54.681}}
charges (dict) – Per-element charges in electron units, e.g. {“Si”: 2.4, “O”: -1.2}
cutoff (float) – Cutoff distance in Angstrom.
alpha (float) – Wolf summation damping parameter (1/Angstrom). Default 0.2 works well for cutoff >= 8 A.
coulomb (bool) – If True, include Coulomb interactions. Default True.
device (str) – “cpu” (default, vectorized NumPy) or “cuda”/”mps” (PyTorch GPU).
- implemented_properties = ['energy', 'forces']
Deprecated aliases
- amorphgen.utils.calculators.get_mace_calculator(model='mace-mpa-0', device='cuda', model_path=None, **kwargs)[source]
Build and return a MACE calculator.
Deprecated since version 2.0.0: Use
get_calculator()instead, which supports MACE and all other backends (CHGNet, SevenNet).