Skip to main content

Manipulate quantum many-body operators

Project description


Opyrators is a lightweight python package that represents many-body fermion- and spin-operators as strings.

For example, the fermionic string "012003" stands for a 6-site operator formed by a creation operator on site 2, an annihilation operator on site 3, a density operator on site 6 and identity operators on the rest. See the encodings below.

In this representation, operator manipulations such as addition and multiplication are easily implemented. Super useful if you want to quickly compute commutators (and/or use this for research projects). See the example below.


pip install opyrators


Here is a quick example showing some of the basic features of fermionic opyrators.

# Import the fermion operators.
from fermions import operator

# The operator takes a dictionary as input, with its key-value pairs being
# the operator string and its coefficient.
A = operator({"112233":1.3})
B = operator({"221133":0.34})
C = A * B - B * A

# The output of the print operation shows that this complex
# operator consists of 6 terms, but is fully diagonal.
# Term 0: 330033 0.442
# Term 1: 330333 -0.442
# Term 2: 333033 -0.442
# Term 3: 003333 -0.442
# Term 4: 033333 0.442
# Term 5: 303333 0.442

# As another example, here is an operator describing the hopping terms on a
# 3-site periodic lattice.
J = operator({"120":1, "012":1, "201":1})
J = J + J.conj()



For particles, the encoding works as follows:

  • 0 = Identity operator
  • 1 = Creation operator
  • 2 = Annihilation operator
  • 3 = Density operator


For spin-1/2 operators, the encoding works as follows:

  • 0 = Identity operator
  • 1 = Pauli-X operator
  • 2 = Pauli-Y operator
  • 3 = Pauli-Z operator

An operator with X on site 2, Y on site 4 and Z on site 5, in a system of 8 sites, hence would be "01023000".

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

opyrators-1.0.0.tar.gz (4.6 kB view hashes)

Uploaded source

Built Distribution

opyrators-1.0.0-py3-none-any.whl (7.4 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page