def save_fig(state, figname):
    fig, ax = qt.hinton(state, [
        '00',
        '01',
        '10',
        '11',
    ], [
        '00',
        '01',
        '10',
        '11',
    ])
    plt.savefig('state_hinton_' + str(figname) + '.png')
    fig, ax = qt.matrix_histogram(state, [
        '00',
        '01',
        '10',
        '11',
    ], [
        '00',
        '01',
        '10',
        '11',
    ])
    plt.savefig('state_hist_' + str(figname) + '.png')
    np.savetxt('state_' + str(figname),
               state,
               header='density matrix data, 00,01,10,11')
Example #2
0
from matplotlib import pyplot
import qutip as q
import numpy as np

measurement = [1.0, 0.5, 0.5]

p1, p2, p3 = measurement
density_matrx = np.array([[1-p1, p3 - .5 + 1.j * (p2-.5)],[p3 - .5 - 1.j * (p2-.5), p1]])
real = np.real(density_matrx)
imag = np.imag(density_matrx)

fig = pyplot.figure()
ax = fig.add_subplot(131, projection = '3d')
q.matrix_histogram(real,  title = 'Real', limits = [-1,1], fig = fig, ax = ax)
ax = fig.add_subplot(132, projection = '3d')
q.matrix_histogram(imag, title = 'Imaginary', limits = [-1,1], fig = fig, ax = ax)
ax = fig.add_subplot(133)
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)

def errorBarSimple(trials, prob):
    #look at wiki http://en.wikipedia.org/wiki/Checking_whether_a_coin_is_fair
    '''returns 1 sigma error bar on each side i.e 1 sigma interval is val - err < val + err'''
    Z = 1.0
    s = np.sqrt(prob * (1.0 - prob) / float(trials))
    err = Z * s
    return err

err = errorBarSimple
trials = 100
Example #3
0
density_matrx = np.array([[z, x + 1j*y],[x - 1j*y, 1 - z]])

real = np.real(density_matrx)
imag = np.imag(density_matrx)

#make the figure
#this uses the qutip routine as the baseline but then makes modifications for bigger font sizes
fig = pyplot.figure()

labels = ['|D>','|S>']
zlim = [-1,1]
norm = matplotlib.colors.Normalize(zlim[0], zlim[1])
#first plot
ax = fig.add_subplot(121, projection = '3d')
ax.set_title('Real', fontsize = 30)
q.matrix_histogram(real,  limits = zlim, fig = fig, ax = ax, colorbar = False)
ax.set_xticklabels(labels, fontsize = 22)
ax.set_yticklabels(labels, fontsize = 22)
ax.tick_params(axis='z', labelsize=22)
cax, kw = matplotlib.colorbar.make_axes(ax, shrink=.75, pad=.0)
cb1 = matplotlib.colorbar.ColorbarBase(cax, norm = norm)
cl = pyplot.getp(cax, 'ymajorticklabels') 
pyplot.setp(cl, fontsize=22)
#next subplot
ax = fig.add_subplot(122, projection = '3d')
ax.set_title('Imaginary', fontsize = 30)
q.matrix_histogram(imag, limits = zlim, fig = fig, ax = ax, colorbar = False)
ax.set_xticklabels(labels, fontsize = 22)
ax.set_yticklabels(labels, fontsize = 22)
ax.tick_params(axis='z', labelsize=22)
cax, kw = matplotlib.colorbar.make_axes(ax, shrink=.75, pad=.0)
Example #4
0
density_matrx = np.array([[z, x + 1j * y], [x - 1j * y, 1 - z]])

real = np.real(density_matrx)
imag = np.imag(density_matrx)

#make the figure
#this uses the qutip routine as the baseline but then makes modifications for bigger font sizes
fig = pyplot.figure()

labels = ['|D>', '|S>']
zlim = [-1, 1]
norm = matplotlib.colors.Normalize(zlim[0], zlim[1])
#first plot
ax = fig.add_subplot(121, projection='3d')
ax.set_title('Real', fontsize=30)
q.matrix_histogram(real, limits=zlim, fig=fig, ax=ax, colorbar=False)
ax.set_xticklabels(labels, fontsize=22)
ax.set_yticklabels(labels, fontsize=22)
ax.tick_params(axis='z', labelsize=22)
cax, kw = matplotlib.colorbar.make_axes(ax, shrink=.75, pad=.0)
cb1 = matplotlib.colorbar.ColorbarBase(cax, norm=norm)
cl = pyplot.getp(cax, 'ymajorticklabels')
pyplot.setp(cl, fontsize=22)
#next subplot
ax = fig.add_subplot(122, projection='3d')
ax.set_title('Imaginary', fontsize=30)
q.matrix_histogram(imag, limits=zlim, fig=fig, ax=ax, colorbar=False)
ax.set_xticklabels(labels, fontsize=22)
ax.set_yticklabels(labels, fontsize=22)
ax.tick_params(axis='z', labelsize=22)
cax, kw = matplotlib.colorbar.make_axes(ax, shrink=.75, pad=.0)
Example #5
0
def genertate_bell_state(state, noise, tc, dec):
    '''
	state [int]:
		0 : |00> + |11>
		1 : |00> - |11>
		2 : |01> - |10>
		3 : |01> + |10>
	noise [boolean]:
		add noise to the exp
	tc [boolean]:
		turn tunnelcoupling completely off when you do single qubit gates
	dec [boolean]: # not yet implemented.
		enable decoupled gate
	'''

    # Start in |00>
    psi0 = np.array(list(basis(6, 0) * basis(6, 0).dag()))[:, 0]

    # define hamiltonian
    if tc == True:
        db = double_dot_hamiltonian(19.7e9, 18.4e9, 850e9, 840e9, 0 * 0.250e9)
    else:
        db = double_dot_hamiltonian(19.7e9, 18.4e9, 850e9, 840e9, 0.250e9)

    # # # J = ~6MHZ @ epsilon 835e9, t = 210e6 // note a bit of assymetry, so you will get a tiny bit of phase
    chargingE = 850e9 * np.pi * 2
    detuningE = 828.6e9 * np.pi * 2

    # Number of simulation to average.
    num_sim = 500
    if noise == True:
        db = my_noise.add_nuclear_and_charge_noise(db)
        db.number_of_sim_for_static_noise(num_sim)

    # Do MW on both qubits.
    if state == 0 or state == 3:
        db.mw_pulse(19.7e9, np.pi / 2, 2e6, 0e-9, 125e-9)
    else:
        db.mw_pulse(19.7e9, -np.pi / 2, 2e6, 0e-9, 125e-9)

    db.mw_pulse(18.4e9, np.pi / 2, 2e6, 0e-9, 125e-9)

    # If decoupled is used
    if dec == True:

        # implement tunnel coupling pulse.
        if tc == True:
            a = 49e-9
        else:
            a = 40e-9
        db.awg_pulse(detuningE / np.pi / 2, 125e-9, 125e-9 + a, 1e-9)
        if tc == True:
            db.awg_pulse_tc(0.25e9, 123e-9, 127e-9 + a, 0.05e-9)

        db.mw_pulse(18.4e9, 0, 2e6, 200e-9, 450e-9)
        db.mw_pulse(19.7e9, 0, 2e6, 200e-9, 450e-9)
        db.awg_pulse(detuningE / np.pi / 2, 450e-9, 450e-9 + a, 1e-9)
        if tc == True:
            db.awg_pulse_tc(0.25e9, 448e-9, 452e-9 + a, 0.05e-9)

        if state == 1 or state == 3:
            db.mw_pulse(19.7e9, 0, 2e6, 500e-9, 625e-9)
        else:
            db.mw_pulse(19.7e9, np.pi, 2e6, 500e-9, 625e-9)

        db.calc_time_evolution(psi0, 0e-9, 625e-9, int((625e-9) * 1e9 * 100))

    else:
        if tc == True:
            a = 91e-9
        else:
            a = 85e-9
        db.awg_pulse(detuningE / np.pi / 2, 130e-9, 130e-9 + a, 1e-9)
        if tc == True:
            db.awg_pulse_tc(0.25e9, 125e-9, 135e-9 + a, 0.05e-9)

        if state == 1 or state == 3:
            db.mw_pulse(19.7e9, 0, 2e6, 235e-9, 360e-9)
        else:
            db.mw_pulse(19.7e9, np.pi, 2e6, 235e-9, 360e-9)

        db.calc_time_evolution(psi0, 0e-9, 365e-9, int((625e-9) * 1e9 * 100))

    rho = db.get_density_matrix_final()[:4, :4]
    rho_full = db.get_density_matrix_final()

    C = calc_concurrence(rho)
    bell_states = ['00', '01', '11', '10']
    Bell = bell_state(bell_states[state])
    Bell.dims = [[4], [1]]

    F = (Bell.dag() * Qobj(rho) * Bell)[0, 0]

    fig, ax = hinton(rho, ['00', '01', '10', '11'], ['00', '01', '10', '11'])
    plt.savefig('Bell_' + str(state) + '_hinton_dec_' + str(dec) + '_noise_' +
                str(noise) + "_tc_" + str(tc) + '.png')
    fig, ax = matrix_histogram(rho, ['00', '01', '10', '11'],
                               ['00', '01', '10', '11'])
    plt.savefig('Bell_' + str(state) + '_hist_dec_' + str(dec) + '_noise_' +
                str(noise) + "_tc_" + str(tc) + '.png')
    np.savetxt('Bell_' + str(state) + "_dec_" + str(dec) + '_noise_' +
               str(noise) + '_tc_' + str(tc) + '_DM.txt',
               rho_full,
               header='density matrix data, 00,01,10,11,0S,S0')
    np.savetxt('Bell_' + str(state) + "_dec_" + str(dec) + '_noise_' +
               str(noise) + '_tc_' + str(tc) + '_FID.txt',
               np.array([F, C]),
               header='State overlap -- Concurrence')
    db.clear()
Example #6
0
dv.cd(['', 'Experiments', 'RabiTomography', '2013Mar01'])
dv.cd(folder)
dv.open(1)
trials = dv.get_parameter('Tomography.repeat_each_measurement')
measurement = dv.get().asarray
p1, p2, p3 = measurement.transpose()[1]

density_matrx = np.array([[1 - p1, p3 - .5 + 1.j * (p2 - .5)],
                          [p3 - .5 - 1.j * (p2 - .5), p1]])
real = np.real(density_matrx)
imag = np.imag(density_matrx)

fig = pyplot.figure()
ax = fig.add_subplot(131, projection='3d')
q.matrix_histogram(real, title='Real', limits=[-1, 1], fig=fig, ax=ax)
ax = fig.add_subplot(132, projection='3d')
q.matrix_histogram(imag, title='Imaginary', limits=[-1, 1], fig=fig, ax=ax)
ax = fig.add_subplot(133)
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)


def errorBarSimple(trials, prob):
    #look at wiki http://en.wikipedia.org/wiki/Checking_whether_a_coin_is_fair
    '''returns 1 sigma error bar on each side i.e 1 sigma interval is val - err < val + err'''
    Z = 1.0
    s = np.sqrt(prob * (1.0 - prob) / float(trials))
    err = Z * s
    return err