OperatorAlgebra.jl Documentation
Overview
Operator Algebra provides a minimalist framework to construct Hamiltonians of arbitrary quantum systems with discrete Hilbert spaces efficiently. In particular, this package allows for the creation of the Hamiltonians operator structure without allocating large matrices, while providing the full flexibility of arithmetic operations on the algebraic ring of operators. Compared to other similar projects, OperatorAlgebra.jl allows for highly flexible indexing, where Julia's native multiple dispatched is leveraged to allow for creative implementations. OperatorAlgebra.jl is not a solution to your problems, but rather a toolbox that will help you to write simple, efficient and short codes in the familiar language of blackbord quantum mechanics.
Key Features
Create Operators:
- Add and multiply objects representing the abstract operators
- Define objects representing your custom, abstract operators.
- Use a flexible description of your basis to convert to the matrix representation of the operators.
Matrix representation:
- Easily convert your abstract operators into different Matrix representations.
- Initialize the matrix efficiently as sparse, dense or memory-less.
Linear Algebra Operations:
- Compute traces of operators on tensor product spaces.
ITensor Integration:
- Automatic conversion to Matrix Product Operators (MPOs) when ITensorMPS.jl is loaded.
Quick Example
using OperatorAlgebra
# Define Pauli operators on different sites
σx = Op(PAULI_X, 1)
σz = Op(PAULI_Z, 2)
# Build a Hamiltonian
H = σx + σz + 0.5 * σx * σz
# Convert to sparse matrix
basis = [1, 2]
H_matrix = sparse(H, basis)
# Apply to a product state
state = [[1.0, 0.0], [1.0, 0.0]] # |00⟩
new_state = apply(σx, state) # |10⟩Contents
- Getting Started
- Operator Types
- Matrix Representation of Operators
- Examples
- Type Reference
- Operations Reference
- Constants Reference
Index
OperatorAlgebra.OperatorAlgebraOperatorAlgebra.LOWEROperatorAlgebra.OCC_HOLEOperatorAlgebra.OCC_PARTOperatorAlgebra.PAULI_XOperatorAlgebra.PAULI_YOperatorAlgebra.PAULI_ZOperatorAlgebra.RAISEOperatorAlgebra.AbstractOpOperatorAlgebra.OpOperatorAlgebra.OpChainOperatorAlgebra.OpSumBase.eltypeLinearAlgebra.trLinearAlgebra.trLinearAlgebra.trOperatorAlgebra.:⊗OperatorAlgebra.applyOperatorAlgebra.apply!OperatorAlgebra.atsiteOperatorAlgebra.kronpowOperatorAlgebra.sitetype
OperatorAlgebra.OperatorAlgebra — ModuleOperatorAlgebraA Julia package for working with quantum operators using an algebraic approach.
OperatorAlgebra provides efficient representations and operations for quantum operators acting on tensor product spaces, with support for:
- Flexible operator types:
Op,OpChain,OpSum - Tensor products: Kronecker operations with
⊗,kronpow,atsite - Multiple backends: Sparse matrices, dense matrices, and matrix-free LinearMaps
- Product state operations: Efficient
applyfor tensor product states
Main Types
AbstractOp: Base type for all operatorsOp: Single-site operatorOpChain: Product of operators (A * B * C)OpSum: Sum of operators (A + B + C)
Key Functions
apply,apply!: Apply operators to product statesatsite: Extend operator to full Hilbert spacesparse: Convert to sparse matrix representationLinearMap: Create matrix-free representation⊗,kronpow: Tensor product operations
Predefined Operators
Common quantum operators are exported as constants:
- Pauli matrices:
PAULI_X,PAULI_Y,PAULI_Z - Creation/annihilation:
RAISE,LOWER - Occupation operators:
OCC_PART,OCC_HOLE
Example
using OperatorAlgebra
# Define operators
σx = Op(PAULI_X, 1)
σz = Op(PAULI_Z, 2)
# Build Hamiltonian
H = σx + σz + 0.5 * σx * σz
# Convert to matrix
basis = [1, 2]
H_matrix = sparse(H, basis)
# Apply to product state
state = [[1.0, 0.0], [1.0, 0.0]]
new_state = apply(σx, state)