DiffTB: Differentiable Density Functional Tight Binding
A JAX-based implementation of DFTB with automatic differentiation support, enabling gradient-based optimization of Slater-Koster parameters against experimental data.
Features
- Fully Differentiable: Built on JAX for automatic differentiation through all calculations
- Spin Polarization: Support for magnetic systems with collinear spin
- Spin-Orbit Coupling: On-site L·S coupling for heavy elements (Bi, Te, etc.)
- Periodic Systems: k-space Hamiltonian construction with Brillouin zone sampling
- Inverse Problems: Tools for fitting SK parameters to experimental ARPES data
Installation
pip install difftb
For development:
git clone https://github.com/debangshu-ornl/difftb.git
cd difftb
pip install -e ".[dev]"
Quick Start
import jax.numpy as jnp
from difftb import (
CrystalStructure,
SlaterKosterParams,
compute_bands,
BrillouinZone,
)
from difftb.io.structure import bi2te3_structure
from difftb.io.slater_koster import create_test_sk_params
# Load structure
structure = bi2te3_structure()
# Create SK parameters (use create_test_sk_params for testing)
sk_params = create_test_sk_params(['Bi', 'Te'])
# Define k-path
from difftb.core.lattice import Lattice, hexagonal_path
lattice = Lattice.from_vectors(
structure.lattice_vectors[0],
structure.lattice_vectors[1],
structure.lattice_vectors[2]
)
bz = BrillouinZone.from_path(lattice, hexagonal_path(), num_points=100)
# Compute band structure
# (Full example requires Hamiltonian construction - see examples/)
Core Components
Slater-Koster Tables
from difftb.io.slater_koster import SlaterKosterTable, interpolate_sk_integrals
# Interpolation is differentiable!
H_sk, S_sk = interpolate_sk_integrals(distances, sk_table)
Spin-Orbit Coupling
from difftb.physics.soc import build_spinor_hamiltonian, get_soc_params
soc_params = get_soc_params(['Bi', 'Te']) # Uses tabulated ξ values
H_soc, S_soc = build_spinor_hamiltonian(H, S, elements, soc_params, orbital_info)
Parameter Fitting
from difftb.utils.optimization import fit_parameters, hierarchical_fit
# Define loss function (e.g., MSE to experimental ARPES)
def loss_fn(params):
# Compute predicted spectrum
# Compare to experiment
return mse
# Fit parameters
result = fit_parameters(loss_fn, initial_params, max_iterations=1000)
# Hierarchical fitting for transferability
final_params, results = hierarchical_fit(
loss_fn,
param_groups=[bi_te_params, mn_params],
group_names=['Bi-Te', 'Mn']
)
Acknowledgments
DiffTB builds on ideas from:
Metadata
Release files for difftb 2025.12.16
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| difftb-2025.12.16.tar.gz | 36.1 kB | Without provenance | Details for difftb-2025.12.16.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| difftb-2025.12.16-py3-none-any.whl | Python 3 | none | any | Details for difftb-2025.12.16-py3-none-any.whl |
Total release size: 77.9 kB
Release files / difftb-2025.12.16.tar.gz
| Download URL | difftb-2025.12.16.tar.gz |
|---|---|
| Size | 36.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
861b81c3369ae0393b7f5629ad813a560122653808328e4200b954cc44858088
|
|
BLAKE2b-256 checksum How to use checksums |
7ae441327c3959dd2af57be984565cd61980fa13387e2496e96e435678e553d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.9
|
Release files / difftb-2025.12.16-py3-none-any.whl
| Download URL | difftb-2025.12.16-py3-none-any.whl |
|---|---|
| Size | 41.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fdea4ea101a8184a831d923b421dc1dde8abd78914d2b900da7ffc78c7daa06f
|
|
BLAKE2b-256 checksum How to use checksums |
d5e2dc7ede9bab375c203c1a27cbeede5409dff8e00c104871ec859d70c3e166
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.9
|
Security for difftb 2025.12.16
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.