get_calculator
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
The model to use. Accepts:
- An
MLIPEnummember (e.g.MLIPEnum["MACE-MP(M)"]). - A string name matching a registered model (e.g.
"MACE-MP(M)"). Looked up viaMLIPEnum[calculator]. - A
BaseCalculatorsubclass (not an instance). Instantiated withcalculator_kwargs. - An existing
BaseCalculatorinstance. Returned as-is;calculator_kwargsare ignored.
ValueError if none of the above match.Keyword arguments forwarded to the calculator constructor. The
device key is automatically injected, so you do not need to pass it here.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.Keyword arguments forwarded to The
TorchDFTD3Calculator. Defaults to:device key is automatically injected. Common keys:| Key | Default | Description |
|---|---|---|
damping | "bj" | Damping scheme. "bj" (Becke-Johnson) or "zero". |
xc | "pbe" | Exchange-correlation functional used when the model was trained. |
cutoff | 40.0 * units.Bohr | Real-space cutoff for the D3 sum (~21 Å). |
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
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
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.