Site Tools


qutip-quantum-objects

Quantum Objects (Qobj)

Quantum objects (Qobj) are the fundamental data structure in QuTiP, representing quantum states (kets, density matrices) and operators (Hamiltonians, measurement operators). A Qobj stores a matrix and metadata: dimensions, shape, and whether it's a ket, bra, operator, or superoperator.

Every QuTiP calculation uses Qobjs. Create them from numpy arrays, use built-in functions (basis(), sigmaz(), etc.), or import from other formats. QuTiP handles the linear algebra automatically.

from qutip import *
import numpy as np
 
# Create a ket (column vector) for a two-level system
psi = basis(2, 0)  # Ground state
print(psi)  # Qobj with dims [[2], [1]]
 
# Create an operator (density matrix)
rho = psi * psi.dag()  # Outer product: |ψ⟩⟨ψ|
print(rho)  # dims [[2], [2]]
 
# Built-in operators
H = sigmaz()    # Pauli Z
X = sigmax()    # Pauli X
print(H * psi)  # Apply operator to state

Qobj automatically tracks dimensions, enabling safe composition of multi-qubit systems. Arithmetic operations (addition, multiplication, tensor products) work intuitively on Qobjs.

Qobj Properties

Access components: .full() returns the numpy array, .dims gives dimensions, .shape is the matrix shape. Check .type to distinguish kets, operators, etc.

psi = basis(2, 0)
print(psi.full())        # [[1.], [0.]]
print(psi.dims)          # [[2], [1]]
print(psi.isherm)        # False (ket is not Hermitian)
 
rho = psi * psi.dag()
print(rho.isherm)        # True (density matrix is Hermitian)

Qobj is the interface between QuTiP and your physics. Master every operation on Qobjs—they're the foundation of all simulations.

qutip-quantum-objects.md · Last modified: by 127.0.0.1