Skip to main content

Many-body dispersion library

Project description

Libmbd

build coverage python release conda pypi commits since last commit license code style

Libmbd implements the many-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.

Installing Pymbd

The easiest way to get Pymbd is to install the Pymbd Conda package, which ships with pre-built Libmbd.

conda install -c libmbd pymbd

Alternatively, if you have Libmbd already installed on your system (see below), you can install Pymbd with Pip, in which case it links against the installed Libmbd. To support Libmbd built with ScaLAPACK/MPI, the mpi extras is required, which installs mpi4py as an extra dependency.

pip install pymbd  # or pymbd[mpi]

If Libmbd is installed in a non-standard location, you can point Pymbd to it with

env LIBMBD_PREFIX=<path to Libmbd> pip install pymbd

If you don’t need the Fortran bindings in Pymbd, you can install it without the C extension, in which case pymbd.fortran becomes unimportable:

env LIBMBD_PREFIX= pip install pymbd

Installing Libmbd

Libmbd uses CMake for compiling and installing, and requires a Fortran compiler, LAPACK, and optionally ScaLAPACK/MPI.

On Ubuntu:

apt-get install gfortran libblas-dev liblapack-dev [mpi-default-dev mpi-default-bin libscalapack-mpi-dev]

On macOS:

brew install gcc [open-mpi scalapack]

The compiling and installation can then proceed with

git clone https://github.com/jhrmnn/libmbd.git && cd libmbd
mkdir build && cd build
cmake .. [-DENABLE_SCALAPACK_MPI=ON]
make
make install

This installs the Libmbd shared library, C API header file, and high-level Fortran API module file.

Examples

from pymbd import mbd_energy_species, ang
from pymbd.fortran import MBDCalc

ene_py = mbd_energy_species(  # pure Python implementation
    [(0, 0, 0), (0, 0, 4*ang)], ['Ar', 'Ar'], [1, 1], 0.83
)
with MBDCalc() as calc:
    ene_f = calc.mbd_energy_species(  # Fortran implementation
        [(0, 0, 0), (0, 0, 4*ang)], ['Ar', 'Ar'], [1, 1], 0.83
    )
assert abs(ene_f-ene_py) < 1e-15
use mbd, only: mbd_input_t, mbd_calc_t

type(mbd_input_t) :: inp
type(mbd_calc_t) :: calc
real(8) :: energy, gradients(3, 2)
integer :: code
character(200) :: origin, msg

inp%atom_types = ['Ar', 'Ar']
inp%coords = reshape([0d0, 0d0, 0d0, 0d0, 0d0, 7.5d0], [3, 2])
inp%xc = 'pbe'
call calc%init(inp)
call calc%get_exception(code, origin, msg)
if (code > 0) then
    print *, msg
    stop
end if
call calc%update_vdw_params_from_ratios([0.98d0, 0.98d0])
call calc%evaluate_vdw_method(energy)
call calc%get_gradients(gradients)
call calc%destroy()

Links

Developing

For development, Libmbd doesn't have to be installed on the system, and Pymbd can be linked against local installation of Libmbd.

git clone https://github.com/jhrmnn/libmbd.git && cd libmbd
python3 -m venv venv && source venv/bin/activate
make
# development work...
make

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymbd-0.9.2.tar.gz (27.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymbd-0.9.2-cp37-cp37m-macosx_10_15_x86_64.whl (35.8 kB view details)

Uploaded CPython 3.7mmacOS 10.15+ x86-64

File details

Details for the file pymbd-0.9.2.tar.gz.

File metadata

  • Download URL: pymbd-0.9.2.tar.gz
  • Upload date:
  • Size: 27.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.9 CPython/3.7.7 Darwin/19.5.0

File hashes

Hashes for pymbd-0.9.2.tar.gz
Algorithm Hash digest
SHA256 85403305ca809f6883439aadd6ebdb294e69222dab62784c9c52f79708da1684
MD5 e74ed05322c34f9f4d1056e49e91a457
BLAKE2b-256 8fa9e080095ba3f9bb569f55944e17e9475fe507611450530e185640dabc94ac

See more details on using hashes here.

File details

Details for the file pymbd-0.9.2-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: pymbd-0.9.2-cp37-cp37m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 35.8 kB
  • Tags: CPython 3.7m, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.9 CPython/3.7.7 Darwin/19.5.0

File hashes

Hashes for pymbd-0.9.2-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 d9594be1d0112f4a452c3a0ad3c194f751973ba92c8652fa518c2f2b21a6f616
MD5 14a8d66e3516ba7aac21baa032807087
BLAKE2b-256 18114a15d65664f4009682a060cbe68964f140a92bf7b194eca324fb3240db1d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page