Skip to content

Quantum chemistry

QuSpin

Maintained by weinbe58

QuSpin is an open-source Python package for Exact Diagonalization and quantum dynamics of arbitrary boson, fermion and spin many-body systems, supporting the use of various (user-defined) symmetries in one and higher dimensional...

PythonBSD-3-Clause
QuSpin illustration

Resource snapshot

Category

Quantum chemistry

Stars

30

Last pushed

Dec 22, 2022Updated 3y ago

Open issues

0

What it is

QuSpin is maintained by weinbe58 and sits in the Quantum chemistry lane of the open-source quantum map.

QuSpin is an open-source Python package for Exact Diagonalization and quantum dynamics of arbitrary boson, fermion and spin many-body systems, supporting the use of various (user-defined) symmetries in one and higher dimensional...

Last verified by Qtangl generator on May 27, 2026

Who it's for

Researchers, students, and developers exploring how quantum software is used for chemistry and electronic-structure problems.

What you can build or learn

  • See how chemistry problems are mapped into quantum-friendly representations.
  • Understand the workflow around Hamiltonians, ansatze, and measurement loops.
  • Compare beginner-friendly entry points into chemistry-focused quantum tooling.

Code samples

Examples from the repository.

Bhm (examples/notebooks/BHM.ipynb)
##### define model parameters #####
L=6 # system size
J=1.0 # hopping
U=np.sqrt(2.0) # interaction
mu=2.71 # chemical potential
Bhm (examples/notebooks/BHM.py)
from __future__ import print_function, division
import sys,os
# line 4 and line 5 below are for development purposes and can be removed
qspin_path = os.path.join(os.getcwd(),"../../")
sys.path.insert(0,qspin_path)
#
from quspin.operators import hamiltonian # Hamiltonians and operators
from quspin.basis import boson_basis_1d # Hilbert space boson basis
import numpy as np # generic math functions
#
##### define model parameters #####
L=6 # system size
J=1.0 # hopping
U=np.sqrt(2.0) # interaction
mu=0.0 # chemical potential
#
##### construct Bose-Hubbard Hamiltonian #####
# define boson basis with 3 states per site L bosons in the lattice
#basis = boson_basis_1d(L,Nb=L) # full boson basis
#basis = boson_basis_1d(L,Nb=L,sps=3) # particle-conserving basis, 3 states per site
#basis = boson_basis_1d(L,Nb=L,sps=3,kblock=0) # ... and zero momentum sector
#basis = boson_basis_1d(L,Nb=L,sps=3,kblock=1) # ... and first non-zero momentum
basis = boson_basis_1d(L,Nb=L,sps=3,kblock=0,pblock=1) # ... + zero momentum and positive parity
print(basis)
# define site-coupling lists
hop=[[-J,i,(i+1)%L] for i in range(L)] #PBC
interact=[[0.5*U,i,i] for i in range(L)] # U/2 \sum_j n_j n_j
pot=[[-mu-0.5*U,i] for i in range(L)] # -(\mu + U/2) \sum_j j_n
# define static and dynamic lists
static=[['+-',hop],['-+',hop],['n',pot],['nn',interact]]
dynamic=[]
# build Hamiltonian
H=hamiltonian(static,dynamic,basis=basis,dtype=np.float64)
# calculate eigensystem
E,V=H.eigh()
E_GS,V_GS=H.eigsh(k=2,which='SA',maxiter=1E10) # only GS
print("eigenenergies:", E)
print("GS energy is %0.3f" %(E_GS[0]))
# calculate entanglement entropy per site of GS
subsystem=[i for i in range(L//2)] # sites contained in subsystem
Fhm (examples/notebooks/FHM.ipynb)
from quspin.operators import hamiltonian # Hamiltonians and operators
from quspin.basis import spinless_fermion_basis_1d, tensor_basis # Hilbert space fermion and tensor bases
import numpy as np # generic math functions
##### define model parameters #####
L=4 # system size
J=1.0 # hopping
U=np.sqrt(2.0) # interaction
mu=0.0 # chemical potential

License

BSD-3-Clause

SPDX identifier detected from the repository metadata or license files.

Repository README

Preview from the project README.

Rendered as Markdown inside a scrollable preview. Long READMEs stay contained; expand or open on GitHub for the full document.

~762 words · about 3 min readOpen on GitHub

QuSpin

QuSpin is an open-source Python package for Exact Diagonalization and quantum dynamics of arbitrary boson, fermion and spin many-body systems, supporting the use of various (user-defined) symmetries in one and higher dimensional lattice systems and (imaginary) time evolution following a user-specified driving protocol.

The complete Documentation for QuSpin (including a number of recent tutorials) can be found at

http://quspin.github.io/QuSpin/

Examples with python scripts and Jupyter notebooks which show how to use QuSpin can be downloaded at

http://quspin.github.io/QuSpin/Examples.html

For an indepth introduction to the package, check out the following papers:

QuSpin wraps Scipy, Numpy, and custom Cython libraries together to offer state-of-the art exact diagonalization calculations. The interface allows the user to define any many-body (and single particle) Hamiltonian which can be constructed from local single-particle operators. It also gives the user the flexibility of accessing many pre-defined symmetries in 1d (e.g. translation, reflection, spin inversion), as well as user-defined symmetry based on elementary transformations, such as site and spin flips. Moreover, there are convenient built-in ways to specify the time and parameter dependence of operators in the Hamiltonian, which is interfaced with user-friendly routines to solve the time dependent Schrödinger equation numerically. All the Hamiltonian data is stored either using Scipy's sparse matrix library for sparse Hamiltonians or dense Numpy arrays which allows the user to access any powerful Python scientific computing tools.

Contents


Installation

automatic install

The latest version of the package has the compiled modules written in Cython which has made the code far more portable across different platforms. We will support precompiled version of the package for Linux, OS X and Windows 64-bit systems. The automatic installation of QuSpin requires the Anaconda package manager for Python. Once Anaconda has been installed, all one has to do to install QuSpin is run:

$ conda install -c weinbe58 quspin

This will install the latest version on your computer. Right now the package is in its beta stages and so it may not be available for installation on all platforms using this method. In such a case one can also manually install the package.

OpenMP support is available starting from QuSpin 0.3.1. To instal quspin with OpenMP, use

$ conda install -c weinbe58 omp quspin

manual install

To install QuSpin manually, download the source code either from the master branch, or by cloning the git repository. In the top directory of the source code you can execute the following commands from bash:

Unix:

python setup.py install --default-compiler-flags

or Windows command line:

setup.py install --default-compiler-flags

For the manual installation you must have all the prerequisite python packages installed:

For Windows machines one needs the correct verion of the Microsoft Visual Stuios compiler for the given python version you are building the package for. A good resource which can help you with this is here. For OS-X and Linux the standard compilers should be fine for building the package. Note that some of the compiled extensions require Openmp 2.0 or above. For most setups We recommend Anaconda or Miniconda to manage your python packages and we have pre-built code which should be compatible with most 64-bit systems. When installing the package manually, if you add the flag --record install.txt, the location of all the installed files will be output to install.txt which stores information about all installed files. This can prove useful when updating the code.

For manual installation with OpenMP, use:

Unix:

python setup.py install --omp --default-compiler-flags

or Windows command line:

setup.py install --omp --default-compiler-flags

updating the package

To update the package with Anaconda, all one has to do is run the installation command again.

To safely update a manually installed version of QuSpin, one must first manually delete the entire package from the python 'site-packages/' directory. In Unix, provided the flag --record install.txt has been used in the manual installation, the following command is sufficient to completely remove the installed files: cat install.txt | xargs rm -rf. In Windows, it is easiest to just go to the folder and delete it from Windows Explorer.

Documentation

The complete QuSpin documentation can be found under

http://quspin.github.io/QuSpin/

Read on GitHub

Activity

Latest release

—

Watchers

0

Python support

—

Learn digest

Get monthly updates when library entries change.

Monthly digest: new library entries, updated flagships, and one editorial pick.

Related resources

Keep exploring nearby tools.

ProjectQ-Framework

FermiLib

FermiLib: Open source software for analyzing fermionic quantum simulation algorithms

PythonApache-2.0

90 stars · Updated 8y ago

cda-tum

mqt-dasqa

MQT DASQA - Designer for Superconducting Quantum Architectures

PythonMIT

21 stars · Updated 1y ago

quantumlib

OpenFermion

Python package for compiling and analyzing quantum algorithms to simulate electronic structures.

PythonApache-2.0Flagship

1,697 stars · Updated 3mo ago

eclipse-qrisp

Qrisp

Qrisp - The next generation of quantum algorithm development

PythonEPL-2.0

267 stars · Updated 3mo ago

aspuru-guzik-group

tequila

A High-Level Abstraction Framework for Quantum Algorithms

PythonMITFlagship

428 stars · Updated 3mo ago

ornl-qci

xacc-vqe

DEPRECATED - Variational quantum eigensolver built on XACC

C++BSD-3-Clause

14 stars · Updated 7y ago