コード例 #1
0
ファイル: pulseshapes.py プロジェクト: wiwa/qc
def plotShape(pulsef, name, end=14*pi/3):
    shape = plt.figure()
    pulse_time = np.linspace(0, end, 5000)
    plt.plot(pulse_time, [pulsef(t) for t in pulse_time], "b-", label=name)
    plt.legend(loc="best")
    plt.ylabel(r"Amplitude in $a_{max}$")
    plt.xlabel(r"t in $\hbar/a_{max}$")
    plt.ylim([-1.1,1.1])
    plt.xlim([0.,end])
    filename = base + name.replace(" ", "_") + "-shape.png"
    shape.savefig(filename)
コード例 #2
0
        return pool.map(f, xs)
    return map(f, xs)


p_t = []

# XXX SHAPE
pulseshape = donorm(x2p(2., periods=_periods),
                    0,
                    2 * _periods,
                    normproc="none")
# pulseshape = X_factory(pi, 2, True, 1, normproc="full")
tis = np.linspace(0, 6, 1000)
pulseshape_data = [pulseshape(ti) for ti in tis]
pshape = plt.figure()
plt.plot(tis, pulseshape_data, 'b-')
# plt.show()

plt.ion()
fig, ax = plt.subplots()
fig.suptitle(wave + ":" + ptitle)

p1, = plt.plot(p_t, sym1, 'b--', label="t=1")
p3, = plt.plot(p_t, sym3, 'r-', label="t=3")
p15, = plt.plot(p_t, sym12, 'g--', label="t=12")

plt.xlabel(r"width in $\hbar / a_max$")
plt.ylabel(r"$\phi(\rho_f, \rho_0)$")
plt.legend(loc='best')
plt.show()
plt.pause(0.0001)
コード例 #3
0
rho_0 = dm_1
rho_f = dm_0
eta_0 = Delta
N = 420  # number of RTN trajectories
t_end = 21  # end of RTN
T = pi

tau_c_0 = 0.5 * (a_max / hbar)
tau_c_f = 20. * (a_max / hbar)
dtau_c = 0.5 * (a_max / hbar)
tau_c = tau_c_0
tau_cs = [tau_c]
while tau_c < tau_c_f:
    tau_c += dtau_c
    tau_cs.append(tau_c)

fids = []

for i in range(len(tau_cs)):
    print(str(i) + "/" + str(len(tau_cs)))
    tau_c = tau_cs[i]
    rho_pi = ezGenerate_Rho(a_pi, t_end, tau_c, eta_0, rho_0, N)
    fid = fidSingleTxDirect(rho_f, rho_pi, T)
    fids.append(fid)

fig = plt.figure()
plt.plot(tau_cs, fids, 'r--', label="pi pulse")
plt.axis([0, 30, 0.975, 1])
plt.legend(loc='best')
plt.show()
コード例 #4
0
fids_pi = np.loadtxt(base + "fids_pi.txt", dtype=ct)
fids_C = np.loadtxt(base + "fids_C.txt", dtype=ct)
fids_SC = np.loadtxt(base + "fids_SC.txt", dtype=ct)

# tx = []
# print(len(fids_C))
# tx.append(fids_C[0])
# for i in range(1,len(fids_C) - 1):
#     # if i % 2 == 0:
#     #     continue
#     avg = (fids_C[i-1] + fids_C[i] + fids_C[i+1]) / 3.
#     mx = max([fids_C[i-1], fids_C[i], fids_C[i+1]])
#     tx.append(avg)
#     # tx.append(avg)
# tx.append(fids_C[-1])
# print(len(tx))
# fids_C = np.array(tx)

tau_cs = np.array(tau_cs)
xnew = tau_cs
# xnew = np.linspace(tau_cs.min(),tau_cs.max(),400)
# fids_pi = spline(tau_cs, fids_pi, xnew)
# fids_C = spline(tau_cs, fids_C, xnew)
# fids_SC = spline(tau_cs, fids_SC, xnew)

plt.plot(xnew, fids_pi, 'b--', label="pi pulse")
plt.plot(xnew, fids_C, 'r-', lw=2, label="CORPSE pulse")
plt.plot(xnew, fids_SC, 'r--', label="SCORPSE pulse")

plt.show()
コード例 #5
0
ファイル: scorpseSearch.py プロジェクト: wiwa/qc
Starting...
""".format(**locals()))


def ezmap(f, xs):
    if parallel:
        return pool.map(f, xs)
    return map(f, xs)


p_t = []

plt.ion()
fig, ax = plt.subplots()

p1, = plt.plot(p_t, sym1, 'b--', label="t=1")
p3, = plt.plot(p_t, sym3, 'r-', label="t=3")
p15, = plt.plot(p_t, sym15, 'g--', label="t=15")

plt.xlabel("tau in (hbar / a_max)")
plt.ylabel("fidelity \\phi(rho_f, rho_0)")
plt.legend(loc='best')
plt.show()
plt.pause(0.0001)

start = time.time()
prev_time = -1
for i in range(len(taus)):
    tau = taus[i]

    p_t.append(tau)
コード例 #6
0
ファイル: q1.py プロジェクト: wiwa/qc
checkGrape = False
# checkGrape = True
if checkGrape:
    pulses = buildGrapePulses([1.,0.5,0.25,0.75,1.],3)
    ts = np.linspace(0, 3, 1000)
    az = []
    for t in ts:
        dt = 3. / len(pulses)
        t_bin = int(np.floor((t / dt)))
        t_bin = min(t_bin, len(pulses) - 1)
        az.append(pulses[t_bin](t))
    # print(pulses[0](0.))
    # print(pulses[0](0))
    # print(az)
    plt.plot(ts, az, 'r-')
    plt.show()
    raw_input()

# T_G = 5. * hoa # sousa figure 2
T_G = T_SC # can just make them the same
n = 8 # number of different pulse amplitudes
epsilon = 0.009 # amount each gradient step can influence amps
grape_steps = 3000 # number of optimization steps
### Grape
doGrape = True
if doGrape:
    tau_grape = 30. # optimize for this point...
    # init_amps = [a_max for i in range(n)]
    init_amps = [x*a_max for x in [-1, -1, 1, 1, 1, 1, 1, -1]]
    grape_amps = init_amps
コード例 #7
0
#         fids: []
#     }
# pulse_infos = {
#     pi: mkInfo(a_pi, T_pi),
#     corpse: mkInfo(a_C, T_C),
#     scorpse: mkInfo(a_SC, T_SC),
#     sym: mkInfo(sym_pi, tau)
#     }

p_t = []

shapefig = plt.figure()
chi_time = np.linspace(0 - 1, mytau + 1, 1000)
if do_sym:
    plt.plot(chi_time, [sym_pi(t) for t in chi_time],
             "c-",
             label="Symmetric Pulse shape")
if do_asym:
    plt.plot(chi_time, [asym_pi(t) for t in chi_time],
             "m-",
             label="Antisymmetric Pulse shape")
plt.legend(loc="best")

plt.ion()
fig, ax = plt.subplots()

pulse_plots = []
if do_pi:
    p_pi, = plt.plot(p_t, fids_pi, 'b--', label="pi pulse")
    pulse_plots.append(p_pi)
if do_c:
コード例 #8
0
checkGrape = False
# checkGrape = True
if checkGrape:
    pulses = buildGrapePulses([1., 0.5, 0.25, 0.75, 1.], 3)
    ts = np.linspace(0, 3, 1000)
    az = []
    for t in ts:
        dt = 3. / len(pulses)
        t_bin = int(np.floor((t / dt)))
        t_bin = min(t_bin, len(pulses) - 1)
        az.append(pulses[t_bin](t))
    # print(pulses[0](0.))
    # print(pulses[0](0))
    # print(az)
    plt.plot(ts, az, 'r-')
    plt.show()
    raw_input()

T_G = 7 * pi / 3. * hoa  # sousa figure 2
n = 7  # number of different pulse amplitudes
epsilon = 0.025  # amount each gradient step can influence amps
grape_steps = 2500  # number of optimization steps
### Grape
# doGrape = True
doGrape = False
if doGrape:
    tau_grape = 30.
    # init_amps = [a_max for i in range(n)]
    inits = [-0.7, 0.7, 0.7, 0.7, 0.7, 0.7, -0.7]
    # inits = [-0.98,0.98,0.98,0.98,0.98,0.98,-0.98]