{"id":18574525,"url":"https://github.com/dftd4/dftd4","last_synced_at":"2026-03-08T09:35:52.528Z","repository":{"id":37892688,"uuid":"173139980","full_name":"dftd4/dftd4","owner":"dftd4","description":"Generally Applicable Atomic-Charge Dependent London Dispersion Correction ","archived":false,"fork":false,"pushed_at":"2025-02-13T15:29:50.000Z","size":1642,"stargazers_count":172,"open_issues_count":12,"forks_count":51,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-02-13T16:36:20.487Z","etag":null,"topics":["ase","computational-chemistry","dispersion-correction","fortran-package-manager","pyscf","qcschema","quantum-chemistry"],"latest_commit_sha":null,"homepage":"https://dftd4.readthedocs.io","language":"Fortran","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dftd4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.bib","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-28T15:45:22.000Z","updated_at":"2025-02-13T15:29:18.000Z","dependencies_parsed_at":"2023-02-18T23:15:20.898Z","dependency_job_id":"27a52108-f8f9-47ea-b616-b0f1167a71f8","html_url":"https://github.com/dftd4/dftd4","commit_stats":{"total_commits":188,"total_committers":16,"mean_commits":11.75,"dds":"0.18085106382978722","last_synced_commit":"bd278d442789cbca13187f7d19dfeded793e8e2d"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dftd4%2Fdftd4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dftd4%2Fdftd4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dftd4%2Fdftd4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dftd4%2Fdftd4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dftd4","download_url":"https://codeload.github.com/dftd4/dftd4/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239311299,"owners_count":19618008,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ase","computational-chemistry","dispersion-correction","fortran-package-manager","pyscf","qcschema","quantum-chemistry"],"created_at":"2024-11-06T23:15:42.165Z","updated_at":"2026-03-08T09:35:52.517Z","avatar_url":"https://github.com/dftd4.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"DFT-D4 project\n==============\n\n[![License](https://img.shields.io/github/license/dftd4/dftd4?cacheSeconds=86400)](https://github.com/dftd4/dftd4/blob/main/COPYING.LESSER)\n[![Latest Version](https://img.shields.io/github/v/release/dftd4/dftd4)](https://github.com/dftd4/dftd4/releases/latest)\n[![Build Status](https://github.com/dftd4/dftd4/workflows/CI/badge.svg)](https://github.com/dftd4/dftd4/actions)\n[![Documentation Status](https://readthedocs.org/projects/dftd4/badge/?version=latest)](https://dftd4.readthedocs.io/en/latest/?badge=latest)\n[![docs](https://github.com/dftd4/dftd4/workflows/docs/badge.svg)](https://dftd4.github.io/dftd4/)\n[![codecov](https://codecov.io/gh/dftd4/dftd4/branch/main/graph/badge.svg?token=IFtEF1Hwqj)](https://codecov.io/gh/dftd4/dftd4)\n\nGenerally Applicable Atomic-Charge Dependent London Dispersion Correction.\n\n\n## Installing\n\nA statically linked binary distribution for Linux platforms is available at the [latest release](https://github.com/dftd4/dftd4/releases/latest) tag.\n\n\n### Conda package\n\n[![Conda Version](https://img.shields.io/conda/vn/conda-forge/dftd4.svg?label=dftd4)](https://anaconda.org/conda-forge/dftd4)\n[![Conda Version](https://img.shields.io/conda/vn/conda-forge/dftd4-python.svg?label=dftd4-python)](https://anaconda.org/conda-forge/dftd4-python)\n\nThis project is packaged for the *conda* package manager and available on the *conda-forge* channel.\nTo install the *conda* package manager we recommend the [miniforge](https://github.com/conda-forge/miniforge/releases) installer.\nIf the *conda-forge* channel is not yet enabled, add it to your channels with\n\n```\nconda config --add channels conda-forge\n```\n\nOnce the *conda-forge* channel has been enabled, this project can be installed with:\n\n```\nconda install dftd4\n```\n\nIf you want to enable the Python API as well install\n\n```\nconda install dftd4-python\n```\n\nIt is possible to list all of the versions available on your platform with:\n\n```\nconda search dftd4 --channel conda-forge\n```\n\nNow you are ready to use `dftd4`.\n\n\n### Spack package\n\n[![Spack](https://img.shields.io/spack/v/dftd4)](https://packages.spack.io/package.html?name=dftd4)\n\nThis project is available with [spack](https://spack.io) in its develop version.\nYou can install and load `dftd4` with\n\n```\nspack install dftd4\nspack load dftd4\n```\n\nThe Python API can be enabled by adding `+python` to the command.\n\n\n### FreeBSD Port\n\n[![FreeBSD port](https://repology.org/badge/version-for-repo/freebsd/dftd4.svg)](https://www.freshports.org/science/dftd4/)\n\nA port for FreeBSD is available and can be installed using\n\n```\npkg install science/dftd4\n```\n\nIn case no package is available build the port using\n\n```\ncd /usr/ports/science/dftd4\nmake install clean\n```\n\nFor more information see the [dftd4 port details](https://www.freshports.org/science/dftd4/).\n\n\n\n### Building from Source\n\nTo build this project from the source code in this repository you need to have\na Fortran compiler supporting Fortran 2008 and one of the supported build systems:\n- [meson](https://mesonbuild.com) version 0.55 or newer, with\n  a build-system backend, *i.e.* [ninja](https://ninja-build.org) version 1.7 or newer\n- [cmake](https://cmake.org) version 3.14 or newer, with\n  a build-system backend, *i.e.* [ninja](https://ninja-build.org) version 1.10 or newer\n- [fpm](https://github.com/fortran-lang/fpm) version 0.2.0 or newer\n\nCurrently this project supports GCC and Intel compilers.\n\n\u003cdetails\u003e\n\u003csummary\u003eProblematic Versions\u003c/summary\u003e\n\nGCC versions 15.0.x - 15.1.x contain a [compiler bug](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119928) leading to \"Interface mismatch\" errors during compilation.\n\n\u003c/details\u003e\n\n\n#### Building with meson\n\nTo compile this version of DFT-D4 with meson the following programs are needed\n(the number in parentheses specifies the tested versions).\n\nTo build this project from the source code in this repository you need to have\n- a Fortran compiler supporting Fortran 2008\n- [meson](https://mesonbuild.com) version 0.55 or newer\n- a build-system backend, *i.e.* [ninja](https://ninja-build.org) version 1.7 or newer\n- a LAPACK / BLAS provider, like MKL or OpenBLAS\n\nOptional dependencies are\n- asciidoctor to build the manual page\n- FORD to build the developer documentation\n- C compiler to test the C-API and compile the Python extension module\n- Python 3.6 or newer with the CFFI package installed to build the Python API\n\nSetup a build with\n\n```sh\nmeson setup _build\n```\n\nYou can select the Fortran compiler by the `FC` environment variable.\nTo compile and run the projects testsuite use\n\n```sh\nmeson test -C _build --print-errorlogs\n```\n\nIf the testsuite passes you can install with\n\n```sh\nmeson configure _build --prefix=/path/to/install\nmeson install -C _build\n```\n\nThis might require administrator access depending on the chosen install prefix.\n\n\n#### Building with CMake\n\nAlternatively, this project can be build with CMake (in this case ninja 1.10 or newer is required):\n\n```\ncmake -B _build -G Ninja -DCMAKE_INSTALL_PREFIX=$HOME/.local\n```\n\nTo compile the project with CMake run\n\n```\ncmake --build _build\n```\n\nYou can run the project testsuite with\n\n```\nctest --test-dir _build --parallel --output-on-failure\n```\n\nFinally, you can install the project to the selected prefix\n\n```\ncmake --install _build\n```\n\nNote that the CMake build does not support to build the Python extension module as part of the main build.\n\n\n#### Building with fpm\n\nThis project support the Fortran package manager (fpm).\nInvoke fpm in the project root with\n\n```\nfpm build\n```\n\nTo run the testsuite use\n\n```\nfpm test\n```\n\nYou can access the ``dftd4`` program using the run subcommand\n\n```\nfpm run -- --help\n```\n\nTo use ``dftd4`` for testing include it as dependency in your package manifest\n\n```toml\n[dependencies]\ndftd4.git = \"https://github.com/dftd4/dftd4\"\n```\n\nNote that the fpm build does not support exporting the C-API, it only provides access to the standalone binary.\n\n\n## Usage\n\nDFT-D4 calculations can be performed with the `dftd4` executable.\nTo calculate the dispersion correction for PBE0-D4 run:\n\n```sh\ndftd4 --func pbe0 coord\n```\n\nIn case you want to access the DFT-D4 results from other programs, dump the results to JSON with\n(the `--noedisp` flag prevents the `.EDISP` file generation):\n\n```sh\ndftd4 --func pbe0 --json --grad --noedisp struct.xyz\n```\n\nDispersion related properties can be calculated as well:\n\n```sh\ndftd4 --property geo.gen\n```\n\nTo evaluate pairwise resolved dispersion energies use\n\n```sh\ndftd4 --pair-resolved mol.xyz\n```\n\nFor an overview over all command line arguments use the `--help` argument or checkout the [`dftd4(1)`](https://github.com/dftd4/dftd4/blob/main/man/dftd4.1.adoc) manpage.\n\n\n### Parallelism\n\nDFT-D4 calculations can be performed with shared-memory parallelism (OpenMP).\n\nThe number of parallel threads can be set through environment variables.\n\n```sh\nexport OMP_NUM_THREADS=4\nexport MKL_NUM_THREADS=4  # Intel\n```\n\nFor large calculations, additional speed-ups might be possible by enabling dynamic scheduling in OMP by setting `OMP_SCHEDULE=dynamic`.\nThis might help particularly for versions \u003c4.0.0 ([explanation](https://github.com/dftd4/dftd4/pull/319)).\n\nNote that DFT-D4 is not MPI parallelized, and there are currently no plans to implement MPI parallelism.\n\n\n## Parameters\n\nDFT-D4 is parametrized for plenty of density functionals.\nThe available parameters are listed in the [parameters.toml file](https://github.com/dftd4/dftd4/blob/main/assets/parameters.toml) or with the following command.\n\n```sh\ndftd4 param --list\n```\n\nWhile the functionals can be selected with their common names (e.g., `PBE`), the [libxc](https://www.tddft.org/programs/libxc/functionals/) names can also be used (e.g., `GGA_X_PBE:GGA_C_PBE`).\n\n```sh\ndftd4 --func PBE coord\ndftd4 --func GGA_X_PBE:GGA_C_PBE coord\n```\n\nThe exchange and correlation functional must be separated by a colon.\nAll names are case-insensitive.\n\n\u003cdetails\u003e\n\u003csummary\u003eNote on ωB97X-type functionals\u003c/summary\u003e\n\nSince there has been some confusion concerning the different ωB97X functionals, we provide a detailed summary: \n\n- [ωB97X](https://doi.org/10.1063/1.2834918) (original functional, 2008, parameters: `wb97x-2008`)\n- [ωB97X-D](https://doi.org/10.1039/B810189B) (re-optimization of ωB97X to include dispersion correction, 2008, no D4 parameters)\n- [ωB97X-D3](https://doi.org/10.1021/ct300715s) (re-optimization of ωB97X-D with improved dispersion corrections, D3(0), 2013, no D4 parameters)\n- [ωB97X-V](https://doi.org/10.1039/C3CP54374A) (new functional, different from the above ωB97X's and not just a re-optimization for VV10 dispersion, 2013)\n- [ωB97X-D4](https://doi.org/10.1002/jcc.26411) (ωB97X-V with D4 dispersion instead of VV10 dispersion, parameters: `wb97x`)\n- [ωB97X-D4rev](https://doi.org/10.1063/5.0133026) (revised D4 parameters for ωB97X-V with D4 dispersion instead of VV10 dispersion, parameters: `wb97x-rev`)\n- [ωB97X-3c](https://doi.org/10.1063/5.0133026) (Composite \"3c\" method based on ωB97X-V, parameters: `wb97x-3c`)\n\nNote that the ωB97X parameters (`wb97x-2008`) cannot be used for the ωB97X-V functional (`wb97x`, `wb97x-rev`).\n\nWe recommend the revised D4 parameters for ωB97X-V (`wb97x-rev`).\n\n\u003c/details\u003e\n\n\u003cbr\u003e\n\nYou can add new functionals using to the TOML file by adding a new subtable\n\n```toml\n[parameter.name]\nreference.doi = [\"\u003cfunctional reference\u003e\"]\nd4.bj-eeq-atm = { s8=1.0, a1=0.4, a2=5.0, doi=\"\u003cparameter reference\u003e\" }\n```\n\nThose parameters are currently only used as reference and not yet usable in the library or executable.\n\n\n## API access\n\nThe DFT-D4 project provides first class API support Fortran, C and Python.\nOther programming languages should try to interface with to DFT-D4 via one of those three APIs.\nTo provide first class API support for a new language the interface specification should be available as meson build files.\n\nThe `dftd4` binary provides with the `--json` option access to all quantities available from the APIs as well.\n\n\n### Fortran API\n\nThe recommended way to access the Fortran module API is by using `dftd4` as a meson subproject.\nAlternatively, the project is accessible by the Fortran package manager ([fpm](https://github.com/fortran-lang/fpm)).\n\nThe complete API is available from `dftd4` module, the individual modules are available to the user as well but are not part of the public API and therefore not guaranteed to remain stable.\nABI compatibility is only guaranteed for the same minor version.\n\nThe communication with the Fortran API uses the `error_type` and `structure_type` of the modular computation tool chain library (mctc-lib) to handle errors and represent geometries, respectively.\n\n\n#### Building Vasp with support for D4\n\nTo use ``dftd4`` in Vasp the compatibility layer for the 2.5.x API has to be enable with ``-Dapi_v2=true`` (meson) or ``-DWITH_API_V2=ON`` (CMake).\nIt is important to build ``dftd4`` with the same Fortran compiler you build Vasp with.\n\nAfter you completed the installation of ``dftd4``, make sure it is findable by ``pkg-config``, you can check by running:\n\n```\npkg-config --modversion dftd4\n```\n\nIf your ``dftd4`` installation is not findable, you have to update your environment variables.\nOne option is to provide a module file for your ``dftd4`` installation.\nThe example module file below can be placed in your ``MODULEPATH`` to provide access to an installation in ``~/opt/dftd4/4.0.2``.\nRetry the above comment after loading the ``dftd4`` module and adjust the module file until ``pkg-config`` finds your installation.\n\n```lua\n-- dftd4/4.0.2.lua\nlocal name = \"dftd4\"\nlocal version = \"4.0.2\"\nlocal prefix = pathJoin(os.getenv(\"HOME\"), \"opt\", name, version)\nlocal libdir = \"lib\"  -- or lib64\n\nwhatis(\"Name        : \" .. name)\nwhatis(\"Version     : \" .. version)\nwhatis(\"Description : Generally applicable charge dependent London dispersion correction\")\nwhatis(\"URL         : https://github.com/dftd4/dftd4\")\n\nprepend_path(\"PATH\", pathJoin(prefix, \"bin\"))\nprepend_path(\"MANPATH\", pathJoin(prefix, \"share\", \"man\"))\nprepend_path(\"CPATH\", pathJoin(prefix, \"include\"))\nprepend_path(\"LIBRARY_PATH\", pathJoin(prefix, libdir))\nprepend_path(\"LD_LIBRARY_PATH\", pathJoin(prefix, libdir))\nprepend_path(\"PKG_CONFIG_PATH\", pathJoin(prefix, libdir, \"pkgconfig\"))\n```\n\nTo enable support for D4 in Vasp add the following lines to the Makefile:\n\n```make\nCPP_OPTIONS += -DDFTD4\nLLIBS       += $(shell pkg-config --libs dftd4)\nINCS        += $(shell pkg-config --cflags dftd4)\n```\n\nDepending on how you built DFT-D4, DFT-D4's dependencies might not be properly recognized during the VASP build. Try to explicitly add them to the link line.\n\n```make\nCPP_OPTIONS += -DDFTD4\nLLIBS       += $(shell pkg-config --libs dftd4) -lmulticharge -lmctc-lib -lmstore\nINCS        += $(shell pkg-config --cflags dftd4)\n```\n\nIf you still run into issues, check out [VASP-related issues](https://github.com/dftd4/dftd4/issues?q=label%3Avasp%20) on the ``dftd4`` issue tracker.\n\n\n### C API\n\nThe C API provides access to the basic Fortran objects and their most important methods to interact with them.\nAll Fortran objects are available as opaque `void*` in C and can only be manipulated with the correct API calls.\nTo evaluate a dispersion correction in C four objects are available:\n\n1. the error handler:\n\n   Simple error handler to carry runtime exceptions created by the library.\n   Exceptions can be handled and/or transfered to the downstream error handling system by this means.\n\n2. the molecular structure data:\n\n   Provides a representation of the molecular structure with immutable number of atoms, atomic species, total charge and boundary conditions.\n   The object provides a way to update coordinates and lattice parameters, to update immutable quantities the object has to be recreated.\n\n3. the dispersion model:\n\n   Instantiated for a given molecular structure type, it carries no information on the geometry but relies on the atomic species of the structure object.\n   Recreating a structure object requires to recreate the dispersion model as well.\n\n4. the damping parameters:\n\n   Damping parameter object determining the short-range behaviour of the dispersion correction.\n   Standard damping parameters like the rational damping are independent of the molecular structure and can easily be reused for several structures or easily exchanged.\n\nThe user is responsible for creating and deleting the objects to avoid memory leaks.\nFor convenience the type-generic macro ``dftd4_delete`` is available to free any memory allocation made in the library.\n\n\n### Python API\n\nThe Python API is disabled by default and can be built in-tree or out-of-tree.\nThe in-tree build is mainly meant for end users and packages.\nTo build the Python API with the normal project set the `python` option in the configuration step with\n\n```sh\nmeson setup _build -Dpython=true -Dpython_version=$(which python3)\n```\n\nThe Python version can be used to select a different Python version, it defaults to `'python3'`.\nPython 2 is not supported with this project, the Python version key is meant to select between several local Python 3 versions.\n\nProceed with the build as described before and install the projects to make the Python API available in the selected prefix.\n\nFor the out-of-tree build see the instructions in the [`python`](https://github.com/dftd4/dftd4/blob/main/python) directory.\n\n\n## Citation\n\nAlways cite:\n\nEike Caldeweyher, Christoph Bannwarth and Stefan Grimme, *J. Chem. Phys.*, **2017**, 147, 034112.\nDOI: [10.1063/1.4993215](https://doi.org/10.1063/1.4993215)\n\nEike Caldeweyher, Sebastian Ehlert, Andreas Hansen, Hagen Neugebauer, Sebastian Spicher, Christoph Bannwarth and Stefan Grimme, *J. Chem Phys*, **2019**, 150, 154122.\nDOI: [10.1063/1.5090222](https://doi.org/10.1063/1.5090222)\nchemrxiv: [10.26434/chemrxiv.7430216](https://doi.org/10.26434/chemrxiv.7430216.v2)\n\nEike Caldeweyher, Jan-Michael Mewes, Sebastian Ehlert and Stefan Grimme, *Phys. Chem. Chem. Phys.*, **2020**, 22, 8499-8512.\nDOI: [10.1039/D0CP00502A](https://doi.org/10.1039/D0CP00502A)\nchemrxiv: [10.26434/chemrxiv.10299428](https://doi.org/10.26434/chemrxiv.10299428.v1)\n\n\u003cbr\u003e\n\nIn the range-separate hybrid context:\n\nMarvin Friede, Sebastian Ehlert, Stefan Grimme and Jan-Michael Mewes, *J. Chem. Theory Comput.*, **2023**, 19 (22), 8097-8107.\nDOI: [10.1021/acs.jctc.3c00717](10.1021/acs.jctc.3c00717)\n\n\u003cbr\u003e\n\nExtension to Fr, Ra, and full Actinide series:\n\nLukas Wittmann, Igor Gordiy, Marvin Friede, Benjamin Helmich-Paris, Stefan Grimme, Andreas Hansen and Markus Bursch, *Phys. Chem. Chem. Phys.*, **2024**, 26, 21379-21394.\nDOI: [10.1039/D4CP01514B](10.1039/D4CP01514B)\n\n\u003cbr\u003e\n\nCitations can also be viewed via `dftd4 --citation` or in the [BibTeX file](CITATION.bib).\n\n\n## License\n\nThis project is free software: you can redistribute it and/or modify it under\nthe terms of the Lesser GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis project is distributed in the hope that it will be useful,\nbut without any warranty; without even the implied warranty of\nmerchantability or fitness for a particular purpose.  See the\nLesser GNU General Public License for more details.\n\nUnless you explicitly state otherwise, any contribution intentionally\nsubmitted for inclusion in this project by you, as defined in the\nLesser GNU General Public license, shall be licensed as above, without any\nadditional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdftd4%2Fdftd4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdftd4%2Fdftd4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdftd4%2Fdftd4/lists"}