| This is part of the metatomic module | |
| It is only available if you configure PLUMED with ./configure –enable-modules=metatomic . Furthermore, this feature is still being developed so take care when using it and report any problems on the mailing list. |
Use arbitrary machine learning models as collective variables.
This action enables the use of fully custom machine learning models — based on the metatomic models interface — as collective variables in PLUMED. Such machine learning model are typically written and customized using Python code, and then exported to run within PLUMED as TorchScript, which is a subset of Python that can be executed by the C++ torch library.
Metatomic offers a way to define such models and pass data from PLUMED (or any other simulation engine) to the model and back. For more information on how to define such model, have a look at the corresponding tutorials, or at the code in regtest/metatomic/. Each of the Python scripts in this directory defines a custom machine learning CV that can be used with PLUMED.
The following input shows how you can call metatomic and evaluate the model that is described in the file custom_cv.pt from PLUMED.
SPECIES1=1-26 SPECIES2=27-62 SPECIES3=63-76 SPECIES_TO_TYPES=6,1,8 @newline
The numbered SPECIES labels are used to indicate the list of atoms that belong to each atomic species in the system. The SPECIES_TO_TYPE keyword then provides information on the atom type for each species. The first number here is the atomic type of the atoms that have been specified using the SPECIES1 flag, the second number is the atomic number of the atoms that have been specified using the SPECIES2 flag and so on.
METATOMIC action also accepts the following options:
EXTENSIONS_DIRECTORY should be the path to a directory containing TorchScript extensions (as shared libraries) that are required to load and execute the model. This matches the collect_extensions argument to AtomisticModel.export in Python.CHECK_CONSISTENCY can be used to enable internal consistency checks;SELECTED_ATOMS can be used to signal the metatomic models that it should only run its calculation for the selected subset of atoms. The model still need to know about all the atoms in the system (through the SPECIES keyword); but this can be used to reduce the calculation cost. Note that the indices of the selected atoms should start at 1 in the PLUMED input file, but they will be translated to start at 0 when given to the model (i.e. in Python/TorchScript, the forward method will receive a selected_atoms which starts at 0)Here is another example with all the possible keywords:
CHECK_CONSISTENCY SPECIES1=1-10 SPECIES2=11-20 SPECIES_TO_TYPES=8,13 # only run the calculation for the Aluminium (type 13) atoms, but # include the Oxygen (type 8) as potential neighbors. SELECTED_ATOMS=11-20 @newline
PLUMED can use the "features" output of metatomic models as a collective variables.
By default this Action calculates the following quantities. These quantities can be referenced elsewhere in the input by using this Action's label followed by a dot and the name of the quantity required from the list below.
| Quantity | Description |
| outputs | collective variable created by the metatomic model |
| .#!value | collective variable created by the metatomic model |
| SPECIES | the indices of atoms in each PLUMED species. You can use multiple instances of this keyword i.e. SPECIES1, SPECIES2, SPECIES3... |
| SELECTED_ATOMS | subset of atoms that should be used for the calculation |
| MODEL | path to the exported metatomic model |
| NUMERICAL_DERIVATIVES | ( default=off ) calculate the derivatives for these quantities numerically |
| CHECK_CONSISTENCY | ( default=off ) should we enable internal consistency checks when executing the model |
| EXTENSIONS_DIRECTORY | path to the directory containing TorchScript extensions to load |
| DEVICE | Torch device to use for the calculations |
| SPECIES_TO_TYPES | mapping from PLUMED SPECIES to metatomic's atom types |