Registry / ai-ml / torch-dftd

torch-dftd

JSON →
library0.5.3pypypiunverified

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-dftd
INSTALL
IMPORT
SIG · TORCH-DFTD
T
torch-dftd
ai-mlpythonv0.5.3
Install
29.7s avg
Import
Disk
632MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
installs and imports cleanly · install 29.7s · import 0.000s · 591MB
632MB installed
● package 632MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TorchDFTD3Calculator
from torch_dftd import TorchDFTD3Calculator
from torch_dftd import TorchDFTD3Calculator

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.

import torch import ase.build from torch_dftd.torch_dftd3_calculator import TorchDFTD3Calculator # Create an ASE Atoms object for methanol atoms = ase.build.molecule("CH3OH") # Determine device for computation device = "cuda:0" if torch.cuda.is_available() else "cpu" print(f"Using device: {device}") # Initialize the DFTD3 calculator with the atoms object and device # Common damping functions are 'zero', 'bj', 's6' calc = TorchDFTD3Calculator(atoms=atoms, device=device, damping="bj") # Attach the calculator to the atoms object atoms.set_calculator(calc) # Get potential energy and forces energy = atoms.get_potential_energy() forces = atoms.get_forces() print(f"Total DFT-D3 energy: {energy:.4f} eV") print(f"Forces (first atom): {forces[0]}")
Debug
Known issues
maintenanceThe official GitHub repository for torch-dftd explicitly states that the project is 'not actively maintained'. While releases might still occur, active development, bug fixes for new issues, or compatibility updates for future PyTorch/Python versions may be limited.
fix
Be aware that long-term support may be minimal. Consider forking the repository if deep customization or active maintenance is critical for your project.
affects: All versions
gotchaThe library is tested against specific Python (3.10) and CUDA (12.2) versions, and specific torch (2.0.1) and ase (3.22.1) versions. Using significantly different versions may lead to unexpected behavior or incompatibilities.
fix
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.
affects: <=0.5.3
Upgrade
Version history
0.5.3latest on PyPI · released Mar 11, 2026
Audit
Dependencies
torchrequiredCore deep learning framework for tensor operations and autodifferentiation.
aserequiredAtomic Simulation Environment, used for creating and manipulating atomic structures (e.g., `ase.build.molecule`, `ase.Atoms`). Required for common use cases.
cupy-cuda12xoptionalRequired for accelerating 3-body terms on specific CUDA versions for GPU computation. Only needed if using 3-body terms and a compatible CUDA setup.
Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources
torch-dftd — pip install torch-dftd · libregistry