Ejemplo n.º 1
0
def compute(n):
    spins = [2 for i in range(n)]
    sc = spinchain.Spin_Chain(spins)  # create the chain
    sc.clean()
    sc = spinchain.Spin_Chain(spins)  # create the chain

    def fj(i, j):
        if 0.9 < abs(i - j) < 1.1: return 1.0
        return 0.0

    sc.set_exchange(fj)  # set exchange couplings
    #sc.set_fields(lambda x: [0.2,0.2,0.2]) # set exchange couplings
    sc.maxm = 10
    sc.nsweeps = 2
    sc.get_gs()
    i = 0
    j = 1
    t0 = time.time()
    sc.fit_td = True
    #  (x,y) = sc.evolution(nt=100,dt=0.03,name="ZZ",i=i,j=j)
    (x2, y2) = sc.get_dynamical_correlator(es=es, use_kpm=False, dt=0.1)
    t1 = time.time()
    print("Time", t1 - t0)
    return t1 - t0
Ejemplo n.º 2
0
# Add the root path of the dmrgpy library
import os
import sys
sys.path.append(os.getcwd() + '/../../src')

import numpy as np
import spinchain
n = 20
spins = [2 for i in range(n)]  # spin 1/2 heisenberg chain
sc = spinchain.Spin_Chain(spins)  # create the spin chain


# dimerized coupling
def fj(i, j):
    if abs(i - j) == 1:
        ij = (i + j) % 4
        dj = -0.2
        if ij == 1: return 1.0 + dj
        else: return 1.0 - dj
    return 0.0


sc.set_exchange(fj)  # set those exchange couplings
sc.kpmmaxm = 10  # KPM max m
fo = open("DCF.OUT", "w")  # dynamical correlation function
for i in range(n):  # loop over sites
    (xs, ys) = sc.get_spismj(n=1000, mode="DMRG", i=i, j=i)
    print("Doing", i)
    for (x, y) in zip(xs, ys):
        fo.write(str(i) + "  ")
        fo.write(str(x) + "  ")