def swap_map(x): base = (1j * x * swap()).expm() dims = [[[2], [2]], [[2], [2]]] return Qobj(base, dims=dims, type='super', superrep='super')
from qutip.qip.operations import swap from diamond import * from qutip import * from math import * # Define gates for 2 diamond chip # -- 1: z = π/2 -------- 2: z = π/3 --- # # 0:C1a 4:C1b # 2:T1a | 3:T2a –– 6:T1b | 7:T2b # 1:C2a 5:C2b # N = 2 * 4 U2 = lambda t: UN(t, t) SWAP = swap(N, [3, 6]) init = ket('0' * 8) entangling_opers = [{ 'oper': U2(π / 2) * X(N, 0) * U2(π / 2) * X(N, 1), 'state': (ket('11000000') + zero8) / sqrt(2), 'goal state': '1100 0000' }, { 'oper': U2(π / 2) * X(N, 4) * U2(π / 2) * X(N, 5), 'state': (ket('00001100') + zero8) / sqrt(2), 'goal state': '0000 1100' }, { 'oper': U2(π / 2) * X(N, 2) * U2(π / 2) * X(N, 3), 'state': (ket('00110000') + zero8) / sqrt(2), 'goal state': '0011 0000'
def __init__(self): # We start out with all zeros |0000> self._dm = sp.ImmutableDenseMatrix([[1] + [0] * (2**4 - 1), *([[0] * (2**4)] * (2**4 - 1))]) self._swap_matrix = swap(4, [1, 2])
[x3 * sp.exp(1j * phi3)], [x4 * sp.exp(1j * phi4)]]) ws = sp.symbols('w:2:2', real=True, nonnegative=True) omegas = sp.symbols('omega:2:2', real=True) ws_conj = (sp.conjugate(w) for w in ws) w1, w2, w3, w4 = ws _, omega2, omega3, omega4 = omegas init_w_state = sp.ImmutableDenseMatrix([[w1], [w2 * sp.exp(1j * omega2)], [w3 * sp.exp(1j * omega3)], [w4 * sp.exp(1j * omega4)]]) xs2_sum = sum([1.0 * xs[i]**2 for i in range(4)]) ws2_sum = sum([1.0 * ws[i]**2 for i in range(4)]) state = sp.kronecker_product(state, init_w_state) state = swap(4, [1, 2]) @ state norm_factor = normalization_factor(state) state2_sum = 1 / norm_factor**2 # state = norm_factor * state # state = normalize_state(state) state = Ut @ state state = state.subs(1.0, 1).expand(basic=True, complex=True).simplify() dm = density_matrix( state) #.subs(xs[0]*sp.conjugate(xs[0]), sp.abs xs[0].norm()**2) # Measurement of C2 dm_C2 = partial_trace(dm, 4, [0, 2, 3]) P0_C2 = dm_C2[0, 0].simplify() P1_C2 = dm_C2[1, 1].simplify() P01_C2 = (P0_C2 + P1_C2).simplify() # Measurement of T2