def getChern(omega, delta, epsilon, U, n, S, m0, kList=np.linspace(-1.0, 1.0, 600), plot=True): i = 0 s = int(2 * S + 1) N = 2 * n + 1 E = np.zeros((kList.size, s * N)) m = np.zeros((kList.size, s * N)) pops = np.zeros((kList.size, s * N, s)) ktot = np.zeros((kList.size, s * N)) mFvect = np.array([np.float(j - S) for j in range(s)]) for k in kList: H, kstates = RamanLatHam(k, omega, delta, epsilon, U, n, S, m0) Energies, eigenstates = LA.eig(H) sort = np.argsort(Energies) Esorted, eVsorted = Energies[sort], eigenstates[:, sort] E[i] = Esorted ev = eVsorted.transpose() evA = ev.reshape(N * s, N, s) popsA = np.sum(evA * np.conjugate(evA), axis=1) pops[i] = popsA evB = ev.reshape(N * s, N * s) popsB = evB * np.conjugate(evB) ktot[i] = np.einsum('i,ji->j', kstates, popsB) m[i] = np.dot(popsA, mFvect) i = i + 1 if plot: cDict = {} cDict[-2] = 'm-' cDict[-1] = 'r-' cDict[0] = 'g-' cDict[1] = 'b-' cDict[2] = 'c-' # fig5 = plt.figure() pan5 = fig5.add_subplot(1, 1, 1) for mF in np.arange(-S, S + 1): if S <= 2: pan5.plot(kList, pops[:, 0, mF + S], cDict[mF], label=r'$m_F$=' + str(mF)) else: pan5.plot(kList, pops[:, 0, mF + S]) #, cDict[mF], label=r'$m_F$='+str(mF)) pan5.set_xlabel(r'Crystal momentum [$k_L$]') pan5.set_ylabel('Fractional populations') pan5.set_title('Lowest band') plt.legend() if c > 0: indM = kList.size / 6 ind0 = kList.size / 2 indP = 5 * kList.size / 6 elif c < 0: indM = 5 * kList.size / 6 ind0 = kList.size / 2 indP = kList.size / 6 else: indM = kList.size / 2 ind0 = kList.size / 2 indP = kList.size / 2 xMth, dxMth = getMaxFitTheory( kList, pops[:, 0, S - 1], np.ones(pops[:, 0].size) * 0.001, indC=indM, plot=plot) #[np.where(pops[:,0,S-1]==np.max(pops[:,0,S-1]))] x0th, dx0th = getMaxFitTheory(kList, pops[:, 0, S], np.ones(pops[:, 0].size) * 0.001, indC=ind0, plot=plot) xPth, dxPth = getMaxFitTheory(kList, pops[:, 0, S + 1], np.ones(pops[:, 0].size) * 0.001, indC=indP, plot=plot) Ath, Bth, dAth, dBth = lineFit2.lineFit(np.array([xMth, x0th, xPth]), np.array([-1, 0, 1]), 'q', 'max. m', errorbars=True, yerr=np.array( [dxMth, dx0th, dxPth]), plot=plot) print xMth, x0th, xPth print 'chern theory = ' + str(Ath * 2 / 3) + '+/-' + str(dAth * 2 / 3) chern = Ath * 2.0 / 3.0 return pops, chern
def getChernTB(omega, delta, epsilon, tx, S, m0, c=4.0 / 3.0, kList=np.linspace(-1.0, 1.0, 600), Flat=True, save=False, plots=True): kList, E, m, pops = tbh.plotSynDimBandStructGenTBClean(omega, delta, epsilon, tx, S, m0, c=c, kList=kList, Flat=Flat, save=save, plots=plots) if c > 0: indM = kList.size / 6 ind0 = kList.size / 2 indP = 5 * kList.size / 6 elif c < 0: indM = 5 * kList.size / 6 ind0 = kList.size / 2 indP = kList.size / 6 else: indM = kList.size / 2 ind0 = kList.size / 2 indP = kList.size / 2 if plots: fig = plt.figure() pan = fig.add_subplot(111) pan.plot(kList, pops[:, 0, S - 1], 'r-') pan.plot(kList, pops[:, 0, S], 'g-') pan.plot(kList, pops[:, 0, S + 1], 'b-') xMth, dxMth = getMaxFitTheory( kList, pops[:, 0, S + 1], np.ones(pops[:, 0].size) * 0.001, indC=indM, plot=plots) #[np.where(pops[:,0,S-1]==np.max(pops[:,0,S-1]))] x0th, dx0th = getMaxFitTheory(kList, pops[:, 0, S], np.ones(pops[:, 0].size) * 0.001, indC=ind0, plot=plots) xPth, dxPth = getMaxFitTheory(kList, pops[:, 0, S - 1], np.ones(pops[:, 0].size) * 0.001, indC=indP, plot=plots) Ath, Bth, dAth, dBth = lineFit2.lineFit(np.array([xMth, x0th, xPth]), np.array([-1, 0, 1]), 'q', 'max. m', errorbars=True, yerr=np.array( [dxMth, dx0th, dxPth]), plot=plots) print xMth, x0th, xPth print 'chern theory = ' + str(Ath * 2 / 3) + '+/-' + str(dAth * 2 / 3) chern = Ath * 2.0 / 3.0 delChern = dAth * 2.0 / 3.0 # popAvg=np.zeros(pops[:,0,:].shape) # s=2*S+1 # for ind,k in enumerate(kList): # for i in range(s): # popAvg[ind,i]=np.average(pops[ind,0:int(np.ceil(s/q)),i]) # # xMth,dxMth=getMaxFitTheory(kList,popAvg[:,S+1],np.ones(pops[:,0].size)*0.001,indC=indM,plot=plots) #[np.where(pops[:,0,S-1]==np.max(pops[:,0,S-1]))] # x0th,dx0th=getMaxFitTheory(kList,popAvg[:,S],np.ones(pops[:,0].size)*0.001,indC=ind0,plot=plots) # xPth,dxPth=getMaxFitTheory(kList,popAvg[:,S-1],np.ones(pops[:,0].size)*0.001,indC=indP,plot=plots) # # # # Ath,Bth,dAth,dBth=lineFit2.lineFit(np.array([xMth,x0th,xPth]),np.array([-1,0,1]),'q','max. m',errorbars=True,yerr=np.array([dxMth,dx0th,dxPth]),plot=plots) # print xMth, x0th, xPth # print 'chern theory = '+ str(Ath*2/3) + '+/-'+str(dAth*2/3) # # chern = Ath*2.0/3.0 # delChern = dAth*2.0/3.0 return pops, chern, delChern
# qlistF2p[i] = qlistF2p[i] + 2.0 # #A,B,dA,dB = lineFit2.lineFit(tlistF2p,qlistF2p,'','') # #qlistF2pFit = tlistF2p*A #sortF2p=np.argsort(qlistF2pFit) odF2m = datafileF2m['odFiltAll'] xCentersF2m = datafileF2m['xCenters'] tlistF2m = datafileF2m['tlist'] qlistF2m = datafileF2m['qlist'] for i, q in enumerate(qlistF2m): if q > -0.8: qlistF2m[i] = qlistF2m[i] - 2.0 A, B, dA, dB = lineFit2.lineFit(tlistF2m, qlistF2m, '', '') qlistF2mFit = tlistF2m * A sortF2m = np.argsort(qlistF2mFit) figure = plt.figure() figure.clear() figure.set_size_inches(3.0, 1.7) gs = gridspec.GridSpec(5, 1) gs.update(left=0.05, right=0.95, top=1.0, bottom=0.2, wspace=0, hspace=0) vmax = 0.4 vmin = 0.0
x0, dx0 = figureChenOfOmegaSize.getMaxFitTheory(qlist, fraction0, sigma0, indC=ind0d, plot=plotBool) xM, dxM = figureChenOfOmegaSize.getMaxFitTheory(qlist, fractionM, sigmaM, indC=indMd, plot=plotBool) print 'S = ' + str(S) A, B, dA, dB = lineFit2.lineFit(np.array([xM, x0, xP]), np.array([-1, 0, 1]), 'q', 'max. m', errorbars=True, yerr=np.array([dxM, dx0, dxP]), plot=plotBool) print 'chern = ' + str(A * 2 / 3) + '+/-' + str(dA * 2 / 3) Ath, Bth, dAth, dBth = lineFit2.lineFit(np.array([xMth, x0th, xPth]), np.array([-1, 0, 1]), 'q', 'max. m', errorbars=True, yerr=np.array( [dxMth, dx0th, dxPth]), plot=plotBool) print 'chern theory = ' + str(Ath * 2 / 3) + '+/-' + str(dAth * 2 / 3)
def getChern(omega, delta, epsilon, U, n, S, m0, kList=np.linspace(-1.0, 1.0, 600), plot=True): i = 0 s = int(2 * S + 1) N = 2 * n + 1 E = np.zeros((kList.size, s * N)) m = np.zeros((kList.size, s * N)) pops = np.zeros((kList.size, s * N, s)) ktot = np.zeros((kList.size, s * N)) mFvect = np.array([np.float(j - S) for j in range(s)]) for k in kList: H, kstates = RamanLatHam(k, omega, delta, epsilon, U, n, S, m0) Energies, eigenstates = LA.eig(H) sort = np.argsort(Energies) Esorted, eVsorted = Energies[sort], eigenstates[:, sort] E[i] = Esorted ev = eVsorted.transpose() evA = ev.reshape(N * s, N, s) popsA = np.sum(evA * np.conjugate(evA), axis=1) pops[i] = popsA evB = ev.reshape(N * s, N * s) popsB = evB * np.conjugate(evB) ktot[i] = np.einsum('i,ji->j', kstates, popsB) m[i] = np.dot(popsA, mFvect) i = i + 1 if plot: cDict = {} cDict[-2] = 'm-' cDict[-1] = 'r-' cDict[0] = 'g-' cDict[1] = 'b-' cDict[2] = 'c-' # fig5 = plt.figure() pan5 = fig5.add_subplot(1, 1, 1) for mF in np.arange(-S, S + 1): if S <= 2: pan5.plot(kList, pops[:, 0, mF + S], cDict[mF], label=r'$m_F$=' + str(mF)) else: pan5.plot(kList, pops[:, 0, mF + S]) #, cDict[mF], label=r'$m_F$='+str(mF)) pan5.set_xlabel(r'Crystal momentum [$k_L$]') pan5.set_ylabel('Fractional populations') pan5.set_title('Lowest band') plt.legend() if c > 0: indM = kList.size / 6 ind0 = kList.size / 2 indP = 5 * kList.size / 6 elif c < 0: indM = 5 * kList.size / 6 ind0 = kList.size / 2 indP = kList.size / 6 else: indM = kList.size / 2 ind0 = kList.size / 2 indP = kList.size / 2 xMth, dxMth = getMaxFitTheory( kList, pops[:, 0, S - 1], np.ones(pops[:, 0].size) * 0.001, indC=indM, plot=plot) #[np.where(pops[:,0,S-1]==np.max(pops[:,0,S-1]))] x0th, dx0th = getMaxFitTheory(kList, pops[:, 0, S], np.ones(pops[:, 0].size) * 0.001, indC=ind0, plot=plot) xPth, dxPth = getMaxFitTheory(kList, pops[:, 0, S + 1], np.ones(pops[:, 0].size) * 0.001, indC=indP, plot=plot) Ath, Bth, dAth, dBth = lineFit2.lineFit(np.array([xMth, x0th, xPth]), np.array([-1, 0, 1]), 'q', 'max. m', errorbars=True, yerr=np.array( [dxMth, dx0th, dxPth]), plot=plot) print xMth, x0th, xPth print 'chern theory = ' + str(Ath * 2 / 3) + '+/-' + str(dAth * 2 / 3) chern = Ath * 2.0 / 3.0 return pops, chern #q=3.0 #c=4.0/q#1064.0/790.0#0.0# #Flat=False # #omegaList=np.linspace(0.0,2.0,50) #chernList1=np.zeros(omegaList.size) #chernList2=np.zeros(omegaList.size) #for ind, omega in enumerate(omegaList): # pops, chernList1[ind]=getChern(omega, 0.0, 0.02, 4.4, 7,1,0,kList=np.linspace(-1.0,1.0,200), plot=False) # pops, chernList2[ind]=getChern(omega, 0.0, 0.02, 4.4, 7,2,0,kList=np.linspace(-1.0,1.0,200), plot=False) # #figure=plt.figure() #pan=figure.add_subplot(111) #pan.plot(omegaList,chernList1, 'bo') #pan.set_xlabel(r'$\Omega$ [$E_L$]') #pan.set_ylabel(r'Chern number') # #figure2=plt.figure() #pan2=figure2.add_subplot(111) #pan2.plot(omegaList,chernList2, 'bo') #pan2.set_xlabel(r'$\Omega$ [$E_L$]') #pan2.set_ylabel(r'Chern number') #filename = 'ChernOfOmegaNotFlat' #np.savez(filename, c=c,Flat=Flat, omegaList = omegaList, chernList1=chernList1,chernList2=chernList2, # delta=0.0,epsilon=0.02,U=4.4,m0=0,kList=np.linspace(-1.0,1.0,200)) #q=3.0 #c=4.0/q#1064.0/790.0#0.0# #Flat=True #Slist=np.arange(1,21) #chernList=np.zeros(Slist.size) #for ind, Sloc in enumerate(Slist): # pops, chernList[ind]=getChern(0.5, 0.0, 0.0, 4.4, 7,Sloc,0,kList=np.linspace(-1.0,1.0,200), plot=False) # print Sloc # # #figure3=plt.figure() #pan3=figure3.add_subplot(111) #pan3.plot(Slist,chernList, 'bo') #pan3.set_xlabel(r'F') #pan3.set_ylabel(r'Chern number') # #filename = 'ChernOfSystemSizeOmega05' #np.savez(filename, c=c,Flat=Flat, Slist = Slist, chernList=chernList, omega=0.5,delta=0.0,epsilon=0.0,U=4.4,m0=0,kList=np.linspace(-1.0,1.0,200))
pan=fig.add_subplot(gs[i*2]) pan.errorbar(qlist[fitGoodList]/2.0, mode[fitGoodList],yerr=sigmaMode[fitGoodList],fmt='o',color='Grey',markersize=2) pan.plot(kList[fitGoodTheoryList]/2.0,modeTheory[fitGoodTheoryList],'r-',linewidth=1) qrangeList = np.linspace(0.2,1.0,20) Alist = np.zeros(qrangeList.size) dAlist = np.zeros(qrangeList.size) numPointsList = np.zeros(qrangeList.size) for ind,qrange in enumerate(qrangeList): qrangeBool=((qlist[fitGoodList]<qrange) & (qlist[fitGoodList]>-qrange)) Alist[ind],B,dAlist[ind],dB = lineFit2.lineFit(qlist[fitGoodList][qrangeBool], mode[fitGoodList][qrangeBool],'q data','m data',yerr=sigmaMode[fitGoodList][qrangeBool],plot=False,errorbars=True, bounds=(np.array([-np.inf,-0.001]),np.array([np.inf,0.001]))) numPointsList[ind] = qlist[fitGoodList][qrangeBool].size #pan.set_xlabel(r'$q_x$ [$k_L$]',size=14) #pan.set_ylabel(r'$\langle m \rangle$',size=14) qrangeListTh = np.linspace(0.01,1.0,25) AlistTh = np.zeros(qrangeListTh.size) dAlistTh = np.zeros(qrangeListTh.size) numPointsListTh = np.zeros(qrangeListTh.size) for ind,qrange in enumerate(qrangeListTh): krangeBool=((kList[fitGoodTheoryList]<qrange) & (kList[fitGoodTheoryList]>-qrange)) AlistTh[ind],B,dAlistTh[ind],dB = lineFit2.lineFit(kList[fitGoodTheoryList][krangeBool],modeTheory[fitGoodTheoryList][krangeBool],'q theory','m theory',plot=False, bounds=(np.array([-np.inf,-0.001]),np.array([np.inf,0.001]))) numPointsListTh[ind] = kList[fitGoodTheoryList][krangeBool].size #if clist2[i]!=0: # axins = inset_axes(pan, # width="20%", # width = 30% of parent_bbox # height="30%", # height : 1 inch
TDSEfile['latticeRampOnt'] - TDSEfile['ramanRampOnt']) / ( TDSEfile['tgrid'][-1] * hbar / Erecoil - TDSEfile['latticeRampOnt'] - TDSEfile['ramanRampOnt']) modeTDSE = TDSEfile['modeList'][qlistTDSE > 0] fracs = TDSEfile['fracs'][qlistTDSE > 0] qlistTDSE = qlistTDSE[qlistTDSE > 0] qlistTDSE = np.append(-qlistTDSE[::-1], qlistTDSE) modeTDSE = np.append(-modeTDSE[::-1], modeTDSE) fracs = np.append(fracs[::-1, ::-1], fracs, axis=0) pan.plot(qlistTDSE / 2.0, modeTDSE, label=np.round(forcelist[ind], 3)) A, B, dA, dB = lineFit2.lineFit(qlistTDSE, modeTDSE, 'q theory', 'm theory', plot=plotBool, bounds=(np.array([-np.inf, -0.001]), np.array([np.inf, 0.001]))) chernLine[ind] = A * 2.0 / 3.0 delChernLine[ind] = dA * 2.0 / 3.0 indM = qlistTDSE.size / 6 ind0 = qlistTDSE.size / 2 indP = 5 * qlistTDSE.size / 6 xPth, dxPth = figureChenOfOmegaSize.getMaxFitTheory( qlistTDSE, fracs[:, 1], np.ones(fracs[:, 1].size) * 0.001, indC=indP,