def fid14(Uf, N, Uks): c = np.array(1./(12*N)) sigs = [sigmaX, sigmaY, sigmaZ] UfH = Uf.conj().T def term_func(Uk): UkH = Uk.conj().T res = 0. for sig in sigs: red = reduce(np.dot, [Uf, sig, UfH, Uk, sig, UkH]) res += np.trace(red) return res terms = map(term_func, Uks) res = np.array(1/2.) + c * sum(terms) return res
def U_k(t): a_, err1 = integrate.quad(a, 0, t) eta_k_, err2 = integrate.quad(eta_k, 0, t) H_ = -(1.j / hbar) * H_t(a_, eta_k_) # print("U_K") # print(np.array(H_)) return expm(np.array(H_))
def grad_phi_am(T, N, m, Us_mk, rho_0, rho_f): delta_t = T / n c = np.array((-1.j/2) * delta_t / N) terms = [] res = 0 def makeTerm(k): # U_k = Us_mk[k] # Us_nm_k = U_k[m:(n-1)] # # Us_nm_k.reverse() # Us_m1_k = U_k[0:(m-1)] # # Us_m1_k.reverse() # # U_nm_k = reduce(np.dot, reversed(Us_nm_k),identity) # U_nm_kH = U_nm_k.conj().T # U_m1_k = reduce(np.dot, reversed(Us_m1_k),identity) # U_m1_kH = U_m1_k.conj().T # # lambda_mk = reduce(np.dot, [U_nm_kH, rho_f, U_nm_k]) # lambda_H = lambda_mk.conj().T # rho_mk = reduce(np.dot, [U_m1_k, rho_0, U_m1_kH]) U_k = Us_mk[k] lambda_mk = makeLambda_mk(U_k, m, rho_f) lambda_H = lambda_mk.conj().T rho_mk = makeRho_mk(U_k, m, rho_0) term = np.trace(np.dot(lambda_H, comm(sigmaX, rho_mk))) return term # if parallel: # terms = pool.map(makeTerm, range(N)) # else: terms = map(makeTerm, range(N)) res = sum(terms) res = c * res return res
def fidSingleTxFull(rho_0, rho_f, T, N, Us): U_k_ts = [np.array(U_k(T), np.complex128) for U_k in Us] mats = [ np.dot(np.dot(rho_f.conj().T, U_k_t), np.dot(rho_0, U_k_t.conj().T)) for U_k_t in U_k_ts ] terms = [np.trace(mat) for mat in mats] return (1. / N) * sum(terms)
def U_k(t): if t < t0: return identity if te is not None \ and te < t: return identity start = time.time() steps = int(np.ceil(t / stepsize)) # steps = 700 ts = np.linspace(t0, t, steps) dt = ts[1] - ts[0] cvec = np.array(dt * -(1j), np.complex128) def G(t_): if profiling: start = time.time() hp = H_p(a, eta_k, t_) teatime = time.time() th_time[0] += teatime - start res = np.dot(cvec, hp) g_time[0] += time.time() - teatime return res return np.dot(cvec, H_t2(a(t_), eta_k(t_))) C = G(ts[0]) for i in range(1, len(ts)): # G_avg = 0.5 * (G(ts[i-1]) + G(ts[i])) C = BCH(C, G(ts[i]), order=5) # C = sum(Ss) # U_count[0] += 1 end = time.time() delts = str(end - start) # sys.stdout.write("\rU++: " + str(U_count[0]) + "; " + delts) # sys.stdout.flush() # return linmax.powerexp(C) return expm(C)
def R(U_k): U = np.array(U_k(t)) return np.dot(np.dot(U, rho_0), U.conj().T)
def evalMat(dec_U_k): U_k, t = dec_U_k return np.array(U_k(t))
bch_time = [0.] g_time = [0.] a_time = [0.] eta_time = [0.] h_time = [0.] th_time = [0.] ### # Reproduction of: # High-fidelity one-qubit operations under random telegraph noise # Mikko Mottonen and Rogerio de Sousa ### profiling = False parallel = (not profiling) and False sigmaX = np.array([[0., 1.], [1., 0.]], np.complex128) sigmaY = np.array([[0., -1.j], [1.j, 0.]], np.complex128) sigmaZ = np.array([[1., 0.], [0., -1.]], np.complex128) #### hbar = 1. # Maximum amplitude of control field # set to hbar so that hbar/a_max = 1 a_max = hbar # Noise strength # 0.125 is the factor used in the paper Delta = 0.125 * a_max
sigmaY = np.matrix([[0, -1j], [1j, 0]]) sigmaZ = np.matrix([[1, 0], [0, -1]]) #### # Maximum amplitude of control field # set to hbar so that hbar/a_max = 1 a_max = hbar # Noise strength # 0.125 is the factor used in the paper Delta = 0.125 * a_max # Computational Bases cb_0 = np.array([1, 0]) cb_1 = np.array([0, 1]) # Density Matrices dm_0 = np.matrix([cb_0, [0, 0]]).T dm_1 = np.matrix([[0, 0], cb_1]).T ### Pulses # Eq. 15 # Pi pulse def a_pi(t): if 0 < t and t < (pi * hbar / a_max): return a_max return 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()
def G(t_): return np.array(-(1.j/hbar) * H_t(self.pulse(t_), eta(t_)))
th_time = [0.] ### # Reproduction of: # High-fidelity one-qubit operations under random telegraph noise # Mikko Mottonen and Rogerio de Sousa ### profiling = False parallel = (not profiling) and False base = "pulse_plots/" if not os.path.exists(base): print "Creating directory" os.makedirs(base) sigmaX = np.array([ [0., 1.] , [1., 0.] ], np.complex128) sigmaY = np.array([ [0.,-1.j] , [1.j, 0.] ], np.complex128) sigmaZ = np.array([ [1., 0.] , [0.,-1.] ], np.complex128) #### hbar = 1. # Maximum amplitude of control field # set to hbar so that hbar/a_max = 1 a_max = hbar # Noise strength