Skip to main content

GFN-FF

A general force field for elements Z = 1–103

build status PyPI version conda-forge version Documentation License: LGPL v3

A standalone library implementation of the GFN-FF method by S. Spicher and S. Grimme, adapted from the xtb code (most recently at commit 6d44803 and validated against that version's results). It is meant to be linked into other Fortran, C, and C++ projects, and it also ships Python bindings. From this point forward, development may diverge from the upstream xtb implementation. As of version v0.3.0 of this repository divergence is the case in order to add analytical Hessians and other features.

GFN-FF (Geometries, Frequencies, Non-covalent interactions Force-Field) is a completely automated, topology-based force field for fast structure optimisations and non-covalent interaction energies. The topology and parametrisation are derived entirely from the input geometry, without user-defined atom types or connectivity.

Quick start

pip install "gfnff[ase]"
from ase.build import molecule
from gfnff import GFNFF

atoms = molecule("caffeine")
atoms.calc = GFNFF()

energy = atoms.get_potential_energy()   # eV
forces = atoms.get_forces()             # eV / Å

The same install provides a command-line tool:

gfnff molecule.xyz --opt --alpb h2o

Documentation

The documentation is hosted at https://pprcht.github.io/gfnff/. It contains the guides listed below and a Python API reference generated from the docstrings.

Topic Page
Fortran, C and C++ interfaces, periodic systems, use as a CMake or Meson subproject docs/library.md
Python: installation, command-line tool, GFNFFCalculator, ASE calculator, Hessians docs/python.md
Force-field versions, conformer2020, custom parameter files, user-supplied molecular graphs docs/parametrisation.md
Benchmarks and choice of BLAS backend docs/performance.md
TOML parameter file format param/README.md
Python API reference pprcht.github.io/gfnff

Building from source

The library requires a Fortran and C compiler (e.g. gfortran/gcc), LAPACK/BLAS (e.g. OpenBLAS), and optionally OpenMP. Both CMake (≥ 3.21) and Meson (≥ 0.59) are supported.

CMake Meson
Build cmake -B _build
cmake --build _build
meson setup _build
ninja -C _build
Test cmake -B _build -DWITH_TESTS=ON
cmake --build _build
ctest --test-dir _build
meson setup _build -Dtests=true
ninja -C _build test

The compiled library (libgfnff.a by default) is placed in the build directory and can be linked into any downstream project.

Using the library

Initialise a calculator once (topology setup, the expensive step), then call the singlepoint routine as often as needed:

use gfnff_interface
type(gfnff_data) :: calc

call calc%init(nat, at, xyz, ichrg=ichrg, iostat=io)
call calc%singlepoint(nat, at, xyz, energy, gradient, iostat=io, sigma=sigma)
call calc%deallocate()

Coordinates are in Bohr, energies in Hartree, gradients in Eh/Bohr. The C/C++ header include/gfnff_interface_c.h mirrors these calls; see docs/library.md.

Performance

GFN-FF benchmark

Caffeine clusters from 24 to 1536 atoms on 8 cores. Energy and gradient are 1.2–1.6x faster than the pre-refactor code from 192 atoms upwards, and the analytic Hessian is 28x (24 atoms) to 59x (768 atoms) faster than finite differences. Hessian speed depends mainly on the BLAS backend; details are in docs/performance.md.

References

  • Molecular GFN-FF, a generic, partially polarisable force field covering organic, organometallic, and biochemical systems: S. Spicher, S. Grimme, Angew. Chem. Int. Ed. 2020, 59, 15665. doi:10.1002/anie.202004239
  • Periodic boundary conditions and molecular crystals, with adjusted non-covalent interactions for lattice energies and unit-cell optimisations: S. Grimme, T. Rose, Z. Naturforsch. B 2024, 79, 191. doi:10.1515/znb-2023-0088
  • Lanthanide and actinide extension, a reparametrised f-element treatment: T. Rose, M. Bursch, J.-M. Mewes, S. Grimme, Inorg. Chem. 2024. doi:10.1021/acs.inorgchem.4c03215

License

This project is licensed (as the original xtb code) under the GNU Lesser General Public License v3 or later. See LICENSE for details.

Metadata

Release files for gfnff 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gfnff 0.3.0
File Size Uploaded
gfnff-0.3.0.tar.gz 935.2 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for gfnff 0.3.0
File Interpreter ABI Platform
gfnff-0.3.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
gfnff-0.3.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.27+ ARM64, Linux glibc 2.28+ ARM64 Details
gfnff-0.3.0-py3-none-macosx_14_0_arm64.whl Python 3 none macOS 14.0+ ARM64 Details

Total release size: 36.1 MB

Release files / gfnff-0.3.0.tar.gz

Download URL gfnff-0.3.0.tar.gz
Size 935.2 kB
Tags Source
SHA-256 checksum
How to use checksums
06044345a7143135f97cba973de32b3212036807cc686152c1084d5f59812bb9
BLAKE2b-256 checksum
How to use checksums
9588293d3b9c99f8a3669693a7d9c6777149e64cc563321cd2c99ef6f221764f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release files / gfnff-0.3.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL gfnff-0.3.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 17.8 MB
Tags Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
f443d33280b2ec157c41d33de404503482a203b72630838818758e066ccbf818
BLAKE2b-256 checksum
How to use checksums
f2ce3eee2ef3e037359f1a2ff45b3d88d11bdf4a9023aaa6c2dc16764065e1bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release files / gfnff-0.3.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL gfnff-0.3.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 10.6 MB
Tags Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
b030f8d6c41934995d859e07e76692ecdabf92b70178f40ef620d9910d31dcd5
BLAKE2b-256 checksum
How to use checksums
e44cbe8b73c85b7d2c7e6e33577ca47c3c1ed11614bf6d8bedea9f9766a5afb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release files / gfnff-0.3.0-py3-none-macosx_14_0_arm64.whl

Download URL gfnff-0.3.0-py3-none-macosx_14_0_arm64.whl
Size 6.7 MB
Tags Python 3 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
df4e1f4d28ce1f85fe5544cbebc03c49485c2f51fdfa17a90bfb3a2d2b2ef359
BLAKE2b-256 checksum
How to use checksums
d2062876ea97d0dd74f80471333f6856c73ccd06f5a4ce80518a0c8968127cd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

4 release files

0.2.0

12 release files

0.1.1

12 release files

0.1.0

12 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page