nequip.integrations.torchsim¶
- class nequip.integrations.torchsim.NequIPTorchSimCalc(model: Module, device: str | device = 'cpu', transforms: List[Callable] = [], atomic_numbers: Tensor | None = None, system_idx: Tensor | None = None)[source]¶
NequIP framework torch-sim calculator.
This torch-sim calculator is compatible with models from the NequIP framework, including NequIP and Allegro models.
The recommended way to use this calculator is with a compiled model, i.e.
nequip-compilethe model and load it into the calculator withNequIPTorchSimCalc.from_compiled_model(...).- Parameters:
model (
torch.nn.Module) – a model in the NequIP frameworkdevice (str or
torch.device) – device for model to evaluate on, e.g."cpu"or"cuda"(default:"cpu")transforms (List[Callable]) – list of data transforms
atomic_numbers (
torch.Tensoror None) – atomic numbers with shape[n_atoms]. If provided at initialization, cannot be provided again during forward passsystem_idx (
torch.Tensoror None) – batch indices with shape[n_atoms]indicating which system each atom belongs to. If not provided withatomic_numbers, all atoms are assumed to be in the same system
- classmethod from_compiled_model(compile_path: str | Path, device: str | device = 'cpu', chemical_species_to_atom_type_map: Dict[str, str] | bool | None = None, neighborlist_backend: str = 'alchemiops', **kwargs)[source]¶
Build an integration calculator from a compiled model artifact.
- Parameters:
compile_path – path to the compiled model artifact.
device – device where the model is loaded and evaluated.
chemical_species_to_atom_type_map – optional chemical species mapping override.
neighborlist_backend – neighbor list backend used by neighbor transforms.
**kwargs – forwarded to the integration class constructor.
- setup_from_system_idx(atomic_numbers: Tensor, system_idx: Tensor) None[source]¶
Set up internal state from atomic numbers and system indices.
- Parameters:
atomic_numbers (
torch.Tensor) – atomic numbers with shape[n_atoms].system_idx (
torch.Tensor) – system indices with shape[n_atoms].