Skip to content

Straightforward Operator Algebra to create quantum Hamiltonians with a flexible, integrated toolbox of functions to convert operators into a chosen matrix representation.

License

Notifications You must be signed in to change notification settings

h-mnzlr/OperatorAlgebra.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OperatorAlgebra.jl

Documentation Documentation CI codecov

A Julia package for working with quantum operators using an algebraic approach. This package provides efficient representations and operations for quantum operators acting on tensor product spaces.

Features

  • Flexible Operator Types: Three main operator types for different use cases:

    • Op: Single-site operators
    • OpChain: Products of operators (non-commutative multiplication)
    • OpSum: Sums of operators (linear combinations)
  • Efficient Representations: Support for both dense and sparse matrices

  • LinearMap Integration: Efficient matrix-free operator representations

  • Linear Algebra Operations: Trace calculations for operators on tensor product spaces

  • ITensor Integration: Automatic conversion to Matrix Product Operators (MPOs) when ITensorMPS.jl is loaded

Installation

The package is available through the Julia package manager. You can directly install it from the Julia REPL:

Using the Julia REPL package mode (]):

add OperatorAlgebra

Quick Start

using OperatorAlgebra
using SparseArrays

# Define single-site operators
σx = Op(PAULI_X, 1)  # Pauli X on site 1
σz = Op(PAULI_Z, 2)  # Pauli Z on site 2

# Create operator products (OpChain)
product = σx * σz

# Create operator sums (OpSum)
hamiltonian = σx + σz + 0.5 * product

# Convert to matrix representation
basis = [1, 2]
H_matrix = sparse(hamiltonian, basis)

Simple Linear Algebra Operations

Compute traces of operators over tensor product spaces:

using LinearAlgebra

# Single operator trace
σz = Op(PAULI_Z, 1)
tr(σz, [1, 2])  # Trace over 2-site system

# Trace of operator products and sums
product = σx * σz
tr(product, [1, 2])

hamiltonian = σx + σz + 0.5 * product
tr(hamiltonian, [1, 2])

ITensorMPS Integration

When ITensorMPS.jl is loaded, operators can be automatically converted to Matrix Product Operators:

using OperatorAlgebra
using ITensorMPS  # Extension loads automatically

# Define a spin chain
sites = siteinds("S=1/2", 4)

# Create a Hamiltonian
σx = Op(PAULI_X, 1)
σz = Op(PAULI_Z, 2)
H = σx + σz + 0.5 * (σx * σz)

# Convert to MPO for use with ITensor algorithms
mpo = MPO(H, sites)

Contributing

This is an academic/research project. For questions or suggestions, please contact the author.

About

Straightforward Operator Algebra to create quantum Hamiltonians with a flexible, integrated toolbox of functions to convert operators into a chosen matrix representation.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages