def set_paras(sample, key, value=None): sample, qubits, Qubits = loadQubits(sample, write_access=True) if value is None: values = list(map(lambda q: q.get(key), qubits)) return values else: for Q in Qubits: Q[key] = value return value
def qqiswap(sample, measure=0, delay=20 * ns, zpa=None, name='iswap', des=''): """ sample: select experimental parameter from registry; stats: Number of Samples for one sweep point; """ sample, qubits, Qubits = loadQubits(sample, write_access=True) prep_Nqbit(qubits) q = qubits[measure] q_ref = qubits[0] if zpa is None: zpa = q['zpa'] # set some parameters name; axes = [(delay, 'delay'), (zpa, 'zpa')] deps = deps_Nqbitpopu(nq=2, qLevel=2) # create dataset dataset = sweeps.prepDataset(sample, name, axes, deps, kw={}) def runSweeper(devices, para_list): delay, zpa = para_list start = 0. q.xy = XYnothing(q) addXYgate(q, start, np.pi, 0.) start += q['piLen']['s'] + 50e-9 q.z = waveforms.square(amp=zpa, start=start, length=q.piLen[s] + 100e-9) start += 100e-9 start += q['qa_start_delay'][s] for _q in qubits: _q.r = readoutPulse(_q) _q['experiment_length'] = start _q['do_readout'] = True set_qubitsDC(qubits, q_ref['experiment_length']) data = runQ(qubits, devices) prob = tunneling(qubits, data, level=2) clear_waveforms(qubits) return prob axes_scans = gridSweep(axes) result_list = RunAllExp(runSweeper, axes_scans, dataset) return
def tune_f21(sample, dh, df=ar[-40:40:2, MHz], idx_pro=7, measure=0, _key='f21'): sample, qubits, Qubits = loadQubits(sample, write_access=True) Qubit = Qubits[measure] mp.rabihigh21(sample, piamp21=None, df=df, measure=measure, name='rabihigh ' + _key) time.sleep(0.5) _tune_freq(sample, dh, Qubit, idx=-1, idx_pro=idx_pro, _key=_key)
def Nqubit_state(sample, reps=10, measure=[0, 1], states=[0, 0], name='Nqubit_state', des=''): sample, qubits, Qubits = loadQubits(sample, write_access=True) reps = np.arange(reps) prep_Nqbit(qubits) axes = [(reps, 'reps')] labels = gene_binary(len(measure), 2) states_str = functools.reduce(lambda x, y: str(x) + str(y), states) def get_dep(x): return ('', 'measure ' + str(x), '') deps = list(map(get_dep, labels)) q_ref = qubits[0] kw = {} kw['states'] = states dataset = sweeps.prepDataset(sample, name + des, axes, deps, kw=kw) def runSweeper(devices, para_list): start = 0. for i, _qb in enumerate(qubits): _qb.xy = XYnothing(_qb) addXYgate(_qb, start, np.pi * states[i], 0.) start += max(map(lambda q: q['piLen']['s'], qubits)) + 50e-9 for _q in qubits: _q.r = readoutPulse(_q) _q['experiment_length'] = start _q['do_readout'] = True set_qubitsDC(qubits, q_ref['experiment_length']) data = runQ(qubits, devices) prob = tunneling(qubits, data, level=2) clear_waveforms(qubits) return prob axes_scans = gridSweep(axes) result_list = RunAllExp(runSweeper, axes_scans, dataset) return
def tune_piamp(sample, dh, idx=-1, idx_pro=5, measure=0, amp_key='piAmp', steps=30): sample, qubits, Qubits = loadQubits(sample, write_access=True) Qubit = Qubits[measure] piamp0 = Qubit[amp_key] mp.rabihigh(sample, piamp=ar[0.:2. * piamp0:2. * piamp0 / steps], measure=measure, name='rabihigh ' + amp_key) time.sleep(0.5) _tune_piamp(sample, dh, Qubit, idx=idx, idx_pro=idx_pro, plot=True, update=True, amp_key=amp_key)
def measureFidelity(sample, rep=10, measure=0, stats=1024, update=True, analyze=False, name='measureFidelity', des='', back=True): reps = np.arange(rep) sample, qubits, Qubits = loadQubits(sample, write_access=True) q = qubits[measure] Qb = Qubits[measure] q.channels = dict(q['channels']) for qb in qubits: qb.demod_freq = qb['readout_freq'][Hz] - qb['readout_mw_fc'][Hz] q.sb_freq = (q['f10'] - q['xy_mw_fc'])[Hz] # set some parameters name; axes = [(reps, 'reps')] def deps_text(idxs): return ('measure |%d>, prepare (|%d>)' % (idxs[0], idxs[1]), '', '') deps = list(map(deps_text, itertools.product([0, 1], [0, 1]))) kw = {'stats': stats} # create dataset dataset = sweeps.prepDataset(sample, name + des, axes, deps, kw=kw, measure=measure) def runSweeper(devices, para_list): # with pi pulse --> |1> ## reps = para_list start = 0 q.z = waveforms.square(amp=q.zpa[V], start=start, length=q.piLen[s] + 100e-9) start += 50e-9 q.xy = XYnothing(q) addXYgate(q, start, np.pi, 0.) start += q['piLen']['s'] + 50e-9 start += 100e-9 start += q['qa_start_delay'][s] for _q in qubits: _q.r = readoutPulse(_q) _q['experiment_length'] = start _q['do_readout'] = True set_qubitsDC(qubits, q['experiment_length']) result = [] # start to run experiment data1 = runQ(qubits, devices)[measure] # no pi pulse --> |0> ## q.xy = XYnothing(q) addXYgate(q, start, 0., 0.) # start to run experiment data0 = runQ(qubits, devices)[measure] prob0 = tunneling([q], [data0], level=2) prob1 = tunneling([q], [data1], level=2) clear_waveforms(qubits) return [prob0[0], prob1[0], prob0[1], prob1[1]] axes_scans = gridSweep(axes) results = RunAllExp(runSweeper, axes_scans, dataset) if update: Qb['MatRead'] = np.mean(results, 0)[1:].reshape(2, 2) if back: return results
def IQraw210(sample, measure=0, stats=1024, update=False, analyze=False, reps=1, name='IQ raw210', des='', back=True): sample, qubits, Qubits = loadQubits(sample, write_access=True) q = qubits[measure] Qb = Qubits[measure] for qb in qubits: qb.power_r = power2amp(qb['readout_amp']['dBm']) qb.demod_freq = qb['readout_freq'][Hz] - qb['readout_mw_fc'][Hz] q['stats'] = stats # set some parameters name; axes = [(reps, 'reps')] deps = [] for i in range(3): deps += [('Is', str(i), ''), ('Qs', str(i), '')] kw = {'stats': stats} # create dataset dataset = sweeps.prepDataset(sample, name + des, axes, deps, kw=kw, measure=measure) def get_IQ(data): Is = np.real(data[0]) Qs = np.imag(data[0]) return [Is, Qs] def runSweeper(devices, para_list): reps = para_list[0] # |1> start = 0 q.z = waveforms.square(amp=q.zpa[V], start=start, length=q.piLen[s] + q.piLen21[s]) q['xy'] = XYnothing(q) addXYgate(q, start, theta=np.pi, phi=0.) start += q.piLen[s] + q.piLen21[s] start += q['qa_start_delay'][s] for _qb in qubits: _qb['experiment_length'] = start q['do_readout'] = True set_qubitsDC(qubits, q['experiment_length']) q.r = readoutPulse(q) # start to run experiment data1 = runQ(qubits, devices) # state 2 start = 0 q.z = waveforms.square(amp=q.zpa['V'], start=start, length=q.piLen['s'] + q.piLen21['s']) q['xy'] = XYnothing(q) addXYgate(q, start, theta=np.pi, phi=0.) start += q.piLen['s'] addXYgate(q, start, theta=np.pi, phi=0., piAmp='piAmp21', fq='f21', piLen='piLen21') start += q.piLen21['s'] start += q['qa_start_delay'][s] data2 = runQ(qubits, devices) # state 0 q.xy = [waveforms.square(amp=0), waveforms.square(amp=0)] data0 = runQ(qubits, devices) result = [] for data in [data0, data1, data2]: result += get_IQ(data) clear_waveforms(qubits) return result collect, raw = True, True axes_scans = gridSweep(axes) results = RunAllExp(runSweeper, axes_scans, dataset, collect, raw) data = np.asarray(results[0]) if update: adjuster.IQ_center_multilevel(qubit=Qb, data=data) return data
def IQraw(sample, measure=0, stats=16384, update=False, analyze=False, reps=1, name='IQ raw', des='', back=True): sample, qubits, Qubits = loadQubits(sample, write_access=True) q = qubits[measure] Qb = Qubits[measure] q.channels = dict(q['channels']) q['stats'] = stats for qb in qubits: qb.power_r = power2amp(qb['readout_amp']['dBm']) qb.demod_freq = qb['readout_freq'][Hz] - qb['readout_mw_fc'][Hz] # set some parameters name; axes = [(reps, 'reps')] deps = [('Is', '|0>', ''), ('Qs', '|0>', ''), ('Is', '|1>', ''), ('Qs', '|1>', '')] kw = {'stats': stats} # create dataset dataset = sweeps.prepDataset(sample, name + des, axes, deps, kw=kw, measure=measure) def runSweeper(devices, para_list): reps = para_list[0] # with pi pulse --> |1> ## start = 0 q.z = waveforms.square(amp=q.zpa[V], start=start, length=q.piLen[s] + 100e-9) start += 50e-9 q['xy'] = XYnothing(q) addXYgate(q, start, theta=np.pi, phi=0.) start += q.piLen[s] + 50e-9 start += 100e-9 start += q['qa_start_delay'][s] for _q in qubits: _q.r = readoutPulse(_q) _q['experiment_length'] = start _q['do_readout'] = True set_qubitsDC(qubits, q['experiment_length']) # start to run experiment data1 = runQ(qubits, devices)[measure] q['xy'] = XYnothing(q) data0 = runQ(qubits, devices)[measure] Is0 = np.real(data0) Qs0 = np.imag(data0) Is1 = np.real(data1) Qs1 = np.imag(data1) result = [Is0, Qs0, Is1, Qs1] clear_waveforms(qubits) return result collect, raw = True, True axes_scans = gridSweep(axes) results = RunAllExp(runSweeper, axes_scans, dataset, collect, raw) data = np.asarray(results[0]) # print(data) if update: dataProcess._updateIQraw2(data=data, Qb=Qb, dv=None, update=update, analyze=analyze) return data
def rabihigh21(sample, measure=0, stats=1024, piamp21=None, piLen21=None, df=0 * MHz, zpa=None, name='rabihigh21', des='', back=False): """ sample: select experimental parameter from registry; stats: Number of Samples for one sweep point; """ sample, qubits, Qubits = loadQubits(sample, write_access=True) q = qubits[measure] q.channels = dict(q['channels']) q_copy = q.copy() if zpa is None: zpa = q['zpa'] if piamp21 is None: piamp21 = q['piAmp21'] if piLen21 is None: piLen21 = q['piLen21'] q.power_r = power2amp(q['readout_amp']['dBm']) q.demod_freq = q['readout_freq'][Hz] - q['readout_mw_fc'][Hz] # set some parameters name; axes = [(zpa, 'zpa'), (df, 'df'), (piamp21, 'piamp21'), (piLen21, 'piLen21')] deps = dependents_1q()[:-1] deps_pro = [('pro', str(i), '') for i in range(3)] deps.extend(deps_pro) kw = {'stats': stats} for qb in qubits: qb['awgs_pulse_len'] += q['piLen'] + q['piLen21'] # create dataset dataset = sweeps.prepDataset(sample, name + des, axes, deps, kw=kw, measure=measure) def runSweeper(devices, para_list): zpa, df, piamp21, piLen21 = para_list q['piAmp21'] = piamp21 q['piLen21'] = Value(piLen21, 's') q['f21'] = q_copy['f21'] + Value(df, 'Hz') start = 0. q.z = waveforms.square(amp=zpa, start=start, length=q.piLen['s'] + q.piLen21['s']) q['xy'] = XYnothing(q) addXYgate(q, start, theta=np.pi, phi=0.) start += q['piLen']['s'] start += 50e-9 addXYgate(q, start, theta=np.pi, phi=0., piAmp='piAmp21', fq='f21', piLen='piLen21') start += q['piLen21']['s'] start += 100e-9 start += q['qa_start_delay']['s'] q['experiment_length'] = start q['do_readout'] = True set_qubitsDC(qubits, q['experiment_length']) q.r = readoutPulse(q) data = runQ([q], devices) _d_ = data[0] amp = np.abs(np.mean(_d_)) / q.power_r phase = np.angle(np.mean(_d_)) Iv = np.mean(np.real(_d_)) Qv = np.mean(np.imag(_d_)) prob = tunneling([q], [_d_], level=3) # multiply channel should unfold to a list for return result result = [amp, phase, Iv, Qv, prob[0], prob[1], prob[2]] clear_waveforms(qubits) return result axes_scans = gridSweep(axes) result_list = RunAllExp(runSweeper, axes_scans, dataset) return
def rabihigh(sample, measure=0, stats=1024, piamp=None, piLen=None, df=0 * MHz, bias=None, zpa=None, name='rabihigh', des='', back=False): """ sample: select experimental parameter from registry; stats: Number of Samples for one sweep point; """ sample, qubits, Qubits = loadQubits(sample, write_access=True) q = qubits[measure] if bias is None: bias = q['bias'] if zpa is None: zpa = q['zpa'] if piamp is None: piamp = q['piAmp'] if piLen is None: piLen = q['piLen'] q.power_r = power2amp(q['readout_amp']['dBm']) q.demod_freq = q['readout_freq'][Hz] - q['readout_mw_fc'][Hz] q.sb_freq = (q['f10'] - q['xy_mw_fc'])[Hz] # set some parameters name; axes = [(bias, 'bias'), (zpa, 'zpa'), (df, 'df'), (piamp, 'piamp'), (piLen, 'piLen')] deps = dependents_1q() kw = {'stats': stats} for qb in qubits: qb['awgs_pulse_len'] += np.max(piLen) # add max length of hd waveforms # create dataset dataset = sweeps.prepDataset(sample, name + des, axes, deps, kw=kw, measure=measure) q_copy = q.copy() def runSweeper(devices, para_list): bias, zpa, df, piamp, piLen = para_list # since we only have one uwave source for _qb in qubits: _qb['xy_mw_fc'] = q_copy['xy_mw_fc'] + df * Hz start = 0 q.z = waveforms.square(amp=zpa, start=start, length=piLen + 100e-9) start += 50e-9 q.xy = [ waveforms.cosine(amp=piamp, freq=q.sb_freq, start=start, length=piLen), waveforms.sine(amp=piamp, freq=q.sb_freq, start=start, length=piLen) ] start += piLen + 50e-9 q['bias'] = bias * V # additional readout gap, avoid hdawgs fall affect start += 100e-9 # align qa & hd start start += q['qa_start_delay']['s'] q['experiment_length'] = start q['do_readout'] = True set_qubitsDC(qubits, q['experiment_length']) q.r = readoutPulse(q) data = runQ(qubits, devices)[0] clear_waveforms(qubits) return processData_1q(data, q) axes_scans = gridSweep(axes) result_list = RunAllExp(runSweeper, axes_scans, dataset)
def spectroscopy(sample, measure=0, stats=1024, freq=None, specLen=1 * us, specAmp=0.05, sb_freq=None, bias=None, zpa=None, name='spectroscopy', des='', back=False): """ sample: select experimental parameter from registry; stats: Number of Samples for one sweep point; """ sample, qubits, Qubits = loadQubits(sample, write_access=True) q = qubits[measure] q.stats = stats if freq is None: freq = q['f10'] if bias is None: bias = q['bias'] if zpa is None: zpa = q['zpa'] if sb_freq is None: sb_freq = (q['f10'] - q['xy_mw_fc']) q.power_r = power2amp(q['readout_amp']['dBm']) q.demod_freq = (q['readout_freq'] - q['readout_mw_fc'])[Hz] # set some parameters name; axes = [(freq, 'freq'), (specAmp, 'specAmp'), (specLen, 'specLen'), (bias, 'bias'), (zpa, 'zpa')] deps = dependents_1q() kw = {'stats': stats, 'sb_freq': sb_freq} for qb in qubits: # add max length of hd waveforms qb['awgs_pulse_len'] += np.max(specLen) # create dataset dataset = sweeps.prepDataset(sample, name + des, axes, deps, kw=kw, measure=measure) def runSweeper(devices, para_list): freq, specAmp, specLen, bias, zpa = para_list q['xy_mw_fc'] = freq * Hz - sb_freq start = 0 q.z = waveforms.square(amp=zpa, start=start, length=specLen + 100e-9) start += 50e-9 q.xy = [ waveforms.cosine(amp=specAmp, freq=sb_freq['Hz'], start=start, length=specLen), waveforms.sine(amp=specAmp, freq=sb_freq['Hz'], start=start, length=specLen) ] start += specLen + 50e-9 q['bias'] = bias start += 100e-9 start += q['qa_start_delay']['s'] q['experiment_length'] = start q['do_readout'] = True set_qubitsDC(qubits, q['experiment_length']) q.r = readoutPulse(q) data = runQ(qubits, devices)[measure] clear_waveforms(qubits) return processData_1q(data, q) axes_scans = gridSweep(axes) result_list = RunAllExp(runSweeper, axes_scans, dataset) if back: return result_list
def IQ_cali(sample, dh, idx=-1, measure=0, n_cluster=None, plot=True, update=True, plot_scatter=True, cmap='Greys', do_return=False): """ Args: dh: zilabrad.plots.dataProcess.datahelp idx: iq raw data index level: number of clusters, default is len(data) //2, for example, data is [I0,Q0,I1,Q1], then level = 4//2 = 2 measure: index for qubit, whose IQ center will be updated """ sample, qubits, Qubits = loadQubits(sample, write_access=True) Q = Qubits[measure] data = dh.getDataset(idx) _centers_average = np.mean(data, 0) level = len(_centers_average) // 2 if n_cluster is None: n_cluster = level centers_average = _centers_average.reshape(level, 2) def get_IQ_data(i): return data[:, [2 * i, 2 * i + 1]] def IQ_center_assign(center_state, centers): # center_state (array): the averaged IQ data # [I,Q] for a given state dis = [] for i, center in enumerate(centers): _dis = np.linalg.norm(center - center_state, ord=2) dis.extend([_dis]) dis = np.asarray(dis) idx = np.where(dis == np.min(dis)) return np.int(idx[0]) data_cluster = np.vstack(list(map(get_IQ_data, range(level)))) state_pred = KMeans(n_clusters=n_cluster).fit_predict(data_cluster) _return = {} centers = np.zeros((level, 2)) for i in range(level): xs = data_cluster[state_pred == i, 0] ys = data_cluster[state_pred == i, 1] center = np.mean(xs), np.mean(ys) centers[i] = center idx_assign = [] if update: for i in range(level): idx = IQ_center_assign(centers_average[i], centers) idx_assign += [idx] Q[f'center|{i}>'] = centers[idx] print(f'update: center|{i}> = {np.round(centers[idx],3)}') centers_I, centers_Q = centers[idx_assign, 0], centers[idx_assign, 1] def plot_cali_center(): facecolor = 'w' colors = color_generator(level) for i in range(level): color_i = next(colors)['color'] ax.scatter(centers_I[i], centers_Q[i], linewidth=2, facecolor=facecolor, edgecolor=color_i, s=200, marker="*", label=i) plt.legend() return if plot: fig = plt.figure() ax = fig.add_subplot(1, 1, 1) data_hist2d = ax.hist2d(*data_cluster.T, bins=50, cmap=cmap, shading='auto') plot_cali_center() plt.show() if plot_scatter: colors = color_generator(level) for i in range(level): color_i = next(colors)['color'] plt.scatter(*data[:1000, [2 * i, 2 * i + 1]].T, alpha=0.2, label=i, color=color_i) plot_cali_center() plt.legend() # for test if do_return: _return['centers'] = centers _return['data_hist2d'] = data_hist2d return _return
def correct_zero(sample): sample, qubits, Qubits = loadQubits(sample, write_access=True) qc = qubitContext() corr = qc.zero_correction for qubit in qubits: corr.correct_xy(qubit)
def Qstate_tomo(sample, rep=10, state=[0, 1], name='tomoTest', tbuffer=10e-9, des=''): sample, qubits, Qubits = loadQubits(sample, write_access=True) num_q = len(qubits) prep_Nqbit(qubits) reps = range(rep) axes = [(reps, 'reps')] deps = tomo_deps(num_q) piLens = list(map(lambda q: q['piLen'], qubits)) kw = {'state': state} dataset = sweeps.prepDataset(sample, name, axes, deps, kw=kw) fid_matNq = read_correct_mat(qubits) def add_tomo_gate(qubits, idx_qst, start): angles = [0, np.pi / 2, np.pi / 2] phases = [0, 0, np.pi / 2] _base3 = number_to_base(idx_qst, 3) idx_qst_base3 = [0] * (len(qubits) - len(_base3)) + _base3 for i, _qt in enumerate(qubits): idx_pulse = idx_qst_base3[i] theta = angles[idx_pulse] phi = phases[idx_pulse] addXYgate(_qt, start, theta, phi) return def prepare_state(qubits, start): for i, q in enumerate(qubits): q['xy'] = XYnothing(q) if state[i] == 1: addXYgate(q, start, np.pi, 0.) else: addXYgate(q, start, 0., 0.) return def read_pulse(qubits, start): for _q in qubits: _q.r = readoutPulse(_q) _q['experiment_length'] = start _q['do_readout'] = True set_qubitsDC(qubits, qubits[0]['experiment_length']) return def get_prob(data): prob_raw = tunneling(qubits, data, level=2) prob = np.asarray(np.dot(fid_matNq, prob_raw))[0] return prob def runSweeper(devices, para_list): reps = para_list reqs = [] q_ref = qubits[0] for idx_qst in np.arange(3**len(qubits)): start = 0. prepare_state(qubits, start) start += np.max(piLens)['s'] + tbuffer add_tomo_gate(qubits, idx_qst, start) start += np.max(piLens)['s'] + tbuffer start += q_ref['qa_start_delay']['s'] read_pulse(qubits, start) data = runQ(qubits, devices) prob = get_prob(data) reqs.append(prob) clear_waveforms(qubits) return np.hstack(reqs) axes_scans = gridSweep(axes) result_list = RunAllExp(runSweeper, axes_scans, dataset) return
def s21_dispersiveShift(sample, measure=0, stats=1024, freq=ar[6.4:6.5:0.02, GHz], delay=0 * ns, mw_power=None, bias=None, power=None, sb_freq=None, name='s21_disperShift', des='', back=False): """ sample: select experimental parameter from registry; stats: Number of Samples for one sweep point; """ sample, qubits, Qubits = loadQubits(sample, write_access=True) q = qubits[measure] q.channels = dict(q['channels']) if bias is None: bias = q['bias'] if power is None: power = q['readout_amp'] if sb_freq is None: sb_freq = q['readout_freq'][Hz] - q['readout_mw_fc'][Hz] if mw_power is None: mw_power = q['readout_mw_power'] q.awgs_pulse_len += np.max(delay) # add max length of hd waveforms q.demod_freq = q['readout_freq'][Hz] - q['readout_mw_fc'][Hz] # set some parameters name; axes = [(freq, 'freq'), (bias, 'bias'), (power, 'power'), (sb_freq, 'sb_freq'), (mw_power, 'mw_power'), (delay, 'delay')] deps = [('Amplitude|0>', 'S11 for %s' % q.__name__, ''), ('Phase|0>', 'S11 for %s' % q.__name__, rad)] deps.append(('I|0>', '', '')) deps.append(('Q|0>', '', '')) deps.append(('Amplitude|1>', 'S11 for %s' % q.__name__, rad)) deps.append(('Phase|1>', 'S11 for %s' % q.__name__, rad)) deps.append(('I|1>', '', '')) deps.append(('Q|1>', '', '')) deps.append(('SNR', '', '')) kw = {'stats': stats} # create dataset dataset = sweeps.prepDataset(sample, name + des, axes, deps, kw=kw, measure=measure) def runSweeper(devices, para_list): freq, bias, power, sb_freq, mw_power, delay = para_list q['readout_amp'] = power * dBm q.power_r = power2amp(power) # set microwave source device q['readout_mw_fc'] = (freq - q['demod_freq']) * Hz # write waveforms # with pi pulse --> |1> ## q.xy_sb_freq = (q['f10'] - q['xy_mw_fc'])[Hz] start = 0 q.z = waveforms.square(amp=q.zpa[V], start=start, length=q.piLen[s] + 100e-9) start += 50e-9 q.xy = [ waveforms.cosine(amp=q.piAmp, freq=q.xy_sb_freq, start=start, length=q.piLen[s]), waveforms.sine(amp=q.piAmp, freq=q.xy_sb_freq, start=start, length=q.piLen[s]) ] start += q.piLen[s] + 50e-9 q['bias'] = bias start += delay start += 100e-9 start += q['qa_start_delay'][s] q['experiment_length'] = start set_qubitsDC(qubits, q['experiment_length']) q['do_readout'] = True q.r = readoutPulse(q) # start to run experiment data1 = runQ([q], devices) # no pi pulse --> |0> ## q.xy = [waveforms.square(amp=0), waveforms.square(amp=0)] # start to run experiment data0 = runQ([q], devices) # analyze data and return _d_ = data0[0] # unit: dB; only relative strength; amp0 = np.abs(np.mean(_d_)) / q.power_r phase0 = np.angle(np.mean(_d_)) Iv0 = np.mean(np.real(_d_)) Qv0 = np.mean(np.imag(_d_)) _d_ = data1[0] # unit: dB; only relative strength; amp1 = np.abs(np.mean(_d_)) / q.power_r phase1 = np.angle(np.mean(_d_)) Iv1 = np.mean(np.real(_d_)) Qv1 = np.mean(np.imag(_d_)) # multiply channel should unfold to a list for return result result = [amp0, phase0, Iv0, Qv0] result += [amp1, phase1, Iv1, Qv1] result += [np.abs((Iv1 - Iv0) + 1j * (Qv1 - Qv0))] clear_waveforms(qubits) return result axes_scans = gridSweep(axes) result_list = RunAllExp(runSweeper, axes_scans, dataset) if back: return result_list
def T1_visibility(sample, measure=0, stats=1024, delay=0.8 * us, zpa=None, bias=None, name='T1_visibility', des='', back=False): """ sample: select experimental parameter from registry; stats: Number of Samples for one sweep point; """ sample, qubits, Qubits = loadQubits(sample, write_access=True) q = qubits[measure] for qb in qubits: qb.channels = dict(qb['channels']) if bias is None: bias = q['bias'] if zpa is None: zpa = q['zpa'] q.power_r = power2amp(q['readout_amp']['dBm']) q.demod_freq = q['readout_freq'][Hz] - q['readout_mw_fc'][Hz] q.sb_freq = (q['f10'] - q['xy_mw_fc'])[Hz] for qb in qubits: qb['awgs_pulse_len'] += np.max(delay) # add max length of hd waveforms # set some parameters name; axes = [(bias, 'bias'), (zpa, 'zpa'), (delay, 'delay')] deps = [('Amplitude', '1', 'a.u.'), ('Phase', '1', 'rad'), ('prob with pi pulse', '|1>', ''), ('Amplitude', '0', 'a.u.'), ('Phase', '0', 'rad'), ('prob without pi pulse', '|1>', '')] kw = {'stats': stats} # create dataset dataset = sweeps.prepDataset(sample, name + des, axes, deps, kw=kw, measure=measure) def runSweeper(devices, para_list): bias, zpa, delay = para_list # ## set device parameter # ----- with pi pulse ----- ### start = 0 q['bias'] = bias q.z = waveforms.square(amp=zpa, start=start, length=delay + q.piLen[s] + 100e-9) start += 10e-9 q.xy = XYnothing(q) addXYgate(q, start, np.pi, 0.) start += q.piLen['s'] + delay start += q['qa_start_delay']['s'] q['experiment_length'] = start set_qubitsDC(qubits, q['experiment_length']) q['do_readout'] = True q.r = readoutPulse(q) # start to run experiment data1 = runQ(qubits, devices) # analyze data and return _d_ = data1[0] # unit: dB; only relative strength; amp1 = np.mean(np.abs(_d_)) / q.power_r phase1 = np.mean(np.angle(_d_)) prob1 = tunneling([q], [_d_], level=2) # ----- without pi pulse ----- ### q.xy = XYnothing(q) # start to run experiment data0 = runQ(qubits, devices) _d_ = data0[0] # analyze data and return amp0 = np.abs(np.mean(_d_)) / q.power_r phase0 = np.angle(np.mean(_d_)) prob0 = tunneling([q], [_d_], level=2) # multiply channel should unfold to a list for return result result = [amp1, phase1, prob1[1], amp0, phase0, prob0[1]] clear_waveforms(qubits) return result axes_scans = gridSweep(axes) result_list = RunAllExp(runSweeper, axes_scans, dataset)
def ramsey(sample, measure=0, stats=1024, delay=ar[0:10:0.4, us], repetition=1, df=0 * MHz, fringeFreq=10 * MHz, PHASE=0, name='ramsey', des='', back=False): """ sample: select experimental parameter from registry; stats: Number of Samples for one sweep point; """ sample, qubits, Qubits = loadQubits(sample, write_access=True) q = qubits[measure] q.power_r = power2amp(q['readout_amp']['dBm']) q.demod_freq = q['readout_freq'][Hz] - q['readout_mw_fc'][Hz] q.sb_freq = (q['f10'] - q['xy_mw_fc'])[Hz] for qb in qubits: qb['awgs_pulse_len'] += np.max(delay) # set some parameters name; axes = [(repetition, 'repetition'), (delay, 'delay'), (df, 'df'), (fringeFreq, 'fringeFreq'), (PHASE, 'PHASE')] deps = [('Amplitude', 's21 for', 'a.u.'), ('Phase', 's21 for', 'rad'), ('I', '', ''), ('Q', '', ''), ('prob |1>', '', '')] kw = {'stats': stats, 'fringeFreq': fringeFreq} # create dataset dataset = sweeps.prepDataset(sample, name + des, axes, deps, kw=kw, measure=measure) q_copy = q.copy() def runSweeper(devices, para_list): repetition, delay, df, fringeFreq, PHASE = para_list # set device parameter q['xy_mw_fc'] = q_copy['xy_mw_fc'] + df * Hz # ----- begin waveform ----- ### start = 0 q.z = waveforms.square(amp=q.zpa[V], start=start, length=delay + 2 * q.piLen[s] + 100e-9) start += 50e-9 q.xy = XYnothing(q) addXYgate(q, start, theta=np.pi / 2., phi=0.) start += delay + q.piLen['s'] addXYgate(q, start, theta=np.pi / 2., phi=PHASE + fringeFreq * delay * 2. * np.pi) start += q.piLen[s] + 50e-9 start += 100e-9 + q['qa_start_delay'][s] q['experiment_length'] = start set_qubitsDC(qubits, q['experiment_length']) q['do_readout'] = True q.r = readoutPulse(q) # start to run experiment data = runQ(qubits, devices) # analyze data and return _d_ = data[0] # unit: dB; only relative strength; amp = np.abs(np.mean(_d_)) / q.power_r phase = np.angle(np.mean(_d_)) Iv = np.mean(np.real(_d_)) Qv = np.mean(np.imag(_d_)) prob = tunneling([q], [_d_], level=2) # multiply channel should unfold to a list for return result result = [amp, phase, Iv, Qv, prob[1]] clear_waveforms(qubits) return result axes_scans = gridSweep(axes) result_list = RunAllExp(runSweeper, axes_scans, dataset)
def s21_scan(sample, measure=0, stats=1024, freq=6.0 * GHz, delay=0 * ns, phase=0, mw_power=None, bias=None, power=None, zpa=0.0, name='s21_scan', des=''): """ s21 scanning Args: sample: select experimental parameter from registry; stats: Number of Samples for one sweep point; """ sample, qubits, Qubits = loadQubits(sample, write_access=True) q = qubits[measure] q.channels = dict(q['channels']) q.stats = stats if freq is None: freq = q['readout_freq'] if bias is None: bias = q['bias'] if power is None: power = q['readout_amp'] q.power_r = power2amp(q['readout_amp']['dBm']) q.demod_freq = q['readout_freq'][Hz] - q['readout_mw_fc'][Hz] if mw_power is None: mw_power = q['readout_mw_power'] q.awgs_pulse_len += np.max(delay) # add max length of hd waveforms # set some parameters name; axes = [(freq, 'freq'), (bias, 'bias'), (zpa, 'zpa'), (power, 'power'), (mw_power, 'mw_power'), (delay, 'delay'), (phase, 'phase')] deps = [('Amplitude', 's21 for', 'a.u.'), ('Phase', 's21 for', 'rad'), ('I', '', ''), ('Q', '', '')] kw = {'stats': stats} # create dataset dataset = sweeps.prepDataset(sample, name + des, axes, deps, measure=measure, kw=kw) def runSweeper(devices, para_list): freq, bias, zpa, power, mw_power, delay, phase = para_list q['bias'] = Value(bias, 'V') q['readout_amp'] = power * dBm q.power_r = power2amp(power) q['readout_mw_fc'] = (freq - q['demod_freq']) * Hz start = 0 q.z = waveforms.square(amp=zpa) q.xy = [waveforms.square(amp=0), waveforms.square(amp=0)] start += delay start += 100e-9 start += q['qa_start_delay']['s'] for _qb in qubits: _qb['experiment_length'] = start q['do_readout'] = True q.r = readoutPulse(q) set_qubitsDC(qubits, q['experiment_length']) data = runQ([q], devices) _d_ = data[0] amp = np.abs(np.mean(_d_)) / q.power_r phase = np.angle(np.mean(_d_)) Iv = np.real(np.mean(_d_)) Qv = np.imag(np.mean(_d_)) return [amp, phase, Iv, Qv] axes_scans = gridSweep(axes) result_list = RunAllExp(runSweeper, axes_scans, dataset)