torch-dftd is a Python library providing a PyTorch implementation of the DFT-D2 and DFT-D3 dispersion correction models for quantum chemistry calculations. It leverages PyTorch's automatic differentiation capabilities to efficiently compute energies, forces, and virials. The library is currently at version 0.5.3, released on March 11, 2026. While it has seen recent updates, its GitHub repository indicates that it is "not actively maintained".
pip install torch-dftdVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up a DFT-D3 calculation for a methanol molecule using `torch-dftd` with `ase`. It initializes an `ase.Atoms` object, creates a `TorchDFTD3Calculator`, attaches it to the atoms, and then computes the potential energy and atomic forces. It dynamically selects between CUDA (GPU) and CPU for computation.
Be aware that long-term support may be minimal. Consider forking the repository if deep customization or active maintenance is critical for your project.
Refer to the project's `README.md` or `pyproject.toml` for the exact tested environment. It's recommended to use a Python version compatible with PyTorch < 3.11 for older PyTorch versions on macOS/Windows.