VASPml library: Difference between revisions
(Created page with "'''VASPml''' is a C++ library accompanying '''VASP''', providing functionality related to machine-learned force fields. It is supposed to extend, and eventually replace, the original Fortran machine learning code inside '''VASP'''. Currently, it does not yet offer any training capabilities but rather focuses on inference. At this point '''VASPml''' is in a beta-testing stage and provides its first application, an interface to the popular molecular dynamics (MD) software...") |
No edit summary |
||
Line 1: | Line 1: | ||
VASPml is a C++ library accompanying {{VASP}}, providing functionality related to machine-learned force fields. It is supposed to extend, and eventually replace, the original Fortran machine learning code inside {{VASP}}. Currently, it does not yet offer any training capabilities but rather focuses on inference. At this point VASPml is in a beta-testing stage and provides its first application, an interface to the popular molecular dynamics (MD) software [https://www.lammps.org LAMMPS]. This allows users to combine {{VASP}}-generated machine-learned force fields with the large amount of MD-related features provided by LAMMPS, some of which may not be offered in {{VASP}} directly. | |||
= Build instructions = | = Build instructions = | ||
In future the source of | In future the source of VASPml will be distributed as part of the official {{VASP}} release. The build process of {{VASP}} will include the steps necessary to compile and link also the VASPml library and interfaces. However, at this point (and most likely even when integrated into {{VASP}}) it is possible to build VASPml completely independent of {{VASP}}. The following sections describe details of such an independent build of VASPml. | ||
=== Prerequisites === | === Prerequisites === | ||
# | # VASPml requires a C++ compiler conforming to the C++17 language standard, for example compilers which are part of: | ||
#* GNU Compiler Collection | #* GNU Compiler Collection | ||
#* Intel oneAPI Base Toolkit | #* Intel oneAPI Base Toolkit | ||
Line 25: | Line 25: | ||
=== Build library and applications === | === Build library and applications === | ||
Similar to | Similar to {{VASP}} also VASPml requires to enter compiler details and library paths into a file named <code>makefile.include</code> before the build process can be started. Template files for this file can be found in the <code>arch</code> subdirectory. Usually it is convenient to start from one of these files. Hence, first copy it to the base directory and rename it to <code>makefile.include</code>, e.g. | ||
<pre>cp arch/makefile.include.gnu makefile.include</pre> | <pre>cp arch/makefile.include.gnu makefile.include</pre> | ||
Then modify the contents to reflect the compiler and library settings on your machine, for details see the [[#compiler-and-linker-options|compiler and linker options]] section below. Once done, the | Then modify the contents to reflect the compiler and library settings on your machine, for details see the [[#compiler-and-linker-options|compiler and linker options]] section below. Once done, the VASPml library can be built by executing this command in the top directory: | ||
<pre>make -j </pre> | <pre>make -j </pre> | ||
Line 59: | Line 59: | ||
* <code>--no-color</code>: Disables colored output of makefiles. | * <code>--no-color</code>: Disables colored output of makefiles. | ||
* <code>--no-logo</code>: Disables the logo | * <code>--no-logo</code>: Disables the logo VASPml logo output. | ||
=== Automatic patching and compilations of | === Automatic patching and compilations of LAMMPS === | ||
<pre>make lammps -j</pre> | <pre>make lammps -j</pre> | ||
==== Technical details ==== | ==== Technical details ==== | ||
From a technical standpoint | From a technical standpoint LAMMPS and VASPml interact in the following way: on the LAMMPS side a new class <code>PairVASP</code> (inheriting from <code>Pair</code>) is implemented in <code>pair_vasp.cpp/h</code>. Its purpose is to transfer the neighbor lists to VASPml, trigger processing, and receive back the energy and force contributions. VASPml enters the received neighbor list data into its own structures and computes energy and force predictions according to the pre-trained machine-learned force field. A typical build for the combination of the two codes requires to first compile the <code>libvaspml</code> library. Then, LAMMPS is patched with the additional <code>pair_vasp.cpp/h</code> files, which are automatically compiled during the LAMMPS build. In the final stage, LAMMPS is linked to the <code>libvaspml</code> library, resulting in a patched executable. This can be done manually but VASPml also offers a convenient automated way covering all steps (<code>make lammps</code>). |
Revision as of 10:00, 18 October 2024
VASPml is a C++ library accompanying VASP, providing functionality related to machine-learned force fields. It is supposed to extend, and eventually replace, the original Fortran machine learning code inside VASP. Currently, it does not yet offer any training capabilities but rather focuses on inference. At this point VASPml is in a beta-testing stage and provides its first application, an interface to the popular molecular dynamics (MD) software LAMMPS. This allows users to combine VASP-generated machine-learned force fields with the large amount of MD-related features provided by LAMMPS, some of which may not be offered in VASP directly.
Build instructions
In future the source of VASPml will be distributed as part of the official VASP release. The build process of VASP will include the steps necessary to compile and link also the VASPml library and interfaces. However, at this point (and most likely even when integrated into VASP) it is possible to build VASPml completely independent of VASP. The following sections describe details of such an independent build of VASPml.
Prerequisites
- VASPml requires a C++ compiler conforming to the C++17 language standard, for example compilers which are part of:
- GNU Compiler Collection
- Intel oneAPI Base Toolkit
- NVIDIA HPC SDK
- NEC SDK
- Numerical libraries: LAPACK and BLAS, which are distributed for example as part of:
- OpenBLAS
- Intel oneAPI Math Kernel Library (part of Base Toolkit)
- NVIDIA HPC SDK
- NEC NLC (NEC Numeric Library Collection)
- An MPI (Message Passing Interface) implementation, e.g. in
- OpenMPI
- Intel MPI (part of Intel oneAPI HPC Toolkit)
- NVIDIA HPC SDK (OpenMPI)
- NEC MPI
Build library and applications
Similar to VASP also VASPml requires to enter compiler details and library paths into a file named makefile.include
before the build process can be started. Template files for this file can be found in the arch
subdirectory. Usually it is convenient to start from one of these files. Hence, first copy it to the base directory and rename it to makefile.include
, e.g.
cp arch/makefile.include.gnu makefile.include
Then modify the contents to reflect the compiler and library settings on your machine, for details see the compiler and linker options section below. Once done, the VASPml library can be built by executing this command in the top directory:
make -j
This will automatically build the two targets libvaspml
and applications
, and is equivalent of running two make commands explicitly in this order:
make libvaspml -j make applications -j
The libvaspml
target builds the library with same name and places it in the lib
folder. The applications
target compiles and links standalone applications present in src/applications
. At the moment there is only one application named vaspml-predict
which predicts energy, forces and stress for one POSCAR
file with a given ML_FF
force field file. The executable will be copied to the bin
directory.
With the -j
flag present make
will run the build process in parallel, starting as many parallel jobs as possible. You can limit the maximum load the build process is allowed to cause with the -l
flag, please review the documentation of GNU make
.
Compiler and linker options
The following compiler and linker options in the makefile.include
should be reviewed and eventually modified before starting the build process:
CXX
: This should be a C++17-compatible C++ compiler with MPI support.CXXFLAGS
: Specifies the flags for the C++ compiler.INCLUDE
: Paths in which to look for headers of required libraries. Here the include directory of BLAS should be listed.FC
(deprecated)FFLAGS
(deprecated)
Compile-time options
-DVASPML_DEBUG_LEVEL
: If set to 1, 2 or 3 enables various sanity checks during runtime with low, medium and high impact on performance, respectively.-DVASPML_USE_CBLAS
: Use CBLAS (C interface for BLAS routines) for linear algebra. This is the default and should always be used.-DVASPML_USE_MKL
: Use Intel MKL for linear algebra.-DVASPML_FORTRAN_MATH
(deprecated): Enable legacy Fortran math routines.
Makefile options
--no-color
: Disables colored output of makefiles.--no-logo
: Disables the logo VASPml logo output.
Automatic patching and compilations of LAMMPS
make lammps -j
Technical details
From a technical standpoint LAMMPS and VASPml interact in the following way: on the LAMMPS side a new class PairVASP
(inheriting from Pair
) is implemented in pair_vasp.cpp/h
. Its purpose is to transfer the neighbor lists to VASPml, trigger processing, and receive back the energy and force contributions. VASPml enters the received neighbor list data into its own structures and computes energy and force predictions according to the pre-trained machine-learned force field. A typical build for the combination of the two codes requires to first compile the libvaspml
library. Then, LAMMPS is patched with the additional pair_vasp.cpp/h
files, which are automatically compiled during the LAMMPS build. In the final stage, LAMMPS is linked to the libvaspml
library, resulting in a patched executable. This can be done manually but VASPml also offers a convenient automated way covering all steps (make lammps
).