def plot_mcf(self, haloprop, **kwargs): color = iter(cm.Set1(np.linspace(0, 1, 9))) for cat in self.__catlist: mcf = cat.calculate_mcf(haloprop, **kwargs) binmids = cat.binmids_last lowererr = cat.mcf_lowererr uppererr = cat.mcf_uppererr c = next(color) plt.semilogx(binmids, mcf, c=c, linewidth=3.0) plt.fill_between(binmids, lowererr, uppererr, color=c, alpha=0.05) plt.xlabel(r'r') plt.ylabel(r'$\mathcal{M}$')
def plot_bar_FeOx(): # FeOx df = pd.read_csv( '../results/dynamic_results/FeOx_vintage_results_0226.csv', index_col=[0, 1]) market_name = [ 'Household & Furniture', 'Automotive', 'Medical', 'Other Industries', 'Packaging', 'Electronics', 'Construction & Building' ] amount = [ df.loc[mat, 'Manufacturing Release']['2010.0'] + df.loc[mat, 'In Use']['2010.0'] + df.loc[mat, 'End of Life']['2010.0'] for mat in market_name ] width = 0.15 last_num = 0 color = iter(cm.Set1(np.linspace(0, 1, 7))) for name, num in zip(market_name, amount): c = next(color) if name == 'Construction & Building': plt.bar(0.1, num, width, bottom=last_num, color=c, label=name, yerr=1000, error_kw=dict(ecolor='rosybrown', lw=2, capsize=5, capthick=2)) else: plt.bar(0.1, num, width, bottom=last_num, color=c, label=name) last_num += num plt.bar(0.7, 13860, width, color='salmon', label='Static Results (aggregated, all uses)') plt.legend(loc='upper left') plt.xlim(0, 1) plt.xticks((0.18, 0.78), ('Dynamic Model', 'Static Model')) plt.tick_params(labelsize=14) plt.show()
def plot_bar_TiO2(): # TiO2 market_name = [ 'Household & Furniture', 'Automotive', 'Medical', 'Other Industries', 'Packaging', 'Electronics', 'Construction & Building' ] amount = [ 1468.35487751, 540.792628124, 1122.57862278, 833.309532892, 1137.82004151, 863.93634447, 3705.56984166 ] width = 0.15 last_num = 0 color = iter(cm.Set1(np.linspace(0, 1, 7))) for name, num in zip(market_name, amount): c = next(color) if name == 'Construction & Building': plt.bar(0.1, num, width, bottom=last_num, color=c, label=name, yerr=3000, error_kw=dict(ecolor='rosybrown', lw=2, capsize=5, capthick=2)) else: plt.bar(0.1, num, width, bottom=last_num, color=c, label=name) last_num += num plt.bar(0.7, 39600, width, color='salmon', label='Static Results (aggregated, all uses)') plt.legend(loc='upper left') plt.xlim(0, 1) plt.xticks((0.18, 0.78), ('Dynamic Model', 'Static Model')) plt.tick_params(labelsize=14) plt.show()
def plot_market_vintage(self,args='Total Release'): ''' Function to plot out the vintage results by markets This verion is going to plot out graph depending on the input arguments Total Release (defult): will plot out the total release (end of life + in use) for each market End of Life: will plot out the end of life release for each market ''' color=iter(cm.Set1(np.linspace(0,1,7))) if args == 'Total Release': fig,ax = plt.subplots(1) for each_mak, each_val in self.market_vintage_results.iteritems(): c=next(color) this_tot_release = each_val['Manufacturing Release']+each_val['In Use']+ each_val['End of Life'] ax.plot(self.years, this_tot_release,label = each_mak, linewidth = 2.5,c=c) #order legend handles, labels = ax.get_legend_handles_labels() handles = [handles[6],handles[0],handles[2],handles[3],handles[4],handles[5],handles[1]] labels = [labels[6], labels[0], labels[2],labels[3],labels[4],labels[5],labels[1]] ax.legend(handles,labels,loc='upper left') plt.xlabel('Year', fontsize=20, fontweight='bold') plt.ylabel('Total Releases in Tons', fontsize=20, fontweight='bold') plt.tick_params(labelsize=14) plt.show() elif args =='End of Life': plt.figure() for each_mak, each_val in self.market_vintage_results.iteritems(): plt.plot(self.years, each_val['End of Life'],label = each_mak) plt.legend(loc ='upper left') plt.xlabel('Year', fontsize=20, fontweight='bold') plt.ylabel('End of Life Releases in Tonnes', fontsize=20, fontweight='bold') plt.show() elif args =='In Use': plt.figure() for each_mak, each_val in self.market_vintage_results.iteritems(): plt.plot(self.years, each_val['In Use'],label = each_mak) plt.legend(loc ='upper left') plt.xlabel('Year', fontsize=20, fontweight='bold') plt.ylabel('In Use Releases in Tonnes', fontsize=20, fontweight='bold') plt.show()
def plotChart(data, out): colors = iter(cm.Set1(np.linspace(0, 1, len(data)))) # colors=iter(cm.Dark2(np.linspace(0,1,len(data)))) fig = plt.figure(figsize=(20, 10)) ax = fig.add_subplot(111) ax.xaxis.set_major_formatter(ticker.FuncFormatter(myticks)) plt.grid() plt.yscale("log") plt.xlabel("Ilość iteracji", fontsize="xx-large") plt.ylabel("Błąd śreniokwadratowy", fontsize="xx-large") for n_of_neurons, lists in data.items(): c = next(colors) ax.plot(lists[0], lists[1], color=c, label="Ilość neuronow {0}-błąd dla danych treningowych" .format(n_of_neurons)) ax.plot(lists[0], lists[2], color=c, linestyle=":", label="Ilość neuronow {0}-błąd dla danych testowych" .format(n_of_neurons)) legend = plt.legend(loc='upper center', ncol=3, fancybox=True, shadow=True) legend.get_frame() plt.title(out) plt.savefig(out + ".png")
for ix in range(nx): temp_y = abs(datetime.datetime.strptime(x[ix], time_format) - origin).total_seconds() y.append(temp_y) y = np.asarray(y) multi_dir = "/media/sf_e/john/optim_5/single_h5/" results_dir = "/media/sf_e/john/optim_5/" img_dir = "/media/sf_e/john/optim_5/figures/" material_file = "/media/sf_e/john/optim_5/300A_material.h5" river_stage = "/media/sf_e/john/optim_5/DatumH_River_filtered_6h_321.txt" sampling_file = "/media/sf_e/john/optim_5/Sample_Data_2015_U.csv" wells_dir = "/media/sf_e/john/wells/" colors = cm.Set1(np.linspace(0, 1, 9))[np.array([6, 2, 1, 3, 4, 0, 7, 8, 5])] #colors = np.array(["brown", "green", "blue", "purple", "orange", "red"]) # cluster information from Chris well = [ "399-1-10A", "399-1-21A", "399-2-1", "399-2-2", "399-2-23", "399-2-3", "399-2-32", "399-2-33", "399-2-5", "399-2-7", "399-3-19", "399-3-9", "399-4-9" ] well_name = [ "1-10A", "1-21A", "2-01", "2-02", "2-23", "2-03", "2-32", "2-33", "2-05", "2-07", "3-19", "3-09", "4-09" ] well_cluster = [1, 3, 4, 4, 2, 4, 2, 2, 2, 2, 3, 4, 1] well_coord = np.array([[594346.57, 116733.99], [594160.78, 116183.88], [594467.25, 116121.22], [594385.8, 116282.6],
plt.savefig(pltfolder + 'occupation_systems.eps', format='eps', dpi=1000) plt.clf() print('.', end='', flush=True) ### occupation number in levels against level index occavg = np.loadtxt(pltfolder + 'occ_fluctuation_N' + str(sysVar.N) + '.txt', usecols=(1, )) plt.xlim(-0.1, sysVar.m - 0.9) for l in range(0, sysVar.m): plt.errorbar(l, occavg[int(7 + 3 * l)] / sysVar.N, xerr=None, yerr=occavg[int(8 + 3 * l)] / sysVar.N, marker='o', color=cm.Set1(0)) plt.ylabel(r'Relative level occupation') plt.xlabel(r'Level index') plt.tight_layout(padding) plt.savefig(pltfolder + 'occupation_distribution.eps', format='eps', dpi=1000) plt.clf() plt.xlim( np.min(np.arange(sysVar.m)[sysVar.mask]) - 0.1, np.max(np.arange(sysVar.m)[sysVar.mask]) + 0.1) for l in np.arange(sysVar.m)[sysVar.mask]: plt.errorbar(l, occavg[int(7 + 3 * l)] / sysVar.N, xerr=None, yerr=occavg[int(8 + 3 * l)] / sysVar.N, marker='o',
def plotData(sysVar): print("Plotting datapoints to pdf", end='') avgstyle = 'dashed' avgsize = 0.6 expectstyle = 'solid' expectsize = 1 loavgpercent = sysVar.plotLoAvgPerc #percentage of time evolution to start averaging loavgind = int(loavgpercent * sysVar.dataPoints ) #index to start at when calculating average and stddev loavgtime = np.round( loavgpercent * (sysVar.deltaT * sysVar.steps * sysVar.plotTimeScale), 2) if sysVar.boolPlotAverages: print(' with averaging from Jt=%.2f' % loavgtime, end='') fwidth = sysVar.plotSavgolFrame ford = sysVar.plotSavgolOrder params = { 'legend.fontsize': sysVar.plotLegendSize, 'font.size': sysVar.plotFontSize, 'mathtext.default': 'rm' # see http://matplotlib.org/users/customizing.html } plt.rcParams['agg.path.chunksize'] = 0 plt.rcParams.update(params) plt.rc('text', usetex=True) plt.rc('font', **{'family': 'sans-serif', 'sans-serif': ['Arial']}) pp = PdfPages('./plots/plots.pdf') occfile = './data/occupation.txt' occ_array = np.loadtxt(occfile) #multiply step array with time scale step_array = occ_array[:, 0] * sysVar.plotTimeScale normfile = './data/norm.txt' norm_array = np.loadtxt(normfile) #want deviation from 1 norm_array[:, 1] = 1 - norm_array[:, 1] entfile = './data/entropy.txt' ent_array = np.loadtxt(entfile) if sysVar.boolPlotEngy: engies = np.loadtxt('./data/hamiltonian_eigvals.txt') if sysVar.boolPlotDecomp: stfacts = np.loadtxt('./data/state.txt') if sysVar.boolTotalEnt: totentfile = './data/total_entropy.txt' totent_array = np.loadtxt(totentfile) if sysVar.boolTotalEnergy: energyfile = './data/energy.txt' en_array = np.loadtxt(energyfile) en0 = en_array[0, 1] en_array[:, 1] -= en0 #en_micind = find_nearest(engies[:,1], en0) #print(' - |(E0 - Emicro)/E0|: %.0e - ' % (np.abs((en0 - engies[en_micind,1])/en0)), end='' ) if sysVar.boolPlotDiagExp: microexpfile = './data/diagexpect.txt' microexp = np.loadtxt(microexpfile) if sysVar.boolPlotOffDiag: offdiagfile = './data/offdiagonal.txt' offdiag = np.loadtxt(offdiagfile) if sysVar.boolPlotOffDiagDens: offdiagdensfile = './data/offdiagonaldens.txt' offdiagdens = np.loadtxt(offdiagdensfile) if sysVar.boolPlotGreen: greenfile = './data/green.txt' greendat = np.loadtxt(greenfile) def complete_system_enttropy(): return 0 #### Complete system Entropy if (sysVar.boolTotalEnt): plt.plot(totent_array[:, 0] * sysVar.plotTimeScale, totent_array[:, 1] * 1e13, linewidth=0.6, color='r') plt.grid() plt.xlabel(r'$J\,t$') plt.ylabel(r'Total system entropy $/ 10^{-13}$') plt.tight_layout() ### pp.savefig() plt.clf() print('.', end='', flush=True) def subsystem_entropy(): return 0 ### Subsystem Entropy plt.plot(step_array, ent_array[:, 1], linewidth=0.8, color='r') plt.grid() if sysVar.boolPlotAverages: tavg = savgol_filter(ent_array[:, 1], fwidth, ford) plt.plot(step_array, tavg, linewidth=avgsize, linestyle=avgstyle, color='black') plt.xlabel(r'$J\,t$') plt.ylabel('Subsystem entropy') plt.tight_layout() pp.savefig() plt.clf() print('.', end='', flush=True) ''' ###FFT print('') fourier = np.fft.rfft(ent_array[loavgind:,1]) print(fourier[0].real) freq = np.fft.rfftfreq(np.shape(ent_array[loavgind:,1])[-1], d=step_array[1]) plt.plot(freq[1:],np.abs(fourier[1:])) print('') plt.ylabel(r'$A_{\omega}$') plt.xlabel(r'$\omega$') plt.grid() plt.tight_layout() ### pp.savefig() plt.clf() print('.',end='',flush=True) ''' def single_level_occ(): return 0 ### Single-level occupation numbers for i in range(0, sysVar.m): plt.plot(step_array, occ_array[:, i + 1], label=r'$n_' + str(i) + '$', linewidth=0.5) if sysVar.boolPlotAverages: tavg = savgol_filter(occ_array[:, i + 1], fwidth, ford) plt.plot(step_array, tavg, linewidth=avgsize, linestyle=avgstyle, color='black') if sysVar.boolPlotDiagExp: plt.axhline(y=microexp[i, 1], color='purple', linewidth=expectsize, linestyle=expectstyle) plt.ylabel(r'Occupation number') plt.xlabel(r'$J\,t$') plt.legend(loc='upper right') plt.grid() plt.tight_layout() ### pp.savefig() plt.clf() print('.', end='', flush=True) ''' ###FFT print('') for i in range(0,sysVar.m): plt.xlim(xmax=30) #GK = -i(2n-1) fourier = (rfft(occ_array[loavgind:,i+1],norm='ortho'))*2 -1 print(fourier[0].real) freq = rfftfreq(np.shape(occ_array[loavgind:,i+1])[-1], d=step_array[1]) plt.plot(freq,fourier.real,linewidth = 0.05) plt.plot(freq,fourier.imag,linewidth = 0.05) plt.ylabel(r'$G^K_{\omega}$') plt.xlabel(r'$\omega$') plt.grid() plt.tight_layout() ### pp.savefig() plt.clf() print('.',end='',flush=True) ''' def bath_occ(): return 0 ### Traced out (bath) occupation numbers for i in sysVar.kRed: plt.plot(step_array, occ_array[:, i + 1], label=r'$n_' + str(i) + '$', linewidth=0.6) if sysVar.boolPlotDiagExp: plt.axhline(y=microexp[i, 1], color='purple', linewidth=expectsize, linestyle=expectstyle) if sysVar.boolPlotAverages: tavg = savgol_filter(occ_array[:, i + 1], fwidth, ford) plt.plot(step_array, tavg, linewidth=avgsize, linestyle=avgstyle, color='black') plt.ylabel(r'Occupation number') plt.xlabel(r'$J\,t$') plt.legend(loc='lower right') plt.grid() plt.tight_layout() ### pp.savefig() plt.clf() print('.', end='', flush=True) def system_occ(): return 0 ### Leftover (system) occupation numbers for i in np.arange(sysVar.m)[sysVar.mask]: plt.plot(step_array, occ_array[:, i + 1], label=r'$n_' + str(i) + '$', linewidth=0.6) if sysVar.boolPlotDiagExp: plt.axhline(y=microexp[i, 1], color='purple', linewidth=expectsize, linestyle=expectstyle) if sysVar.boolPlotAverages: tavg = savgol_filter(occ_array[:, i + 1], fwidth, ford) plt.plot(step_array, tavg, linewidth=avgsize, linestyle=avgstyle, color='black') plt.ylabel(r'Occupation number') plt.xlabel(r'$J\,t$') plt.legend(loc='lower right') plt.grid() plt.tight_layout() ### pp.savefig() plt.clf() print('.', end='', flush=True) def subsystem_occupation(): return 0 ### Subsystems occupation numbers #store fluctuations in a data fldat = open('./data/fluctuation.txt', 'w') fldat.write('N_tot: %i\n' % (sysVar.N)) tmp = np.zeros(len(step_array)) for i in sysVar.kRed: tmp += occ_array[:, i + 1] plt.plot(step_array, tmp, label="bath", linewidth=0.8, color='magenta') if sysVar.boolPlotAverages: tavg = savgol_filter(tmp, fwidth, ford) plt.plot(step_array, tavg, linewidth=avgsize, linestyle=avgstyle, color='black') if sysVar.boolPlotDiagExp: mictmp = 0 for i in sysVar.kRed: mictmp += microexp[i, 1] plt.axhline(y=mictmp, color='purple', linewidth=expectsize, linestyle=expectstyle) avg = np.mean(tmp[loavgind:], dtype=np.float64) stddev = np.std(tmp[loavgind:], dtype=np.float64) fldat.write('bath_average: %.16e\n' % avg) fldat.write('bath_stddev: %.16e\n' % stddev) fldat.write('bath_rel._fluctuation: %.16e\n' % (stddev / avg)) tmp.fill(0) for i in np.arange(sysVar.m)[sysVar.mask]: tmp += occ_array[:, i + 1] plt.plot(step_array, tmp, label="system", linewidth=0.8, color='darkgreen') if sysVar.boolPlotAverages: tavg = savgol_filter(tmp, fwidth, ford) plt.plot(step_array, tavg, linewidth=avgsize, linestyle=avgstyle, color='black') if sysVar.boolPlotDiagExp: mictmp = 0 for i in np.arange(sysVar.m)[sysVar.mask]: mictmp += microexp[i, 1] plt.axhline(y=mictmp, color='purple', linewidth=expectsize, linestyle=expectstyle) avg = np.mean(tmp[loavgind:], dtype=np.float64) stddev = np.std(tmp[loavgind:], dtype=np.float64) fldat.write('system_average: %.16e\n' % avg) fldat.write('system_stddev: %.16e\n' % stddev) fldat.write('system_rel._fluctuation: %.16e\n' % (stddev / avg)) for i in range(sysVar.m): avg = np.mean(occ_array[loavgind:, i + 1], dtype=np.float64) stddev = np.std(occ_array[loavgind:, i + 1], dtype=np.float64) fldat.write('n%i_average: %.16e\n' % (i, avg)) fldat.write('n%i_stddev: %.16e\n' % (i, stddev)) fldat.write('n%i_rel._fluctuation: %.16e\n' % (i, (stddev / avg))) avg = np.mean(ent_array[loavgind:, 1], dtype=np.float64) stddev = np.std(ent_array[loavgind:, 1], dtype=np.float64) fldat.write('ssentropy_average: %.16e\n' % avg) fldat.write('ssentropy_stddev: %.16e\n' % stddev) fldat.write('ssentropy_rel._fluctuation: %.16e\n' % (stddev / avg)) fldat.close() plt.ylabel(r'Occupation number') plt.xlabel(r'$J\,t$') plt.legend(loc='center right') plt.grid() plt.tight_layout() ### pp.savefig() plt.clf() print('.', end='', flush=True) def occ_distribution(): return 0 #occupation number in levels against level index occavg = np.loadtxt('./data/fluctuation.txt', usecols=(1, )) plt.xlim(-0.1, sysVar.m - 0.9) for l in range(0, sysVar.m): plt.errorbar(l, occavg[int(7 + 3 * l)] / sysVar.N, xerr=None, yerr=occavg[int(8 + 3 * l)] / sysVar.N, marker='o', color=cm.Set1(0)) plt.ylabel(r'Relative level occupation') plt.xlabel(r'Level index') plt.grid() plt.tight_layout() ### pp.savefig() plt.clf() print('.', end='', flush=True) def sum_offdiagonals(): return 0 #sum of off diagonal elements in energy eigenbasis if sysVar.boolPlotOffDiag: for i in range(0, sysVar.m): plt.plot(step_array, offdiag[:, i + 1], label=r'$n_' + str(i) + '$', linewidth=0.5) plt.ylabel(r'Sum of off diagonals') plt.xlabel(r'$J\,t$') plt.legend(loc='upper right') plt.grid() plt.tight_layout() ### pp.savefig() plt.clf() dt = offdiag[1, 0] - offdiag[0, 0] nrm = offdiag[:, 0] / dt nrm[1:] = 1 / nrm[1:] for i in range(0, sysVar.m): ###### only sum (subsystem-thermalization) plt.ylabel('Sum of off diagonals in $n^{%i}$' % (i)) # start at 10% of the whole x-axis lox = (offdiag[-1, 0] - offdiag[0, 0]) / 10 + offdiag[0, 0] hiy = offdiag[int(len(offdiag[:, 0]) / 10), 0] * 1.1 plt.plot(offdiag[:, 0], offdiag[:, i + 1], linewidth=0.5) plt.xlim(xmin=lox) plt.ylim(ymax=hiy) plt.grid() plt.tight_layout() ###inlay with the whole deal a = plt.axes([0.62, 0.6, 0.28, 0.28]) a.plot(offdiag[:, 0], offdiag[:, i + 1], linewidth=0.8) a.set_xticks([]) a.set_yticks([]) ### pp.savefig() plt.clf() plt.ylabel('Sum of off diagonals in $n^{%i}$' % (i)) plt.semilogy(offdiag[:, 0], np.abs(offdiag[:, i + 1]), linewidth=0.5) plt.xlim(xmin=lox) plt.ylim(ymin=1e-2) plt.grid() plt.tight_layout() ###inlay with the whole deal a = plt.axes([0.62, 0.6, 0.28, 0.28]) a.semilogy(offdiag[:, 0], offdiag[:, i + 1], linewidth=0.8) a.set_ylim(ymin=1e-2) a.set_xticks([]) a.set_yticks([]) ### pp.savefig() plt.clf() ###### average (eigenstate-thermalization) f, (ax1, ax2) = plt.subplots(2, sharex=False, sharey=False) tmp = cumtrapz(offdiag[:, i + 1], offdiag[:, 0], initial=offdiag[0, i + 1]) tmp = np.multiply(tmp, nrm) f.text(0.03, 0.5, 'Average of summed off diagonals in $n^{%i}$' % (i), ha='center', va='center', rotation='vertical') ax1.ticklabel_format(style='sci', axis='y', scilimits=(0, 0)) ax1.plot(offdiag[:, 0], tmp, linewidth=0.5) ax1.grid() ax2.loglog(offdiag[:, 0], np.abs(tmp), linewidth=0.5) ax2.set_ylim(bottom=1e-4) ax2.grid() plt.tight_layout() plt.subplots_adjust(left=0.12) ### pp.savefig() plt.clf() print('.', end='', flush=True) def sum_offdiagonalsdens(): return 0 if sysVar.boolPlotOffDiagDens: plt.plot(step_array, offdiagdens[:, 1], linewidth=0.5) plt.ylabel(r'Sum of off diagonals (red. dens. mat.)') plt.xlabel(r'$J\,t$') plt.grid() plt.tight_layout() ### pp.savefig() plt.clf() def total_energy(): return 0 ### Total system energy if sysVar.boolTotalEnergy: plt.title('$E_{tot}, \; E_0$ = %.2e' % en0) plt.plot(en_array[:, 0] * sysVar.plotTimeScale, en_array[:, 1] * 1e10, linewidth=0.6) plt.ylabel(r'$E_{tot} - E_0 / 10^{-10}$') plt.xlabel(r'$J\,t$') plt.grid() plt.tight_layout() ### pp.savefig() plt.clf() print('.', end='', flush=True) def norm_deviation(): return 0 ### Norm deviation plt.plot(step_array, norm_array[:, 1], "ro", ms=0.5) plt.ylabel('norm deviation from 1') plt.xlabel(r'$J\,t$') plt.grid(False) plt.tight_layout() ### pp.savefig() plt.clf() print('.', end='', flush=True) ### plt.title('State Norm multiplied (deviation from 1)') plt.plot(step_array, norm_array[:, 2] - 1, linewidth=0.6, color='r') plt.ylabel('correction factor - 1') plt.xlabel(r'$J\,t$') plt.grid() plt.tight_layout() ### pp.savefig() plt.clf() print('.', end='', flush=True) def eigenvalues(): return 0 ### Hamiltonian eigenvalues (Eigenenergies) if sysVar.boolPlotEngy: linearize = False if linearize: tap = [] lal = -1 for e in engies[:, 1]: if lal == -1: tap.append(e) lal += 1 elif np.abs(e - tap[lal]) > 1: lal += 1 tap.append(e) plt.plot(tap, linestyle='none', marker='o', ms=0.5, color='blue') else: plt.plot(engies[:, 0], engies[:, 1], linestyle='none', marker='o', ms=0.5, color='blue') plt.ylabel(r'E/J') plt.xlabel(r'\#') plt.grid(False) plt.xlim(xmin=-(len(engies[:, 0]) * (2.0 / 100))) plt.tight_layout() ### pp.savefig() plt.clf() print('.', end='', flush=True) def density_of_states(): return 0 ### DOS if sysVar.boolPlotDOS: dos = np.zeros(sysVar.dim) window = 50 iw = window for i in range(iw, sysVar.dim - iw): dos[i] = (window) * 2 / (engies[i + iw, 1] - engies[i - iw, 1]) dos /= (sysVar.dim - iw) print(scint.simps(dos[iw:], engies[iw:, 1])) plt.plot(engies[:, 1], dos, lw=0.005) plt.ylabel(r'DOS') plt.xlabel(r'E') plt.grid(False) plt.tight_layout() ### pp.savefig() plt.clf() print('.', end='', flush=True) def greensfunction(): return 0 ### Greensfunction if sysVar.boolPlotGreen: gd = greendat ''' gd = np.zeros((np.shape(greendat)[0]*2,np.shape(greendat)[1])) gd[int(np.shape(greendat)[0]/2):-int(np.shape(greendat)[0]/2 + np.shape(greendat)[0]%2)] = greendat[:,:].copy() ''' spec = [] discpoints = len(gd[:, 0]) print('') for i in range(0, sysVar.m): plt.title(r'two time Green function of level $%i$' % (i)) ind = 2 * i + 1 plt.plot(greendat[:, 0] * sysVar.plotTimeScale, greendat[:, ind], lw=0.1, color='red', label='real') plt.plot(greendat[:, 0] * sysVar.plotTimeScale, greendat[:, ind + 1], lw=0.1, color='blue', label='imaginary') #plt.xlim(xmax=10) plt.ylabel(r'$G^R(\tau)$') plt.xlabel(r'$J\,\tau$') plt.legend(loc='lower right') plt.grid() plt.tight_layout() ### pp.savefig() plt.clf() ### plt.title(r'Spectral function of level $%i$' % (i)) green_ret = gd[:, ind] + 1j * gd[:, ind + 1] green_ret_freq = fft(np.hanning(len(green_ret)) * green_ret, norm='ortho') spec_tmp = np.abs(-2 * fftshift(green_ret_freq.imag))[::-1] if i == 0: samp_spacing = sysVar.deltaT * ( sysVar.steps / sysVar.dataPoints) * sysVar.plotTimeScale hlpfrq = fftshift(fftfreq( len(spec_tmp))) * (2 * np.pi) / samp_spacing ### !!! normalize by hand! this might be strange but is necessary here spec_tmp /= (np.trapz(spec_tmp, x=hlpfrq) / (2 * np.pi)) if i == 0: spec_total = spec_tmp[:] # scale on x-axis is frequency else: spec_total += spec_tmp spec.append(spec_tmp) print(i, np.trapz(spec_tmp, x=hlpfrq) / (2 * np.pi)) #exit() plt.plot(hlpfrq, spec_tmp, color='red', lw=0.1) plt.minorticks_on() plt.ylabel(r'$A$') plt.xlabel(r'$\omega / J$') plt.grid() plt.grid(which='minor', color='blue', linestyle='dotted', lw=0.2) plt.tight_layout() ### pp.savefig() plt.clf() plt.title(r'Spectral function') plt.plot(hlpfrq, spec_total, color='red', lw=0.1) plt.ylabel(r'$A$') plt.xlabel(r'$\omega / J$') #plt.xlim([-100,100]) plt.grid() plt.tight_layout() ### pp.savefig() plt.clf() plt.plot(hlpfrq, np.abs(spec_total), color='red', lw=0.1) plt.ylabel(r'$|A|$') plt.xlabel(r'$\omega / J$') #plt.xlim([-100,100]) plt.grid() plt.tight_layout() ### pp.savefig() plt.clf() print('.', end='', flush=True) print() weights = np.zeros(len(spec)) for s in range(0, len(spec)): print(np.average(hlpfrq, weights=spec[s]), np.average(hlpfrq, weights=np.abs(spec[s]))) weights[s] = np.abs(np.average(hlpfrq, weights=np.abs(spec[s]))) print('') ''' # the integrated version def occno(spec,freq,temp,mu): rt = [] for i in range(0,len(freq)): rt.append(spec[i]/(np.exp((freq[i]-mu)/temp)-1.0)) return np.trapz(np.array(rt), x=freq) ''' # the averaged version def occno(freq, temp, mu): return (1 / (np.exp((freq - mu) / temp) - 1.0)) def bestatd(args): temp = args[0] mu = args[1] ret = [] for i in range(0, sysVar.m): ret.append( occno(weights[i], temp, mu) - occavg[int(7 + 3 * i)]) return np.array(ret) def bestat(args): temp = args[0] mu = args[1] ret = [] for i in range(0, sysVar.m): ret.append(occno(weights[i], temp, mu)) return np.array(ret) strt = np.array([10, -0.1]) bnds = np.array([[0.0001, -500], [1000, weights[0]]]) rgs = least_squares(bestatd, x0=strt, bounds=bnds, loss='soft_l1') print(rgs) print(rgs.x) print(bestat(rgs.x)) a = [] for i in range(0, sysVar.m): a.append(occavg[int(7 + 3 * i)]) print(a) #occupation number in levels against renormalized energy plt.title('Bose-Einstein distribution fit') ws = np.sort(weights) lo = ws[0] - ws[0] / 100 hi = ws[-1] + ws[-1] / 100 plt.xlim(lo, hi) xvals = np.linspace(lo, hi, 1e3) yvals = occno(xvals, rgs.x[0], rgs.x[1]) / sysVar.N for l in range(0, sysVar.m): plt.errorbar(weights[l], occavg[int(7 + 3 * l)] / sysVar.N, xerr=None, yerr=occavg[int(8 + 3 * l)] / sysVar.N, marker='o', color=cm.Set1(0)) plt.plot(xvals, yvals, color='blue', lw=0.4) plt.ylabel(r'Relative level occupation') plt.xlabel(r'energy') plt.grid() plt.tight_layout() ### pp.savefig() plt.clf() print('.', end='', flush=True) if sysVar.boolPlotDecomp: def eigendecomposition(): return 0 ### Hamiltonian eigenvalues (Eigenenergies) with decomposition fig, ax1 = plt.subplots() ax1.plot(engies[:, 0], engies[:, 1], linestyle='none', marker='o', ms=0.7, color='blue') ax1.set_ylabel(r'Energy') ax1.set_xlabel(r'\#') ax2 = ax1.twinx() ax2.bar(engies[:, 0], engies[:, 2], alpha=0.8, color='red', width=0.03, align='center') ax2.set_ylabel(r'$|c_n|^2$') plt.grid(False) ax1.set_xlim(xmin=-(len(engies[:, 0]) * (5.0 / 100))) plt.tight_layout() ### pp.savefig() plt.clf() print('.', end='', flush=True) ### Eigenvalue decomposition with energy x-axis plt.bar(engies[:, 1], engies[:, 2], alpha=0.8, color='red', width=0.03, align='center') plt.xlabel(r'Energy') plt.ylabel(r'$|c_n|^2$') plt.grid(False) plt.xlim(xmin=-(np.abs(engies[0, 1] - engies[-1, 1]) * (5.0 / 100))) plt.tight_layout() ### pp.savefig() plt.clf() print('.', end='', flush=True) # omit this in general ''' ### Eigenvalue decomposition en detail n_rows = 3 #abs**2, phase/2pi, energy on a range from 0 to 1 n_rows += 1 #spacer n_rows += sysVar.m #occupation numbers index = np.arange(sysVar.dim) bar_width = 1 plt.xlim(0,sysVar.dim) # Initialize the vertical-offset for the stacked bar chart. y_offset = np.array([0.0] * sysVar.dim) spacing = np.array([1] * sysVar.dim) enInt = np.abs(engies[-1,1] - engies[0,1]) cmapVar = plt.cm.OrRd cmapVar.set_under(color='black') plt.ylim(0,n_rows) #energy plt.bar(index, spacing , bar_width, bottom=y_offset, color=cmapVar((engies[:,1]-engies[0,1])/enInt), linewidth=0.00, edgecolor='gray') y_offset = y_offset + spacing #abs squared plt.bar(index, spacing , bar_width, bottom=y_offset, color=cmapVar(engies[:,2]/np.amax(engies[:,2]) - 1e-16), linewidth=0.00, edgecolor='gray') y_offset = y_offset + spacing #phase / 2pi plt.bar(index, spacing , bar_width, bottom=y_offset, color=cmapVar(engies[:,3] - 1e-16), linewidth=0.00, edgecolor='gray') y_offset = y_offset + spacing plt.bar(index, spacing, bar_width, bottom=y_offset, color='white', linewidth=0) y_offset = y_offset + np.array([1] * sysVar.dim) #expectation values for row in range(4, n_rows): plt.bar(index, spacing , bar_width, bottom=y_offset, color=cmapVar(engies[:,row]/sysVar.N - 1e-16), linewidth=0.00, edgecolor='gray') y_offset = y_offset + spacing plt.ylabel("tba") plt.tight_layout() ### pp.savefig() plt.clf() print('.',end='',flush=True) ### Occupation number basis decomposition en detail n_rows = 2 #abs**2, phase/2pi n_rows += 1 #spacer n_rows += sysVar.m #occupation numbers index = np.arange(sysVar.dim) bar_width = 1 plt.xlim(0,sysVar.dim) # Initialize the vertical-offset for the stacked bar chart. y_offset = np.array([0.0] * sysVar.dim) spacing = np.array([1] * sysVar.dim) cmapVar = plt.cm.OrRd cmapVar.set_under(color='black') plt.ylim(0,n_rows) # abs squared plt.bar(index, spacing , bar_width, bottom=y_offset, color=cmapVar(stfacts[:,1]/np.amax(stfacts[:,1]) - 1e-16), linewidth=0.00, edgecolor='gray') y_offset = y_offset + spacing # phase / 2pi plt.bar(index, spacing , bar_width, bottom=y_offset, color=cmapVar(stfacts[:,2] - 1e-16), linewidth=0.00, edgecolor='gray') y_offset = y_offset + spacing plt.bar(index, spacing, bar_width, bottom=y_offset, color='white', linewidth=0) y_offset = y_offset + np.array([1] * sysVar.dim) for row in range(3, n_rows): plt.bar(index, spacing , bar_width, bottom=y_offset, color=cmapVar(stfacts[:,row]/sysVar.N - 1e-16), linewidth=0.00, edgecolor='gray') y_offset = y_offset + spacing plt.ylabel("tba") plt.tight_layout() ### pp.savefig() plt.clf() print('.',end='',flush=True) ''' def densmat_spectral(): return 0 ####### Density matrix in spectral repesentation if sysVar.boolPlotSpectralDensity: ### plt.title('Density matrix spectral repres. abs') dabs = np.loadtxt('./data/spectral/dm.txt') cmapVar = plt.cm.Reds cmapVar.set_under(color='black') plt.imshow(dabs, cmap=cmapVar, interpolation='none', vmin=1e-16) plt.colorbar() ### pp.savefig() plt.clf() print('.', end='', flush=True) ### pp.close() print(" done!")