Esempio n. 1
0
def rundmrg(i, t, N, it, iN):
    storagedir = bhdir + '/' + str(i)
    os.makedirs(storagedir)
    # parms = [dict(parmsbase.items() + {'N_total': N, 't': t, 'it': it, 'iN': iN}.items())]
    parms = [
        dict(
            parmsbase.items() + {
                'N_total': N,
                't': 'get(x,' + ",".join([str(Ji)
                                          for Ji in JW(speckle(t))]) + ')',
                'U': 'get(x,' + ",".join([str(Ui)
                                          for Ui in UW(speckle(t))]) + ')',
                'it': it,
                'iN': iN,
                'storagedir': storagedir,
                'seed': str(int(time.time()))
            }.items())
    ]
    # parms = [x for x in itertools.chain(parms, parms)]
    # parms = [dict(parm.items() + {'ip': j, 'seed': seed0 + j}.items()) for j, parm in enumerate(parms)]
    input_file = pyalps.writeInputFiles(filenameprefix + str(i), parms)
    pyalps.runApplication(app(appname), input_file, writexml=True)
    # checkpoints = glob.glob(filenameprefix + str(i) + '*.chkp')
    # [shutil.rmtree(chkp) for chkp in checkpoints]
    shutil.rmtree(storagedir)
Esempio n. 2
0
def runmc(i, t, mu, it, imu):
    parms = [dict(parmsbase.items() + {'t': t, 'mu': str(mu) + '-' + getnu, 'it': it, 'imu': imu}.items())]
    input_file = pyalps.writeInputFiles(filenameprefix + str(i), parms)
    if limit > 0:
        pyalps.runApplication('/opt/alps/bin/'+app, input_file, writexml=True, Tmin=5, T=limit)
    else:
        pyalps.runApplication('/opt/alps/bin/'+app, input_file, writexml=True, Tmin=5)
Esempio n. 3
0
def rundmrg(i, t, N, it, iN):
    parms = [dict(parmsbase.items() + {'N_total': N, 't': t, 'it': it, 'iN': iN}.items())]
    # parms = [x for x in itertools.chain(parms, parms)]
    parms = [x for x in itertools.chain.from_iterable(itertools.repeat(parms, reps))]
    parms = [dict(parm.items() + {'ip': j}.items()) for j, parm in enumerate(parms)]
    input_file = pyalps.writeInputFiles(filenameprefix + str(i), parms)
    pyalps.runApplication('/opt/alps/bin/dmrg2', input_file, writexml=True)
def runmps(task, iW, isigma, Wi, sigma):
    parmsi = deepcopy(parms)
    parmsi['iW'] = iW
    parmsi['is'] = isigma

    t = JW(speckle(Wi, sigma))
    U = UW(speckle(Wi, sigma))
    for i in range(L):
        parmsi['t'+str(i)] = t[i]
    for i in range(L):
        parmsi['U'+str(i)] = U[i]

    # try:
    #     if ximax == 0:
    #         raise ValueError
    #     ns = VarArray(L, nmax)
    #     E = Sum([n*(n-1) for n in ns], (0.5*U).tolist())
    #     model = Model(Minimize(E), [Sum(ns) == N])
    #     solver = model.load('SCIP')
    #     solver.setTimeLimit(60)
    #     solved = solver.solve()
    #     parmsi['solved'] = solved
    # except:
    #     basen = N // L
    #     ns = [basen] * L
    #     rem = N % L
    #     excessi = [i for (xii, i) in xisort[:rem]]
    #     for i in excessi:
    #         ns[i] += 1
    # parmsi['initial_local_N'] = ','.join([str(n) for n in ns])

    input_file = pyalps.writeInputFiles(basename + str(task), [parmsi])
    pyalps.runApplication('mps_optim', input_file, writexml=True)
Esempio n. 5
0
def run_dmrg(nsite, J2):
    #prepare the input parameters
    parms = [{
        'LATTICE_LIBRARY': 'j1j2_%d.xml' % nsite,
        'LATTICE': 'J1J2',
        'MODEL': 'spin',
        'local_S0': '0.5',  # local_S0 means type 0 site, right?
        'CONSERVED_QUANTUMNUMBERS': 'N,Sz',
        'Sz_total': 0,
        'J0': 1,
        'J1': J2,
        'SWEEPS': 4,
        'NUMBER_EIGENVALUES': 1,
        'MAXSTATES': 400
    }]

    #write the input file and run the simulation
    prefix = 'data/j1j2_%dJ2%s' % (nsite, J2)
    input_file = pyalps.writeInputFiles(prefix, parms)
    res = pyalps.runApplication('dmrg', input_file, writexml=True)

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

    # print properties of the eigenvector for each run:
    for run in data:
        for s in run:
            print('%s : %s' % (s.props['observable'], s.y[0]))
Esempio n. 6
0
def runmps(task, it, iN, Ui, ti, N):
    parmsi = deepcopy(parms)
    parmsi['it'] = it
    parmsi['iN'] = iN

    t = xi * ti
    if twist:
        t[0] *= -1
    U = xi * Ui
    for i in range(L):
        parmsi['t'+str(i)] = t[i]
    for i in range(L):
        parmsi['U'+str(i)] = U[i]

    parmsi['N_total'] = N

    try:
        if ximax == 0:
            raise ValueError
        ns = VarArray(L, nmax)
        E = Sum([n*(n-1) for n in ns], U.tolist())
        model = Model(Minimize(E), [Sum(ns) == N])
        solver = model.load('SCIP')
        solver.setTimeLimit(600)
        solved = solver.solve()
        parmsi['solved'] = solved
    except:
        basen = N // L
        ns = [basen] * L
        rem = N % L
        excessi = [i for (xii, i) in xisort[:rem]]
        for i in excessi:
            ns[i] += 1
    parmsi['initial_local_N'] = ','.join([str(n) for n in ns])

    # subprocess.call(['mkdir Tasks/Task.'+str(task)], shell=True)
    # input_file = pyalps.writeInputFiles('Tasks/Task.' + str(task) + '/bh.' + str(L) + '.' + str(resi) + '.' + str(task), [parmsi])
    input_file = pyalps.writeInputFiles(basename + str(task), [parmsi])
    # subprocess.call(['bash','-c','read'])
    pyalps.runApplication('mps_optim', input_file)
Esempio n. 7
0
def runmps(task, iW, iN, Wi, N):
    parmsi = deepcopy(parms)
    parmsi['iW'] = iW
    parmsi['iN'] = iN

    W = Wi * xi
    t = JW(W)
    U = UW(W)
    if twist:
        t[0] *= -1
    for i in range(L):
        parmsi['t'+str(i)] = t[i]
    for i in range(L):
        parmsi['U'+str(i)] = U[i]

    parmsi['N_total'] = N

    try:
        if ximax == 0:
            raise ValueError
        ns = VarArray(L, nmax)
        E = Sum([n*(n-1) for n in ns], U.tolist())
        model = Model(Minimize(E), [Sum(ns) == N])
        solver = model.load('SCIP')
        solver.setTimeLimit(600)
        solved = solver.solve()
        parmsi['solved'] = solved
    except:
        basen = N // L
        ns = [basen] * L
        rem = N % L
        excessi = [i for (xii, i) in xisort[:rem]]
        for i in excessi:
            ns[i] += 1
    parmsi['initial_local_N'] = ','.join([str(n) for n in ns])

    input_file = pyalps.writeInputFiles(basename + str(task), [parmsi])
    pyalps.runApplication('mps_optim', input_file, writexml=True)
Esempio n. 8
0
    p['initial_local_Sz'] = ','.join(['-0.5'] * 25 + ['0.5'] * 25)
    p['te_order'] = 'second'
    p['DT'] = dt
    p['TIMESTEPS'] = nsteps
    p['tau'] = tau  # not used in the simulation, but useful in the evaluation below
    p['Jz'] = z
    p['ALWAYS_MEASURE'] = 'Local Magnetization'
    p['chkp_each'] = nsteps
    p['measure_each'] = 5
    p['COMPLEX'] = 1

    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'])
Esempio n. 9
0
    'hz': hz,
    'cg': cg,
    'sg': sg,
    'SWEEPS': sweeps,
    'NUM_WARMUP_STATES': warmup_states,
    'NUMBER_EIGENVALUES': 1,
    'MAXSTATES': max_states,
    'MEASURE_LOCAL[nUP]': 'nUP',
    'MEASURE_LOCAL[nDO]': 'nDO',
    'MEASURE_CORRELATIONS[One-body Correlation UP]': "bdagUP:bUP",
    'MEASURE_CORRELATIONS[One-body Correlation DO]': "bdagDO:bDO",
    'MEASURE_CORRELATIONS[One-body Correlation UPDO]': "bdagUP:bDO",
    'MEASURE_CORRELATIONS[Two-body Correlation UP]': "nUP:nUP",
    'MEASURE_CORRELATIONS[Two-body Correlation DO]': "nDO:nDO",
    'MEASURE_CORRELATIONS[Two-body Correlation UPDO]': "nUP:nDO"
}]

#Write the input file and run the simulation
input_file = pyalps.writeInputFiles(filename, parms)
res = pyalps.runApplication('dmrg', input_file, writexml=False, MPI=None)

#Load measurements for the ground state
data = pyalps.loadEigenstateMeasurements(
    pyalps.getResultFiles(prefix=filename))

#Print the properties of the ground state
if __name__ == '__main__':

    for s in data[0]:
        print s.props['observable'], ' : ', s.y[0]
Esempio n. 10
0
                 'T'              : t,
                 'D'              : 1.,
                 'THERMALIZATION' : 50000,
                 'SWEEPS'         : 100000,
                 'UPDATE'         : "ssf",
                 'cutoff_distance': 1.8,
                 'L'              : l,
                 'Each_Measurement': 15
               }
           )

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

def f_alpha(Le, Lo, b=2, d=2):
    return 2-d*log(b)/log(Le)
def f_beta(Le, Lo, b=2, d=2):
    return (d*log(b)-log(Lo))/log(Le) 
def f_gamma(Le, Lo, b=2, d=2):
    return log(b)/log(Le)*(2*log(Lo)/log(b)-d)
def f_nu(Le, Lo, b=2, d=2):
    return log(b)/log(Le)

#load the susceptibility and collect it as function of temperature T
data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm'),['M', 'c_V', 'BinderCumulant', 'susceptibility'])

Tc0=2.269
Tc_min=2
Esempio n. 11
0
            'ALGORITHM': 'loop',
            'SEED': 0,
            'BETA': 2 * l,
            'J0': 1,
            'J1': 1,
            'J2': j2,
            'THERMALIZATION': 5000,
            '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
Esempio n. 12
0
import pyalps

#prepare the input parameters
parms = [{ 
          'LATTICE'                   : "chain lattice", 
          'MODEL'                     : "spin",
          'local_S'                   :  0.5,
          'J'                         :  1,
          'L'                         :  16,
          'CONSERVED_QUANTUMNUMBERS'  :  'Sz',
          'Sz_total'                  :  0, 
 	      'TRANSLATION_SYMMETRY'      :  'true',
          'NUMBER_EIGENVALUES'        :  5,
          'TOTAL_MOMENTUM'            :  "0"
        }]

#write the input file and run the simulation
input_file = pyalps.writeInputFiles('heisenberg',parms)
res = pyalps.runApplication('sparsediag',input_file)
parms['update_each'] = 1
xi = (1 + 0.5 * np.random.uniform(-1, 1, L))
for i in range(L-1):
    parms['t'+str(i)] = mathematica(JW(W_i*xi)[i])
for i in range(L):
    parms['U'+str(i)] = mathematica(UW(W_i*xi)[i])

resi = 302
basename = 'DynamicsTasks/bhramp.'+str(L)+'.'+str(resi)
# gbasename = basename
gbasename = 'DynamicsTasks/bhramp.'+str(L)+'.300'

start = datetime.datetime.now()

input_file = pyalps.writeInputFiles(gbasename+'.ground',[parms])
res = pyalps.runApplication('mps_optim',input_file,writexml=True)

initstate = pyalps.getResultFiles(prefix=gbasename+'.ground')[0].replace('xml', 'chkp')

parms['initfile'] = initstate
parms['MEASURE_OVERLAP[Overlap]'] = initstate
parms['always_measure'] = 'Overlap,Local density,Local density squared,One body density matrix,Density density'

taus = [1e-6]#np.linspace(1e-7, 2e-7, 2)#[1e-7,1.1e-7,1.2e-7]

parmslist = []
for tau in taus:
    parmsi = deepcopy(parms)
    parmsi['tau'] = tau
    steps = round(2*tau / dt)
    parmsi['TIMESTEPS'] = steps#int(2*tau / dt)
Esempio n. 14
0
import numpy as np

#prepare the input parameters
parms = [{
    'LATTICE': "ladder",
    'MODEL': "spin",
    'CONSERVED_QUANTUMNUMBERS': 'Sz',
    'local_S': 0.5,
    'J0': 1,
    'J1': 1,
    'L': 6
}]

#write the input file and run the simulation
input_file = pyalps.writeInputFiles('ed06b', parms)
res = pyalps.runApplication('fulldiag', input_file)

#run the evaluation and load all the plots
data = pyalps.evaluateFulldiagVersusT(pyalps.getResultFiles(prefix='ed06b'),
                                      DELTA_T=0.05,
                                      T_MIN=0.05,
                                      T_MAX=5.0)

#make plot
for s in pyalps.flatten(data):
    plt.figure()
    plt.title("Antiferromagnetic Heisenberg ladder")
    pyalps.plot.plot(s)

plt.show()
Esempio n. 15
0
# Preparing and running the simulation using Python
import pyalps

parms = [{
    'LATTICE': 'inhomogeneous simple cubic lattice',
    'L': 120,
    'MODEL': 'boson Hubbard',
    'Nmax': 20,
    't': 1.,
    'U': 8.11,
    'mu':
    '4.05 - (0.0073752*(x-(L-1)/2.)*(x-(L-1)/2.) + 0.0036849*(y-(L-1)/2.)*(y-(L-1)/2.) + 0.0039068155*(z-(L-1)/2.)*(z-(L-1)/2.))',
    'T': 1.,
    'THERMALIZATION': 1500,
    'SWEEPS': 7000,
    'SKIP': 50,
    'MEASURE[Local Density]': 1
}]

input_file = pyalps.writeInputFiles('parm2a', parms)
res = pyalps.runApplication('dwa', input_file)

# Evaluating and plotting in Python
import pyalps
import pyalps.plot as aplt

data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm2a'),
                               'Local Density')
aplt.plot3D(data, centeredAtOrigin=True)
Esempio n. 16
0
parms['t'] = 0.3
parms['U'] = 1

resi = 1000
try:
    shutil.rmtree('SingleSite')
    os.mkdir('SingleSite')
except:
    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
Esempio n. 17
0
#prepare the input parameters
parms = [ { 
        'LATTICE'                   : "open chain lattice", 
        'MODEL'                     : "spin",
        'CONSERVED_QUANTUMNUMBERS'  : 'N,Sz',
        'Sz_total'                  : 0,
        'J'                         : 1,
        'SWEEPS'                    : 4,
        'NUMBER_EIGENVALUES'        : 1,
        'L'                         : 32,
        'MAXSTATES'                 : 100
       } ]

#write the input file and run the simulation
input_file = pyalps.writeInputFiles('parm_spin_one_half',parms)
res = pyalps.runApplication('dmrg',input_file,writexml=True)

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

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

# load and plot iteration history
iter = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm_spin_one_half'),
                               what=['Iteration Energy','Iteration Truncation Error'])

plt.figure()
pyalps.plot.plot(iter[0][0])
plt.title('Iteration history of ground state energy (S=1/2)')
for i in range(L):
    parms["U" + str(i) + "[Time]"] = ",".join([mathematica(UW(W)[i]) for W in quench(W_i, W_f, xi, tf, dt)])
parmslist = [parms]
# for tau in taus:
#     parmsi = deepcopy(parms)
#     parmsi['tau'] = tau
#     parmsi['TIMESTEPS'] = int(2*tau / dt)
#     for i in range(L-1):
#         parmsi['t'+str(i)+'[Time]'] = ','.join([mathematica(JW(W)[i]) for W in quench(W_i, W_f, xi, 2*tau, dt)])
#     for i in range(L):
#         parmsi['U'+str(i)+'[Time]'] = ','.join([mathematica(UW(W)[i]) for W in quench(W_i, W_f, xi, 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=["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":
Esempio n. 19
0
temp = "temp"
try:
  os.mkdir(temp)
except:
  pass

try:
  os.mkdir(os.path.join(temp, timestamp))
except:
  pass

input_file = pyalps.writeInputFiles(os.path.join(os.getcwd(), temp, timestamp), parms)

#run the simulation

res = pyalps.runApplication('fulldiag',input_file, writexml=True)

print res
#load all measurements for all states
# data = pyalps.loadEigenstateMeasurements(pyalps.getResultFiles(prefix='parm1a'))
result_name = 'nx{nx}_ny{ny}_J{J}_J1{J1}_f{f}'.format(nx=Nx, ny=Ny, J=J, f=dilution, J1=J1)
data = pyalps.evaluateFulldiagVersusT(pyalps.getResultFiles(prefix=str(timestamp)),DELTA_T=args.Ts, T_MIN=args.Ti, T_MAX=args.Tf)

# print 'data = ', data

d_xml = data2xml.DataToXML(data=data, ed=True)
results = 'results'

try:
  os.mkdir(results)
except:
Esempio n. 20
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. 21
0
parms = []
for t in [1.5, 2, 2.5]:
    parms.append({
        'LATTICE': "square lattice",
        'T': t,
        'J': 1,
        'THERMALIZATION': 1000,
        'SWEEPS': 100000,
        'UPDATE': "cluster",
        'MODEL': "Ising",
        'L': 8
    })

#write the input file and run the simulation
input_file = pyalps.writeInputFiles('parm1', parms)
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|')
Esempio n. 22
0
            2.35
    ]:
        parms.append({
            'LATTICE': "square lattice",
            'T': t,
            'J': 1,
            'THERMALIZATION': 5000,
            'SWEEPS': 150000,
            'UPDATE': "cluster",
            'MODEL': "Ising",
            'L': l
        })

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

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

#load the susceptibility and collect it as function of temperature T
# data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm7b'),['|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 a plot of the Binder cumulant:
# plt.figure()
Esempio n. 23
0
for t in [1.5,2,2.5]:
   parms.append(
       { 
         'LATTICE'        : "square lattice", 
         'T'              : t,
         'J'              : 1 ,
         'THERMALIZATION' : 1000,
         'SWEEPS'         : 100000,
         'UPDATE'         : "cluster",
         'MODEL'          : "Ising",
         'L'              : 8
       }
   )

input_file = pyalps.writeInputFiles('parm1',parms)
desc = pyalps.runApplication('spinmc',input_file,Tmin=5,writexml=True)

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)
Esempio n. 24
0
#prepare the input parameters
parms = [{
    'LATTICE': "chain lattice",
    'MODEL': "spin",
    'local_S': 1,
    'J': 1,
    'L': 4,
    'CONSERVED_QUANTUMNUMBERS': 'Sz',
    'MEASURE_STRUCTURE_FACTOR[Structure Factor S]': 'Sz',
    'MEASURE_CORRELATIONS[Diagonal spin correlations]=': 'Sz',
    'MEASURE_CORRELATIONS[Offdiagonal spin correlations]': 'Splus:Sminus'
}]

#write the input file and run the simulation
input_file = pyalps.writeInputFiles('ed01a', parms)
res = pyalps.runApplication('sparsediag', input_file)

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

# print properties of ground states in all sectors:
for sector in data[0]:
    print '\nSector with Sz =', sector[0].props['Sz'],
    print 'and k =', sector[0].props['TOTAL_MOMENTUM']
    for s in sector:
        if pyalps.size(s.y[0]) == 1:
            print s.props['observable'], ' : ', s.y[0]
        else:
            for (x, y) in zip(s.x, s.y[0]):
                print s.props['observable'], '(', x, ') : ', y
Esempio n. 25
0
import matplotlib.pyplot as plt
import pyalps.plot

#prepare the input parameters
parms = [{
    'LATTICE': "chain lattice",
    'MODEL': "spin",
    'local_S': 0.5,
    'L': 40,
    'J': -1,
    'CUTOFF': 1000
}]

#write the input file and run the simulation
input_file = pyalps.writeInputFiles('parm6a', parms)
res = pyalps.runApplication('qwl', input_file)

#run the evaluation and load all the plots
data = pyalps.evaluateQWL(pyalps.getResultFiles(prefix='parm6a'),
                          DELTA_T=0.1,
                          T_MIN=0.1,
                          T_MAX=10.0)

#make plot
for s in pyalps.flatten(data):
    plt.figure()
    plt.title("Ferromagnetic Heisenberg chain")
    pyalps.plot.plot(s)

plt.show()
Esempio n. 26
0
            'LATTICE': "square lattice",
            'MODEL': "boson Hubbard",
            'T': 0.05,
            'L': l,
            't': t,
            'U': 1.0,
            'mu': 0.5,
            'NONLOCAL': 0,
            'Nmax': 2,
            'THERMALIZATION': 15000,
            'SWEEPS': 600000
        })

#write the input file and run the simulation
input_file = pyalps.writeInputFiles('mc05b', 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='mc05b'),
                               'Stiffness')
rhos = pyalps.collectXY(data, x='t', y='Stiffness', foreach=['L'])

# multiply with the system size for the scaling plot
for s in rhos:
    s.y = s.y * float(s.props['L'])

#make plot
plt.figure()
pyalps.plot.plot(rhos)
plt.xlabel('Hopping $t/U$')
plt.ylabel('$\
Esempio n. 27
0
      'J'              : J,
      'J1'             : J1,
      'THERMALIZATION': 5000,
      'SWEEPS'         : 50000,
      'ALGORITHM'      : "loop",
      # 'MEASURE[Winding Number]': 1,
      # 'MEASURE_CORRELATIONS[Diagonal spin correlations]':"Sz",
    }
)


#write the input file and run the simulation

input_file = pyalps.writeInputFiles(os.path.join(os.getcwd(), temp, timestamp, lattice_name), parms)

pyalps.runApplication('loop', input_file, writexml=True)

data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix=lattice_name))

results = 'results'

try:
  os.mkdir(results)
except:
  pass

file_name = os.path.join(results, lattice_name + "_beta_{beta}_Nx_{Nx}_Ny_{Ny}_J_{J}_J1_{J1}.xml".format(beta=beta,
                                                                                                         Nx=Nx,
                                                                                                         Ny=Ny,
                                                                                                         J=J,
                                                                                                         J1=J1))
Esempio n. 28
0
            'LATTICE': "square lattice",
            'MODEL': "boson Hubbard",
            'T': 0.1,
            'L': L,
            't': t,
            'mu': 0.5,
            '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)
Esempio n. 29
0
parms = []
parms.append( { 
    'LATTICE'                               : "open ladder",
    'L'                                     : 10,
    'MODEL_LIBRARY'                         : "mymodels.xml",
    'MODEL'                                 : "fermion Hubbard",
    'CONSERVED_QUANTUMNUMBERS'              : 'Nup,Ndown',
    'Nup_total'                             : 10,
    'Ndown_total'                           : 10,
    't0'                                    : "1+0.6*I",
    'ct0'                                   : "1-0.6*I",
    't1'                                    : 0.1,
    'U'                                     : 0.,
    'SWEEPS'                                : 6,
    'MAXSTATES'                             : 400,
    'COMPLEX'                               : 1,
   } )

#write the input file and run the simulation
input_file = pyalps.writeInputFiles(basename,parms)
res = pyalps.runApplication('mps_optim',input_file,writexml=True)

#load all measurements for all states
data = pyalps.loadEigenstateMeasurements(pyalps.getResultFiles(prefix=basename), ['Energy'])

en_exact = -28.1129977
print('Exact energy for MAXSTATES=inf ::', en_exact)
for d in pyalps.flatten(data):
    print(d.props['observable'], '=', d.y)