def mergeXY(sets, foreach=[]): foreach_sets = {} for iset in pyalps.flatten(sets): fe_par_set = tuple((iset.props[m] for m in foreach)) if fe_par_set in foreach_sets: foreach_sets[fe_par_set].append(iset) else: foreach_sets[fe_par_set] = [iset] for k, v in foreach_sets.items(): common_props = pyalps.dict_intersect([q.props for q in v]) res = pyalps.DataSet() res.props = common_props for im in range(0, len(foreach)): m = foreach[im] res.props[m] = k[im] for data in v: if len(res.x) > 0 and len(res.y) > 0: res.x = np.concatenate((res.x, data.x)) res.y = np.concatenate((res.y, data.y)) else: res.x = data.x res.y = data.y order = np.argsort(res.x, kind='mergesort') res.x = res.x[order] res.y = res.y[order] res.props['label'] = '' for im in range(0, len(foreach)): res.props['label'] += '%s = %s ' % (foreach[im], k[im]) foreach_sets[k] = res return foreach_sets.values()
def __init__(self, sets, x, obs): self.props = pyalps.dict_intersect( [d.props for d in pyalps.flatten(sets)] ) self.props['observable'] = str(obs) self.xname = str(x) self.obsx = [] self.ydata = np.empty((0,0)) self.xdata = np.empty(0) self.bonddims = np.empty(0) self.init_data(sets) self.xdata = np.array(self.xdata) self.ydata = np.array(self.ydata) order = np.argsort(self.xdata) self.bonddims = self.bonddims[order] self.xdata = self.xdata[order] for i in range(len(self.ydata)): self.ydata[i] = self.ydata[i][order]
plotdata = pyalps.collectXY(data, 'T', '|Magnetization|') plt.figure() pyalps.plot.plot(plotdata) plt.xlim(0, 3) plt.ylim(0, 1) plt.title('Ising model') plt.show() # convert the data to text file for plotting using another tool print(pyalps.plot.convertToText(plotdata)) # convert the data to grace file for plotting using xmgrace print(pyalps.plot.makeGracePlot(plotdata)) # convert the data to gnuplot file for plotting using gnuplot print(pyalps.plot.makeGnuplotPlot(plotdata)) #calculate the Binder cumulants using jackknife-analysis binder = pyalps.DataSet() binder.props = pyalps.dict_intersect([d[0].props for d in data]) binder.x = [d[0].props['T'] for d in data] binder.y = [d[1].y[0] / (d[0].y[0] * d[0].y[0]) for d in data] print(binder) # ... and plot them plt.figure() pyalps.plot.plot(binder) plt.xlabel('T') plt.ylabel('Binder cumulant') plt.show()
import numpy as np import matplotlib.pyplot as plt import pyalps.plot ## Please run the tutorial5a.py before this one listobs = ['0', '2'] # we look at convergence of a single flavor (=0) ## load all results data = pyalps.loadDMFTIterations(pyalps.getResultFiles(pattern='parm_u_*.h5'), measurements=listobs, verbose=True) ## create a figure for each BETA grouped = pyalps.groupSets(pyalps.flatten(data), ['U', 'observable']) for sim in grouped: common_props = pyalps.dict_intersect([ d.props for d in sim ]) ## rescale x-axis and set label for d in sim: d.x = d.x * d.props['BETA']/float(d.props['N']) d.y *= -1. d.props['label'] = 'it'+d.props['iteration'] ## plot all iterations for this BETA plt.figure() plt.xlabel(r'$\tau$') plt.ylabel(r'$-G_{flavor=%8s}(\tau)$' % common_props['observable']) plt.title('DMFT-05: Orbitally Selective Mott Transition on the Bethe lattice: ' + r'$U = %.4s$' % common_props['U']) pyalps.plot.plot(sim) plt.legend() plt.yscale("log")
print "Your simulations has not yet ended, please run this command again later." else: if desc.failed(): print "Your submission has failed" sys.exit(-1) result_files = pyalps.getResultFiles(prefix='parm1') print result_files print pyalps.loadObservableList(result_files) data = pyalps.loadMeasurements(result_files,['|Magnetization|','Magnetization^2']) print data plotdata = pyalps.collectXY(data,'T','|Magnetization|') plt.figure() pyalps.plot.plot(plotdata) plt.xlim(0,3) plt.ylim(0,1) plt.title('Ising model') plt.show() print pyalps.plot.convertToText(plotdata) print pyalps.plot.makeGracePlot(plotdata) print pyalps.plot.makeGnuplotPlot(plotdata) binder = pyalps.DataSet() binder.props = pyalps.dict_intersect([d[0].props for d in data]) binder.x = [d[0].props['T'] for d in data] binder.y = [d[1].y[0]/(d[0].y[0]*d[0].y[0]) for d in data] print binder plt.figure() pyalps.plot.plot(binder) plt.xlabel('T') plt.ylabel('Binder cumulant') plt.show()
data = pyalps.loadEigenstateMeasurements(pyalps.getResultFiles(prefix=prefix)) # join all momenta grouped = pyalps.groupSets(pyalps.flatten(data), ['J1', 'L', 'Sz_total']) nd = [] for group in grouped: ally = [] allx = [] for q in group: ally += list(q.y) allx += list(q.x) r = pyalps.DataSet() sel = np.argsort(ally) r.y = np.array(ally)[sel] r.x = np.array(allx)[sel] r.props = pyalps.dict_intersect([q.props for q in group]) nd.append( r ) data = nd # remove states in the s=1 sector from the s=0 sector grouped = pyalps.groupSets(pyalps.flatten(data), ['J1', 'L']) nd = [] for group in grouped: if group[0].props['Sz_total'] == 0: s0 = group[0] s1 = group[1] else: s0 = group[1] s1 = group[0] s0 = pyalps.subtract_spectrum(s0, s1) nd.append(s0)
#print the observables stored in those files: print("The files contain the following mesurements:", end=' ') print(pyalps.loadObservableList(result_files)) #load a selection of measurements: data = pyalps.loadMeasurements(result_files, ['|Magnetization|', 'Magnetization^2']) obschoose = lambda d, o: np.array(d)[np.nonzero( [xx.props['observable'] == o for xx in d])] binder = [] for dd in data: magn2 = obschoose(dd, 'Magnetization^2')[0] magnabs = obschoose(dd, '|Magnetization|')[0] res = pyalps.DataSet() res.props = pyalps.dict_intersect([d.props for d in dd]) res.x = np.array([magnabs.props['T']]) res.y = np.array([magn2.y[0] / (magnabs.y[0] * magnabs.y[0])]) res.props['observable'] = 'Binder cumulant' binder.append(res) binder = pyalps.collectXY(binder, 'T', 'Binder cumulant') # ... and plot them plt.figure() pyalps.plot.plot(binder) plt.xlabel('T') plt.ylabel('Binder cumulant') plt.show()