def fixed_S(self): w=2*pi*self.fixed_freq L_arr=self._get_L(fq=self.fixed_fq) if self.S_type=="simple": return array([self._get_simple_S(f=self.fixed_freq, YL=-1.0j/(w*L)) for L in L_arr]) P=self.fixed_P[0] #return self.PtoS(*P, YL=self.YL) return array([self.PtoS(*P, YL=-1.0j/(w*L)) for L in L_arr])
def fixed_S(self): w = 2 * pi * self.fixed_freq L_arr = self._get_L(fq=self.fixed_fq) if self.S_type == "simple": return array([ self._get_simple_S(f=self.fixed_freq, YL=-1.0j / (w * L)) for L in L_arr ]) P = self.fixed_P[0] #return self.PtoS(*P, YL=self.YL) return array([self.PtoS(*P, YL=-1.0j / (w * L)) for L in L_arr])
def _get_S11(self, f, couple_mult, f0, K2, Np, C, L): Ga=self._get_Ga(f=f, couple_mult=couple_mult, f0=f0, K2=K2, Np=Np, C=C) Ba=self._get_Ba(f=f, couple_mult=couple_mult, f0=f0, K2=K2, Np=Np, C=C) w=2*pi*f try: return Ga/(Ga+1j*Ba+1j*w*C+1.0/(1j*w*L)) except ValueError: return array([Ga/(Ga+1j*Ba+1j*w*C+1.0/(1j*w*qL)) for qL in L])
def test_plot(**kwargs): rho=Rho.process_kwargs(kwargs) rho.ft="single" kdiv2pi=(rho.fixed_freq[1]-rho.fixed_freq[0])/rho.vf k=2*pi*rho.fixed_freq/rho.vf lbda0=1.0 #rho.lbda0 xx=linspace(-1.75*lbda0, 1.75*lbda0, 201) rhox=array([sum(2*kdiv2pi*rho.fixed_alpha*cos(k*x)) for x in xx]) pl=line(xx, rhox, linewidth=0.5)[0] return pl
def test_plot(**kwargs): rho = Rho.process_kwargs(kwargs) rho.ft = "single" kdiv2pi = (rho.fixed_freq[1] - rho.fixed_freq[0]) / rho.vf k = 2 * pi * rho.fixed_freq / rho.vf lbda0 = 1.0 #rho.lbda0 xx = linspace(-1.75 * lbda0, 1.75 * lbda0, 201) rhox = array([sum(2 * kdiv2pi * rho.fixed_alpha * cos(k * x)) for x in xx]) pl = line(xx, rhox, linewidth=0.5)[0] return pl
def _get_ls_f(self, f, couple_mult, f0, K2, Np): try: return array([ sqrt(qf * (qf - 2 * self._get_Lamb_shift( f=qf, couple_mult=couple_mult, f0=f0, K2=K2, Np=Np))) for qf in f ]) except TypeError: return sqrt(f * (f - 2 * self._get_Lamb_shift( f=f, couple_mult=couple_mult, f0=f0, K2=K2, Np=Np)))
def update_EkdivEc(self, ng, Ec, Ej, Nstates, order): """calculates transmon energy level with N states (more states is better approximation) effectively solves the mathieu equation but for fractional inputs (which doesn't work in scipy.special.mathieu_a)""" # if type(ng) not in (int, float): # d=zeros((order, len(ng))) # elif type(Ec) not in (int, float): # d=zeros((order, len(Ec))) # elif type(Ej) not in (int, float): # d=zeros((order, len(Ej))) if type(ng) in (int, float): ng = array([ng]) d1 = [] d2 = [] d3 = [] Ej = Ej / Ec Ec = 1.0 #/4.0 for a in ng: NL = 2 * Nstates + 1 A = zeros((NL, NL)) for b in range(0, NL): A[b, b] = 4.0 * Ec * (b - Nstates - a)**2 if b != NL - 1: A[b, b + 1] = -Ej / 2.0 if b != 0: A[b, b - 1] = -Ej / 2.0 #w,v=eig(A) w = eigvalsh(A) d = w[0:order] # d1.append(min(w))#/h*1e-9) # w=delete(w, w.argmin()) # d2.append(min(w))#/h*1e-9) # w=delete(w, w.argmin()) # d3.append(min(w))#/h*1e-9) return array([array(d1), array(d2), array(d3)]).transpose()
def surface_charge_plot(pl="surface charge", **kwargs): rho=Rho.process_kwargs(kwargs) #rho.ft="single" #"double" #charge=real(fft.fftshift(fft.ifft(rho.fixed_alpha)))#.astype(float64) print rho.a, rho.g #print rho.surface_charge.dtype #print max(rho.surface_voltage/rho.epsinf) #x=linspace() #x=linspace(-rho.N_fixed/2+.001, rho.N_fixed/2+0.0, rho.N_fixed)/800.0 print rho.surface_charge.shape, rho.surface_x.shape pieta=pi*rho.eta #a=0.25 #rho.a lbda0=1.0 #rho.lbda0 x=linspace(-1.75*10*lbda0, 1.75*10*lbda0, 20001) s=linspace(0.0,1.0, 20001) def rh(x): m=int(2*x/(lbda0)) if absolute(2*x/lbda0-m)<1.0/4.0: theta=4*pi*x/lbda0 return 2/lbda0*2*sqrt(2.0)*((1.0)**m)/sqrt(cos(theta)-cos(pieta))*trapz(sin(pi*s)*cos((s-1/2)*theta)/rho.lgf1.Pv(-s),s) if absolute(2*x/lbda0-m-1)<1.0/4.0: theta=4*pi*x/lbda0 return 2/lbda0*2*sqrt(2.0)*((1.0)**m)/sqrt(cos(theta)-cos(pieta))*trapz(sin(pi*s)*cos((s-1/2)*theta)/rho.lgf1.Pv(-s),s) if absolute(2*x/lbda0-m+1)<1.0/4.0: theta=4*pi*x/lbda0 return 2/lbda0*2*sqrt(2.0)*((1.0)**m)/sqrt(cos(theta)-cos(pieta))*trapz(sin(pi*s)*cos((s-1/2)*theta)/rho.lgf1.Pv(-s),s) return 0.0 rgh=array([rh(xx) for xx in x])/1.694 line(1*x, rgh, linewidth=0.5, pl=pl) #line(real(fft.fft(rgh))) #line(imag(fft.fft(rgh))) line(rho.fixed_freq, rho.fixed_alpha) print "line done" pl=line(rho.surface_x, rho.surface_charge*rgh[10000]/rho.surface_charge[rho.N_fixed/2], plotter=pl, plot_name="single", color="blue", label="single finger", **kwargs) #charge=real(fft.fftshift(fft.ifft(rho.fixed_alpha/rho.fixed_freq*rho.f0)))#.astype(float64) pl=line(rho.surface_x, rho.surface_voltage*1e6, plotter=pl, plot_name="singled", color="red", label="single finger2", **kwargs) xprime=linspace(-2.000001, 2.0, 200) #[0.01, 1.01] #range(10) print "trapz" #line(xprime, array([trapz(rho.surcharge/absolute(x-xp), x) for xp in xprime])) print "trapz done" pl.xlabel="frequency/center frequency" pl.ylabel="element factor" #pl.legend() return pl
def center_coupling_vs_eta(pl="f0_vs_eta", **kwargs): idt=Rho.process_kwargs(kwargs) idt.couple_type="full expr" idt.fixed_update=True idt.N_fixed=1000 idt.fixed_freq_max=2*idt.f0 idt.ft="single" eta_arr=linspace(0.1, 0.9, 21) alpha_arr1=[] alpha_arr2=[] alpha_arr3=[] for eta in eta_arr: idt.eta=eta alpha=idt._get_alpha(f=idt.f0, eta=eta) alpha_arr1.append(alpha) alpha=idt._get_alpha(f=3*idt.f0, eta=eta) alpha_arr2.append(alpha) alpha=idt._get_alpha(f=5*idt.f0, eta=eta) alpha_arr3.append(alpha) pl=line(eta_arr, array(alpha_arr1), plotter=pl) line(eta_arr, array(alpha_arr2), plotter=pl, color="red") line(eta_arr, array(alpha_arr3), plotter=pl, color="green") return pl #line(eta, idt._get_alpha(f=3*idt.f0, eta=eta))[0]
def center_coupling_vs_eta(pl="f0_vs_eta", **kwargs): idt = Rho.process_kwargs(kwargs) idt.couple_type = "full expr" idt.fixed_update = True idt.N_fixed = 1000 idt.fixed_freq_max = 2 * idt.f0 idt.ft = "single" eta_arr = linspace(0.1, 0.9, 21) alpha_arr1 = [] alpha_arr2 = [] alpha_arr3 = [] for eta in eta_arr: idt.eta = eta alpha = idt._get_alpha(f=idt.f0, eta=eta) alpha_arr1.append(alpha) alpha = idt._get_alpha(f=3 * idt.f0, eta=eta) alpha_arr2.append(alpha) alpha = idt._get_alpha(f=5 * idt.f0, eta=eta) alpha_arr3.append(alpha) pl = line(eta_arr, array(alpha_arr1), plotter=pl) line(eta_arr, array(alpha_arr2), plotter=pl, color="red") line(eta_arr, array(alpha_arr3), plotter=pl, color="green") return pl #line(eta, idt._get_alpha(f=3*idt.f0, eta=eta))[0]
def update_EkdivEc(self, ng, Ec, Ej, Nstates, order): """calculates transmon energy level with N states (more states is better approximation) effectively solves the mathieu equation but for fractional inputs (which doesn't work in scipy.special.mathieu_a)""" # if type(ng) not in (int, float): # d=zeros((order, len(ng))) # elif type(Ec) not in (int, float): # d=zeros((order, len(Ec))) # elif type(Ej) not in (int, float): # d=zeros((order, len(Ej))) if type(ng) in (int, float): ng=array([ng]) d1=[] d2=[] d3=[] Ej=Ej/Ec Ec=1.0#/4.0 for a in ng: NL=2*Nstates+1 A=zeros((NL, NL)) for b in range(0,NL): A[b, b]=4.0*Ec*(b-Nstates-a)**2 if b!=NL-1: A[b, b+1]= -Ej/2.0 if b!=0: A[b, b-1]= -Ej/2.0 #w,v=eig(A) w=eigvalsh(A) d=w[0:order] # d1.append(min(w))#/h*1e-9) # w=delete(w, w.argmin()) # d2.append(min(w))#/h*1e-9) # w=delete(w, w.argmin()) # d3.append(min(w))#/h*1e-9) return array([array(d1), array(d2), array(d3)]).transpose()
def _get_S11(self, f, couple_mult, f0, K2, Np, C, L): Ga = self._get_Ga(f=f, couple_mult=couple_mult, f0=f0, K2=K2, Np=Np, C=C) Ba = self._get_Ba(f=f, couple_mult=couple_mult, f0=f0, K2=K2, Np=Np, C=C) w = 2 * pi * f try: return Ga / (Ga + 1j * Ba + 1j * w * C + 1.0 / (1j * w * L)) except ValueError: return array([ Ga / (Ga + 1j * Ba + 1j * w * C + 1.0 / (1j * w * qL)) for qL in L ])
def surface_charge_plot(pl="surface charge", **kwargs): rho = Rho.process_kwargs(kwargs) #rho.ft="single" #"double" #charge=real(fft.fftshift(fft.ifft(rho.fixed_alpha)))#.astype(float64) print rho.a, rho.g #print rho.surface_charge.dtype #print max(rho.surface_voltage/rho.epsinf) #x=linspace() #x=linspace(-rho.N_fixed/2+.001, rho.N_fixed/2+0.0, rho.N_fixed)/800.0 print rho.surface_charge.shape, rho.surface_x.shape pieta = pi * rho.eta #a=0.25 #rho.a lbda0 = 1.0 #rho.lbda0 x = linspace(-1.75 * 10 * lbda0, 1.75 * 10 * lbda0, 20001) s = linspace(0.0, 1.0, 20001) def rh(x): m = int(2 * x / (lbda0)) if absolute(2 * x / lbda0 - m) < 1.0 / 4.0: theta = 4 * pi * x / lbda0 return 2 / lbda0 * 2 * sqrt(2.0) * ( (1.0)**m) / sqrt(cos(theta) - cos(pieta)) * trapz( sin(pi * s) * cos( (s - 1 / 2) * theta) / rho.lgf1.Pv(-s), s) if absolute(2 * x / lbda0 - m - 1) < 1.0 / 4.0: theta = 4 * pi * x / lbda0 return 2 / lbda0 * 2 * sqrt(2.0) * ( (1.0)**m) / sqrt(cos(theta) - cos(pieta)) * trapz( sin(pi * s) * cos( (s - 1 / 2) * theta) / rho.lgf1.Pv(-s), s) if absolute(2 * x / lbda0 - m + 1) < 1.0 / 4.0: theta = 4 * pi * x / lbda0 return 2 / lbda0 * 2 * sqrt(2.0) * ( (1.0)**m) / sqrt(cos(theta) - cos(pieta)) * trapz( sin(pi * s) * cos( (s - 1 / 2) * theta) / rho.lgf1.Pv(-s), s) return 0.0 rgh = array([rh(xx) for xx in x]) / 1.694 line(1 * x, rgh, linewidth=0.5, pl=pl) #line(real(fft.fft(rgh))) #line(imag(fft.fft(rgh))) line(rho.fixed_freq, rho.fixed_alpha) print "line done" pl = line(rho.surface_x, rho.surface_charge * rgh[10000] / rho.surface_charge[rho.N_fixed / 2], plotter=pl, plot_name="single", color="blue", label="single finger", **kwargs) #charge=real(fft.fftshift(fft.ifft(rho.fixed_alpha/rho.fixed_freq*rho.f0)))#.astype(float64) pl = line(rho.surface_x, rho.surface_voltage * 1e6, plotter=pl, plot_name="singled", color="red", label="single finger2", **kwargs) xprime = linspace(-2.000001, 2.0, 200) #[0.01, 1.01] #range(10) print "trapz" #line(xprime, array([trapz(rho.surcharge/absolute(x-xp), x) for xp in xprime])) print "trapz done" pl.xlabel = "frequency/center frequency" pl.ylabel = "element factor" #pl.legend() return pl
fixed_freq_max=7e9, fixed_fq_min=1e9, fixed_fq_max=10e9, Cc=30e-15, gate_type="capacitive", Cground=100e-12) a._get_simple_S(f=7e9) #a.K2=0.01 #a.Np=3 a.fitter.gamma = 0.05 if 0: pl = colormesh(a.fixed_freq, a.fixed_fq, a.MagAbs) colormesh(a.fixed_freq, a.fixed_fq, a.MagAbsFit, pl=pl) #.show() pl = line(a.fixed_freq, array([fp[1] for fp in a.fitter.fit_params]) * 1e9, label="center S33") line(a.fixed_freq, a.fixed_fq[argmin(a.MagAbs**2, axis=0)], pl=pl, label="min S33", color="red") line(a.fixed_freq, a.fixed_freq - a.fixed_Lamb_shift, pl=pl, label="theory", color="green") #.show() #a.gate_type="constant" line(a.fixed_freq, a.fixed_freq - a._get_Lamb_shift(f=a.fixed_freq), pl=pl,
def _get_ls_f(self, f, couple_mult, f0, K2, Np): try: return array([sqrt(qf*(qf-2*self._get_Lamb_shift(f=qf, couple_mult=couple_mult, f0=f0, K2=K2, Np=Np))) for qf in f]) except TypeError: return sqrt(f*(f-2*self._get_Lamb_shift(f=f, couple_mult=couple_mult, f0=f0, K2=K2, Np=Np)))
# except ValueError: # return array([1j*sqrt(2.0*Ga*GL)/(Ga+1j*Ba+1j*w*Ct+1.0/(1j*w*qL)) for qL in L]) if 0: a=QDT(#Ga_type="sinc", Ba_type="formula", magabs_type="S33", fixed_freq_min=3e9, fixed_freq_max=7e9, fixed_fq_min=1e9, fixed_fq_max=10e9, Cc=30e-15, gate_type="capacitive", Cground=100e-12) a._get_simple_S(f=7e9) #a.K2=0.01 #a.Np=3 a.fitter.gamma=0.05 if 0: pl=colormesh(a.fixed_freq, a.fixed_fq, a.MagAbs) colormesh(a.fixed_freq, a.fixed_fq, a.MagAbsFit, pl=pl)#.show() pl=line(a.fixed_freq, array([fp[1] for fp in a.fitter.fit_params])*1e9, label="center S33") line(a.fixed_freq, a.fixed_fq[argmin(a.MagAbs**2, axis=0)], pl=pl, label="min S33", color="red") line(a.fixed_freq, a.fixed_freq-a.fixed_Lamb_shift, pl=pl, label="theory", color="green")#.show() #a.gate_type="constant" line(a.fixed_freq, a.fixed_freq-a._get_Lamb_shift(f=a.fixed_freq), pl=pl, label="theory", color="purple")#.show() #-array([fp[1] for fp in a.fitter.fit_params])*1e9+a.fixed_freq=-a._get_Lamb_shift(f=a.fixed_freq) #a.gate_type="capacitive" pl=line(a.fixed_freq, a.fixed_coupling, label="width S33") #a.gate_type="constant" line(a.fixed_freq, a._get_coupling(f=a.fixed_freq), pl=pl, color="red", label="theory").show() def energy_level_plot(qdt, fig_width=9.0, fig_height=6.0): pl=Plotter(fig_width=fig_width, fig_height=fig_height) EjdivEc=linspace(0.1, 300, 3000)