Inference and simulation helpers¶
- mlipaudit.utils.inference.run_inference(atoms_list: list[Atoms], force_field: ForceField | Calculator, batch_size: int = 16) list[Prediction | None]¶
Runs inference for a list of
ase.Atomsobjects.If
ForceFieldobject is passed,run_batched_inferencefrom the mlip library is used.- Parameters:
atoms_list – The list of
ase.Atomsobjects.force_field – The force field.
batch_size – Batch size, default 16. Will only be used if force field is passed as a
ForceFieldobject.
- Returns:
- A list of
Predictionor None objects, None when the model failed to perform inference on a system for whatever reason.
- A list of
- Raises:
ValueError – If force field type is not compatible.
- mlipaudit.utils.simulation.get_simulation_engine(atoms: Atoms, force_field: ForceField | Calculator, **kwargs) JaxMDSimulationEngine | ASESimulationEngineWithCalculator | ASESimulationEngine¶
Returns the correct simulation engine based on the input force field type.
For MD simulations with
mlip.models.ForceFieldobjects, we return aJaxMDSimulationEngine. For energy minimizations with those objects, we return aASESimulationEngine. For any type of simulations with ASE calculator objects, we return aASESimulationEngineWithCalculator, which is a custom class of themlipauditlibrary.- Parameters:
atoms – The ASE atoms.
force_field – The force field, either an
mlip.models.ForceFieldor an ASE calculator.**kwargs – Keyword arguments to be passed to the MD config object. Assumed to be JAX-MD based, will be modified automatically for ASE.
- Returns:
The simulation engine.
- Raises:
ValueError – If force field type is not compatible.
- mlipaudit.utils.simulation.run_simulation(atoms: Atoms, force_field: ForceField | Calculator, **kwargs) SimulationState | None¶
Run the simulation with the appropriate simulation engine based on the input force field type.
For MD simulations with
mlip.models.ForceFieldobjects, runs the simulation withJaxMDSimulationEngine. For energy minimizations with those objects, runs with anASESimulationEngine. For any type of simulations with ASE calculator objects, runs with anASESimulationEngineWithCalculator, which is a custom class of themlipauditlibrary. If the simulation fails, the error will be caught and None will be returned.- Parameters:
atoms – The ASE atoms.
force_field – The force field, either an
mlip.models.ForceFieldor an ASE calculator.**kwargs – Keyword arguments to be passed to the MD config object. Assumed to be JAX-MD based, will be modified automatically for ASE.
- Returns:
The simulation state or None if the simulation failed.
- Raises:
ValueError – If force field type is not compatible.
- class mlipaudit.utils.simulation.ASESimulationEngineWithCalculator(atoms: Atoms, ase_calculator: Calculator, config: ASESimulationConfig)¶
Class derived from mlip’s ASE simulation engine but allowing for a passed ASE calculator object.