Skip to content

Instantly share code, notes, and snippets.

@quantshah
Created December 13, 2021 16:30
Show Gist options
  • Save quantshah/3418e44cdad517fc86a340f114d4e407 to your computer and use it in GitHub Desktop.
Save quantshah/3418e44cdad517fc86a340f114d4e407 to your computer and use it in GitHub Desktop.
Cubic phase state definition and Wigner function
import numpy as np
from qutip.wigner import wigner
from qutip import coherent, squeeze, destroy, displace
import matplotlib.pyplot as plt
from matplotlib import colors
def cubic(initial_state, squeezing, gamma):
"""
Generates the cubic phase state ket.
Args:
initial_state (qutip.Qobj): Ket representing the initial state
Default: vacuum, i.e., coherent(N, 0)
squeezing (float): Squeezing parameter.
gamma (float): Cubicity.
Returns:
state (qutip.Qobj): ket representing the initial state
"""
hilbert_size = initial_state.shape[0]
a = destroy(hilbert_size)
op = (1j) * gamma * ((a + a.dag()) / np.sqrt(2)) ** 3
cubic_op = op.expm()
squeezing_op = squeeze(hilbert_size, -squeezing)
state = cubic_op * (squeezing_op * initial_state)
state = state.unit() # Trace normalization
return state
N = 128 # Hilbert space cutoff
squeezing = 0.5
cubicity = -0.3
# initial vacuum state
initial_state = coherent(N, 0)
target_state = cubic(initial_state, squeezing, cubicity)
# Marina displaces the state up to see more of the fringes
target_state = displace(N, 1.5j) * target_state
xvec = np.linspace(-4, 4, 200)
yvec = np.linspace(-4, 4, 200)
# g = 2 sets the convention for hbar that Marina used
w_target = wigner(target_state, xvec, yvec, g=2)
norm = colors.TwoSlopeNorm(vmin=-2 / np.pi, vcenter=0, vmax=2 / np.pi)
im = plt.pcolor(xvec, yvec, w_target, cmap="RdBu_r", norm=norm, shading="auto")
plt.colorbar(im)
plt.xlabel("x")
plt.xlabel("p")
plt.title(
"Cubic phase state \n Squeezing = {} cubicity = {}".format(squeezing, cubicity)
)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment