Ejemplo n.º 1
0
  def measureSCurve(self,voltages = None,ntimes = 40,microwaveOff = True):
    self.notify("status","Measuring S curve...")
    def getVoltageBounds(v0,jba,variable,ntimes):
      v = v0
      jba.setVoltage(v)
      jba._acqiris.bifurcationMap(ntimes = ntimes)
      p = jba._acqiris.Psw()[variable]
      
      while p > 0.03 and v < v0*2.0:
        v*=1.05
        jba.setVoltage(v)
        jba._acqiris.bifurcationMap(ntimes = ntimes)
        p = jba._acqiris.Psw()[variable]
      vmax = v
      
      v = v0
      jba.setVoltage(v)
      jba._acqiris.bifurcationMap(ntimes = ntimes)
      p = jba._acqiris.Psw()[variable]
      
      while p < 0.98 and v > v0/2.0:
        v/=1.05
        jba.setVoltage(v)
        jba._acqiris.bifurcationMap(ntimes = ntimes)
        p = jba._acqiris.Psw()[variable]
      vmin = v
      return (vmin*0.95,vmax*1.2)

    try:
      v0 = self.voltage()
      state = self._qubitmwg.output()
      self._attenuator.turnOn()
      data = Datacube("S Curve")
      dataManager = DataManager()
      dataManager.addDatacube(data)
      if microwaveOff:
        self._qubitmwg.turnOff()
      if voltages == None:
        self.notify("status","Searching for proper voltage range...")
        (vmin,vmax) = getVoltageBounds(v0,self,self._params["variable"],ntimes)
        voltages = arange(vmin,vmax,0.005)
        self.notify("status","Measuring S curve in voltage range  [%g - %g]..." % (vmin,vmax))
      for v in voltages:
        self.setVoltage(v)
        self._acqiris.bifurcationMap(ntimes = ntimes)
        data.set(v = v)
        data.set(**(self._acqiris.Psw()))
        data.commit()
        self.notify("sCurve",(data.column("v"),data.column(self._params["variable"])))
    finally:
      self.notify("status","S curve complete.")
      self.setVoltage(v0)
      if state:
        self._qubitmwg.turnOn()
                t += dt
            else:
                rho_t = integrationMethod(rho_t, L, t, tt - t)
                t += tt - t
        print "t = %g" % tt
        rhos[i] = rho_t
        i += 1
    return rhos


##Simulate a quantum process

tomography = Datacube("simulation of quantum process tomography")
densityMatrices = Datacube("density matrices", dtype=complex128)
tomography.addChild(densityMatrices, name="density matrices")
dataManager.addDatacube(tomography)

#We store the parameters of the simulation in the datacube

g = 0.1

times = arange(0, 40, 0.1)

Delta = 0 * math.pi * 2.0
Delta1 = 0
Delta2 = 0

measurements = [
    "xx", "xy", "xz", "yx", "yy", "yz", "zx", "zy", "zz", "xi", "yi", "zi",
    "ix", "iy", "iz", "ii"
]
plot(vs,ees[:,2]-ees[:,0],color = 'white',lw = 2,ls = 'solid')
plot(vs,ees[:,1]-ees[:,0],color = 'white',lw = 2,ls = 'solid')

xlim(1.26,1.29)
ylim(5.1,5.15)

figtext(0.02,0.02,gv.survey.filename()[:-4])
figtext(0.02,0.95,"$g = %g Mhz$\ncrosstalk = %g %%" % (g*1000,crosstalk * 100))
show()
##
from pyview.helpers.datamanager import DataManager

dataManager = DataManager()

fit = Datacube("fit")
dataManager.addDatacube(fit)

for i in range(0,len(gv.survey)):

	fit.set(i= i,flux = gv.survey["flux"][i])

	j = argmin(abs(vs-gv.survey["flux"][i]))
	fqb1 = real(ees[j,2]-ees[j,0])
	fqb2 = real(ees[j,1]-ees[j,0])
	print gv.survey["flux"][i],vs[j]
	import scipy.optimize
	import numpy.linalg
	fitfunc = lambda p, x: 1./math.pi*p[0]/((x-p[1])*(x-p[1])/p[3]/p[3]+1)+p[2]+1./math.pi*p[4]/((x-p[5])*(x-p[5])/p[6]/p[6]+1) # Target function
	errfunc = lambda p, x, y: fitfunc(p, x) - y # Distance to the target function
	ps = [0.4,fqb1,0.1,0.002,0.3,fqb2,0.002]
	p2,success = scipy.optimize.leastsq(errfunc, array(ps), args=(array(fs), array(m1[i])))
Ejemplo n.º 4
0
instrumentManager=Manager()
vna=instrumentManager.getInstrument('vna')
print vna
coilVoltage=instrumentManager.getInstrument('Yoko1')
print coil


##
def setMyVNAPower(power):
	atten=-20*math.modf(power/20.)[1]
	pow=power+atten-5
	vna.setAttenuation(atten)
	vna.setPower(pow)	
##
data=Datacube('VNAvsCoil1')
dataManager.addDatacube(data)
k=0
voltages=arange(-3,0.1,0.05)
for voltages in voltages:
	print "voltages=%f V"%voltages
	coilVoltage.setVoltage(voltages)
	#time.sleep(4)
	child=vna.getTrace(waitFullSweep=True)
	child.setName("voltages=%f V"%voltages)
	data.addChild(child)
	data.set(k=k,Voltage=voltages)
	data.commit()
	#child.savetxt()
	k+=1
data.savetxt()
coilVoltage.setVoltage(0)
Ejemplo n.º 5
0
 def toDataManager(self):
   dataManager = DataManager()
   dataManager.addDatacube(self)
		try:
			plotDensityMatrix(densityMatrix,export="film of swap/rhomats/rhomat_%.3d.png" % i,figureTitle = "t = %g ns" % rhoMatData.column("duration")[i])#,figureName="phibell = %s" % str(phibell))
		except:
			print "Failed!"
			print sys.exc_info()
			rhoMatData.setAt(i,errorimage=1)
rhoMatData.savetxt()

##

##
from pyview.helpers.datamanager import DataManager
dataManager = DataManager()3
##
phi_wit=Datacube()
dataManager.addDatacube(phi_wit)
phi_wit.setName("phi_wit")
phi_wit.createColumn("zPulseLength",real(rhoMatData.column("zPulseLength")))
phi_wit.createColumn("phibell",real(rhoMatData.column("phibell")))
phi_wit.createColumn("w_phi_minus",real(rhoMatData.column("w_phi_minus")))
phi_wit.createColumn("w_phi_plus",real(rhoMatData.column("w_phi_plus")))
phi_wit.savetxt()


##

#chshdata=Datacube()
#chshdata.setName("CHSH from rhoMat theory")
#rhoMatData.addChild(chshdata)

state=tensor(gs,es)-tensor(es,gs)
				rho_t = integrationMethod(rho_t,L,t,dt)
				t+=dt
			else:
				rho_t = integrationMethod(rho_t,L,t,tt-t)
				t+=tt-t
		print "t = %g" % tt
		rhos[i] = rho_t
		i+=1
	return rhos

##Simulate a quantum process

tomography = Datacube("simulation of quantum process tomography")
densityMatrices = Datacube("density matrices",dtype =complex128)
tomography.addChild(densityMatrices,name = "density matrices")
dataManager.addDatacube(tomography)

#We store the parameters of the simulation in the datacube

g = 0.1

times = arange(0,40,0.1)

Delta = 0*math.pi*2.0
Delta1 = 0
Delta2 = 0

measurements = ["xx","xy","xz","yx","yy","yz","zx","zy","zz","xi","yi","zi","ix","iy","iz","ii"]
matrixMap = {"x":sigmax,"y":sigmay,"z":sigmaz,"i":idatom}

states = [(tensor(es,gs)-tensor(gs,es))/sqrt(2.0)]
import csv

##
from pyview.lib.datacube import Datacube
from pyview.helpers.datamanager import DataManager
import re
filename = "qubit_chip_sonnet_model.csv"
dataManager = DataManager()
file = open(filename,"rb")
content = file.read()
file.close()
lines = content.split("\n")
curves = Datacube("curves")
dataManager.clear()
dataManager.addDatacube(curves)
i = 0
curve = None
while i < len(lines):
	elements = lines[i].split(",")
	if re.search("l1=(\d+\.\d+)",lines[i],re.I):
		if curve != None and len(curve) == 0:
			curves.removeChild(curve)
		print lines[i]
		lq = float(re.search("l1=(\d+\.\d+)",lines[i],re.I).group(1))
		print lq
		i+=2
		if i >= len(lines):	
			break
		curve = Datacube("l1 = %g nH" % lq)
		curves.addChild(curve,lq = lq)
Ejemplo n.º 9
0
  def measureSCurve(self,voltages = None,ntimes = 10,microwaveOff = True,data=None,fspPower=False,corelations=False,**extraInDatacube):
    self.notify("status","Measuring S curve...")
    def getVoltageBounds(v0,jba,variable,ntimes):
      return (0.5,5)
      v = v0
      jba.setVoltage(v)
      jba._acqiris.bifurcationMap(ntimes = ntimes)
      p = jba._acqiris.Psw()[variable]
      
      while p > 0.03 and v < v0*2.0:
        v*=1.05
        jba.setVoltage(v)
        jba._acqiris.bifurcationMap(ntimes = ntimes)
        p = jba._acqiris.Psw()[variable]
      vmax = v
      
      v = v0
      jba.setVoltage(v)
      jba._acqiris.bifurcationMap(ntimes = ntimes)
      p = jba._acqiris.Psw()[variable]
      
      while p < 0.98 and v > v0/2.0:
        v/=1.05
        jba.setVoltage(v)
        jba._acqiris.bifurcationMap(ntimes = ntimes)
        p = jba._acqiris.Psw()[variable]
      vmin = v
      return (vmin*0.95,vmax*1.2)
    if fspPower:
      self._pulseGenerator._mixer._fsp.setFrequency(self._frequency)  
    if data==None:
      data = Datacube("%s S Curve - f=%f" %(self.name(),self._frequency))
      dataManager = DataManager()
      dataManager.addDatacube(data)
    else:
      data.setName("%s S Curve - f=%f" %(self.name(),self._frequency))

    if voltages==None:
      bounds=[self._vMaxAmplitude-2*max(self._vMaxAmplitude/5,abs(self._sCurveParams[0])),self._vMaxAmplitude+2*max(self._vMaxAmplitude/5,abs(self._sCurveParams[0]))]
      voltages=linspace(bounds[0],bounds[1],200)
    try:
      for v in voltages:
        self.setAmplitude(v)
        data.set(v = v)
        d=self.measure(nLoops=ntimes)
        #d=self.getThisMeasure()
        data.set(**d[1])
        if corelations:
          data.set(**d[4])
        data.set(**extraInDatacube)
        if fspPower:
          time.sleep(1)
          data.set(fspPower=self._pulseGenerator._mixer._fsp.getValueAtMarker())          
        #self.notify("histograms",d[2][self.bit][0])
        #self.notify("iqdata",(d[2][self.bit][0],d[2][self.bit][1]))
        ##self.notify("iqP",(d[0][:,0],d[0][:,1],((0,0,0))))
        data.commit()
        #self.notify("sCurve",(data.column("v"),data.column("b%i"%self.bit)))
      data.createColumn("p-0.5",abs(data["b%i"%self.bit]-0.5))
      data.sortBy("p-0.5")
      self._p50fromS=data['v'][0]
      data.sortBy('v')
      #data.sortBy("b%i"%self.bit)
      #p=data["b%i"%self.bit]
      #v=data['v']
      #p=p[p>0]
      #v=v[p>0]
      ##p=p[p<1]
      #v=v[p<1]
      #self.sInterpolateVP=scipy.interpolate.interp1d(p,v)
      #data.sortBy('v')
      
    except:
      raise
    finally:
      data.savetxt()
      self.notify("status","S curve complete.")
      self.setAmplitude(self._vMaxAmplitude)
      return data
Ejemplo n.º 10
0
plot(vs, ees[:, 1] - ees[:, 0], color='white', lw=2, ls='solid')

xlim(1.26, 1.29)
ylim(5.1, 5.15)

figtext(0.02, 0.02, gv.survey.filename()[:-4])
figtext(0.02, 0.95,
        "$g = %g Mhz$\ncrosstalk = %g %%" % (g * 1000, crosstalk * 100))
show()
##
from pyview.helpers.datamanager import DataManager

dataManager = DataManager()

fit = Datacube("fit")
dataManager.addDatacube(fit)

for i in range(0, len(gv.survey)):

    fit.set(i=i, flux=gv.survey["flux"][i])

    j = argmin(abs(vs - gv.survey["flux"][i]))
    fqb1 = real(ees[j, 2] - ees[j, 0])
    fqb2 = real(ees[j, 1] - ees[j, 0])
    print gv.survey["flux"][i], vs[j]
    import scipy.optimize
    import numpy.linalg
    fitfunc = lambda p, x: 1. / math.pi * p[0] / (
        (x - p[1]) *
        (x - p[1]) / p[3] / p[3] + 1) + p[2] + 1. / math.pi * p[4] / (
            (x - p[5]) * (x - p[5]) / p[6] / p[6] + 1)  # Target function
	return LH+L

times = arange(0,int(t_gate_end)+4.0,0.1)
delta_qq = 2.*math.pi*0.15
points = 3

l=0

def generate_image(cube,element):
	im = zeros((len(cube.children()),len(cube.children()[0])))
	for i in range(0,len(cube.children())):
		im[i,:] = cube.children()[i][element]
	return im

cube = Datacube("master equation simulation - swap 01-10",dtype=complex128)
dataManager.addDatacube(cube)

cube.parameters()["defaultPlot"]=[["t","zzp00"],["t","zzp01"],["t","zzp10"],["t","zzp11"]]
cube.parameters()["simulation"] = {'alpha':alpha,'beta':beta,'g':g,'gamma10_1':gamma10_1,'gamma10_2':gamma10_2,'gammaphi10_1':gammaphi10_1,'gammaphi10_2':gammaphi10_2,'delta_qq':delta_qq}

def optimizeDrivePulse(targetRho):
	def optimization_function(params,targetRho):
		print params
		finalRho = devectorizeRho(integrate(rho,lambda t:L_drive(t,a = params[0],delta = params[1],phi = params[2]),ts = arange(0,14,0.1),dt = 0.01)[-1])
		tf = 1.-abs(trace(finalRho*targetRho))
		print tf
		return tf
	params0 = [0.2,0,0]
	return fmin_powell(optimization_function,params0,args = [targetRho])

targetState = tensor(matrix([1,1,0]),matrix([1,0,0]))
Ejemplo n.º 12
0
  def measureSCurve(self,voltages = None,nLoops = 5,microwaveOff = True,data=None,fspPower=False,corelations=False,**extraInDatacube):
    self.notify("status","Measuring S curve...")
    def getVoltageBounds(v0,jba,variable,ntimes):
      return (0.5,5)
      v = v0
      jba.setVoltage(v)
      jba._acqiris.bifurcationMap(ntimes = nLoops)
      p = jba._acqiris.Psw()[variable]
      
      while p > 0.03 and v < v0*2.0:
        v*=1.05
        jba.setVoltage(v)
        jba._acqiris.bifurcationMap(ntimes = nLoops)
        p = jba._acqiris.Psw()[variable]
      vmax = v
      
      v = v0
      jba.setVoltage(v)
      jba._acqiris.bifurcationMap(ntimes = nLoops)
      p = jba._acqiris.Psw()[variable]
      
      while p < 0.98 and v > v0/2.0:
        v/=1.05
        jba.setVoltage(v)
        jba._acqiris.bifurcationMap(ntimes = nLoops)
        p = jba._acqiris.Psw()[variable]
      vmin = v
      return (vmin*0.95,vmax*1.2)
    if fspPower:
      self._pulseGenerator._mixer._fsp.setFrequency(self._frequency)  
    if data==None:
      data = Datacube("%s S Curve - f=%f" %(self.name(),self._frequency))
      dataManager = DataManager()
      dataManager.addDatacube(data)
    else:
      data.setName("%s S Curve - f=%f" %(self.name(),self._frequency))

    if voltages==None:
      bounds=[self.center-self.width*1,self.center+self.width*1]
#      voltages=linspace(bounds[0],bounds[1],200)
      voltages=SmartLoop(bounds[0],(bounds[1]-bounds[0])/50, bounds[1], name="Scurve voltages")
    print "entering in loop"
    try:
      for v in voltages:
        print "voltage :",v
        self.setAmplitude(v)
        data.set(v = v)
        print "measuring"
        d=self.measure(nLoops=nLoops)
        print "got point"
        #d=self.getThisMeasure()
        #data.set(**d[1])
        data.set(**d[-1])
        print "in datacube"
        #data.set(**extraInDatacube)
        print "extra in datacube"
        if fspPower:
          time.sleep(1)
          data.set(fspPower=self._pulseGenerator._mixer._fsp.getValueAtMarker())          
        #self.notify("histograms",d[2][self.bit][0])
        #self.notify("iqdata",(d[2][self.bit][0],d[2][self.bit][1]))
        ##self.notify("iqP",(d[0][:,0],d[0][:,1],((0,0,0))))
        print "commiting"
        data.commit()
        print "commited"
        #self.notify("sCurve",(data.column("v"),data.column("b%i"%self.bit)))
        print "first loop over"
      #data.sortBy('v')
      #data.sortBy("b%i"%self.bit)
      #p=data["b%i"%self.bit]
      #v=data['v']
      #p=p[p>0]
      #v=v[p>0]
      ##p=p[p<1]
      #v=v[p<1]
      #self.sInterpolateVP=scipy.interpolate.interp1d(p,v)
      #data.sortBy('v')
      print "first loop over"
    except:
      raise
    finally:
      data.savetxt()
      self.notify("status","S curve complete.")
      self.setAmplitude(self._vMaxAmplitude)
      return data
times = arange(0, int(t_gate_end) + 4.0, 0.1)
delta_qq = 2. * math.pi * 0.15
points = 3

l = 0


def generate_image(cube, element):
    im = zeros((len(cube.children()), len(cube.children()[0])))
    for i in range(0, len(cube.children())):
        im[i, :] = cube.children()[i][element]
    return im


cube = Datacube("master equation simulation - swap 01-10", dtype=complex128)
dataManager.addDatacube(cube)

cube.parameters()["defaultPlot"] = [["t", "zzp00"], ["t", "zzp01"],
                                    ["t", "zzp10"], ["t", "zzp11"]]
cube.parameters()["simulation"] = {
    'alpha': alpha,
    'beta': beta,
    'g': g,
    'gamma10_1': gamma10_1,
    'gamma10_2': gamma10_2,
    'gammaphi10_1': gammaphi10_1,
    'gammaphi10_2': gammaphi10_2,
    'delta_qq': delta_qq
}