Skip to main content

Bodge: Python package for efficient tight-binding modeling of superconductors.

Project description

Bodge

Bodge is a Python package for constructing large real-space tight-binding models. Although quite general tight-binding models can be constructed, we focus on the Bogoliubov-DeGennes ("BoDGe") Hamiltonian, which is used to model superconductivity in clean materials. In other words: If you want a lattice model for superconducting nanostructures, and want something that is computationally efficient yet easy to use, you've come to the right place.

Research papers where this code has been used include:

Bodge can be used on anything from a normal laptop to an HPC cluster, as long as it runs an operating system where the SciPy stack is available (e.g. Linux, MacOS, or Windows). It is mainly meant for CPU-based calculations on one node (i.e. no MPI support), however some functions on the development branch contains optional support for GPU-based calculations via CuPy (CUDA).

Internally, Bodge uses a sparse matrix (scipy.sparse) to represent the Hamiltonian, which allows you to efficiently construct tight-binding models with millions of lattice sites if needed. However, you can also easily convert the result to a dense matrix (numpy.array) if that's more convenient. The package follows modern software development practices: near-complete test coverage (pytest), fast runtime type checking (beartype), and mostly PEP-8 compliant (black).

The full documentation of the Bodge package is available here.

Quickstart

This package is published on PyPi, and is easily installed via pip:

pip install bodge

Bodge should be quite easy to use if all you want is a real-space lattice Hamiltonian with superconductivity. For instance, consider a $100a\times100a$ s-wave superconductor with a chemical potential $μ = -3t$, superconducting gap $Δ_s = 0.1t$, magnetic spin splitting along the $z$ axis $m = 0.05t$, and nearest-neighbor hopping $t = 1$. Using Bodge, you can just write:

from bodge import *

lattice = CubicLattice((100, 100, 1))
system = Hamiltonian(lattice)

t = 1
μ = -3 * t
m = 0.05 * t
Δs = 0.10 * t

with system as (H, Δ):
    for i in lattice.sites():
        H[i, i] = -μ * σ0 -m * σ3
        Δ[i, i] = -Δs * jσ2
    for i, j in lattice.bonds():
        H[i, j] = -t * σ0

If you are familiar with tight-binding models, you might notice that this is intentionally very close to how one might write the corresponding equations with pen and paper. It is similarly easy to model more complex systems: you can e.g. easily add p-wave or d-wave superconductivity, magnetism, altermagnetism, antiferromagnetism, spin-orbit coupling, etc. The lattice site indices are implemented as tuples i = (x_i, y_i, z_i), so that you can easily use the lattice coordinates to design inhomogeneous materials via e.g. if-tests.

The syntax used to construct the Hamiltonian is designed to look like array operations, but this is just a friendly interface; under the hood, some "magic" is required to efficiently translate what you see above into sparse matrix operations, while enforcing particle-hole and Hermitian symmetries. Once you're done with the construction, you can call system.matrix() to extract the Hamiltonian matrix itself (in dense or sparse form), or use methods such as system.diagonalize() and system.free_energy() to get derived properties.

Formally, the Hamiltonian operator that corresponds to the constructed matrix is

$$\mathcal{H} = E_0 + \frac{1}{2} \sum_{ij} \hat{c}^\dagger_i \hat{H}_{ij} \hat{c}_j,$$

where $\hat{c}_i = (c_{i\uparrow}, c_{i\downarrow}, c_{i\uparrow}^\dagger, c_{i\downarrow}^\dagger)$ is a vector of all spin-dependent electron operators on lattice site $i$ and $E_0$ is a constant. The $4\times4$ matrix $\hat{H}_{ij}$ in Nambu⊗Spin space is generally further decomposed into $2\times2$ blocks in spin space:

$$\hat{H}_{ij} = \begin{pmatrix} H_{ij} & \Delta_{ij} \\ \Delta^\dagger_{ij} & -H^*_{ij} \end{pmatrix}$$

It is precisely these $2\times2$ blocks $H_{ij}$ and $\Delta_{ij}$ that are specified when you provide Bodge with values for H[i, j] and ∆[i, j]. After the matrix construction completes, you obtain a $4N\times4N$ matrix in Lattice⊗Nambu⊗Spin space, where $N$ is the number of lattice sites. You don't need to specify the bottom row of $\hat{H}_{ij}$ as these follow from symmetry, and Bodge will warn you if the Hamiltonian is non-Hermitian.

For more information on usage, please see the full documentation.

Development

After cloning the Git repository on a Unix-like system, you can run:

make install

This will create a virtual environment in a subfolder called venv, and then install Bodge into that virtual environment. If you prefer to use a newer Python version (recommended), first install this via your package manager of choice.

For example:

brew install python@3.11          # MacOS with HomeBrew
sudo apt install python3.11-full  # Ubuntu GNU/Linux

Afterwards, mention what Python version to use when installing Bodge:

make install PYTHON=python3.11

Run make without any command-line arguments to see how to proceed further. This should provide information on how to run the bundled unit tests, run scripts that use the Bodge package, or run the autoformatter after you have updated the code. PRs are welcome!

Acknowledgements

I wrote most of this code as a PostDoc in the research group of Prof. Jacob Linder at the Center for Quantum Spintronics, NTNU, Norway. I would like to thank Jacob for introducing me to the BdG formalism that is implemented in this package – and before that, to the theory superconductivity in general.

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

bodge-1.1.1.tar.gz (729.7 kB view details)

Uploaded Source

Built Distribution

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

bodge-1.1.1-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file bodge-1.1.1.tar.gz.

File metadata

  • Download URL: bodge-1.1.1.tar.gz
  • Upload date:
  • Size: 729.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for bodge-1.1.1.tar.gz
Algorithm Hash digest
SHA256 c865301ebca49fc5484f84f4bb27cb4a130ba4d49b61bc0f1f07e9d852eebc42
MD5 6c6ee19bbc6c80b3a49add3e9a7c0180
BLAKE2b-256 716fe661cdd1093dc7e092f8dd5f6db693b165e0e263a08243c0d60ac217f83e

See more details on using hashes here.

File details

Details for the file bodge-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: bodge-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for bodge-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 90a3e4d0d7915c536af9792d6ebe2656d646be465431443e7a34246ef82a6c9c
MD5 4d2e1a46a6b333a40d0943dcfbae4f29
BLAKE2b-256 c4b47ea943ec2e10e2dd1c8e8ff33eb798511d72ec40ac330c5c9baa108aa025

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