|
import numpy as np |
|
|
|
from qutip import basis |
|
|
|
from qm import sweepPhaseDown, sweepPhaseUp, sweepPhaseRound |
|
from plotting import plotQubit |
|
|
|
|
|
url = 'https://mareknarozniak.com/2021/01/09/qubit-berry-phase/' |
|
|
|
tau = 16.*np.pi |
|
res = 60 |
|
angles = np.linspace(0., 2., res) |
|
|
|
refrels = np.zeros(res) |
|
refimag = np.zeros(res) |
|
|
|
resrels = np.zeros(res) |
|
resimag = np.zeros(res) |
|
|
|
for i, angle in enumerate(angles): |
|
theta = np.pi*angle |
|
|
|
psi0 = np.cos(theta/2.)*basis(2, 0)+np.sin(theta/2.)*basis(2, 1) |
|
result = sweepPhaseRound(psi0, theta, 0., 2.*np.pi, tau) |
|
psif = result.final_state |
|
|
|
gamma = -2.*np.pi*np.sin(theta/2.)**2. |
|
dyn = np.pi |
|
|
|
grefe = psif.overlap(psi0) |
|
|
|
resrels[i] = grefe.real |
|
resimag[i] = grefe.imag |
|
|
|
ref = np.exp(1j*gamma) |
|
|
|
refrels[i] = ref.real |
|
refimag[i] = ref.imag |
|
|
|
title = '$\\phi_f \\in [0, 2\\pi]$ and $\\theta$ fixed' |
|
x_axis = '$\\theta$ [$\\pi$]' |
|
filename = 'res_qubit.png' |
|
plotQubit(angles, refrels, refimag, resrels, resimag, title, x_axis, filename, url=url) |
|
|
|
refrels = np.zeros(res) |
|
refimag = np.zeros(res) |
|
|
|
resrels = np.zeros(res) |
|
resimag = np.zeros(res) |
|
|
|
# fix theta_min, vary phi |
|
for i, angle in enumerate(angles): |
|
theta_min = 3.*np.pi/4. |
|
theta_max = 0. |
|
|
|
phi_min = 0. |
|
phi_max = np.pi*angle |
|
|
|
psi0 = np.cos(theta_max/2.)*basis(2, 0)+np.sin(theta_max/2.)*basis(2, 1) |
|
|
|
result = sweepPhaseDown(psi0, theta_min, theta_max, phi_min, tau) |
|
psif = result.final_state |
|
|
|
result = sweepPhaseRound(psif, theta_min, phi_min, phi_max, tau) |
|
psif = result.final_state |
|
|
|
result = sweepPhaseUp(psif, theta_min, theta_max, phi_max, tau) |
|
psif = result.final_state |
|
|
|
gamma = -(phi_max-phi_min)*np.sin(theta_min/2.)**2. |
|
grefe = psif.overlap(psi0) |
|
|
|
ref = np.exp(1j*gamma) |
|
|
|
resrels[i] = grefe.real |
|
resimag[i] = grefe.imag |
|
|
|
refrels[i] = ref.real |
|
refimag[i] = ref.imag |
|
|
|
title = '$\\phi_f \\in [0, 2\\pi]$ and $\\theta = \\frac{3\\pi}{4}$ fixed' |
|
x_axis = '$\\phi_f$ [$\\pi$]' |
|
filename = 'res_qubit_2_1.png' |
|
plotQubit(angles, refrels, refimag, resrels, resimag, title, x_axis, filename, url=url) |
|
|
|
refrels = np.zeros(res) |
|
refimag = np.zeros(res) |
|
|
|
resrels = np.zeros(res) |
|
resimag = np.zeros(res) |
|
|
|
# fix phi_max, vary theta_min |
|
for i, angle in enumerate(angles): |
|
theta_min = np.pi*angle |
|
theta_max = 0. |
|
|
|
phi_min = 0. |
|
phi_max = 3.*np.pi/4. |
|
|
|
psi0 = np.cos(theta_max/2.)*basis(2, 0)+np.sin(theta_max/2.)*basis(2, 1) |
|
|
|
result = sweepPhaseDown(psi0, theta_min, theta_max, phi_min, tau) |
|
psif = result.final_state |
|
|
|
result = sweepPhaseRound(psif, theta_min, phi_min, phi_max, tau) |
|
psif = result.final_state |
|
|
|
result = sweepPhaseUp(psif, theta_min, theta_max, phi_max, tau) |
|
psif = result.final_state |
|
|
|
gamma = -(phi_max-phi_min)*np.sin(theta_min/2.)**2. |
|
grefe = psif.overlap(psi0) |
|
|
|
ref = np.exp(1j*gamma) |
|
|
|
resrels[i] = grefe.real |
|
resimag[i] = grefe.imag |
|
|
|
refrels[i] = ref.real |
|
refimag[i] = ref.imag |
|
|
|
title = '$\\theta \\in [0, 2\\pi]$ and $\\phi_f = \\frac{3\\pi}{4}$ fixed' |
|
x_axis = '$\\theta$ [$\\pi$]' |
|
filename = 'res_qubit_2_2.png' |
|
plotQubit(angles, refrels, refimag, resrels, resimag, title, x_axis, filename, url=url) |