def read_results_from_file(path, prefix, X, Y, ForEach=None):
    """
    Input
    ------------------
    path:  path to result files
    prefix: prefix filenames (ending out.h5), if ending with a dot (.), only one simulation is assumed
                            else the separate simulation are identified and merged.
    X : string, name of parameter
    Y : string, name of observable

    returns
    -----------------
    pyalps X-Y-props list
    """

    if prefix[-1]=='.':
        dataset= pyalps.loadMeasurements(pyalps.getResultFiles(dirname=path,prefix=prefix),Y)

        if ForEach==None:
            return pyalps.collectXY(dataset, x=X, y=Y)
        else:
            return pyalps.collectXY(dataset, x=X, y=Y, foreach=[ForEach])

    else:
        raise ValueError("Not yet implemented for multiple runs.")
Esempio n. 2
0
def load_iterations_observable(fname, observable, remove_equal_indexes=False):
    if not os.path.exists(fname):
        raise IOError('Archive `%s` not found.' % fname)
    if remove_equal_indexes:
        print 'WARNING:', 'removing index not implemented for iterations meas.'
    data = pydmrg.LoadDMRGSweeps([fname], [observable])
    obs = pyalps.collectXY(data, 'sweep', observable)
    obs = pyalps.flatten(obs)
    if len(obs) == 0:
        raise ObservableNotFound(fname, observable)
    return obs[0]
def ReadResults(path, prefix, X, Y):
    """
    Input
    ------------------
    path:  path to result files
    prefix: prefix filenames (ending out.h5), if ending with a dot (.), only one simulation is assumed
                            else the separate simulation are identified and merged.
    X : string, name of parameter
    Y : string, name of observable

    returns
    -----------------
    pyalps X-Y-props list
    """

    if prefix[-1]=='.':
        dataset= pyalps.loadMeasurements(pyalps.getResultFiles(dirname=path,prefix=filename),args.Y)

        return pyalps.collectXY(dataset, x=X, y=Y, foreach=['IncNo'])
    else:
        all_prefixes=[]
        for f in os.listdir(path):
            if fnmatch.fnmatch(f, prefix+'*.out.h5'):
                before_first_dot=f.split('.')[0]+'.'
                if before_first_dot not in all_prefixes:
                    all_prefixes.append(before_first_dot)
        datasetsXY = []
        for pre in all_prefixes:
            tmp_dset= pyalps.loadMeasurements(pyalps.getResultFiles(dirname=path,prefix=pre),args.Y)
            datasetsXY.append( pyalps.collectXY(tmp_dset, x=X, y=Y, foreach=['IncNo']) )

        for i,dxy in enumerate(datasetsXY[0]):   #Take the 1st dataset as reference
            rIncNo = dxy.props['IncNo']
            for dslist in datasetsXY[1:]:
                for dxy2nd in dslist:
                    if rIncNo == dxy2nd.props['IncNo']:
                        datasetsXY[0][i] = pyalps.mergeDataSets([datasetsXY[0][i], dxy2nd])   

        return datasetsXY[0]
Esempio n. 4
0
def extract(data, xname, names, foreach, fe_types):
  if np.isscalar(foreach):
    foreach = [foreach]
  if np.isscalar(fe_types):
    fe_types = [fetypes]
  for name in names:
    for obs in pyalps.collectXY(data, xname, name, foreach=foreach):
      vals = [ typ(obs.props[sym]) for sym, typ in zip(foreach, fe_types) ]
      filename = names[name]
      for sym, val in zip(foreach, vals):
        filename += '-{}{}'.format(sym,val)
      filename += '.dat'
      with open(filename, 'w') as f:
        f.write(plot.convertToText([obs]).replace(' +/- ', ' '))
Esempio n. 5
0
    def compute(self):
        if self.hasInputFromPort('y') \
        and self.hasInputFromPort('x') \
        and self.hasInputFromPort('input'):
            # find all possible values for each for-each
            sets = self.getInputFromPort('input')
            observable = self.getInputFromPort('y')
            versus = self.getInputFromPort('x')

            for_each = []
            if self.hasInputFromPort('for-each'):
                for_each = self.getInputFromPort('for-each')

            self.setResult(
                'output', pyalps.collectXY(sets, versus, observable, for_each))

        else:
            raise EmptyInputPort('for-each || observable')
parser.add_argument('--foreach','-f',default='h',help='Parameter name, (default h)')
parser.add_argument('--steps','-s',nargs=2,type=int,help='Number of increment steps to complete U and O, (default=1/2 1)')
parser.add_argument('--plot','-p',action='store_true')
parser.add_argument('--verbose','-v',action='store_true')
args=parser.parse_args()

REntropy={}


data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix=args.infile),['EG'])


if args.verbose:
    print data

renyi_dataG = pyalps.collectXY(data, x='IncNo', y='EG', foreach=[args.foreach])

if args.verbose:
    print renyi_dataG

if (args.steps!=None):
    IncNosIItoU=range(args.steps[0])
    IncNosUtoO=range(args.steps[0],args.steps[1])
    #IncNos = [%.1f % i for i in range(args.IncNoRange[0], args.IncNoRange[1])]
    print IncNosIItoU, IncNosUtoO
else:
    totIncNos=len(renyi_dataG[0].x)
    IncNosIItoU=range(totIncNos/2)
    IncNosUtoO=range(totIncNos/2,totIncNos)

X,Y1,Yerr1=renyi_sse_add(renyi_dataG, for_each=str(args.foreach),inc_name='IncNo',inc_range=IncNosIItoU)
Esempio n. 7
0
]:
    parms.append({
        'LATTICE': "ladder",
        'T': t,
        'J0': -1,
        'J1': -1,
        'THERMALIZATION': 10000,
        'SWEEPS': 500000,
        'UPDATE': "cluster",
        'MODEL': "Heisenberg",
        'L': 60
    })

#write the input file and run the simulation
input_file = pyalps.writeInputFiles('parm2b', parms)
pyalps.runApplication('spinmc', input_file, Tmin=5)

#load the susceptibility and collect it as function of temperature T
data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm2b'),
                               'Susceptibility')
susceptibility = pyalps.collectXY(data, x='T', y='Susceptibility')

#make plot
plt.figure()
pyalps.plot.plot(susceptibility)
plt.xlabel('Temperature $T/J$')
plt.ylabel('Susceptibility $\chi J$')
plt.ylim(0, 0.22)
plt.title('Heisenberg ladder')
plt.show()
Esempio n. 8
0
right_end=1-left_start
bottom_start=0.3
top_end=1
boarder_width=0.1
width=0.5-boarder_width
height=0.35-boarder_width

fig = plt.subplots()
plt.subplots_adjust(left=left_start, bottom=bottom_start, right = left_start+width, top=bottom_start+height)
#axM= plt.axes([left_start, bottom_start,width,height])
axM=plt.gca()
axChi = plt.axes([left_start, bottom_start+height+boarder_width,width,height])
axBinder = plt.axes([left_start+width+boarder_width, bottom_start,width,height])
axCv = plt.axes([left_start+width+boarder_width,  bottom_start+height+boarder_width, width,height]) 
plt.sca(axChi)
chi = pyalps.collectXY(data,x='T',y='susceptibility',foreach=['L'])
for d in chi:
    d.props['label']='L='+str(d.props['L'])
    d.x -= Tc0
    d.x = d.x/Tc0
    l = d.props['L']
    d.x = d.x * pow(float(l),1/nu0)
    d.y = d.y * pow(float(l),-gamma0/nu0)
pyalps.plot.plot(chi)
plt.xlabel(r'$(T-T_c)L^{\frac{1}{\nu}}$', fontsize='x-large')
plt.ylabel(r'$\chi L^{\frac{-\gamma}{\nu}}$', fontsize='x-large')
plt.title(r'$\chi$', fontsize='x-large')
binder = pyalps.collectXY(data,x='T',y='BinderCumulant',foreach=['L'])
plt.sca(axBinder)
for d in binder:
    d.props['label']='L='+str(d.props['L'])
Esempio n. 9
0
    L = pyalps.flatten(Lsets)[0].props['L']
    # Make a big list of all energy values
    allE = []
    for q in pyalps.flatten(Lsets):
        allE += list(q.y)
    allE = np.sort(allE)
    E0[L] = allE[0]
    E1[L] = allE[1]

# Subtract E0, divide by gap, multiply by 1/8, which we know
# to be the smallest non-vanishing scaling dimension of the Ising CFT
for q in pyalps.flatten(data):
    L = q.props['L']
    q.y = (q.y - E0[L]) / (E1[L] - E0[L]) * (1. / 8.)

spectrum = pyalps.collectXY(data, 'TOTAL_MOMENTUM', 'Energy', foreach=['L'])

# Plot the first few exactly known scaling dimensions
for SD in [0.125, 1, 1 + 0.125, 2]:
    d = pyalps.DataSet()
    d.x = np.array([0, 4])
    d.y = SD + 0 * d.x
    # d.props['label'] = str(SD)
    spectrum += [d]

pyalps.plot.plot(spectrum)

plt.legend(prop={'size': 8})
plt.xlabel("$k$")
plt.ylabel("$E_0$")
Esempio n. 10
0
File: plot.py Progetto: hotta1/LRI
name.append(['Specific Heat by FT','specheatft'])
name.append(['Magnetic Susceptibility connected','magsuscon'])
name.append(['Magnetic Susceptibility connected for Scaling','magsusconsca'])
name.append(['Magnetic Susceptibility disconnected','magsusdis'])
name.append(['Magnetic Susceptibility disconnected for Scaling','magsusdissca'])
name.append(['Binder Ratio of Magnetization connected','bindercon'])
name.append(['Binder Ratio of Magnetization disconnected','binderdis'])
name.append(['Binder Ratio of Magnetization 1 connected','binder1con'])
name.append(['Binder Ratio of Magnetization 1 disconnected','binder1dis'])
name.append(['Specific Heat connected','specheatcon'])

for i in range(0,len(name)):
  data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='LRSW_params'),name[i][0])
  for item in pyalps.flatten(data):
    item.props['L'] = int(item.props['L'])
  graph = pyalps.collectXY(data,x='T',y=name[i][0],foreach=['L'])
  graph.sort(key=lambda item: item.props['L'])
  f1 = open(name[i][1]+'.plt','w')
  f1.write(pyalps.plot.makeGnuplotPlot(graph))
  f1.close()
  f2 = open(name[i][1]+'.dat','w')
  for j in graph:
    L=j.props['L']
    for k in range(0,len(j.x)):
      f2.write(str(L)+' '+str(j.x[k])+' '+str(j.y[k].mean)+' '+str(j.y[k].error)+'\n')
  f2.close()
  print 'finished to output ' + name[i][1] + '.plt and ' + name[i][1] + '.dat'


"""
for i in range(0,len(name)):
Esempio n. 11
0
input_file = pyalps.writeInputFiles(basename, parms)
res = pyalps.runApplication('mps_evolve', input_file)


## simulation results
data = pyalps.loadIterationMeasurements(pyalps.getResultFiles(prefix=basename), what=['Local Magnetization'])

numeric_magnetization = []
for d in pyalps.flatten(data):
    L = d.props['L']
    for loc in [1,2]:
        q = deepcopy(d)
        q.x = [0]
        q.y = np.array([ q.y[0][L/2-loc] ])
        q.props['loc'] = loc
        numeric_magnetization.append(q)

mag_vs_time = pyalps.collectXY(numeric_magnetization, x='Time', y='Local Magnetization', foreach=['loc'])
for d in mag_vs_time:
    d.x = (d.x + 1.) * d.props['dt'] # convert time index to real time
    d.props['label'] = 'Numerical at n='+str(d.props['loc'])

plt.figure()
pyalps.plot.plot(mag_vs_time)
plt.xlabel('Time $t$')
plt.ylabel('Magnetization')
plt.title('Magnetization vs. time')
plt.legend(loc='best')

plt.show()
end = datetime.datetime.now()

## simulation results
# data = pyalps.loadIterationMeasurements(pyalps.getResultFiles(prefix=basename+'.dynamic'), what=['Overlap', 'Local density', 'Local density squared', 'One body density matrix', 'Density density'])
data = pyalps.loadIterationMeasurements(pyalps.getResultFiles(prefix=basename+'.dynamic'), what=['Overlap', 'Energy'])

coords = []
for d1 in data:
    for s1 in d1:
        for d in s1:
            for s in d:
                if(s.props['observable'] == 'One body density matrix'):
                    coords = (s.x[:,0], s.x[:,1])

XY = pyalps.collectXY(data, x='Time', y='Overlap', foreach=['tau'])
p = [[[(x + 1)*dt, 1-abs(y**2)] for (x, y) in zip(xy.x, xy.y)] for xy in XY]

XY = pyalps.collectXY(data, x='Time', y='Energy', foreach=['tau'])
E = [[[(x + 1)*dt, y] for (x, y) in zip(xy.x, xy.y)] for xy in XY]

XY = pyalps.collectXY(data, x='Time', y='Local density', foreach=['tau'])
n = [[[(x + 1)*dt, y] for (x, y) in zip(xy.x, xy.y)] for xy in XY]

XY = pyalps.collectXY(data, x='Time', y='Local density squared', foreach=['tau'])
n2 = [[[(x + 1)*dt, y] for (x, y) in zip(xy.x, xy.y)] for xy in XY]

XY = pyalps.collectXY(data, x='Time', y='One body density matrix', foreach=['tau'])
corr = [[[(x + 1)*dt, sparse.coo_matrix((y, coords)).toarray()] for (x, y) in zip(xy.x, xy.y)] for xy in XY]

XY = pyalps.collectXY(data, x='Time', y='Density density', foreach=['tau'])
Esempio n. 13
0
File: plot.py Progetto: DropD/CQP
import sys, os

import numpy as np
import matplotlib.pyplot as plt
import pyalps
from pyalps.plot import plot

files = pyalps.getResultFiles(dirname='data')
data = pyalps.loadMeasurements(files , ['|m|','m^2', 'Connected Susceptibility', 'Binder Cumulant U2'])

for d in pyalps.flatten(data):
    d.props['M/L'] = d.props['M'] / d.props['L']

m = pyalps.collectXY(data, 'Jx', '|m|', foreach=['L', 'M'])
chi = pyalps.collectXY(data, 'Jx', 'Connected Susceptibility', foreach=['L', 'M'])
binder = pyalps.collectXY(data, 'Jx', 'Binder Cumulant U2', foreach=['L', 'M'])


for d in pyalps.flatten(m):
    d.x = np.exp(2.*d.props['Jy'])*d.x
plt.figure()
plot(m)
plt.xlabel('$J/\\Gamma$')
plt.ylabel('magnetization')
plt.legend(loc='best', frameon=False)


for d in pyalps.flatten(chi):
    d.x = np.exp(2.*d.props['Jy'])*d.x
plt.figure()
plot(chi)
Esempio n. 14
0
                -(1.0 / 3.1415926) *
                math.asin(min(scalingCopy[0].props['Time'], 1.0))
            ]
            scalingCopy[0].props['SIMID'] = 'Exact'

        #The other distances contain the numerical data as a function of the scaling variable M(n/t)
        else:
            scalingCopy[0].props['Time'] = n / scalingCopy[0].props['Time']
            scalingCopy[0].y = [scalingCopy[0].y[syssize / 2 + n - 1]]
            scalingCopy[0].props['SIMID'] = 'Numerical at n=' + str(n)
        #add to the scaling dataset
        scalingForm.extend(scalingCopy)

#Plot the numerical and exact magnetization for comparison
exactMag = pyalps.collectXY(exactResult,
                            x='Time',
                            y='Local Magnetization',
                            foreach=['SIMID'])
for q in exactMag:
    q.props['label'] = q.props['SIMID']
numericalMag = pyalps.collectXY(numericalResult,
                                x='Time',
                                y='Local Magnetization',
                                foreach=['SIMID'])
for q in numericalMag:
    q.props['label'] = q.props['SIMID']

plt.figure()
pyalps.plot.plot([exactMag, numericalMag])
plt.xlabel('Time $t$')
plt.ylabel('Magnetization')
plt.legend(loc='lower right')
Esempio n. 15
0
    
    d = pyalps.DataSet()
    d.props = pyalps.dict_intersect([q.props for q in group])
    d.x = np.array([0])
    d.y = np.array([allE[0]])
    d.props['which'] = 'gs'
    d.props['line'] = '.-'
    sector_E.append(d)
    
    d2 = copy.deepcopy(d)
    d2.y = np.array([allE[1]])
    d2.props['which'] = 'fe'
    d2.props['line'] = '.-'
    sector_E.append(d2)

sector_energies = pyalps.collectXY(sector_E, 'J1', 'Energy', ['Sz_total', 'which', 'L'])
plt.figure()
pyalps.plot.plot(sector_energies)
plt.xlabel('$J_1/J$')
plt.ylabel('$E_0$')
plt.legend(prop={'size':8})

# for each value of J1, L, we need to calculate the singlet and triplet gap:
# singlet: gap from abs. g.s. to first excited in S=0 sector
# triplet: gap from abs. g.s. to lowest in S=1 sector
grouped = pyalps.groupSets( pyalps.groupSets(pyalps.flatten(data), ['J1', 'L']), ['Sz_total'])

gaps = []
for J1g in grouped:
    totalmin = 1000
    for q in flatten(J1g):
Esempio n. 16
0
    p['measure_each'] = 10
    p['update_each'] = 1
    p['COMPLEX'] = 1

    parms.append(p)

## write input files and run application
input_file = pyalps.writeInputFiles(basename + '.dynamic', parms)
res = pyalps.runApplication('mps_evolve', input_file)

## simulation results
data = pyalps.loadIterationMeasurements(pyalps.getResultFiles(prefix=basename +
                                                              '.dynamic'),
                                        what=['Overlap'])

LE = pyalps.collectXY(data, x='Time', y='Overlap', foreach=['tau'])
for d in pyalps.flatten(LE):
    d.x = (d.x + 1.) * d.props['dt']  # convert time index to real time
    d.y = abs(
        d.y)**2  # Loschmidt Echo defined as the module squared of the overlap
    d.props['label'] = r'$\tau={0}$'.format(d.props['tau'])

plt.figure()
pyalps.plot.plot(LE)
plt.xlabel('Time $t$')
plt.ylabel('Loschmidt Echo $|< \psi(0)|\psi(t) > |^2$')
plt.title('Loschmidt Echo vs. Time')
plt.legend(loc='lower right')

## Read V[Time] from props
Ufig = pyalps.collectXY(data, x='Time', y='V', foreach=['tau'])
Esempio n. 17
0
input_file = pyalps.writeInputFiles('parm_spin_one', parms)
res = pyalps.runApplication('mps_optim', input_file, writexml=True)

#load all measurements for all states
data = pyalps.loadEigenstateMeasurements(
    pyalps.getResultFiles(prefix='parm_spin_one'))

# print properties of the eigenvector:
for s in data[0]:
    print(s.props['observable'], ' : ', s.y[0])

# load and plot iteration history
iterations = pyalps.loadIterationMeasurements(
    pyalps.getResultFiles(prefix='parm_spin_one'),
    what=['Energy', 'TruncatedWeight'])
energy_iteration = pyalps.collectXY(pyalps.flatten(iterations), 'iteration',
                                    'Energy')
for d in energy_iteration:
    d.x = range(0, len(d.y))
truncation_iteration = pyalps.collectXY(pyalps.flatten(iterations),
                                        'iteration', 'TruncatedWeight')
for d in truncation_iteration:
    d.x = range(0, len(d.y))

plt.figure()
pyalps.plot.plot(energy_iteration)
plt.title('Iteration history of ground state energy (S=1)')
plt.ylabel('$E_0$')
plt.xlabel('iteration')

plt.figure()
pyalps.plot.plot(truncation_iteration)
Esempio n. 18
0
    pass

basename = 'SingleSite/ss.'

parms['N_total'] = 14
# parms['initial_local_N'] = '3,2,2,2,2,2,2,2,2,2'#'1,1,1,1,1,1,1,1,0,0'#'2,2,1,1,1,1,1,1,1,1'
input_file = pyalps.writeInputFiles(basename + str(resi), [parms])
pyalps.runApplication('mps_optim', input_file, writexml=True)

#load all measurements for all states
data = pyalps.loadEigenstateMeasurements(pyalps.getResultFiles(prefix=basename))

for d in data:
    for s in d:
        if(s.props['observable'] == 'Energy'):
            print s.y[0]
        if(s.props['observable'] == 'Local density'):
            print s.y[0]

iters = pyalps.loadIterationMeasurements(pyalps.getResultFiles(prefix=basename), what=['Energy'])
# print iters
en_vs_iter = pyalps.collectXY(iters, x='iteration', y='Energy')
# print en_vs_iter
Es = np.array([Ei for (i, Ei) in sorted(zip([int(xi) for xi in en_vs_iter[0].x[0:-1:20]], en_vs_iter[0].y[0:-1:20]))[-40:-1]])
Es2 = Es[1:-1] - Es[0:-2]
print Es2
plt.figure()
# pyalps.plot.plot(en_vs_iter)
plt.plot(Es)
# plt.yscale('log')
plt.show()
Esempio n. 19
0
import pyalps

fileheader = 'heisenberg'
data = pyalps.loadEigenstateMeasurements(pyalps.getResultFiles(prefix=fileheader),'Energy')

#print data,len(data)

J_En = pyalps.collectXY(data, x='J', y='Energy')
print data 

for x, y in zip(J_En[0].x, J_En[0].y):
    print x, y 
Esempio n. 20
0
#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()
Esempio n. 21
0
#Get magnetization data
Magdata=pyalps.load.loadTimeEvolution( pyalps.getResultFiles(prefix='tutorial_2b'), measurements=['Local Magnetization'])

#Postprocessing-get the exact result for comparison
for q in Magdata:
        syssize=q[0].props['L']
        #Get the exact result of M(1,t)=-(1/2)*(j_0(t)^2), where j_0(t) is the 0^{th} order
        # bessel function and M(1,t) is the magnetization one site to the right of the chain center
        loc=-0.5*scipy.special.jn(0,q[0].props['Time'])*scipy.special.jn(0,q[0].props['Time'])
        #Get the difference between the computed and exact results
        q[0].y=[abs(q[0].y[syssize/2+1-1]-loc)]



#Plot the Error in the magnetization one site to the right of the chain center
Mag=pyalps.collectXY(Magdata, x='Time', y='Local Magnetization', foreach=['SIMID'])
for q in Mag:
    dt=round(q.props['TAUS']/q.props['NUMSTEPS'],3)
    q.props['label']='dt='+str(dt)

plt.figure()
pyalps.plot.plot(Mag)
plt.xlabel('Time $t$')
plt.yscale('log')
plt.ylabel('Magnetization Error')
plt.title('Error in the magnetization vs. time')
plt.legend(loc='lower left')
plt.show()


## simulation results
data = pyalps.loadIterationMeasurements(
    pyalps.getResultFiles(prefix=basename + ".dynamic"),
    what=["Energy", "Local density", "Local density squared", "One body density matrix", "Density density"],
)

coords = []
for d1 in data:
    for s1 in d1:
        for d in s1:
            for s in d:
                if s.props["observable"] == "One body density matrix":
                    coords = (s.x[:, 0], s.x[:, 1])

XY = pyalps.collectXY(data, x="Time", y="Energy", foreach=["tau"])
E = [[[(x + 1) * dt, y] for (x, y) in zip(xy.x, xy.y)] for xy in XY][0]

# XY = pyalps.collectXY(data, x='Time', y='Overlap', foreach=['tau'])
# p = [[[(x + 1)*dt, 1-abs(y**2)] for (x, y) in zip(xy.x, xy.y)] for xy in XY]

XY = pyalps.collectXY(data, x="Time", y="Local density", foreach=["tau"])
n = [[[(x + 1) * dt, y] for (x, y) in zip(xy.x, xy.y)] for xy in XY][0]

XY = pyalps.collectXY(data, x="Time", y="Local density squared", foreach=["tau"])
n2 = [[[(x + 1) * dt, y] for (x, y) in zip(xy.x, xy.y)] for xy in XY][0]

XY = pyalps.collectXY(data, x="Time", y="One body density matrix", foreach=["tau"])
corr = [[[(x + 1) * dt, sparse.coo_matrix((y, coords)).toarray()] for (x, y) in zip(xy.x, xy.y)] for xy in XY][0]

XY = pyalps.collectXY(data, x="Time", y="Density density", foreach=["tau"])
Esempio n. 23
0
              'J1'             : 1,
              'J2'             : j2,
              'THERMALIZATION' : 5000,
              'SWEEPS'         : 50000, 
              'MODEL'          : "spin",
              'L'              : 8,
              'W'              : 4
            }
    )
    
#write the input file and run the simulation
input_file = pyalps.writeInputFiles('mc08a',parms)
pyalps.runApplication('loop',input_file)

data = pyalps.loadMeasurements(pyalps.getResultFiles(pattern='mc08a.task*.out.h5'),['Staggered Susceptibility','Susceptibility'])
susc1=pyalps.collectXY(data,x='T',y='Susceptibility', foreach=['J2'])

lines = []
for data in susc1:
    pars = [fw.Parameter(1), fw.Parameter(1)]
    data.y= data.y[data.x < 1]
    data.x= data.x[data.x < 1]
    f = lambda self, x, pars: (pars[0]()/np.sqrt(x))*np.exp(-pars[1]()/x)
    fw.fit(None, f, pars, [v.mean for v in data.y], data.x)
    prefactor = pars[0].get()
    gap = pars[1].get()
    print prefactor,gap
    
    lines += plt.plot(data.x, f(None, data.x, pars))
    lines[-1].set_label('$J_2=%.4s$: $\chi = \frac{%.4s}{T}\exp(\frac{-%.4s}{T})$' % (data.props['J2'], prefactor,gap))
Esempio n. 24
0
# The queue is loaded from a configuration file which should either be located in the execution directory or in ~/.batchq/configuration
q = load_queue(LSFBSub, "brutus")
desc = runApplicationBackground('spinmc',input_file,Tmin=5,writexml=True, queue = q, force_resubmit = False )

if not desc.finished():
   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()
Esempio n. 25
0
for t in [0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1]:
    parms.append({
        'LATTICE': "square lattice",
        'MODEL': "boson Hubbard",
        'T': 0.1,
        'L': 4,
        't': t,
        'mu': 0.5,
        'U': 1.0,
        'NONLOCAL': 0,
        'Nmax': 2,
        'THERMALIZATION': 10000,
        'SWEEPS': 500000
    })

#write the input file and run the simulation
input_file = pyalps.writeInputFiles('parm5a', parms)
res = pyalps.runApplication('worm', input_file, Tmin=5)

#load the magnetization and collect it as function of field h
data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm5a'),
                               'Stiffness')
rhos = pyalps.collectXY(data, x='t', y='Stiffness')

#make plot
plt.figure()
pyalps.plot.plot(rhos)
plt.xlabel('Hopping $t/U$')
plt.ylabel('Superfluid density $\\rho _s$')
plt.show()
Esempio n. 26
0
import pyalps
import matplotlib.pyplot as plt
import pyalps.plot

data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='params'),(['Value']))
value = pyalps.collectXY(data,x='T', y='Value')
plt.figure()
pyalps.plot.plot(value)
plt.xlabel('T')
plt.ylabel('Value')
plt.title('Test Plot')
plt.show()
Esempio n. 27
0
#################################################
## load the final iteration of G_{flavor=0}(tau)
data_G_tau = pyalps.loadMeasurements(res_files,
                                     respath='/simulation/results/G_tau',
                                     what=listobs,
                                     verbose=False)

print("Occupation in the last iteration at flavor=0")
for d in pyalps.flatten(data_G_tau):
    # obtain occupation using relation: <n_{flavor=0}> = -<G_{flavor=0}(tau=beta)>
    d.y = np.array([-d.y[-1]])
    print("n_0(beta =", d.props['BETA'], ") =", d.y[0])
    d.x = np.array([0])
    d.props['observable'] = 'occupation'

occupation = pyalps.collectXY(data_G_tau, 'BETA', 'occupation')
for d in occupation:
    d.props['line'] = "scatter"

plt.figure()
pyalps.plot.plot(occupation)
plt.xlabel(r'$\beta$')
plt.ylabel(r'$n_{flavor=0}$')
plt.title('Occupation versus BETA')

plt.show()

#############################################################################
## Display all iterations of the Green's function in Matsubara representation
#############################################################################
## load all iterations of G_{flavor=0}(i omega_n)
Esempio n. 28
0
		cmd.write('y_val is ' + y_val + '\n')
	
	if not x_val in val_list:
		cmd.write('The X-value you inputted do not exist.\n')
		cmd.write('You should choose this list, ' + str(val_list) + '\n')
		sys.exit(1)
	elif not y_val in val_list:
		cmd.write('The Y-value you inputted do not exist.\n')
		cmd.write('You should choose this list, ' + str(val_list) + '\n')
		sys.exit(1)
	
	#XML data file -> gnuplot-form text
	cmd.write('Start to convert the files XML to gnuplot-form.\n')
	data = pyalps.loadMeasurements(read_file, y_val)
	data = pyalps.flatten(data)
	xy_data = pyalps.collectXY(data, x_val, y_val)
	gnu_xy_data = pyalps.plot.makeGnuplotPlot(xy_data)
	if args.debug:
		cmd.write(str(gnu_xy_data))
	cmd.write('Finish to convert the files XML to gnuplot-form.\n')
	
	#gnuplot-form text -> csv-form text
	cmd.write('Start to convert the files gnuplot-form to CSV.\n')
	temp_file = '__tmp_replace__.dat'
	f = open(temp_file, 'w')
	f.write(gnu_xy_data)
	f.close()
	
	head_x = x_val
	head_y = y_val
	if not x_val in no_error_val:
Esempio n. 29
0
    parms.append(p)

## write input files and run application
input_file = pyalps.writeInputFiles(basename, parms)
res = pyalps.runApplication('mps_evolve', input_file)

## simulation results
data = pyalps.loadIterationMeasurements(pyalps.getResultFiles(prefix=basename),
                                        what=['Local Magnetization'])

for q in pyalps.flatten(data):
    L = q.props['L']
    #Compute the integrated flow of magnetization through the center \Delta M=\sum_{n>L/2}^{L} (<S_n^z(t)>+1/2)
    #\Delta M= L/4
    loc = 0.5 * (L / 2)
    #\Delta M-=<S_n^z(t)> from n=L/2 to L
    q.y = np.array([0.5 * (L / 2) - sum(q.y[0][L / 2:L])])

#Plot the Error in the magnetization one site to the right of the chain center
Mag = pyalps.collectXY(data, x='Time', y='Local Magnetization', foreach=['Jz'])
for d in Mag:
    d.x = (d.x + 1) * d.props['DT']

plt.figure()
pyalps.plot.plot(Mag)
plt.xlabel('Time $t$')
plt.ylabel('Integrated Magnetization $\Delta M(t)$')
plt.title('Integrated Magnetization vs. Time')
plt.legend(loc='upper left')
plt.show()
Esempio n. 30
0
    # Scan beta range [0,1] in steps of 0.1
    for beta in [0., .1, .2, .3, .4, .5, .6, .7, .8, .9, 1.]:
        for l in [4, 6, 8]:
            print '-----------'
            print 'beta =', beta
            sim = Simulation(beta, l)
            sim.run(N / 2, N)
            sim.save('ising.L_' + str(l) + 'beta_' + str(beta) + '.h5')

    #how to calculate the Binder Ratio within Python:
    infiles = pyalps.getResultFiles(pattern='ising.L')

    data = pyalps.loadMeasurements(pyalps.getResultFiles(pattern='ising.L*'),
                                   ['E', 'm^2', 'm^4'])
    m2 = pyalps.collectXY(data, x='BETA', y='m^2', foreach=['L'])
    m4 = pyalps.collectXY(data, x='BETA', y='m^4', foreach=['L'])

    u = []
    for i in range(len(m2)):
        d = pyalps.DataSet()
        d.propsylabel = 'U4'
        d.props = m2[i].props
        d.x = m2[i].x
        d.y = m4[i].y / m2[i].y / m2[i].y
        u.append(d)

    plt.figure()
    pyalps.plot.plot(u)
    plt.xlabel('Inverse Temperature $\\beta$')
    plt.ylabel('Binder Cumulant U4 $g$')
Esempio n. 31
0
            'SWEEPS': 50000,
            'MODEL': "spin",
            'L': l,
            'W': l / 2
        })

#write the input file and run the simulation
input_file = pyalps.writeInputFiles('mc08b', parms)
pyalps.runApplication('loop', input_file)

data = pyalps.loadMeasurements(
    pyalps.getResultFiles(pattern='mc08b.task*.out.h5'),
    ['Binder Ratio of Staggered Magnetization', 'Stiffness'])

binder = pyalps.collectXY(data,
                          x='J2',
                          y='Binder Ratio of Staggered Magnetization',
                          foreach=['L'])
stiffness = pyalps.collectXY(data, x='J2', y='Stiffness', foreach=['L'])

for q in stiffness:
    q.y = q.y * q.props['L']

#make plot
plt.figure()
pyalps.plot.plot(stiffness)
plt.xlabel(r'$J2$')
plt.ylabel(r'Stiffness $\rho_s L$')
plt.title('coupled ladders')

plt.figure()
pyalps.plot.plot(binder)
Esempio n. 32
0
              'MODEL'          : "Ising",
              'L'              : l
            }
    )

#write the input file and run the simulation
input_file = pyalps.writeInputFiles('parm7a',parms)
pyalps.runApplication('spinmc',input_file,Tmin=5)
# use the following instead if you have MPI
#pyalps.runApplication('spinmc',input_file,Tmin=5,MPI=2)

pyalps.evaluateSpinMC(pyalps.getResultFiles(prefix='parm7a'))

#load the susceptibility and collect it as function of temperature T
data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm7a'),['|Magnetization|', 'Connected Susceptibility', 'Specific Heat', 'Binder Cumulant', 'Binder Cumulant U2'])
magnetization_abs = pyalps.collectXY(data,x='T',y='|Magnetization|',foreach=['L'])
connected_susc = pyalps.collectXY(data,x='T',y='Connected Susceptibility',foreach=['L'])
spec_heat = pyalps.collectXY(data,x='T',y='Specific Heat',foreach=['L'])
binder_u4 = pyalps.collectXY(data,x='T',y='Binder Cumulant',foreach=['L'])
binder_u2 = pyalps.collectXY(data,x='T',y='Binder Cumulant U2',foreach=['L'])

#make plots
plt.figure()
pyalps.plot.plot(magnetization_abs)
plt.xlabel('Temperature $T$')
plt.ylabel('Magnetization $|m|$')
plt.title('2D Ising model')

plt.figure()
pyalps.plot.plot(connected_susc)
plt.xlabel('Temperature $T$')
Esempio n. 33
0
            'U': 1.0,
            'Nmax': 2,
            'THERMALIZATION': 100000,
            'SWEEPS': 2000000,
            'SKIP': 500,
            'MEASURE[Winding Number]': 1
        })

input_file = pyalps.writeInputFiles('parm1b', parms)
res = pyalps.runApplication('dwa', input_file, Tmin=5, writexml=True)

# Evaluating the simulation and preparing plots using Python
import pyalps
import matplotlib.pyplot as plt
import pyalps.plot as aplt

data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm1b'),
                               'Stiffness')
rhos = pyalps.collectXY(data, x='t', y='Stiffness', foreach=['L'])

for rho in rhos:
    rho.y = rho.y * float(rho.props['L'])

plt.figure()
aplt.plot(rhos)
plt.xlabel('Hopping $t/U$')
plt.ylabel('$\\rho _sL$')
plt.legend()
plt.title('Scaling plot for Bose-Hubbard model')
plt.show()
Esempio n. 34
0
def update(val):
    lo = slo.val
    le = sle.val
    Tc = stc.val
    alpha = f_alpha(le,lo, d=2)
    beta  = f_beta(le,lo, d=2) 
    gamma = f_gamma(le,lo, d=2)
    nu    = f_nu(le,lo, d=2) 
    chi = pyalps.collectXY(data,x='T',y='susceptibility',foreach=['L'])
    plt.sca(axChi)
    for d in chi:
        d.props['label']='L='+str(d.props['L'])
        d.x -= Tc
        d.x = d.x/Tc
        l = d.props['L']
        d.x = d.x * pow(float(l),1/nu)
        d.y = d.y * pow(float(l),-gamma/nu)
    plt.cla()
    pyalps.plot.plot(chi)
    plt.xlabel(r'$(T-T_c)L^{\frac{1}{\nu}}$', fontsize='x-large')
    plt.ylabel(r'$\chi L^{\frac{-\gamma}{\nu}}$', fontsize='x-large')
    plt.title(r'$\chi$', fontsize='x-large')
    cv = pyalps.collectXY(data,x='T',y='c_V',foreach=['L'])
    plt.sca(axCv)
    for d in cv:
        d.props['label']='L='+str(d.props['L'])
        d.x -= Tc
        d.x = d.x/Tc
        l = d.props['L']
        d.x = d.x * pow(float(l),1/nu)
        d.y = d.y * pow(float(l),-alpha/nu)
    plt.cla()
    pyalps.plot.plot(cv)
    plt.xlabel(r'$(T-T_c)L^{\frac{1}{\nu}}$', fontsize='x-large')
    plt.ylabel(r'$C_V L^{\frac{-\alpha}{\nu}}$', fontsize='x-large')
    plt.title(r'$cv$', fontsize='x-large')
    binder = pyalps.collectXY(data,x='T',y='BinderCumulant',foreach=['L'])
    plt.sca(axBinder)
    for d in binder:
        d.props['label']='L='+str(d.props['L'])
        d.x -= Tc
        d.x = d.x/Tc
        l = d.props['L']
        d.x = d.x * pow(float(l),1/nu)
    plt.cla()
    pyalps.plot.plot(binder)
    plt.xlabel(r'$(T-T_c)L^{\frac{1}{\nu}}$', fontsize='x-large')
    plt.ylabel(r'$U^4$', fontsize='x-large')
    plt.title('Binder', fontsize='x-large')
    M = pyalps.collectXY(data,x='T',y='M',foreach=['L'])
    plt.sca(axM)
    for d in M:
        d.props['label']='L='+str(d.props['L'])
        d.x -= Tc
        d.x = d.x/Tc
        l = d.props['L']
        d.x = d.x * pow(float(l),1/nu)
        d.y = d.y * pow(float(l),beta/nu)
    plt.cla()
    pyalps.plot.plot(M)
    plt.xlabel(r'$(T-T_c)L^{\frac{1}{\nu}}$', fontsize='x-large')
    plt.ylabel(r'$ML^{\frac{\beta}{\nu}}$', fontsize='x-large')
    plt.title(r'$M$', fontsize='x-large')
Esempio n. 35
0
# Please run all four other tutorials before running this one.
# This tutorial relies on the results created in those tutorials

import pyalps
import matplotlib.pyplot as plt
import pyalps.plot

# load all files
data = pyalps.loadMeasurements(pyalps.getResultFiles(), 'Susceptibility')

#flatten the hierarchical structure
data = pyalps.flatten(data)

# collect the susceptibility
susceptibility = pyalps.collectXY(data,
                                  x='T',
                                  y='Susceptibility',
                                  foreach=['MODEL', 'LATTICE'])

# assign labels to the data depending on the properties
for s in susceptibility:
    # print s.props
    if s.props['LATTICE'] == 'chain lattice':
        s.props['label'] = "chain"
    elif s.props['LATTICE'] == 'ladder':
        s.props['label'] = "ladder"
    if s.props['MODEL'] == 'spin':
        s.props['label'] = "quantum " + s.props['label']
    elif s.props['MODEL'] == 'Heisenberg':
        s.props['label'] = "classical " + s.props['label']

#make plot
Esempio n. 36
0
        cmd.write('y_val is ' + y_val + '\n')

    if not x_val in val_list:
        cmd.write('The X-value you inputted do not exist.\n')
        cmd.write('You should choose this list, ' + str(val_list) + '\n')
        sys.exit(1)
    elif not y_val in val_list:
        cmd.write('The Y-value you inputted do not exist.\n')
        cmd.write('You should choose this list, ' + str(val_list) + '\n')
        sys.exit(1)

    #XML data file -> gnuplot-form text
    cmd.write('Start to convert the files XML to gnuplot-form.\n')
    data = pyalps.loadMeasurements(read_file, y_val)
    data = pyalps.flatten(data)
    xy_data = pyalps.collectXY(data, x_val, y_val)
    gnu_xy_data = pyalps.plot.makeGnuplotPlot(xy_data)
    if args.debug:
        cmd.write(str(gnu_xy_data))
    cmd.write('Finish to convert the files XML to gnuplot-form.\n')

    #gnuplot-form text -> csv-form text
    cmd.write('Start to convert the files gnuplot-form to CSV.\n')
    temp_file = '__tmp_replace__.dat'
    f = open(temp_file, 'w')
    f.write(gnu_xy_data)
    f.close()

    head_x = x_val
    head_y = y_val
    if not x_val in no_error_val:
Esempio n. 37
0
# FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
# DEALINGS IN THE SOFTWARE.
# 
# ****************************************************************************

# Please run the two other tutorials before running this one. 
# This tutorial relies on the results created in those tutorials

import pyalps
import matplotlib.pyplot as plt
import pyalps.plot

# load all files
data = pyalps.loadMeasurements(pyalps.getResultFiles(),'Magnetization Density')

#flatten the hierarchical structure
data = pyalps.flatten(data)

#load the magnetization and collect it as function of field h
magnetization = pyalps.collectXY(data,x='h',y='Magnetization Density',foreach=['LATTICE'])

#make plot
plt.figure()
pyalps.plot.plot(magnetization)
plt.xlabel('Field $h$')
plt.ylabel('Magnetization $m$')
plt.ylim(0.0,0.5)
plt.legend()
plt.show()
Esempio n. 38
0
    parms.append({
        'LATTICE': "ladder",
        'MODEL': "spin",
        'local_S': 0.5,
        'T': 0.08,
        'J0': 1,
        'J1': 1,
        'THERMALIZATION': 1000,
        'SWEEPS': 10000,
        'L': 20,
        'h': h
    })

#write the input file and run the simulation
input_file = pyalps.writeInputFiles('parm3b', parms)
res = pyalps.runApplication('dirloop_sse', input_file, Tmin=5)

#load the magnetization and collect it as function of field h
data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm3b'),
                               'Magnetization Density')
magnetization = pyalps.collectXY(data, x='h', y='Magnetization Density')

#make plot
plt.figure()
pyalps.plot.plot(magnetization)
plt.xlabel('Field $h$')
plt.ylabel('Magnetization $m$')
plt.ylim(0.0, 0.5)
plt.title('Quantum Heisenberg ladder')
plt.show()
Esempio n. 39
0
# DEALINGS IN THE SOFTWARE.
#
# ****************************************************************************

import pyalps
import pyalps.plot as alpsplot
import matplotlib.pyplot as pyplot

data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm9a'), [
    'Specific Heat', 'Magnetization Density^2', 'Binder Ratio of Magnetization'
])
for item in pyalps.flatten(data):
    item.props['L'] = int(item.props['L'])

magnetization2 = pyalps.collectXY(data,
                                  x='T',
                                  y='Magnetization Density^2',
                                  foreach=['L'])
magnetization2.sort(key=lambda item: item.props['L'])

specificheat = pyalps.collectXY(data, x='T', y='Specific Heat', foreach=['L'])
specificheat.sort(key=lambda item: item.props['L'])

binderratio = pyalps.collectXY(data,
                               x='T',
                               y='Binder Ratio of Magnetization',
                               foreach=['L'])
binderratio.sort(key=lambda item: item.props['L'])

pyplot.figure()
alpsplot.plot(magnetization2)
pyplot.xlabel('Temperture $T$')
Esempio n. 40
0
pyalps.runApplication('spinmc', input_file, Tmin=5, writexml=True)

#get the list of result files
result_files = pyalps.getResultFiles(prefix='parm1')
print("Loading results from the files: ", result_files)

#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'])

#make a plot for the magnetization: collect Magnetziation as function of T
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))
Esempio n. 41
0
        'STEPSFORSTORE': [10, 5],
        'SIMID': count
    })

baseName = 'tutorial_1c'
#write output files
nmlnameList = pyalps.writeTEBDfiles(parms, baseName)
#run the application
res = pyalps.runTEBD(nmlnameList)

#Load the loschmidt echo and U
LEdata = pyalps.load.loadTimeEvolution(
    pyalps.getResultFiles(prefix='tutorial_1c'),
    measurements=['V', 'Loschmidt Echo'])

LE = pyalps.collectXY(LEdata, x='Time', y='Loschmidt Echo', foreach=['SIMID'])
for q in LE:
    q.props['label'] = r'$\tau=$' + str(q.props['POWS'][1])
plt.figure()
pyalps.plot.plot(LE)
plt.xlabel('Time $t$')
plt.ylabel('Loschmidt Echo $|< \psi(0)|\psi(t) > |^2$')
plt.title('Loschmidt Echo vs. Time ')
plt.legend(loc='lower left')

Ufig = pyalps.collectXY(LEdata, x='Time', y='V', foreach=['SIMID'])
for q in Ufig:
    q.props['label'] = r'$\tau=$' + str(q.props['POWS'][1])
plt.figure()
pyalps.plot.plot(Ufig)
plt.xlabel('Time $t$')
Esempio n. 42
0
    data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm'),['|Structure Factor|^2'])

    def Get_0k_range(L):
        return range(0,L*L,L)
    def Get_k0_range(L):
        return range(0,L,1)
    def Get_kk_range(L):
        return range(0,L*L,L+1)
    def Get_0k_data(data,L):
        return data.flatten()[Get_0k_range(L)]
    def Get_k0_data(data,L):
        return data.flatten()[Get_k0_range(L)]
    def Get_kk_data(data,L):
        return data.flatten()[Get_kk_range(L)]

    data = pyalps.collectXY(data,x='T',y='|Structure Factor|^2')[0]
    T_arr=np.unique(data.x)
    N_T=len(T_arr)
    S2 = list()
    S2E= list()
    for i in range(0,len(data.y)):
        S2.append(data.y[i].mean)
        S2E.append(data.y[i].error)

    L=int(sqrt(len(S2)/N_T))
    S2 =np.array(S2 ).reshape((N_T,L,L))
    S2E=np.array(S2E).reshape((N_T,L,L))

    fig=plt.figure()
    left_start=0.05
    right_end=1-left_start
Esempio n. 43
0
        parmsi['t'+str(i)+'[Time]'] = ','.join([mathematica(JW(W)) for W in quench(W_i, W_f, 2*tau, dt)])
    for i in range(L):
        parmsi['U'+str(i)+'[Time]'] = ','.join([mathematica(UW(W)) for W in quench(W_i, W_f, 2*tau, dt)])
    parmslist.append(parmsi)


input_file = pyalps.writeInputFiles(basename+'.dynamic',parmslist)
res = pyalps.runApplication('mps_evolve',input_file,writexml=True)

end = datetime.datetime.now()

## simulation results
data = pyalps.loadIterationMeasurements(pyalps.getResultFiles(prefix=basename+'.dynamic'), what=['Overlap'])

p = []
F = pyalps.collectXY(data, x='Time', y='Overlap', foreach=['tau'])
for d in pyalps.flatten(F):
    p.append([(d.x[-1] + 1) * d.props['dt'], 1 - abs(d.y[-1])**2])
    # d.x =  (d.x + 1.) * d.props['dt'] # convert time index to real time
    # d.y = abs(d.y)**2 # Loschmidt Echo defined as the module squared of the overlap
    # d.props['label']=r'$\tau={0}$'.format( d.props['tau'] )

print p

# print F
# plt.figure()
# pyalps.plot.plot(F)
# plt.xlabel('Time $t$')
# plt.ylabel('Loschmidt Echo $|< \psi(0)|\psi(t) > |^2$')
# plt.title('Loschmidt Echo vs. Time')
# plt.legend(loc='lower right')