PatchSPCalculator

class mlcalcdriver.calculators.schnetpack_patch.PatchSPCalculator(model_dir, available_properties=None, device='cpu', units={'dipole_moment': 'Debye', 'energy': 'eV', 'positions': 'angstrom'}, md=False, subgrid=None)[source]

Bases: mlcalcdriver.calculators.schnetpack.SchnetPackCalculator

Calculator based on a SchnetPack model

Parameters
  • model_dir (str) – Path to the stored model.

  • available_properties (str or list of str) – Same as SchnetPackCalculator

  • device (str) – Same as SchnetPackCalculator

  • units (dict) – Same as SchnetPackCalculator

  • md (bool) – Same as SchnetPackCalculator

  • subgrid (Sequence of length 3) – Number of subdivisions of the initial configuration in all 3 dimensions. The periodic boundary conditions will be kept in the dimensions with 1.

  • model_dir – Path to the stored model on which the calculator will be based. If $MODELDIR is defined, the path can be relative to it. If not, the path must be absolute or relative to the working directory.

  • available_properties – Properties that the model can predict. If None, they automatically determined from the model. Default is None.

  • device – Can be either “cpu” to use cpu or “cuda” to use “gpu”

  • units – Dictionnary containing the units in which the calculator makes predictions. Default is mlcalcdriver.globals.eVA for a SchnetPackCalculator.

  • md – Whether the calculator is used with ASE to do molecular dynamics. Default is False and should be changed through the AseSpkCalculator object.

  • dropout (bool) – Whether the calculator should use the dropout layers to estimate a confidence interval for the prediction. Default is False. No effect if the model hasn’t been trained with dropout layers.

run(property, posinp=None, batch_size=1)[source]

Central method to use when making a calculation with the calculator.

Parameters
  • property (str) – Property to be predicted by the calculator

  • posinp (Posinp) – Atomic configuration to pass to the model

Returns

predictions – Corresponding prediction by the model.

Return type

numpy.ndarray

Warning

Using one or more values of 2 in the subgrid can create problems because the same atom can be present multiple times in the buffers of a single patch.