Skip to main content

Light-weight tight-binding framework

Project description

This directory contains the Python API of the tblite project.

This interface provides access to the C-API of tblite via the CFFI module. The low-level CFFI interface is available in the tblite.library module and only required for implementing other interfaces. A more pythonic interface is provided in the tblite.interface module which can be used to build more specific interfaces.

from tblite.interface import Calculator
import numpy as np
numbers = np.array([1, 1, 6, 5, 1, 15, 8, 17, 13, 15, 5, 1, 9, 15, 1, 15])
positions = np.array([  # Coordinates in Bohr
    [+2.79274810283778, +3.82998228828316, -2.79287054959216],
    [-1.43447454186833, +0.43418729987882, +5.53854345129809],
    [-3.26268343665218, -2.50644032426151, -1.56631149351046],
    [+2.14548759959147, -0.88798018953965, -2.24592534506187],
    [-4.30233097423181, -3.93631518670031, -0.48930754109119],
    [+0.06107643564880, -3.82467931731366, -2.22333344469482],
    [+0.41168550401858, +0.58105573172764, +5.56854609916143],
    [+4.41363836635653, +3.92515871809283, +2.57961724984000],
    [+1.33707758998700, +1.40194471661647, +1.97530004949523],
    [+3.08342709834868, +1.72520024666801, -4.42666116106828],
    [-3.02346932078505, +0.04438199934191, -0.27636197425010],
    [+1.11508390868455, -0.97617412809198, +6.25462847718180],
    [+0.61938955433011, +2.17903547389232, -6.21279842416963],
    [-2.67491681346835, +3.00175899761859, +1.05038813614845],
    [-4.13181080289514, -2.34226739863660, -3.44356159392859],
    [+2.85007173009739, -2.64884892757600, +0.71010806424206],
])
calc = Calculator("GFN2-xTB", numbers, positions)
res = calc.singlepoint()
print(res.get("energy"))  # Results in atomic units
# => -31.716159156026254

Building the extension module

The Python bindings can be built against an existing installation of tblite or free-standing. The free-standing implementation will select a matching version of the shared library, when building against an existing tblite library the API version of the two parts must match.

Setuptools build

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

Ensure that you can find tblite via

pkg-config --modversion tblite

Adjust the PKG_CONFIG_PATH environment variable to include the correct directories to find the installation if necessary. Alternatively, you can set the TBLITE_PREFIX environment variable to point to the installation of the library.

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

export CC=gcc

Install the project with pip

pip install .

Using meson

This directory contains a separate meson build file to allow the out-of-tree build of the CFFI extension module. The out-of-tree build requires

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

  • meson version 0.57.2 or newer

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

  • Python 3.6 or newer with the CFFI package installed

To make a free-standing build you can provide the main repository as subproject to the Python bindings without having to build the shared library first. This can be done for example by symlinking the main repository to the subprojects directory.

mkdir subprojects
ln -s $(realpath ..) subprojects/tblite

Note that this step is not needed if you built against an existing tblite installation.

Setup a build with

meson setup _build -Dpython_version=$(which python3) --prefix=/path/to/install

The Python version can be used to select a different Python version, it defaults to 'python3'. 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/tblite/_libtblite.*.so. You can install as usual with

meson install -C _build

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

tblite-0.3.0.tar.gz (508.3 kB view details)

Uploaded Source

Built Distributions

tblite-0.3.0-cp311-cp311-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.8 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.12+ x86-64

tblite-0.3.0-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.8 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.12+ x86-64

tblite-0.3.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.8 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

tblite-0.3.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.8 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

tblite-0.3.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.8 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

File details

Details for the file tblite-0.3.0.tar.gz.

File metadata

  • Download URL: tblite-0.3.0.tar.gz
  • Upload date:
  • Size: 508.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for tblite-0.3.0.tar.gz
Algorithm Hash digest
SHA256 48654770b2681a354d9f6a849c5bc903b94a18c39c25c61754807d8add1ad7a9
MD5 63454244d4003715ece70984363d60e8
BLAKE2b-256 6860bf86102ff8ac11d3011cb69786eeaa252eef416d547615292071b78caba1

See more details on using hashes here.

File details

Details for the file tblite-0.3.0-cp311-cp311-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for tblite-0.3.0-cp311-cp311-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 74c777d003c8d451b3a0f6cf47368f6afab84a7407e7fea5768134d1307f3541
MD5 44b1c1a725fa34d87010022e52a2e223
BLAKE2b-256 dcf4ba3c37206455ff247c299e57d0826816e8d79000a1aef6ec881eff9ab04b

See more details on using hashes here.

File details

Details for the file tblite-0.3.0-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for tblite-0.3.0-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 ee718f22ae24adf109d3cc1ee03cc427170cabb02ba4d11660be08bfc32d6022
MD5 e2131eb7e8761de294e7560f961de764
BLAKE2b-256 0dea7143a0c1dffc31ae0a558476c44e7f11ff6c972b49b2b84506f82bf5edc5

See more details on using hashes here.

File details

Details for the file tblite-0.3.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for tblite-0.3.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 7e4a4edb0c6c6f810991ac810ee5e68d5b71d382783dea81da9e10d6aa6185d8
MD5 68b2ccf801f123733e50b6afa64a6845
BLAKE2b-256 c34631aaea74c695b860ad177baa127344b784649d1983482b29492f26448b7f

See more details on using hashes here.

File details

Details for the file tblite-0.3.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for tblite-0.3.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 7d4e6e2a68314f4495dbba52c967c97f606100f200a46ec2376c67857e45365b
MD5 1e230e87a1a1f73ddfabfd082381a562
BLAKE2b-256 9c21caaf87040efbf27c5571bad455e2d07c459bd2852f291bd28deffd2653a7

See more details on using hashes here.

File details

Details for the file tblite-0.3.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for tblite-0.3.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 a6f0789da1b21ba0a910d354b439cc2f8315a7d3d50cf2153b6ea041a9234ca0
MD5 d20bd3179ee01754257d1080aeef5fc7
BLAKE2b-256 4e0154bebbe0fa158c77687f24a9a6e39038cbbd65850e6eb4dedb5255bf162a

See more details on using hashes here.

Supported by

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