예제 #1
0
    def send_qubits(self, n):

        # generate n random bits and orientations
        for _ in range(n):
            self.bits.append(random.randint(0, 1))
            self.orientations.append(random.randint(0, 1))

        for i in range(len(self.bits)):
            if (self.orientations[i] == 1):
                self.qubits.append(Qubit(0 + (self.bits[i] * 180)))
            else:
                self.qubits.append(Qubit(90 + (self.bits[i] * 180)))

        return self.qubits
def solve(num):
    if isPrime(num):
        print "prime factor:", num
        return

    # the maximum possile smallest factor of any number is its square root
    maxVal = num**.5
    #we need 2^maxVal qubits
    qubitNum = int(math.ceil(math.log(maxVal, 2)))

    qubits = []
    qubitVals = []
    for x in range(qubitNum):
        qubits.append(Qubit())
        qubitVals.append(0)

    isHorizMeasurement = 1
    while True:
        measure_qubits(qubits, qubitVals, isHorizMeasurement)
        testFactor = calcValue(qubitVals)

        #if testFactor is a factor, then check if it is prime.
        #if the factor is not prime, call solve on both testFactor and num/testFactor
        if testFactor > 1:
            if num % testFactor == 0:
                if isPrime(testFactor):
                    print "prime factor:", testFactor
                    solve(num / testFactor)
                    return
                else:
                    solve(testFactor)
                    solve(num / testFactor)
                    return

        isHorizMeasurement ^= 1
예제 #3
0
 def build_equal_opportunity_qubit():
     """
     This method creates a qubit with equal-opportunity
     :return: equal-opportunity qubit 
     """
     equal_opportunity_number = 1 / pow(2, 0.5)
     alpha_function = Complex(equal_opportunity_number, 0)
     beta_function = Complex(equal_opportunity_number, 0)
     return Qubit(alpha_function, beta_function)
예제 #4
0
def get_pipistrello_default(setup):
    """
    Given an FPGA setup, sets the qubits to be used in our default Pipistrello lab setup
    :param setup: The FPGA object that will be using these qubits
    :return: None
    """
    
    # First, create the qubits
    q0 = Qubit("Q0", {"mw": "ttl0", "green": "ttl1", "apd": "pmt0"}, None)
    setup.qubits = [q0]
예제 #5
0
 def build_random_qubit():
     """
     This method creates a qubit with random probability
     :return: qubit with random probability
     """
     normalize_vector = Utilities.random_distribution_generation(4)
     alpha_function = Complex(pow(normalize_vector[0], 0.5),
                              pow(normalize_vector[1], 0.5))
     beta_function = Complex(pow(normalize_vector[2], 0.5),
                             pow(normalize_vector[3], 0.5))
     return Qubit(alpha_function, beta_function)
예제 #6
0
    def __init__(self, *args):
        """
        Generates a lattice of size l_1 x l_2 x ... for size = (l_1, l_2,
        ...). Each lattice site contains a qubit.

        Args:
            size(list of int): length of the lattice in each directions

        Examples:
            The following code will create an instance my_lattice, whose size
            is 2 x 3.

            >>> my_lattice = Lattice(2, 3)
            >>> print(my_lattice.pts)
            [(0,0), (0,1), (0,2), (1,0), (1,1), (1,2)]
        """
        if args:
            self.pts = [Point(loc) for loc in np.ndindex(args)]
            self.qubits = {v: Qubit(v) for v in self.pts}
        else:
            self.pts = []
            self.qubits = {}
예제 #7
0
    def expand(self, *blowup_factor):
        """
        Expand the existing lattice to a larger lattice.
        Returns a Lattice instance which are expanded by the blowup_factor.
        The qubits of the original instance is used as some of the qubits
        of the new instance. New qubits are created as well.

        Args:
            blowup_factor (tuple): A factor by which each direction is blown
            up.

        Returns:
            Lattice: Returns an expanded lattice. The points in the original
                     instance is blown up by the blowup_factor. Missing sites
                     between these sites is filled up. The qubits on the blown
                     up sites are identified with the qubits of the original
                     instance. For the new sites, new qubits are created.
        """
        if isinstance(blowup_factor, int):
            factor = tuple([blowup_factor for i in range(self.d)])
        else:
            factor = tuple(blowup_factor)
        # set of new points
        pts = [Point(loc) for loc in np.ndindex(self.size * factor)]
        pts_inherited = [v * factor for v in self.pts]
        pts_new = [loc for loc in pts if loc not in pts_inherited]

        # embed the old qubits to a new lattice
        elattice = Lattice()
        elattice.pts = pts
        elattice.qubits = {v * factor: self.qubits[v] for v in self.pts}
        # change the label_circuit for the old qubits
        for v in pts_inherited:
            elattice.qubits[v].label_circuit = v
        # introduce the new qubits
        for v in pts_new:
            elattice.qubits[v] = Qubit(v)
        return elattice
예제 #8
0
x = random.randint(0, 1)
y = random.randint(0, 1)

# Inicjalizacja macierzy pomiaru
M0 = M0()
M1 = M1()

# Inicjalizacja Bramek
H = Hadamard()
CNOT = Cnot()
I = Identity()
RY_pi_4 = RY(pi / 4)
RY_pi_8 = RY(pi / 8)

# Splątany Qubity Alicji i Boba
qx = Qubit(Complex(1, 0), Complex(0, 0))
qy = Qubit(Complex(1, 0), Complex(0, 0))

qx = qx * H
xy = tensordot(qx, qy)
first = np.tensordot(CNOT, xy, axes=[1, 0])
# print("splątany = ", xy)

RYGATE = np.kron(RY(pi / 4), RY(pi / 8))
# print(RY)
second = np.tensordot(RYGATE, first, axes=[1, 0])
# print(second)
# print(x, y)

# Alice
if x == 0:
        )
        pulsar.define_channel(
            id='ch{}_marker2'.format(i + 1),
            name='ch{}_marker2'.format(i + 1),
            type='marker',
            high=2,
            low=0,
            offset=0.,
            delay=0,
            active=True,
        )
    return pulsar


#%%
Qubit_1 = Qubit(name='Qubit_1')

Qubit_2 = Qubit(name='Qubit_2')

Qubit_1.define_gate(gate_name='Microwave1',
                    gate_number=1,
                    microwave=1,
                    channel_I='ch1',
                    channel_Q='ch2',
                    channel_PM='ch1_marker1')

Qubit_1.define_gate(gate_name='T',
                    gate_number=3,
                    gate_function='plunger',
                    channel_VP='ch7')
def initialize(reinit=False, server_name=None):
    global ivvi1, ivvi2, gates, digitizer, lockin1, lockin2, awg, awg2, vsg, vsg2, magnet, sig_gen, keithley, gate_map, station, mwindows, output_map, qubit_1, qubit_2

    #qcodes.installZMQlogger()
    logging.info('LD400: initialize')
    print('\n')

    if _initialized and not reinit:
        return station

    if server_name is None:
        server_name_virtual = None
    else:
        server_name_virtual = server_name + '_virtualgates'

    # initialize qubit object

    qubit_1 = Qubit(name='qubit_1')

    qubit_2 = Qubit(name='qubit_2')

    qubit_1.define_gate(gate_name='Microwave1',
                        gate_number=1,
                        microwave=1,
                        channel_I='ch1',
                        channel_Q='ch2',
                        channel_PM='ch1_marker1')

    #   Qubit_1.define_gate(gate_name = 'RP1', gate_number = 2, microwave = 1, channel_I = 'RP1I', channel_Q = 'RP1Q')
    #
    qubit_1.define_gate(gate_name='T',
                        gate_number=3,
                        gate_function='plunger',
                        channel_VP='ch7')
    #
    qubit_2.define_gate(gate_name='Microwave2',
                        gate_number=4,
                        microwave=1,
                        channel_I='ch3',
                        channel_Q='ch4',
                        channel_PM='ch1_marker2')
    #
    qubit_2.define_gate(gate_name='LP',
                        gate_number=5,
                        gate_function='plunger',
                        channel_VP='ch6')

    qubit_1.define_neighbor(neighbor_qubit='qubit_2', pulse_delay=0e-9)

    qubit_2.define_neighbor(neighbor_qubit='qubit_1', pulse_delay=10e-9)

    # Loading IVVI
    logging.info('LD400: load IVVI driver')

    ivvi1 = IVVI.IVVI(name='ivvi1',
                      dac_step=10,
                      dac_delay=0.025,
                      address='COM5',
                      server_name=server_name,
                      numdacs=16,
                      use_locks=True)

    ivvi2 = IVVI.IVVI(name='ivvi2',
                      dac_step=10,
                      dac_delay=0.025,
                      address='COM6',
                      server_name=server_name,
                      numdacs=16,
                      use_locks=True)

    print('')

    #

    #    def twodotboundaries():
    #        global ivvi1
    #        gate_boundaries = dict({
    #                'VI1': (-600, 600),
    #                'VI2': (-600, 600),
    #                'acQD': (-300, 300),
    #                'acres': (-300, 300),
    #
    #                'RS': (-1000, 200),
    #                'RD': (-1500, 200),
    #                'LP': (-1000, 200),
    #                'LPF': (-100, 100),
    #                'RP': (-1500, 200),
    #                'RPF': (-100, 100),
    #
    #                'LS': (-1000, 200),
    #                'T': (-1000, 200),
    #
    #                'LD': (-1000, 200),
    #                'B': (-1000, 200),
    #
    #                'SQD1': (-1000, 200),
    #                'SQD2': (-1000, 200),
    #                'SQD3': (-1000, 200),
    #                'RQPC': (-1000, 200),
    #            })
    #
    #        if ivvi1 is not None:
    #        # update boundaries to resolution of the dac
    #            for k in gate_boundaries:
    #                bb=gate_boundaries[k]
    #                bb=(ivvi1.round_dac(bb[0]), ivvi1.round_dac(bb[1]) )
    #                gate_boundaries[k] =bb
    #        return gate_boundaries
    #    boundaries = twodotboundaries()

    gates = virtual_IVVI(name='gates',
                         gate_map=gate_map,
                         server_name=server_name_virtual,
                         instruments=[ivvi1, ivvi2])

    gate_boundaries = twodotboundaries()
    gates.set_boundaries(gate_boundaries)

    logging.info('boundaries set to gates')
    # Loading AWG

    logging.info('LD400: load AWG driver')
    awg2 = AWG5014.Tektronix_AWG5014(
        name='awg2',
        address='TCPIP0::192.168.0.4::inst0::INSTR',
        server_name=server_name)
    print('awg2 loaded')

    logging.info('LD400: load AWG driver')
    awg = AWG5014.Tektronix_AWG5014(
        name='awg',
        address='TCPIP0::192.168.0.9::inst0::INSTR',
        server_name=server_name)
    print('awg loaded')

    awg2.write('SOUR1:ROSC:SOUR EXT')
    awg.write('SOUR1:ROSC:SOUR INT')
    awg.force_trigger()
    awg.clock_freq(1e9)
    awg2.clock_freq(1e9)
    awg2.trigger_level(0.5)

    #Loading Microwave source
    logging.info('Keysight signal generator driver')
    vsg = E8267D.E8267D(name='vsg',
                        address='TCPIP::192.168.0.11::INSTR',
                        server_name=server_name)
    print('VSG loaded')

    logging.info('Keysight signal generator driver')
    vsg2 = E8267D.E8267D(name='vsg2',
                         address='TCPIP::192.168.0.12::INSTR',
                         server_name=server_name)
    print('VSG2 loaded')
    """
    logging.info('LD400: load AWG driver')
    awg = AWG5200.Tektronix_AWG5014(name='awg', address='TCPIP0::192.168.0.8::inst0::INSTR', timeout = 180, server_name=server_name)
    print('awg loaded')
    """

    #    #load keithley driver
    keithley = keith2700.Keithley_2700(name='keithley',
                                       address='GPIB0::15::INSTR',
                                       server_name=server_name)
    #

    #     Loading digitizer
    logging.info('LD400: load digitizer driver')
    digitizer = M4i.M4i(name='digitizer', server_name=server_name)
    if digitizer == None:
        print('Digitizer driver not laoded')
    else:
        print('Digitizer driver loaded')
    print('')

    #    logging.info('all drivers have been loaded')
    print('digitizer finished')

    #     Create map for gates and outputs
    #    gates = virtual_gates(name='gates', gate_map=gate_map, server_name=server_name, instruments=[ivvi, lockin1, lockin2])

    #    output_map = {
    #                  'Id': lockin1.X,
    #                  'Is': lockin2.X,
    #                  'Id_R': lockin1.R,
    #                  'Is_R' : lockin2.R,
    #                  'Idc': keithley.amplitude
    #    }

    #Creating the experimental station
    #station = qcodes.Station(ivvi, awg, lockin1, lockin2, digitizer, gates)
    #    station = qcodes.Station(ivvi, lockin1, lockin2, digitizer, gates)
    #    station = qcodes.Station(awg, awg2, vsg, vsg2, digitizer, qubit_1, qubit_2)
    components = [
        awg, awg2, vsg, vsg2, digitizer, qubit_1, qubit_2, gates, keithley
    ]
    station = Station(*components, update_snapshot=True)
    print('station initialized')
    logging.info('Initialized LDHe station')
    print('Initialized LDHe station\n')

    return station


#%% Initializing station
#initialize()
예제 #11
0
from qubit import Qubit, tensordot, Hadamard, Cnot, Measure, Identity, RCnot, randomQ
from complex import Complex
import numpy as np
import math

Cnot = Cnot()
I = Identity()

q1 = randomQ()
q2 = Qubit(Complex(1 / math.sqrt(2), 0), Complex(1 / math.sqrt(2), 0))
q3 = randomQ()

Q = tensordot(q1, q3)
# Q = np.kron(Q, q3.vector())
print(Q)

# Cnot = np.kron(Cnot, I)
# print(Cnot)
#
# Q = np.tensordot(Cnot, Q, axes=[1,0])
# print(Q)
예제 #12
0
import numpy as np
import math

#Inicjalizacja macierzy pomiaru
M0 = M0()
M1 = M1()

#Inicjalizacja Bramek
X = PauliX()
H = Hadamard()
CNOT = Cnot()
RCNOT = RCnot()
I = Identity()

#Splątany Qubity Alicji i Boba
x = Qubit(Complex(1, 0), Complex(0, 0))
y = Qubit(Complex(1, 0), Complex(0, 0))

x = x * H
xy = tensordot(x, y)
xy = np.tensordot(CNOT, xy, axes=[1,0])
print("splątany = ", xy)

#Qubit do teleportowania
psi = randomQ()
# psi = Qubit(Complex(0, 0), Complex(1, 0))
print("Qubit po stronie Alicji")
print("psi = ", psi.alpha, psi.beta)

#Pierwszy Krok
# first = np.kron(xy, psi.vector())
예제 #13
0
 def deallocate_qubit(self, qubit: Qubit):
     qubit.reset()
     self.available_qubits.append(qubit)
예제 #14
0
def measure_message_qubit(basis: bool, q: Qubit):
    if basis:
        q.h()
    result = q.measure()
    return result
예제 #15
0
def prepare_message_qubit(message: bool, basis: bool, q: Qubit):
    if message:
        q.x()
    if basis:
        q.h()
               name='initialize_2',
               refpulse='initialize_1',
               refpoint='center')

initialize.add(CosPulse(
    channel='ch%d' % plungerchannel,
    name='initialize_3',
    frequency=1e6,
    amplitude=0.5 * initialize_amplitude,
    length=1.5e-6,
),
               name='initialize_3',
               refpulse='initialize_1',
               refpoint='end')

Qubit_1 = Qubit(name='Qubit_1')

Qubit_2 = Qubit(name='Qubit_2')

Qubit_1.define_gate(gate_name='LP1',
                    gate_number=1,
                    microwave=1,
                    channel_I='ch2',
                    channel_Q='ch3',
                    channel_PM='ch2_marker1')

#Qubit_1.define_gate(gate_name = 'RP1', gate_number = 2, microwave = 1, channel_I = 'RP1I', channel_Q = 'RP1Q')
#
Qubit_1.define_gate(gate_name='Plunger1',
                    gate_number=3,
                    gate_function='plunger',