from __future__ import annotations
from pathlib import Path
from typing import Iterable, Literal, Sequence
from scm.pisa.block import DriverBlock,EngineBlock,FixedBlock,FreeBlock,InputBlock
from scm.pisa.key import BoolKey,FloatKey,FloatListKey,IntKey,IntListKey,MultipleChoiceKey,PathStringKey,StringKey,BoolType
[docs]class MLPotential(EngineBlock):
r"""
:ivar Backend: The machine learning potential backend.
:vartype Backend: Literal["M3GNet", "NequIP", "PiNN", "RuNNerLAMMPS", "SchNetPack", "sGDML", "TorchANI"]
:ivar Device: Device on which to run the calculation (e.g. cpu, cuda:0).
If empty, the device can be controlled using environment variables for TensorFlow or PyTorch.
:vartype Device: Literal["", "cpu", "cuda:0", "cuda:1", "mps"]
:ivar MLDistanceUnit: Unit of distances expected by the ML backend (not the ASE calculator). The ASE calculator may require this information.
:vartype MLDistanceUnit: Literal["Auto", "angstrom", "bohr"]
:ivar MLEnergyUnit: Unit of energy output by the ML backend (not the unit output by the ASE calculator). The ASE calculator may require this information.
:vartype MLEnergyUnit: Literal["Auto", "Hartree", "eV", "kcal/mol", "kJ/mol"]
:ivar Model: Select a particular parameterization.
ANI-1x and ANI-2x: based on DFT (wB97X)
ANI-1cxx: based on DLPNO-CCSD(T)/CBS
M3GNet-UP-2022: based on DFT (PBE and PBE+U) data.
AIMNet2: based on ωB97m-D3 or B97-3c data.
ANI-1x and ANI-1ccx have been parameterized to give good geometries, vibrational frequencies, and reaction energies for gasphase organic molecules containing H, C, O, and N. ANI-2x can also handle the atoms F, S, and Cl.
M3GNet-UP-2022 is a universal potential (UP) for the entire periodic table and has been primarily trained to crystal data (energies, forces, stresses) from the Materials Project.
AIMNet2 has been parametrized to give good geometries and reaction energies for gasphase molecules and ions containing H, B, C, N, O, F, Si, P, S, Cl, As, Se, Br, I.
Set to Custom to specify the backend and parameter files yourself.
:vartype Model: Literal["Custom", "AIMNet2-B973c", "AIMNet2-wB97MD3", "ANI-1ccx", "ANI-1x", "ANI-2x", "M3GNet-UP-2022"]
:ivar NumThreads: Number of threads.
If not empty, OMP_NUM_THREADS will be set to this number; for PyTorch-engines, torch.set_num_threads() will be called.
:vartype NumThreads: str | StringKey
:ivar ParameterDir: Path to a set of parameters for the backend, if it expects to read from a directory.
:vartype ParameterDir: str | Path | StringKey
:ivar ParameterFile: Path to a set of parameters for the backend, if it expects to read from a file.
:vartype ParameterFile: str | Path | StringKey
:ivar Member: Specify the details of a member of a committee.
:vartype Member: MLPotential._Member
"""
[docs] class _Member(FixedBlock):
r"""
Specify the details of a member of a committee.
:ivar ParameterDir: Path to a set of parameters for the backend, if it expects to read from a directory.
:vartype ParameterDir: str | Path | StringKey
:ivar ParameterFile: Path to a set of parameters for the backend, if it expects to read from a file.
:vartype ParameterFile: str | Path | StringKey
"""
def __post_init__(self):
self.ParameterDir: str | Path | StringKey = PathStringKey(name='ParameterDir', comment='Path to a set of parameters for the backend, if it expects to read from a directory.', hidden=True, gui_name='Parameter directory:', default='', ispath=True, gui_type='directory')
self.ParameterFile: str | Path | StringKey = PathStringKey(name='ParameterFile', comment='Path to a set of parameters for the backend, if it expects to read from a file.', hidden=True, default='', ispath=True)
def __post_init__(self):
self.Backend: Literal["M3GNet", "NequIP", "PiNN", "RuNNerLAMMPS", "SchNetPack", "sGDML", "TorchANI"] = MultipleChoiceKey(name='Backend', comment='The machine learning potential backend.', choices=['M3GNet', 'NequIP', 'PiNN', 'RuNNerLAMMPS', 'SchNetPack', 'sGDML', 'TorchANI'], hiddenchoices=['RuNNerLAMMPS', 'PiNN'], gui_type='literal choices')
self.Device: Literal["", "cpu", "cuda:0", "cuda:1", "mps"] = MultipleChoiceKey(name='Device', comment='Device on which to run the calculation (e.g. cpu, cuda:0).\n\nIf empty, the device can be controlled using environment variables for TensorFlow or PyTorch.', default='', choices=['', 'cpu', 'cuda:0', 'cuda:1', 'mps'])
self.MLDistanceUnit: Literal["Auto", "angstrom", "bohr"] = MultipleChoiceKey(name='MLDistanceUnit', comment='Unit of distances expected by the ML backend (not the ASE calculator). The ASE calculator may require this information.', gui_name='Internal distance unit:', default='Auto', choices=['Auto', 'angstrom', 'bohr'])
self.MLEnergyUnit: Literal["Auto", "Hartree", "eV", "kcal/mol", "kJ/mol"] = MultipleChoiceKey(name='MLEnergyUnit', comment='Unit of energy output by the ML backend (not the unit output by the ASE calculator). The ASE calculator may require this information.', gui_name='Internal energy unit:', default='Auto', choices=['Auto', 'Hartree', 'eV', 'kcal/mol', 'kJ/mol'], gui_type='literal choices')
self.Model: Literal["Custom", "AIMNet2-B973c", "AIMNet2-wB97MD3", "ANI-1ccx", "ANI-1x", "ANI-2x", "M3GNet-UP-2022"] = MultipleChoiceKey(name='Model', comment='Select a particular parameterization.\n\nANI-1x and ANI-2x:\tbased on DFT (wB97X)\nANI-1cxx:\tbased on DLPNO-CCSD(T)/CBS\nM3GNet-UP-2022: based on DFT (PBE and PBE+U) data.\nAIMNet2:\tbased on ωB97m-D3 or B97-3c data.\n\nANI-1x and ANI-1ccx have been parameterized to give good geometries, vibrational frequencies, and reaction energies for gasphase organic molecules containing H, C, O, and N. ANI-2x can also handle the atoms F, S, and Cl. \n\nM3GNet-UP-2022 is a universal potential (UP) for the entire periodic table and has been primarily trained to crystal data (energies, forces, stresses) from the Materials Project.\n\nAIMNet2 has been parametrized to give good geometries and reaction energies for gasphase molecules and ions containing H, B, C, N, O, F, Si, P, S, Cl, As, Se, Br, I.\n\nSet to Custom to specify the backend and parameter files yourself.', default='ANI-2x', choices=['Custom', 'AIMNet2-B973c', 'AIMNet2-wB97MD3', 'ANI-1ccx', 'ANI-1x', 'ANI-2x', 'M3GNet-UP-2022'])
self.NumThreads: str | StringKey = StringKey(name='NumThreads', comment='Number of threads.\n\nIf not empty, OMP_NUM_THREADS will be set to this number; for PyTorch-engines, torch.set_num_threads() will be called.', gui_name='Number of threads:', default='')
self.ParameterDir: str | Path | StringKey = PathStringKey(name='ParameterDir', comment='Path to a set of parameters for the backend, if it expects to read from a directory.', gui_name='Parameter directory:', default='', ispath=True, gui_type='directory')
self.ParameterFile: str | Path | StringKey = PathStringKey(name='ParameterFile', comment='Path to a set of parameters for the backend, if it expects to read from a file.', default='', ispath=True)
self.Member: MLPotential._Member = self._Member(name='Member', comment='Specify the details of a member of a committee.', hidden=True, unique=False)