Skip to main content

get_calculator

Builds and returns an ASE BaseCalculator for a given model. Automatically selects the freest available GPU via get_freer_device unless you pass an explicit device. When dispersion=True, wraps the base calculator in an ASE SumCalculator that adds a DFT-D3 dispersion correction via TorchDFTD3Calculator.

Parameters

str | MLIPEnum | BaseCalculator
required
The model to use. Accepts:
  • An MLIPEnum member (e.g. MLIPEnum["MACE-MP(M)"]).
  • A string name matching a registered model (e.g. "MACE-MP(M)"). Looked up via MLIPEnum[calculator].
  • A BaseCalculator subclass (not an instance). Instantiated with calculator_kwargs.
  • An existing BaseCalculator instance. Returned as-is; calculator_kwargs are ignored.
Raises ValueError if none of the above match.
dict | None
default:"{}"
Keyword arguments forwarded to the calculator constructor. The device key is automatically injected, so you do not need to pass it here.
bool
default:"False"
When True, adds a DFT-D3 dispersion correction on top of the base calculator using TorchDFTD3Calculator from the torch_dftd package. The base calculator and the dispersion calculator are combined with ASE’s SumCalculator.Requires torch_dftd to be installed. Raises ImportError if the package is missing.
dict | None
Keyword arguments forwarded to TorchDFTD3Calculator. Defaults to:
The device key is automatically injected. Common keys:
str | None
default:"None"
Device string passed to the calculator, e.g. "cuda:0" or "cpu". When None, the device is chosen automatically by get_freer_device().

Return value

ase.calculators.calculator.BaseCalculator
required
A ready-to-use ASE calculator. When dispersion=False this is the model’s own calculator. When dispersion=True this is an ASE SumCalculator([model_calc, disp_calc]).

Examples

Basic usage

With DFT-D3 dispersion correction

Explicit device and calculator kwargs

Custom calculator class

When you pass an existing BaseCalculator instance, calculator_kwargs are silently ignored. Pass the class if you want kwargs forwarded.

Registered models (MLIPEnum)

MLIPEnum is an Enum whose members are populated at import time from registry.yaml. Each member’s .value is the calculator class for that model.
Only models whose packages are installed will appear in MLIPEnum. Missing packages produce a warning at import time and the model is skipped.