def calculateGateFidelityProcTomo(self, ErrorBars=False, ind=None): ''' use proctomo to convert error of gate to fidelity ''' #print "Using ProcTomo to calculate gate fidelity. This may take a while ..." if ind != None: indreal = [ind] if ErrorBars: indreal = [ind, ind, ind] elif not ErrorBars: indreal = [self.error0] else: indreal = [self.error0, self.error0max, self.error0min] result = [] for ind in indreal: if self.noisetype == 'all': for noisetype in self.dec.dict_params_static.keys(): self.setNoiseAmp(noisetype, ind) else: self.setNoiseAmp(self.noisetype, ind) if not self.verbose: widgets = [progressbar.Percentage(), ' ', progressbar.Bar(),' ', progressbar.ETA()] pbar = progressbar.ProgressBar(widgets=widgets).start() else: pbar = None pos = self.gates[0] # only do it once, for now newpulseseq = sim.PulseSequence([ copy.deepcopy(self.pulseseq[pos]) ]) self.pulseseq[pos].UtrAll = [] newpulseseq[0].use_ideal=False ScanObj = ips.ScanParameter_in_Sequence(newpulseseq, self.params, self.dec, np.arange(12**self.params.hspace.nuions),type='ProcTomo', verbose=self.verbose, doPP=True, use_ideal=True, pbar=pbar) ScanObj.runScan(batchsize=40) data_proctom = ScanObj.output_dict['qstates_camera'] chi = proctom.proctomo(data_proctom, 100) chiId = qproc.Unitary2Chi(newpulseseq[0].Uidtr.conjugate()) result.append(U.jozsafid(chiId, chi)) #print "PT:" #print np.around(chiId,3) #print np.around(chi,3) # TEMP if ind != None and ErrorBars: result.sort() result.append(result[0]) result.remove(result[0]) if not ErrorBars: print self._printGatetype(self.gatetype),":", np.around(result[0],4) return [result[0], result[0], result[0]] else: print self._printGatetype(self.gatetype) + " : %0.4f + %0.4f - %0.4f" % (np.around(result[0],4), np.around(result[1]-result[0],4), np.around(result[0]-result[2],4) ) return result
def calculateGateFidelityProcTomo(self, ErrorBars=False, ind=None): ''' use proctomo to convert error of gate to fidelity ''' #print "Using ProcTomo to calculate gate fidelity. This may take a while ..." if ind != None: indreal = [ind] if ErrorBars: indreal = [ind, ind, ind] elif not ErrorBars: indreal = [self.error0] else: indreal = [self.error0, self.error0max, self.error0min] result = [] for ind in indreal: if self.noisetype == 'all': for noisetype in self.dec.dict_params_static.keys(): self.setNoiseAmp(noisetype, ind) else: self.setNoiseAmp(self.noisetype, ind) if not self.verbose: widgets = [ progressbar.Percentage(), ' ', progressbar.Bar(), ' ', progressbar.ETA() ] pbar = progressbar.ProgressBar(widgets=widgets).start() else: pbar = None pos = self.gates[0] # only do it once, for now newpulseseq = sim.PulseSequence( [copy.deepcopy(self.pulseseq[pos])]) self.pulseseq[pos].UtrAll = [] newpulseseq[0].use_ideal = False ScanObj = ips.ScanParameter_in_Sequence( newpulseseq, self.params, self.dec, np.arange(12**self.params.hspace.nuions), type='ProcTomo', verbose=self.verbose, doPP=True, use_ideal=True, pbar=pbar) ScanObj.runScan(batchsize=40) data_proctom = ScanObj.output_dict['qstates_camera'] chi = proctom.proctomo(data_proctom, 100) chiId = qproc.Unitary2Chi(newpulseseq[0].Uidtr.conjugate()) result.append(U.jozsafid(chiId, chi)) #print "PT:" #print np.around(chiId,3) #print np.around(chi,3) # TEMP if ind != None and ErrorBars: result.sort() result.append(result[0]) result.remove(result[0]) if not ErrorBars: print self._printGatetype(self.gatetype), ":", np.around( result[0], 4) return [result[0], result[0], result[0]] else: print self._printGatetype( self.gatetype) + " : %0.4f + %0.4f - %0.4f" % (np.around( result[0], 4), np.around(result[1] - result[0], 4), np.around(result[0] - result[2], 4)) return result
print 'statetomo passed' else: print 'statetomo failed' if runProcTomo or runProcTomoPP: NumberOfIons = 2 PhononOverhead = 1 hspace = sim.hspace(NumberOfIons,2,NumberOfIons+PhononOverhead,0) params = sim.parameters(hspace) dec = sim.decoherence(params) params.use_servers(['local']) pulseseq = sim.PulseSequence( [ \ sim.Rcar(params, 2*pi, 0, 0), ] ) if runProcTomo: ScanObj = ScanParameter_in_Sequence(pulseseq, params, dec, np.arange(12**NumberOfIons), type='ProcTomo', verbose=True) ScanObj.runScan() elif runProcTomoPP: ScanObj = ScanParameter_in_Sequence(pulseseq, params, dec, np.arange(12**NumberOfIons), type='ProcTomo', verbose=True, doPP=True, use_ideal=True) ScanObj.runScan(batchsize=40) data_proctom = ScanObj.output_dict['qstates_camera'] chi = proctom.proctomo(data_proctom, 100) if np.real(chi[0,0]) > 0.99: print 'proctomo passed' else: print 'proctomo failed'