Package: pymbd
libMBDlibMBD: A general-purpose package for scalable quantum many-body dispersion calculations.J. Hermann,M. Stöhr, S. Góger,S. Chaudhuri,B. Aradi,R. J. Maurer& A. Tkatchenko.J. Chem. Phys.159, 174802(2023)libMBD implements themany-body dispersion(MBD) method in several programming languages and frameworks:The Fortran implementation is the reference, most advanced implementation, with support for analytical gradients and distributed parallelism, and additional functionality beyond the MBD method itself. It provides a low-level and a high-level Fortran API, as well as a C API. Furthermore, Python bindings to the C API are provided.The Python/Numpy implementation is intended for prototyping, and as a high-level language reference.The Python/Tensorflow implementation is an experiment that should enable rapid prototyping of machine learning applications with MBD.The Python-based implementations as well as Python bindings to the libMBD C API are accessible from the Python package called pyMBD.libMBD is included inFHI-aims,Quantum Espresso,DFTB+, andESL Bundle.InstallingTL;DRInstall prebuilt libMBD binaries viaConda-forgeand pyMBD withPip.conda install -c conda-forge libmbd
pip install pymbdOne can also install the ScaLAPACK/MPI version.conda install -c conda-forge 'libmbd=*=mpi_*' mpi4py
pip install pymbd[mpi]Verify installation with$ python -m pymbd
Expected energy:   -0.0002462647623815428
Calculated energy: -0.0002462647623817456libMBDlibMBD uses CMake for compiling and installing, and requires a Fortran compiler, LAPACK, and optionally ScaLAPACK/MPI.On Ubuntu:apt-getinstallgfortranlibblas-devliblapack-dev[mpi-default-devmpi-default-binlibscalapack-mpi-dev]On macOS:brewinstallgcc[open-mpiscalapack]The compiling and installation can then proceed withcmake -B build [-DENABLE_SCALAPACK_MPI=ON]
make -C build install
[ctest --test-dir build]This installs the libMBD shared library, C API header file,  high-level Fortran API module file, and Cmake package files, and optionally runs tests.pyMBDpyMBD can be installed and updated usingPip, but requires installed libMBD as a dependency (see above).pip install pymbdTo support libMBD built with ScaLAPACK/MPI, thempiextras is required, which installsmpi4pyas an extra dependency. In this case one has to make sure thatmpi4pyis linked against the same MPI library as libMBD (for instance by compiling both manually, or installing both via Conda-forge).pip install pymbd[mpi]If libMBD is installed in a non-standard location, you can point pyMBD to it withenv LIBMBD_PREFIX=<path to libMBD install prefix> pip install pymbdIf you don’t need the Fortran bindings in pyMBD, you can install it without the C extension, in which casepymbd.fortranbecomes unimportable:env LIBMBD_PREFIX= pip install pymbdExamplesfrompymbdimportmbd_energy_speciesfrompymbd.fortranimportMBDGeom# pure Python implementationenergy=mbd_energy_species([(0,0,0),(0,0,7.5)],['Ar','Ar'],[1,1],0.83)# Fortran implementationenergy=MBDGeom([(0,0,0),(0,0,7.5)]).mbd_energy_species(['Ar','Ar'],[1,1],0.83)usembd,only:mbd_input_t,mbd_calc_tuseiso_fortran_env,only:real64type(mbd_input_t)::inptype(mbd_calc_t)::calcreal(real64)::energy,gradients(3,2)integer::codecharacter(200)::origin,msginp%atom_types=['Ar','Ar']inp%coords=reshape([0d0,0d0,0d0,0d0,0d0,7.5d0],[3,2])inp%xc='pbe'callcalc%init(inp)callcalc%get_exception(code,origin,msg)if(code>0)thenprint*,msgstop1end ifcallcalc%update_vdw_params_from_ratios([0.98d0,0.98d0])callcalc%evaluate_vdw_method(energy)callcalc%get_gradients(gradients)callcalc%destroy()LinkslibMBD documentation:https://libmbd.github.iopyMBD documentation:https://libmbd.github.io/pymbdDevelopingFor development, a top-levelMakefileis included, which configures and compiles libMBD, compiles the pyMBD C extension, and runs both libMBD and pyMBD tests.git clone https://github.com/libmbd/libmbd.git && cd libmbd
python3 -m venv venv && source venv/bin/activate
make
# development work...
make