Skip to main content

A Python package for analyzing the Hofstadter model.

Project description

docs pytests license

HofstadterTools (HT) is a set of Python programs and classes for analyzing the Hofstadter model, which describes the behavior of non-interacting quantum particles hopping on a lattice coupled to a gauge field. This package can be used to compute the band structure of a generalized Hofstadter model on any regular Euclidean lattice, as well as its key properties, such as quantum geometry and topology.

Quick Start

Using HofstadterTools is quick and easy!

pip install HofstadterTools

You can now access the band_structure and butterfly programs from any location.

band_structure -lat square -nphi 1 4 --display both --wilson

3D Band Structure Wilson Loops 2D Band Structure

butterfly -lat square -q 97 --color point --wannier --plot_lattice

Butterfly Spectrum Wannier Diagram Lattice

Voilà! You have just plotted the Hofstadter band structure for nearest-neighbor hopping on the square lattice at flux density \(n_\phi=1/4\), together with the corresponding butterfly spectrum at \(q=97\). You can append --help to either of these programs to view the list of options. Alternatively, you can explore the gallery and code reference to see what HofstadterTools has to offer.

Installation

This package was developed using Ubuntu 20.04.6 (x86_64) with Python=3.10.13, however it is designed to be platform-independent and can work with any Python>=3.9.

Basic install

For basic usage of HofstadterTools, i.e. in cases where you do not plan on editing the source code, you can install the package quickly and easily from PyPI:

pip install HofstadterTools

To avoid dependency clashes, we recommend the use of a python virtual environment, such as venv.

Advanced install

For advanced usage of HofstadterTools, i.e. in cases where you do plan on editing the source code, you can install the package from source.

user@domain:any/path$ git clone git@github.com:HofstadterTools/HofstadterTools.github.io.git HofstadterTools; cd HofstadterTools
user@domain:path/to/HofstadterTools$ pip install -e .

The optional -e flag indicates an editable install. Alternatively, if you plan on building the documentation locally, the optional docs dependencies need to be installed.

user@domain:path/to/HofstadterTools$ pip install -e ".[docs]"

Testing

You can confirm that HofstadterTools is correctly installed by running the pytests.

user@domain:any/path$ pytest --pyargs HT

Once the project HofstadterTools is installed, the package HT will be available in your python environment. In addition, you can access the programs band_structure, butterfly, plot_band_structure, and plot_butterfly, from any location.

user@domain:any/path$ band_structure --help
user@domain:any/path$ butterfly --help
user@domain:any/path$ plot_band_structure --help
user@domain:any/path$ plot_butterfly --help

The plot_* programs are used to replot band_structures / butterflies that have been saved to file.

Directory Structure

  • src – sources root with the HT package, along with its configuration settings, subpackages, and programs. A detailed description of the available programs and namespace packages is in the documentation.

    • HTHT package

      • configuration – user-defined configuration files for the programs.

      • functions – helper functions for the programs.

      • models – model classes for the programs.

      • plot – location of the plot scripts.

      • tests – unit tests for the programs.

  • data – output destination for raw data files (if programs are run explicitly from their file location, otherwise the output destination is the current working directory).

    • band_structure – data generated by the band_structure program.

    • butterfly – data generated by the butterfly program.

  • docs – location of the sphinx documentation. To view the documentation locally, compile by running make html or make clean html and then open build/html/index.html in a web browser. This assumes that the optional docs dependencies are installed.

    • build – compiled documentation (once built).

    • source – documentation source.

  • figs – output destination for the figures (if programs are run explicitly from their file location, otherwise the output destination is the current working directory).

    • band_structure – figures generated by the band_structure program.

    • butterfly – figures generated by the butterfly program.

  • logs – output destination for the log files (if programs are run explicitly from their file location, otherwise the output destination is the current working directory).

    • band_structure – logs generated by the band_structure program.

    • butterfly – logs generated by the butterfly program.

  • paper – summary paper introducing HofstadterTools. The formatted pdf can be downloaded as an artifact of the production-pdf workflow under the GitHub actions tab.

How to Cite

If you have found HofstadterTools useful, it would be greatly appreciated if you could cite us in your work. Please find the bibtex reference below.

@misc{HofstadterTools,
title={HofstadterTools: A Python package for analyzing the Hofstadter model},
author={Bartholomew Andrews},
year={2023},
eprint={2311.18726},
archivePrefix={arXiv},
primaryClass={cond-mat.mes-hall}
}

Acknowledgments

We thank Gunnar Möller, Titus Neupert, Rahul Roy, Alexey Soluyanov, Michael Zaletel, Daniel Parker, Stefan Divic, Johannes Mitscherling, and Mathi Raja, for useful discussions. This project was funded by the Swiss National Science Foundation under Grant No. P500PT_203168, and supported by the U.S. Department of Energy, Office of Science, Basic Energy Sciences, under Early Career Award No. DE-SC0022716.

Contributing

The Hofstadter model is an active field of research and therefore HofstadterTools will never be complete. Here is a list of some features that we have on the pipeline to be implemented (in no particular order):

  • support for hyperbolic lattices [Stegmaier22]

  • support for fractal lattices [Chen20]

  • support for higher-dimensional lattices [DiColandrea22]

  • support for quasicrystals [Ghadimi22]

  • support for open boundary conditions [Pena23]

  • interface to quantum chemistry codes [Bodesheim23]

  • capability to compute the non-Abelian Hofstadter moth [Osterloh05], [Yang20]

  • capability to compute Chern numbers using bulk-edge correspondence [Agazzi14]

  • capability to generate the potential function corresponding to hopping amplitudes [Yilmaz17]

  • implementation of other topological flat-band models for benchmarking (e.g. chiral pi-flux model) [Neupert11]

Contributions are always welcome! The easiest way to contribute is to submit a pull request on GitHub or contact Bart Andrews if you have any feedback.

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

HofstadterTools-1.0.0.tar.gz (1.4 MB view hashes)

Uploaded Source

Built Distribution

HofstadterTools-1.0.0-py3-none-any.whl (1.4 MB view hashes)

Uploaded Python 3

Supported by

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