entropy = np.real(entropy) Ls = np.array(Ls) extrap_Ls = np.array([0, 1]+list(Ls)) fit_pts, params, R = analysis.curve_fit_main(entropy, analysis.linear, Ls, extrap_Ls) # flip sign of gamma params = [params[0], -1*params[1]] print params print fit_pts[0], fit_pts[1] plt.plot(Ls, entropy, 'k.', label='Data') plt.plot(extrap_Ls, fit_pts, 'b-', label='Fit') text = text = plt.text(1, 5, r'$S = \alpha W-\gamma$') pl2_txt = lambda params: (r'$\alpha={}$'+'\n'+r'\gamma={}$').format(IO.round_sig(params[0],2),IO.round_sig(params[1], 2)) text2 = plt.text(1, 3.5, pl2_txt(params)) plt.xlim(xmin=-1, xmax=11) plt.ylim(ymin=-1) plt.axhline(0, color='k', ls=':') plt.axvline(0, color='k', ls=':') #plt.title('Computing Topological Entanglement Entropy') plt.xlabel(r'$W$') plt.ylabel('Entanglement Entropy') plt.legend(loc='best', numpoints=1, frameon=False) plt.tight_layout() plt.show()
colors = ['b', 'g', 'r', 'k', 'c'] plt.xlabel(r'$\frac{1}{W}$') plt.ylabel('Entanglement Gap') ax.set_xticks([0]+[1/L for L in xrange(4, 12, 2)]) ax.xaxis.set_major_formatter(ticker.FuncFormatter(lambda x, pos: r'$\frac{1}{'+str(int(round(1/x)))+'}$' if x>0 else r'$\frac{1}{\infty}$')) for k, color in zip(keys, colors): plt.plot([1/L for L in LL(*k)], E(*k), marker='.', ls='', color=color) plt.xlim(-0.01, 0.26) plt.ylim(-.1, 3) plt.grid(axis='y') plt.tight_layout() pl3_txt = lambda params: 'B='+str(IO.round_sig(params[0],3))+'\nC='+str(IO.round_sig(params[1],3)) for k, color in zip(keys, colors): if k[0]==0: params, R, line, text = try_fit([1/L for L in LL(*k)], E(*k), a.quadratic, color, [1 for x in LL(*k)],(0, 0.3), [0, 0.1], pl3_txt) else: params, R, line, text = try_fit([1/L for L in LL(*k)], E(*k), a.quadratic, color, [1 for x in LL(*k)],(0, 0.3), [0, 0.1], pl3_txt) #k = keys[1] #params, R, line, text = try_fit([1/L for L in LL(*k)], E(*k), a.linear, 'g', [1 for x in LL(*k)],(0, 0.3), [0, 0.3], pl3_txt) plt.show() # plt.yscale('log') # ax.set_yticks([0.1, 0.2, 0.5, 1, 2, 3]) # ax.yaxis.set_major_formatter(ticker.FuncFormatter(lambda x, pos: str(IO.round_sig(x, 2))))
symdata = symmetric_inverse_corr2.view_props(['L', 'Correlation Bound']) symdata = np.array([[L, val] for L, val in symdata]) symdata = np.array(sorted(symdata, key = lambda x:x[0])) plt.sca(axs[1]) fit_data = symdata[:, 1][-4:] extrapolate_pnts = np.arange(3, 10, 0.1) fit_func = a.expic fit_Ls = symdata[:, 0][-4:] fit_label = 'Fit' (fit_data, params, R) = a.curve_fit_main(fit_data,fit_func, fit_Ls, extrapolate_pnts) symmetric_inverse_corr2.plot('L', 'Correlation Bound', ax = axs[1], xlabel = 'L', ylabel='Correlation Length', title = 'Symmetric Correlation Length', label = 'Data', marker = '*', color = 'k') plt.plot(extrapolate_pnts, fit_data, label = fit_label, color='k') txt_coords = (5, -0.3) txt = plt.text(txt_coords[0], txt_coords[1], fit_label+': \n$a-ce^{-L/b}$'+'\n a ={} \n b={} \nc={}'.format(*[IO.round_sig(p) for p in params])) plt.xlim(3, 10) plt.ylim(-0.4, 1.5) notsymdata = notsymmetric_inverse_corr.view_props(['L', 'Correlation Bound']) notsymdata = np.array([[L, val] for L, val in notsymdata]) notsymdata = np.array(sorted(notsymdata, key = lambda x:x[0])) plt.sca(axs[1]) fit_data = notsymdata[:, 1][-4:] extrapolate_pnts = np.arange(3, 10, 0.1) fit_func = a.expic fit_Ls = notsymdata[:, 0][-4:] fit_label = 'Fit' (fit_data, params, R) = a.curve_fit_main(fit_data,fit_func, fit_Ls, extrapolate_pnts) notsymmetric_inverse_corr.plot('L', 'Correlation Bound', ax = axs[0], xlabel = 'L', ylabel='Correlation Length', title = 'Overall Correlation Length', label = 'Data', marker = '*', color = 'b')
# plt.plot(xdata, ydata, ls='', marker='.', markersize=4) line = plt.plot(extrap, interp, ls="-", color=color) if show_fit_details: text = plt.text(txt_coords[0], txt_coords[1], txt_func(params)) else: text = 0 return params, R, line, text # set up the plot fig = plt.plot() ax = plt.gca() plt.xscale("log") ax.set_xticks(range(2, 12, 2)) ax.xaxis.set_major_formatter(ticker.FuncFormatter(lambda x, pos: str(int(IO.round_sig(x, 2))))) plt.yscale("log") ax.set_yticks([0.1, 0.2, 0.5, 1, 2, 3]) ax.yaxis.set_major_formatter(ticker.FuncFormatter(lambda x, pos: str(IO.round_sig(x, 2)))) # labels = ['$\\vert 1, 0 \\rangle$', u'$\\vert 2, 0 \\rangle$', u'$\\vert 3, 0 #\\rangle$', # u'$j_{-1} \\vert 0, 0 \\rangle$', '$j_{-1}\\vert 1, 0 \\rangle$'] labels = ["e=1, K=0", "e=2, K=0", "e=3, K=0", "e=0, K=1", "e=1, K=1"] pl = lambda x, a, b: b * x ** (-a) pl3_txt = lambda params: "B=" + str(IO.round_sig(params[0], 3)) + "\nC=" + str(IO.round_sig(params[1], 3)) pl_txt = lambda params: "B=" + str(IO.round_sig(params[0])) + "\nC=" + str(IO.round_sig(params[1])) text_x = 11.5 max_x_in_fit = 11.1
from __future__ import division from matplotlib import pyplot as plt import numpy as np from DataAnalysis import PEPS_plots as pp from PEPS import IO_helper as IO from PEPS.CylinderPEPS import run import sfig ev_to_corr = lambda e: -1/np.log(np.abs(e)) phase = lambda e: 'e^(i pi {})'.format(IO.round_sig(np.angle(e)/np.pi, 2)) def corrbound_data(state, Ls): ans = {} for L in Ls: tmspec = run.load_transfer_matrix_spectrum(state, L) if tmspec: norm = tmspec[(0, 0)][0] ev1 = tmspec[(0, 1)][0]/norm if L>1: symev00 = tmspec[(0, 0)][1]/norm symev10 = tmspec[(1, 0)][0]/norm #K=+-1, N=0 ev is bigger than K=0, N=0 sometimes print abs(symev00), abs(symev10) symev = symev00 if abs(symev00)>abs(symev10) else symev10 #symev = symev00 else: symev00 = tmspec[(0, 0)][1]/norm symev = symev00 ans[L] = ev_to_corr(ev1), phase(ev1), ev_to_corr(symev), phase(symev) return ans IO.go_to_data_parent('softcoreboson', parent='Data//FBI-TM')