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)
Exemple #2
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]))
Exemple #3
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)
Exemple #4
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)
Exemple #5
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)
Exemple #6
0
 def call(self,parm, output=False):
     import pyalps
     import subprocess
     input_file = pyalps.writeInputFiles('parm',parm)
     if not output:
         return subprocess.call('mc++ parm.in.xml', stdout=self.oblivion, stderr=subprocess.STDOUT, shell=True)
     else:
         return subprocess.call('mc++ parm.in.xml', shell=True)
Exemple #7
0
    def compute(self):
        of = self.interpreter.filePool.create_file()
        os.unlink(of.name)
        os.mkdir(of.name)
        dir = basic.Directory
        dir.name = of.name
        o = self.interpreter.filePool.create_file()
        if self.hasInputFromPort('simulationid'):
            base_name = self.getInputFromPort('simulationid')
        else:
            base_name = os.path.basename(o.name)

        print(base_name)

        ofile = basic.File()
        ofile.name = os.path.join(dir.name, base_name + '.in.xml')

        if self.hasInputFromPort('parms'):
            input_values = self.forceGetInputListFromPort('parms')
            l = []
            for p in input_values:
                if isinstance(p, list):
                    l += p
                else:
                    l += [p]

            if self.hasInputFromPort('baseseed'):
                baseseed = self.getInputFromPort('baseseed')
            else:
                baseseed = pyalps.generateSeed()

            Module.annotate(self, {'baseseed': baseseed})

            pyalps.writeInputFiles(os.path.join(dir.name, base_name), l,
                                   baseseed)
            pyalps.copyStylesheet(dir.name)

        self.setResult("output_dir", dir)
        self.setResult("output_file", ofile)
Exemple #8
0
def gen_sitediff_lattice(paras):
    """Generate site different lattice `GRAPH` for given `LATTICE`.

  :paras: dict
      Parameters dict contain `LATTICE` and its parameters.
  :returns: TODO

  """
    paras_ = dict(paras)  # get a copy.
    basename = '.for_get_graph'
    input_xml = pyalps.writeInputFiles(basename, [paras_])
    graph = _get_graph(input_xml)
    new_graph = _set_sitediff(graph)
    new_lattice_lib = _gen_new_lattice_lib(new_graph, paras_)
    paras['LATTICE_LIBRARY'] = new_lattice_lib
    os.system('rm -rf ' + basename + '*')
    return paras
Exemple #9
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)
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)
parms['te_order'] = 'second'
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)
Exemple #12
0
#prepare the input parameters
parms = []
for l in [6, 8, 10]:
    parms.append({
        'LATTICE': "ladder",
        'MODEL': "spin",
        'local_S': 0.5,
        'J0': 1,
        'J1': 1,
        'L': l,
        'CONSERVED_QUANTUMNUMBERS': 'Sz',
        'Sz_total': 0
    })

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

#load all measurements for all states
data = pyalps.loadSpectra(pyalps.getResultFiles(prefix='parm_ladder'))

# collect spectra over all momenta for every simulation
spectra = {}
for sim in data:
    l = int(sim[0].props['L'])
    all_energies = []
    spectrum = pyalps.DataSet()
    for sec in sim:
        all_energies += list(sec.y)
        spectrum.x = np.concatenate(
            (spectrum.x,
Exemple #13
0
    parms['U'+str(i)] = U[i]

parms['N_total'] = 1

basename = 'Tasks/bhstestts3'
# basename = 'Tasks/bhq1'

parmslist = []
for N in range(L+1, 2*L+1):
    parmsi = deepcopy(parms)
    parmsi['N_total'] = N
    parmslist.append(parmsi)


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

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

results = []
for d in data:
    for s in d:
        if(s.props['observable'] == 'Energy'):
            results += [(s.props['N_total'], s.y[0])]

Ns = [res[0] for res in sorted(results)]
energies = [res[1] for res in sorted(results)]
# print(energies)
Exemple #14
0
## common model parameters
model = OrderedDict()
model['LATTICE'] = 'open chain lattice'
model['L'] = 10
model['MODEL'] = 'hardcore boson'
model['CONSERVED_QUANTUMNUMBERS'] = 'N'
model['N_total'] = 5
model['t'] = 1.
model['MAXSTATES'] = 40

## ground state simulation for ground state
ground_parms = deepcopy(model)
ground_parms['V'] = 10.
ground_parms['SWEEPS'] = 4
input_file = pyalps.writeInputFiles(basename + '.ground', [ground_parms])
res = pyalps.runApplication('mps_optim', input_file)

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


def quench(g_i, g_f, steps, dt, p=1):
    t = (1. + np.arange(steps)) * dt
    return g_i + (t / t[-1])**p * (g_f - g_i)


def list_to_string(ll):
    return ','.join([str(li) for li in ll])

Exemple #15
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 = []
# Change system sizes here, if desired
for L in [10, 12]:
    parms.append({
        'LATTICE': "chain lattice",
        'MODEL': "spin",
        'local_S': 0.5,
        'Jxy': 0,
        'Jz': -1,
        'Gamma': 0.5,
        'NUMBER_EIGENVALUES': 5,
        'L': L
    })

prefix = 'ed04a'
input_file = pyalps.writeInputFiles(prefix, parms)
# res = pyalps.runApplication('sparsediag', input_file, MPI=2, mpirun='mpirun')
res = pyalps.runApplication('sparsediag', input_file)
data = pyalps.loadEigenstateMeasurements(pyalps.getResultFiles(prefix=prefix))

# To perform CFT assignments, we need to calculate the ground state
# and the first excited state for each L.
# The output of the above load operation will be a hierarchical list sorted
# by L, so we can just iterate through it
E0 = {}
E1 = {}
for Lsets in data:
    L = pyalps.flatten(Lsets)[0].props['L']
    # Make a big list of all energy values
    allE = []
    for q in pyalps.flatten(Lsets):
Exemple #17
0
import pyalps
import numpy as np

params = []

MCS = 65536

for L in [16, 24, 32]:
  for T in np.linspace(1.1, 1.15, 51):
    params.append({
      'ALGORITHM' : 'cluster',
      'MODEL' : 'Potts'
      'q' : 2,
      'LATTICE' : 'square lattice',
      'L' : L,
      'T' : T,
      'J' : 1.0,
      'SWEEPS' : MCS,
      'THERMALIZATION' : MCS >> 3,
      })

pyalps.writeInputFiles('params', params)

Exemple #18
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
Exemple #19
0
f = list()
g = list()
i = list()
e4 = list()
e5 = list()
e6 = list()

file_name1 = 'e4-' + str(num)
file_name2 = 'e5-' + str(num)
file_name3 = 'e6-' + str(num)

#e4
parms[0]['Nup_total'] = Nup
parms[0]['Ndown_total'] = 0

input_file = pyalps.writeInputFiles(file_name1, parms)
res = pyalps.runApplication('dmrg', input_file, writexml=True)

data = pyalps.loadEigenstateMeasurements(
    pyalps.getResultFiles(prefix=file_name1))
for s in data[0]:
    f.append(s.y[0])

for m in range(0, len(f), 2):
    e4.append(f[m])

print(f)
# e5
parms[0]['Nup_total'] = Nup + 1
parms[0]['Ndown_total'] = 1
import pyalps.plot

#prepare the input parameters
parms= []
for m in [20,40,60]:
    parms.append({ 
        'LATTICE_LIBRARY'           : 'my_lattices.xml',
        'LATTICE'                   : 'open chain lattice with special edges 32',
        'MODEL'                     : 'spin',
        'local_S0'                  : '0.5',
        'local_S1'                  : '1',
        'CONSERVED_QUANTUMNUMBERS'  : 'N,Sz',
        'Sz_total'                  : 0,
        'J'                         : 1,
        'SWEEPS'                    : 4,
        'NUMBER_EIGENVALUES'        : 1,
        'MAXSTATES'                 : m
       })

#write the input file and run the simulation
input_file = pyalps.writeInputFiles('parm_spin_one_multiple',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_multiple'))

# print properties of the eigenvector for each run:
for run in data:
    for s in run:
        print(s.props['observable'], ' : ', s.y[0])
parms['N_total'] = L
parms['init_state'] = 'local_quantumnumbers'
parms['initial_local_N'] = ','.join(['1']*L)
parms['te_order'] = 'second'
parms['update_each'] = 1
for i in range(L-1):
    parms['t'+str(i)+'[Time]'] = ','.join([mathematica(JW(W)) for W in quench(7.9e10, 1.1e12, numsteps, tf / numsteps)])
for i in range(L):
    parms['U'+str(i)+'[Time]'] = ','.join([mathematica(UW(W)) for W in quench(7.9e10, 1.1e12, numsteps, tf / numsteps)])

resi = 32
basename = 'DynamicsTasks/bhd.'+str(L)+'.'+str(resi)

start = datetime.datetime.now()

input_file = pyalps.writeInputFiles(basename,[parms])
res = pyalps.runApplication('mps_evolve',input_file,writexml=True)

end = datetime.datetime.now()

data = pyalps.loadIterationMeasurements(pyalps.getResultFiles(prefix=basename), what=['Local density', 'Local density squared', 'One body density matrix', 'Density density'])
# print data[0][0][0]
# quit()

t = []
nt = []
n2t = []
corrt = []
ncorrt = []
for d1 in data:
    for s1 in d1:
Exemple #22
0
          'MEASURE_ENERGY' : True,
        }]

#write the input file and run the simulation
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'
Exemple #23
0
#prepare the input parameters
parms = []
for l in [10, 12, 14, 16]:
    parms.append({
        'LATTICE': "chain lattice",
        'MODEL': "spin",
        'local_S': 0.5,
        'J': 1,
        'L': l,
        'CONSERVED_QUANTUMNUMBERS': 'Sz',
        'Sz_total': 0
    })

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

#load all measurements for all states
data = pyalps.loadSpectra(pyalps.getResultFiles(prefix='parm_chain'))

# collect spectra over all momenta for every simulation
spectra = {}
for sim in data:
    l = int(sim[0].props['L'])
    all_energies = []
    spectrum = pyalps.DataSet()
    for sec in sim:
        all_energies += list(sec.y)
        spectrum.x = np.concatenate(
            (spectrum.x,
Exemple #24
0
#prepare the input parameters
parms = []
for l in [6, 8, 10]:
    parms.append({
        'LATTICE': "ladder",
        'MODEL': "spin",
        'local_S': 0.5,
        'J0': 0,
        'J1': 1,
        'L': l,
        'CONSERVED_QUANTUMNUMBERS': 'Sz',
        'Sz_total': 0
    })

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

#load all measurements for all states
data = pyalps.loadSpectra(pyalps.getResultFiles(prefix='parm_dimers'))

# collect spectra over all momenta for every simulation
spectra = {}
for sim in data:
    l = int(sim[0].props['L'])
    all_energies = []
    spectrum = pyalps.DataSet()
    for sec in sim:
        all_energies += list(sec.y)
        spectrum.x = np.concatenate(
            (spectrum.x,
#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])
Exemple #26
0
        parms.append(
            { 
                 'LATTICE'        : "square lattice", 
                 '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'])
Exemple #27
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')
Exemple #28
0
    p['initial_local_S'] = ','.join(['0.5'] * 50)
    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
for J in Jlist:
    Geometry=np.genfromtxt(args.geofile+'.geo',dtype=str)
    if (args.half):
        Geometry = Geometry[:len(Geometry)/2]

    for i,IncEl in enumerate(Geometry):
 
        parms.append(
            {
                'LATTICE'	: "bilayer",
                'LATTICE_LIBRARY' : "bilayerlib.xml",
                'Interaction' : 'A',
                'beta'		: beta,
                'THERMALIZATION': args.therm,
                'SWEEPS'	: args.sweeps,
                'Interlayer': J,
                'L'		: args.length,
                'M'     : 100,
                'IncStep': IncEl,
                'IncNo' : i
            }
        )

cuts=np.append(np.arange(0,len(parms),args.partsize),len(parms))
print cuts
path=os.path.dirname(args.infile)
for i,[s,e] in enumerate(zip(cuts[:-1],cuts[1:])):
    fname=path+'/'+os.path.basename(args.infile)+'.'+str(i)
    input_file = pyalps.writeInputFiles(fname,parms[s:e])
Exemple #30
0
        parms.append({
            '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$')
Exemple #31
0
parms = [ {
        'optimization'              : 'singlesite',
        'LATTICE'                   : 'open chain lattice',
        'L'                         : 20,
        'MODEL'                     : 'spin',
        'local_S0'                  : '0.5',
        'local_S1'                  : '1',
        'CONSERVED_QUANTUMNUMBERS'  : 'N,Sz',
        'Sz_total'                  : 9,
        'J'                         : 1,
        'SWEEPS'                    : 4,
        'NUMBER_EIGENVALUES'        : 1,
        'MAXSTATES'                 : 50,
        'MEASURE_LOCAL[Spin]'       : 'Sz',
        # 'init_state'                : 'local_quantumnumbers',
        # 'initial_local_Sz'          : ','.join(['0.5']*10+['-0.5']*1+['0.5']*9),#'0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,-0.5',#'1,0,0,0,0,0,0,0,0,0',
        # 'initial_local_S'           : ','.join(['0.5']*20+['-0.5']*0),#'0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,-0.5',#'1,0,0,0,0,0,0,0,0,0',
       } ]

#write the input file and run the simulation
input_file = pyalps.writeInputFiles('SingleSite3/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='SingleSite3/parm_spin_one'))

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

Exemple #32
0
        parms.append({
            '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()
    parms["t" + str(i) + "[Time]"] = ",".join([mathematica(JW(W)[i]) for W in quench(W_i, W_f, xi, tf, dt)])
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: