Bodge: Python BdG solver

python
condmat
Published

October 10, 2024

My Python package for numerically solving the Bogoliubov–de Gennes equations has been published in the Journal of Open Source Software (JOSS)!

The Bodge package is available on GitHub and via PyPI, but is most easily be installed via the latter:

pip3 install bodge

Alternatively, if you want GPU-accelerated calculations using NVIDIA CUDA:

pip3 install 'bodge[cuda]'

The aim of this package has been to make it as simple as possible to work with tight-binding models for superconductivity in Python. Defining a simple superconductor/ferromagnet hybrid on a \(100\times100\) lattice is e.g. done by:

from bodge import *

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

t = 1.0
μ = -3.0 * t
Δ0 = 0.3 * t
M3 = 0.3 * Δ0

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

That’s all that is required to define the corresponding Hamiltonian matrix, which internally is represented as a BSR sparse matrix for efficiency and scalability. From there on Bodge provides a number of different methods to work with that Hamiltonian matrix, including various sparse matrix algorithms, dense matrix algorithms, and GPU-accelerated algorithms. For instance, to plot the LDOS at the center of the system above we can run:

import numpy as np
import matplotlib.pyplot as plt

i = (50, 50, 0)
ω = np.linspace(-2*Δ0, 2*Δ0, 100)
ρ = system.ldos(i, ω)

plt.xlabel(r"Quasiparticle energy $\omega/t$")
plt.ylabel(r"LDOS $\rho_i(ω)/t$")
plt.plot(ω, ρ)

This example uses an efficient sparse matrix algorithm internally, which runs in less than a minute on my MacBook despite the \(100\times100\) lattice. In this picture, we see a typical example of a “spin-split gapped” density of states that is typical for a superconductor/ferromagnet hybrid structure. To make the model more realistic, one can very easily extend the example above to add spatial inhomogeneities of every kind. Moreover, the Bodge package has also been used to represent more exotic materials such as altermagnets and unconventional superconductors, which is quite straight-forward.

See the JOSS paper, GitHub page, and Bodge tutorial for more information on how this software package can be applied to your research. Moreover, feel free to reach out via email if you need help.