示例#1
0
    def create_EPR(self, host_a_id, host_b_id, q_id=None, block=False):
        """
        Creates an EPR pair for two qubits and returns one of the qubits.

        Args:
            host_a_id (String): ID of the first host who gets the EPR state.
            host_b_id (String): ID of the second host who gets the EPR state.
            q_id (String): Optional id which both qubits should have.
            block (bool): Determines if the created pair should be blocked or not.
        Returns:
            Returns a qubit. The qubit belongs to host a. To get the second
            qubit of host b, the receive_epr function has to be called.
        """
        name1 = str(uuid.uuid4())
        name2 = str(uuid.uuid4())
        host_a = self._hosts.get_from_dict(host_a_id)
        host_b = self._hosts.get_from_dict(host_b_id)
        qubit1 = (QuTipBackend.QubitCollection(name1), name1)
        qubit2 = (QuTipBackend.QubitCollection(name2), name2)
        qubit1[0].apply_single_gate(snot(), qubit1[1])
        qubit1[0].add_qubit(qubit2[0])
        qubit2 = (qubit1[0], name2)
        qubit1[0].apply_double_gate(cnot(), qubit1[1], qubit2[1])
        q1 = Qubit(host_a, qubit=qubit1, q_id=q_id, blocked=block)
        q2 = Qubit(host_b, qubit=qubit2, q_id=q1.id, blocked=block)
        self.store_ent_pair(host_a.host_id, host_b.host_id, q2)
        return q1
示例#2
0
    def cphase(self, qubit, target):
        """
        Applies a controlled z gate to the target qubit.

        Args:
            qubit (Qubit): Qubit to control cphase.
            target (Qubit): Qubit on which the cphase gate should be applied.
        """
        gate = cnot()
        qubit_collection, c_name = qubit.qubit
        qubit_collection2, t_name = target.qubit
        if qubit_collection != qubit_collection2:
            qubit_collection.add_qubit(qubit_collection2)
            target.qubit = (qubit_collection, t_name)
        qubit_collection.apply_double_gate(gate, c_name, t_name)
def evolute(state):
    state = cnot(3, 0, 1) * state
    state = snot(3, 0) * state

    return state.unit()
示例#4
0
measureQ = 0  #index of qubit being measured

#-----------------------------------------------------------------------------
#Initial state
state = qt.basis(2**numQ, 1)
state = state.unit()
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
#Gates (operate on state from highest to lowest)
gates = []
gates.append(qt.tensor(snot(), snot(), snot()))
#gates.append(qt.tensor(qt.qeye(4), qt.sigmax())) #constant f ex. 1
#gates.append(qt.qeye(8)) #constant f ex. 2
#gates.append(cnot(numQ, 0, 2)) #balanced f ex. 1
gates.append(qt.tensor(qt.qeye(2), cnot()))  #balanced f ex. 2
gates.append(qt.tensor(snot(), snot(), qt.qeye(2)))
#-----------------------------------------------------------------------------


def emulate():
    ser = serial.Serial('COM4', 115200,
                        timeout=1)  #open COM4 port at 115200 baud
    count = 0
    gateCount = 0
    outState = qt.basis(2**numQ) - qt.basis(
        2**numQ)  #empty state of appropriate size
    startTime = time.time(
    )  #start the timer here, since gate creation runtime is inconsistent
    #Loop through each element in state and send it to MicroBlaze
    for i in range(2**numQ):
示例#5
0
import qutip.control.pulseoptim as cpo

#example_name = 'Lindblad'

#The Hamiltoninan model
Sx = sigmax()
Sy = sigmay()
Sz = sigmaz()
#Sm = sigmam()
Si = identity(2)
sm1 = tensor(sigmam(),Si)
sm2 = tensor(Si,sigmam())
sz1 = tensor(Sz,Si)
sz2 = tensor(Si,Sz)
#cnot gate
cnot_gate = cnot()
U_targ = cr(phi=-np.pi/2)
U0 = identity(4)

#Hamiltonian parameters
#IBM Bogota
w0 = 5. #GHz
w1 = 4.844 #GHz
del12 = w0-w1 #GHz
J = (0.0083)/(2*np.pi) #GHz
coup = (J*0.25/del12)
t01 = (85.86/1e-3) #ns
t02 = (108.53/1e-3) #ns
t11 = (113.13/1e-3) #ns
t12 = (72.74/1e-3) #ns
# Time allowed for the evolution
示例#6
0
eps = 0.7
Re = eps    # reeward ratio
P = 1./eps  # punishment ratio

t_e = uniform(0,pi)     # random theta angle
p_e = uniform(0,2*pi)   # random phi angle
N = 200   # number of iterations

# operators
X = qip.sigmax()    # x-Pauli operator
Z = qip.sigmaz()    # z-Pauli operator
P_0 = basis(2,0)*basis(2,0).dag()   # projector onto eigenspace spanned by |0>
P_0 = gate_expand_1toN(P_0,2,0)
I = qip.qeye(2)   # identity operator
Ucnot = cnot(control=1, target=0)   # cnot gate

# initial conditions
Delta = 4*pi    # exploration range
U = I
u = I

# initial states
A = basis(2,0)  # agent in the state |0>
E = basis(2,0)*cos(t_e/2) + basis(2,1)*sin(t_e/2)*exp(1j*p_e)   # environment state

F_hist = [fidelity(E,A)]     # list to store fidelities
D_hist = [Delta/pi]     # list to store deltas

# begin iteration
for k in range(2, N+1):