Wigner and Husimi-Q FunctionsΒΆ

This tutorial evaluates phase-space distributions for a finite Fock-space state and plots them with the built-in Matplotlib helpers.

import numpy as np
import openquantumsim as oqs
space = oqs.FockSpace(30, label="cavity")
alpha = 1.0 + 0.5j
rho = oqs.ket2dm(oqs.coherent(space, alpha))

x, p = oqs.phase_space_grid(xlim=(-5.0, 5.0), points=201)
W = oqs.wigner(rho, x, p)
Q = oqs.q_function(rho, x, p)
W.shape, Q.shape
ax = oqs.plot_wigner(rho, x, p)
ax.set_title("Coherent-state Wigner function")
ax = oqs.plot_q_function(rho, x, p)
ax.set_title("Coherent-state Husimi Q function")

The numeric arrays W and Q are ordinary NumPy arrays, so they can be passed to custom plotting, fitting, or export pipelines.