Skip to main content

Differentiable Density Functional Tight Binding in JAX

Project description

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:

  • Jrystal - JAX-based DFT
  • dxtb - Differentiable xTB
  • DFTB+ - Reference DFTB implementation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

difftb-2025.12.16.tar.gz (36.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

difftb-2025.12.16-py3-none-any.whl (41.8 kB view details)

Uploaded Python 3

File details

Details for the file difftb-2025.12.16.tar.gz.

File metadata

  • Download URL: difftb-2025.12.16.tar.gz
  • Upload date:
  • Size: 36.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.9

File hashes

Hashes for difftb-2025.12.16.tar.gz
Algorithm Hash digest
SHA256 861b81c3369ae0393b7f5629ad813a560122653808328e4200b954cc44858088
MD5 4d0dbd0f68c573ed599cca136ba17881
BLAKE2b-256 7ae441327c3959dd2af57be984565cd61980fa13387e2496e96e435678e553d0

See more details on using hashes here.

File details

Details for the file difftb-2025.12.16-py3-none-any.whl.

File metadata

File hashes

Hashes for difftb-2025.12.16-py3-none-any.whl
Algorithm Hash digest
SHA256 fdea4ea101a8184a831d923b421dc1dde8abd78914d2b900da7ffc78c7daa06f
MD5 b6e96bafbfe2c53410a0f3402c174ee7
BLAKE2b-256 d5e2dc7ede9bab375c203c1a27cbeede5409dff8e00c104871ec859d70c3e166

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page