Skip to content

QG-phy/DeePTB

 
 

Repository files navigation

DeePTB Logo

DeepModeling Build Test PyPI version License

🚀 About DeePTB

DeePTB is an innovative Python package that uses deep learning to accelerate ab initio electronic structure simulations. It offers versatile, accurate, and efficient simulations for a wide range of materials and phenomena. Trained on small systems, DeePTB can predict electronic structures of large systems, handle structural perturbations, and integrate with molecular dynamics for finite temperature simulations, providing comprehensive insights into atomic and electronic behavior.

  • Key Features DeePTB contains two main components:
    1. DeePTB-SK: deep learning based local environment dependent Slater-Koster TB.

      • Customizable Slater-Koster parameterization with neural network corrections for .
      • Flexible basis and exchange-correlation functional choices.
      • Handle systems with strong spin-orbit coupling (SOC) effects.
    2. DeePTB-E3: E3-equivariant neural networks for representing quantum operators.

      • Construct DFT Hamiltonians/density and overlap matrices under full LCAO basis.
      • Utilize (Strictly) Localized Equivariant Message-passing ((S)LEM) model for high data-efficiency and accuracy.
      • Employs SO(2) convolution for efficient handling of higher-order orbitals in LCAO basis.

For more details, see our papers:

📚 Documentation

🛠️ Installation

Installing DeePTB is straightforward with UV, a fast Python package manager.

  • Requirements

    • Git
    • Python 3.10 to 3.13
    • UV, used by install.sh as the fast installer frontend
    • For GPU installs: an NVIDIA driver compatible with the selected CUDA runtime
  • From Source (Recommended)

    1. Install UV (if not already installed):

      # On macOS and Linux
      curl -LsSf https://astral.sh/uv/install.sh | sh
      
      # Or using pip
      pip install uv
      
      # On Windows (PowerShell)
      powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
    2. Clone DeePTB:

      git clone https://github.com/deepmodeling/DeePTB.git
      cd DeePTB
    3. Install DeePTB with tested dependencies:

      Automatic CPU/GPU selection:

      ./install.sh

      CPU-only install:

      ./install.sh cpu

      GPU install:

      nvidia-smi  # check the driver-reported CUDA version
      ./install.sh gpu    # auto-detect CUDA backend
      
      # Or force a tested CUDA wheel path:
      ./install.sh cu128  # RTX 50 / CUDA 12.8 path tested with torch 2.10.0
      ./install.sh cu130  # requires a driver new enough for CUDA 13.0 runtime

      This single command will:

      • Automatically create a virtual environment (.venv)
      • Install a tested PyTorch / PyG / torch-scatter binary-wheel combination
      • Refuse unsupported Python or CUDA/backend combinations instead of falling back to source builds
      • Install all runtime and test dependencies
    4. Activate the standalone environment:

      install.sh installs DeePTB into .venv under the current DeePTB repository. Activate it before running dptb:

      source .venv/bin/activate  # On Unix/macOS
      .venv\Scripts\activate     # On Windows
      dptb --help
    5. Validate the installation: DeePTB is under active development, so new installations should run the test suite once before production use.

      python -m pytest ./dptb/tests/

      For a faster local check while iterating:

      python -m pytest ./dptb/tests/ -m "not slow"
    6. Install optional dependencies (if needed):

      # For 3D Fermi surface plotting
      ./install.sh auto --extra 3Dfermi
      
      # For TBtrans initialization
      ./install.sh auto --extra tbtrans_init
      
      # For pybinding support
      ./install.sh auto --extra pybinding
  • Developer Install

    pyproject.toml declares the broader source-compatible range (Python >=3.10,<3.14, torch >=2.5.1,<=2.12.1). Developers who already manage their own Torch/PyG environment can still use:

    uv sync

    This path is for developers who intentionally manage their own environment. For a tested standalone DeePTB environment, prefer install.sh.

  • Library Installation (Existing Environment)

    [!WARNING] This path is for downstream projects or existing environments that import DeePTB as a library. The environment must provide a compatible PyTorch and torch-scatter binary wheel.

    DeePTB keeps a broad Torch compatibility range so downstream projects can choose their own CPU/GPU backend. In that case, install PyTorch first, then install a torch-scatter binary wheel matching the current Torch version and backend. If you are working from a DeePTB source checkout, the helper can inspect the current environment and print the matching PyG wheel command:

    python - <<'PY'
    import torch
    print("torch:", torch.__version__)
    print("cuda runtime:", torch.version.cuda)
    print("cuda available:", torch.cuda.is_available())
    PY
    
    python docs/auto_install_torch_scatter.py --dry-run
    python docs/auto_install_torch_scatter.py

    Then install DeePTB from the current source checkout:

    pip install .

    Use pip install -e . instead if you want an editable developer install. Published package installs, such as pip install dptb, were not part of this compatibility test pass; prefer a source checkout until that path is tested.

    For standalone DeePTB use on a new machine, use the From Source installer above instead; it creates .venv and selects a tested Torch / PyG / torch-scatter combination.

    Example manual torch-scatter commands:

    # CPU, torch 2.12.1
    pip install --only-binary torch-scatter \
      torch-scatter==2.1.2 \
      -f https://data.pyg.org/whl/torch-2.12.1+cpu.html
    
    # CUDA 12.8 / torch 2.10.0
    pip install --only-binary torch-scatter \
      torch-scatter==2.1.2+pt210cu128 \
      -f https://data.pyg.org/whl/torch-2.10.0+cu128.html
  • Julia Backend (Optional - for High-Performance Pardiso Solver)

    [!NOTE] Platform Support: Pardiso backend currently supports Linux only.

    • macOS: Not supported (Intel MKL limitations)
    • Windows: Use WSL2 (Windows Subsystem for Linux)

    If you want to use the Pardiso backend for accelerated band structure calculations:

    Automated Installation (Recommended):

    ./install_julia.sh

    Manual Installation:

    1. Install Julia:
      # Linux (macOS can install Julia, but the Pardiso backend is not supported)
      curl -fsSL https://install.julialang.org | sh
    2. Install required packages:
      julia install_julia_packages.jl

    Verify Installation:

    julia -e 'using Pardiso; println("Pardiso available: ", Pardiso.MKL_PARDISO_LOADED[])'

    Usage:

    dptb pdso band.json -i model.pth -stu structure.vasp -o ./output

    For more details, see:

Test code

To ensure the code is correctly installed, please run the unit tests first:

python -m pytest ./dptb/tests/

Be careful if not all tests pass!

🤝 How to Cite

The following references are required to be cited when using DeePTB. Specifically:

  • For DeePTB-SK:

    Q. Gu, Z. Zhouyin, S. K. Pandey, P. Zhang, L. Zhang, and W. E, Deep Learning Tight-Binding Approach for Large-Scale Electronic Simulations at Finite Temperatures with Ab Initio Accuracy, Nat Commun 15, 6772 (2024).

  • For DeePTB-E3:

    Z. Zhouyin, Z. Gan, S. K. Pandey, L. Zhang, and Q. Gu, Learning Local Equivariant Representations for Quantum Operators, In The 13th International Conference on Learning Representations (ICLR) 2025.

About

DeePTB: A deep learning package for tight-binding approach with ab initio accuracy.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Python 97.7%
  • Julia 1.6%
  • Other 0.7%