Example #1
0
    def set_up_ops(self, N):
        """
        Generate the Hamiltonians for the spinchain model and save them in the
        attribute `ctrls`.

        Parameters
        ----------
        N: int
            The number of qubits in the system.
        """
        # single qubit terms
        self.a = tensor(destroy(self.num_levels))
        self.pulses.append(
            Pulse(self.a.dag() * self.a, [0], spline_kind=self.spline_kind))
        for m in range(N):
            self.pulses.append(
                Pulse(sigmax(), [m + 1], spline_kind=self.spline_kind))
        for m in range(N):
            self.pulses.append(
                Pulse(sigmaz(), [m + 1], spline_kind=self.spline_kind))
        # interaction terms
        a_full = tensor([destroy(self.num_levels)] +
                        [identity(2) for n in range(N)])
        for n in range(N):
            sm = tensor(
                [identity(self.num_levels)] +
                [destroy(2) if m == n else identity(2) for m in range(N)])
            self.pulses.append(
                Pulse(a_full.dag() * sm + a_full * sm.dag(),
                      list(range(N + 1)),
                      spline_kind=self.spline_kind))

        self.psi_proj = tensor([basis(self.num_levels, 0)] +
                               [identity(2) for n in range(N)])
Example #2
0
    def set_up_ops(self, N):
        """
        Generate the Hamiltonians for the circuitqed model and save them in the
        attribute `ctrls`.

        Parameters
        ----------
        N: int
            The number of qubits in the system.
        """
        # single qubit terms
        for m in range(N):
            self.pulses.append(
                Pulse(sigmax(), [m + 1], spline_kind=self.spline_kind))
        for m in range(N):
            self.pulses.append(
                Pulse(sigmaz(), [m + 1], spline_kind=self.spline_kind))
        # coupling terms
        a = tensor([destroy(self.num_levels)] +
                   [identity(2) for n in range(N)])
        for n in range(N):
            sm = tensor(
                [identity(self.num_levels)] +
                [destroy(2) if m == n else identity(2) for m in range(N)])
            self.pulses.append(
                Pulse(a.dag() * sm + a * sm.dag(),
                      list(range(N + 1)),
                      spline_kind=self.spline_kind))
Example #3
0
    def set_up_ops(self, num_qubits):
        """
        Generate the Hamiltonians for the spinchain model and save them in the
        attribute `ctrls`.

        Parameters
        ----------
        num_qubits: int
            The number of qubits in the system.
        """
        # single qubit terms
        for m in range(num_qubits):
            self.add_control(sigmax(), [m + 1], label="sx" + str(m))
        for m in range(num_qubits):
            self.add_control(sigmaz(), [m + 1], label="sz" + str(m))
        # coupling terms
        a = tensor([destroy(self.num_levels)] +
                   [identity(2) for n in range(num_qubits)])
        for n in range(num_qubits):
            sm = tensor([identity(self.num_levels)] + [
                destroy(2) if m == n else identity(2)
                for m in range(num_qubits)
            ])
            self.add_control(a.dag() * sm + a * sm.dag(),
                             list(range(num_qubits + 1)),
                             label="g" + str(n))
Example #4
0
    def set_up_ops(self, N):
        """
        Generate the Hamiltonians for the spinchain model and save them in the
        attribute `ctrls`.

        Parameters
        ----------
        N: int
            The number of qubits in the system.
        """
        # single qubit terms
        self.a = tensor([destroy(self.num_levels)] +
                        [identity(2) for n in range(N)])
        self.ctrls.append(self.a.dag() * self.a)
        self.ctrls += [
            tensor([identity(self.num_levels)] +
                   [sigmax() if m == n else identity(2) for n in range(N)])
            for m in range(N)
        ]
        self.ctrls += [
            tensor([identity(self.num_levels)] +
                   [sigmaz() if m == n else identity(2) for n in range(N)])
            for m in range(N)
        ]
        # interaction terms
        for n in range(N):
            sm = tensor(
                [identity(self.num_levels)] +
                [destroy(2) if m == n else identity(2) for m in range(N)])
            self.ctrls.append(self.a.dag() * sm + self.a * sm.dag())

        self.psi_proj = tensor([basis(self.num_levels, 0)] +
                               [identity(2) for n in range(N)])
Example #5
0
 def eliminate_auxillary_modes(self, U):
     """
     Eliminate the auxillary modes like the cavity modes in cqed.
     """
     psi_proj = tensor([basis(self.num_levels, 0)] +
                       [identity(2) for n in range(self.N)])
     return psi_proj.dag() * U * psi_proj
Example #6
0
    def set_up_ops(self, N):
        """
        Generate the Hamiltonians for the spinchain model and save them in the
        attribute `ctrls`.

        Parameters
        ----------
        N: int
            The number of qubits in the system.
        """
        self.pulse_dict = {}
        index = 0
        # single qubit terms
        for m in range(N):
            self.pulses.append(
                Pulse(sigmax(), [m + 1], spline_kind=self.spline_kind))
            self.pulse_dict["sx" + str(m)] = index
            index += 1
        for m in range(N):
            self.pulses.append(
                Pulse(sigmaz(), [m + 1], spline_kind=self.spline_kind))
            self.pulse_dict["sz" + str(m)] = index
            index += 1
        # coupling terms
        a = tensor([destroy(self.num_levels)] +
                   [identity(2) for n in range(N)])
        for n in range(N):
            sm = tensor(
                [identity(self.num_levels)] +
                [destroy(2) if m == n else identity(2) for m in range(N)])
            self.pulses.append(
                Pulse(a.dag() * sm + a * sm.dag(),
                      list(range(N + 1)),
                      spline_kind=self.spline_kind))
            self.pulse_dict["g" + str(n)] = index
            index += 1
Example #7
0
    def frem_anneal(self, schedules, partition, HR_init_state):
        """
        Performs a numeric FREM anneal on H using QuTip.

        inputs:
        ---------
        schedules - a numeric annealing schedules [reverse, forward]
        partition - a parition of H in the form [HR, HF]
        init_state - the starting state for the reverse anneal listed as string or list
        e.g. '111' or [010]

        outputs:
        ---------
        probs - probability of each output state as a list ordered in canconically w.r.t. tensor product
        """

        # retrieve useful quantities from input data
        f_sch, r_sch = schedules
        times = f_sch[0]
        HR = DictRep(H=partition['HR'],
                     qpu='numerical',
                     vartype='ising',
                     encoding='logical')
        HF = DictRep(H=partition['HF'],
                     qpu='numerical',
                     vartype='ising',
                     encoding='logical')
        Rqubits = partition['Rqubits']

        # prepare the initial state
        statelist = []
        fidx = 0
        ridx = 0
        for qubit in self.qubits:
            # if part of HR, give assigned value by user
            if qubit in Rqubits:
                statelist.append(qts.ket(HR_init_state[ridx]))
                ridx += 1
            # otherwise, put in equal superposition (i.e. gs of x-basis)
            else:
                xstate = (qts.ket('0') - qts.ket('1')).unit()
                statelist.append(xstate)
                fidx += 1
        init_state = qto.tensor(*statelist)

        # Create the numeric Hamiltonian for HR
        ABfuncs = time_interpolation(r_sch, self.processordata)
        numericH = get_numeric_H(HR)
        A = ABfuncs['A(t)']
        B = ABfuncs['B(t)']
        HX = numericH['HX']
        HZ = numericH['HZ']
        # Define list_H for QuTiP
        listHR = [[HX, A], [HZ, B]]

        # create the numeric Hamiltonian for HF
        ABfuncs = time_interpolation(f_sch, self.processordata)
        numericH = get_numeric_H(HF)
        A = ABfuncs['A(t)']
        B = ABfuncs['B(t)']
        HX = numericH['HX']
        HZ = numericH['HZ']
        # "Analytic" or function H(t)
        analHF = lambda t: A(t) * HX + B(t) * HZ
        # Define list_H for QuTiP
        listHF = [[HX, A], [HZ, B]]

        # create the total Hamitlontian of HF + HR
        list_totH = listHR + listHF

        # run the numerical simulation and find probabilities of each state
        frem_results = qt.sesolve(list_totH, init_state, times)
        probs = np.array([
            abs(frem_results.states[-1][i].flatten()[0])**2
            for i in range(self.Hsize)
        ])

        return probs