torchani.ase#
Calculator subclass, used for interfacing with the ASE library
The ASE library can be used to perform molecular dynamics. For more information consult the user guide.
Functions
|
|
|
Classes
TorchANI calculator for ASE |
- class torchani.ase.Calculator(model, overwrite=False, stress_kind='scaling')[source]#
TorchANI calculator for ASE
ANI models can be converted to their ASE Calculator form by calling the
ANI.asemethod.import torchani model = torchani.models.ANI1x() calc = model.ase() # Convert model into its "ASE Calculator" form
- Parameters:
model (
torchani.arch.ANI) – neural network potential model that convert coordinates into energies.overwrite (bool) – Deprecated since version 2.9.0. After wrapping atoms into central box, replace the original positions in the
ase.Atomsobject with the wrapped positions.stress_kind ("fdotr"|"scaling"|"numerical") – Strategy used to calculate stress. The “fdotr” approach only requires the cell volume, so it can be used with domain-decomposition approaches when running in parallel on multiple GPUs. The “scaling” approach uses the analytic gradient with respect to the strain \(\epsilon\), evaluated at \(\epsilon = 0\), after applying the deformation \(h' = h(I + \epsilon)\) to the cell and \(\mathbf{r}_i^T = \mathbf{r}_i^T(I + \epsilon)\) to the atomic coordinates.
- implemented_properties: list[str] = ['energy', 'free_energy', 'forces', 'stress']#
Properties calculator can handle (energy, forces, …)
- calculate(atoms=None, properties=['energy'], system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])[source]#
Do the calculation.
- properties: list of str
List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
- system_changes: list of str
List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.
Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:
self.results = {'energy': 0.0, 'forces': np.zeros((len(atoms), 3)), 'stress': np.zeros(6), 'dipole': np.zeros(3), 'charges': np.zeros(len(atoms)), 'magmom': 0.0, 'magmoms': np.zeros(len(atoms))}
The subclass implementation should first call this implementation to set the atoms attribute and create any missing directories.