Installation#

The preferred method for installing this package is to use a binary release distributed with a package manager. If your preferred package manager is not available, you can also download the source code and build it yourself.

Installing from conda#

This project is packaged for the conda package manager and available on the conda-forge channel. To install the conda package manager we recommend the miniforge installer. If the conda-forge channel is not yet enabled, add it to your channels with

conda config --add channels conda-forge

Once the conda-forge channel has been enabled, this project can be installed with:

conda install simple-dftd3

If you want to enable the Python API as well install

conda install dftd3-python

It is possible to list all of the versions available on your platform with:

conda search simple-dftd3 --channel conda-forge

Now you are ready to use the s-dftd3 executable, find the dftd3.h header or import dftd3 in your Python projects.

Building from source#

This library depends on few Fortran modules to provide the desired functionality

  • mctc-lib: Modular computation tool chain library

  • mstore: Molecular structure store (testing only)

Meson based build#

The primary build system of this project is meson. For the full feature-complete build it is highly recommended to perform the build and development with meson. To setup a build the following software is required

  • A Fortran 2008 compliant compiler, like GCC Fortran and Intel Fortran classic

  • meson, version 0.55 or newer

  • ninja, version 1.7 or newer

Optional dependencies are

  • a linear algebra backend, like MKL or OpenBLAS

  • asciidoctor, to build the manual pages

  • A C compiler to test the C API and compile the Python extension module

  • Python 3.6 or newer with the CFFI package installed to build the Python API

To setup a new build run

meson setup _build --prefix=$HOME/.local

The Fortran and C compiler can be selected with the FC and CC environment variable, respectively. The installation location is selected using the --prefix option. The required Fortran modules will be fetched automatically from the upstream repositories and checked out in the subprojects directory.

Note

By default a redistributed version of the reference BLAS routines are used for matrix vector operations. To use a different BLAS library, the -Dblas option can be set.

For example, to use Intel MKL the custom option should be used and the libraries explicitly provided as in

meson setup _build --prefix=$HOME/.local -Dblas=custom -Dblas_libs="mkl_rt"

Tip

To produce statically linked binaries set --default-library=static and add -Dfortran_link_args=-static as well. To link statically against the MKL library, use the -Dblas_libs option to specify the required library names (-Dblas_libs=mkl_intel_lb64,mkl_intel_thread,mkl_core) If meson cannot find the mkl_intel_thread library, append -qopenmp to the -Dfortran_link_args option.

To compile the project run

meson compile -C _build

Verify that the resulting projects is working correctly by running the testsuite with

meson test -C _build --print-errorlogs

In case meson is spawning too many concurrent test jobs limit the number of processes with the --num-processes option when running the test command. By default the whole library and its subprojects are tested, to limit the testing to the project itself add --suite s-dftd3 as option.

To verify the included parametrizations are working correctly run the extra testsuite by passing the --benchmark argument

meson test -C _build --print-errorlogs --benchmark

Finally, you can make the project available by installation with

meson install -C _build

CMake based build#

This project also provides support for CMake to give projects using it as build system an easier way to interface. The CMake build files usually do not provide a feature-complete build, but contributions are more than welcome. To setup a build the following software is required

  • A Fortran 2008 compliant compiler, like GCC Fortran and Intel Fortran classic

  • cmake, version 3.14 or newer

  • ninja, version 1.10 or newer

Configure a new build with

cmake -B _build -G Ninja -DCMAKE_INSTALL_PREFIX=$HOME/.local

You can set the Fortran compiler in the FC environment variable. The installation location can be selected with the CMAKE_INSTALL_PREFIX, GNU install directories are supported by default. CMake will automatically fetch the required Fortran modules, you can provide specific version in the subprojects directory which will be used instead.

To run a build use

cmake --build _build

After a successful build make sure the testsuite passes

pushd _build && ctest --output-on-failure && popd

To make the project available install it with

cmake --install _build

Fpm based build#

This projects supports building with the Fortran package manager (fpm). Create a new build by running

fpm build

You can adjust the Fortran compiler with the --compiler option and select the compilation profile with --profile release. To test the resulting build run the testsuite with

fpm test

The command line driver can be directly used from fpm wih

fpm run --profile release -- --help

To make the installation accessible install the project with

fpm install --profile release --prefix $HOME/.local

Python extension module#

The Python API is available as Python extension module. The easiest way to setup is to add -Dpython=true to a meson tree build and follow the meson installation instructions. The extension module will become available once the project is installed.

This section describes alternative ways to build the Python API

Using pip#

This project support installation with pip as an easy way to build the Python API.

  • C compiler to build the C-API and compile the extension module (the compiler name should be exported in the CC environment variable)

  • Python 3.6 or newer

  • The following Python packages are required additionally

Make sure to have your C compiler set to the CC environment variable

export CC=gcc

Install the project with pip

pip install .

To install extra dependencies as well use

pip install '.[ase]'

Using meson#

The Python extension module can be built on-top of an existing installation, either provided by meson or CMake.

Building requires against an existing s-dftd3 installation requires

  • C compiler to build the C-API and compile the extension module

  • meson version 0.55 or newer

  • a build-system backend, i.e. ninja version 1.7 or newer

  • Python 3.6 or newer with the CFFI package installed

Setup a build with

meson setup _build_python python -Dpython_version=3

The Python version can be used to select a different Python version, it defaults to '3'. Python 2 is not supported with this project, the Python version key is meant to select between several local Python 3 versions.

Compile the project with

meson compile -C _build

The extension module is now available in _build_python/dftd3/_libdftd3.*.so. You can install as usual with

meson configure _build --prefix=/path/to/install
meson install -C _build