Many-body dispersion library
Project description
Libmbd — many-body dispersion library
This project contains implementations of 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, and 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 implemntation 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 Libmbd
Libmbd uses CMake for building and installation, 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 building and installation can then proceed with
git clone https://github.com/azag0/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.
Tests can be run with
make check
Installing Pymbd
Pymbd links against Libmbd, which can be either installed on the system, or built on the fly by Pip/Setuptools. If the installed Libmbd is built with ScaLAPACK/MPI, the MPI
extras is required. For the Pip/Setuptools build, Fortran compiler must be available on the system (ScaLAPACK/MPI is not supported by the Setuptools build), and Numpy must be installed prior to installing Pymbd.
pip install numpy
pip install pymbd # or pymbd[MPI]
If you have Pytest installed, you can run tests with
pytest --pyargs pymbd -v --durations=3
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, mbd_calculation
type(mbd_input) :: inp
type(mbd_calculation) :: calc
real(dp) :: 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%get_energy(energy)
call calc%get_gradients(gradients)
call calc%destroy()
Developing
For development, Libmbd doesn't have to be installed on the system, and Pymbd can be linked against Libmbd in ./build
git clone https://github.com/azag0/libmbd.git && cd libmbd
mkdir build && cd build
cmake .. -DENABLE_SCALAPACK_MPI=ON
make
make check
cd ..
python3 -m venv venv && source venv/bin/activate
pip install cffi numpy scipy mpi4py
python setup.py build_ext -i
pytest -v --durations=3
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pymbd-0.4.0a7.tar.gz
.
File metadata
- Download URL: pymbd-0.4.0a7.tar.gz
- Upload date:
- Size: 58.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54a215291d15d957f3c934ac3474f7555f4c9950c0a5ecba20ae5f2de3318da0 |
|
MD5 | a22d18486345182986c3098ca5ea1e37 |
|
BLAKE2b-256 | 72a626f0ab1d8e023c32d3acf363e2e042e1a77f2443a4fddcf8780b9dbf6d3c |
File details
Details for the file pymbd-0.4.0a7-cp37-cp37m-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: pymbd-0.4.0a7-cp37-cp37m-macosx_10_14_x86_64.whl
- Upload date:
- Size: 395.3 kB
- Tags: CPython 3.7m, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19c5fdd058bb4fccfa1200e4f26d5a728be89b2c185064b41f6b649fc48943e4 |
|
MD5 | 390900f1e361391b019aa020f5f3a1ff |
|
BLAKE2b-256 | 39ef568e47dd4dbf9644bef02ec8105a31f4be07825c5e0efcbfbcfdd570c1d1 |