issp-center-dev / TeNeS

Massively parallel tensor network solver
http://www.pasums.issp.u-tokyo.ac.jp/tenes/en
GNU General Public License v3.0
46 stars 11 forks source link

RuntimeError(msg) #46

Open HamidArianZad opened 2 years ago

HamidArianZad commented 2 years ago

Dear NeNeS establishers,

During introducing my own lattice in tenes_simple file I got some errors in tenes_std lines. Please let me know where is the problem and how can I fix this problem.

My own lattice structure is as below figure:

Martini_Kagome_1

The code that I reformed in tenes_simple file is as following:

class KagomeLattice(Lattice):
    def __init__(self, param: Dict[str, Any]):
        super().__init__(param)
        self.type = "kagome lattice"
        self.z = 3

        self.L *= 2
        self.W *= 2

        L, W = self.L, self.W

        self.latticevector = np.array([[1.0, 0.0], [0.5, np.sqrt(3.0) / 2]])
        self.latticevector *= np.array([[L], [W]])

        a0 = np.array([1.0, 0.0])
        a1 = np.array([0.5, np.sqrt(3.0) / 2])

        vd = self.vdim
        self.sublattice.append(SubLattice([1, vd, vd, 1]))
        self.sublattice.append(SubLattice([1, 1, vd, vd]))
        self.sublattice.append(SubLattice([vd, 1, 1, vd]))
        self.sublattice.append(SubLattice([vd, vd, 1, 1]))

        # Martini lattice 1: 
        for index in range(L * W):
            x, y = index2coord(index, L)

            if x % 2 == 0 and y % 2 == 0:
                #
                # sublattice A
                #
                self.sublattice[0].add_site(index)
                self.coords.append(a0 * x + a1 * y)

                # 1st neighbors
                self.bonds[0][0].append(Bond(index, 1, 0))
                self.bonds[0][0].append(Bond(index, 0, 1))

            elif x % 2 == 1 and y % 2 == 0:
                #
                # sublattice B
                #
                self.sublattice[1].add_site(index)
                self.coords.append(a0 * x + a1 * y)

                # 1st neighbors
                self.bonds[0][1].append(Bond(index, 0, 1))
                self.bonds[0][0].append(Bond(index, -1, 1))

            elif x % 2 == 0 and y % 2 == 1:
                #
                # sublattice C
                #
                self.sublattice[2].add_site(index)
                self.coords.append(a0 * x + a1 * y)

                # 1st neighbors
                self.bonds[0][1].append(Bond(index, -1, 0))

            elif x % 2 == 1 and y % 2 == 1:
                #
                # sublattice D
                #
                self.sublattice[3].add_site(index)
                self.coords.append(a0 * x + a1 * y)

                # 1st neighbors
                self.bonds[0][1].append(Bond(index, 1, 1))

    def cartesian_coordinate(self, x: int, y: int) -> np.ndarray:
        a0 = np.array([1.0, 0.0])
        a1 = np.array([0.5, np.sqrt(3.0) / 2])
        return a0 * x + a1 * y 

In fact, when I consider following sequence for virtual_dim in Sublattices (full connection) everything works normally and I could calculate the magnetization,

self.sublattice.append(SubLattice([vd, vd, vd, vd]))
self.sublattice.append(SubLattice([vd, vd, vd, vd]))
self.sublattice.append(SubLattice([vd, vd, vd, vd]))
self.sublattice.append(SubLattice([vd, vd, vd, vd]))

But my own lattice has just three connections which two of them are counted as virtual_dim. So, I considered below sequence for the virtual_dim of Sublattices:

self.sublattice.append(SubLattice([1, vd, vd, 1]))
self.sublattice.append(SubLattice([1, 1, vd, vd]))
self.sublattice.append(SubLattice([vd, 1, 1, vd]))
self.sublattice.append(SubLattice([vd, vd, 1, 1]))

and I got following error:

martini2.py > output.dat
Traceback (most recent call last):
  File "/home/arian/bin/tenes_std", line 903, in <module>
    model = Model(param)
  File "/home/arian/bin/tenes_std", line 726, in __init__
    self.unitcell = Unitcell(param["tensor"])
  File "/home/arian/bin/tenes_std", line 218, in __init__
    self.load_dict(lat_dict)
  File "/home/arian/bin/tenes_std", line 239, in load_dict
    self.check()
  File "/home/arian/bin/tenes_std", line 360, in check
    raise RuntimeError(msg)
RuntimeError: ERROR: some sites have problems
[INPUT ERROR]
ERROR: cannot find the input file: input_0_500.toml

Traceback (most recent call last):
  File "magnetization_martini2.py", line 50, in <module>
    with open(join("output_{}_{}".format(idx, num_step), "density.dat")) as f:
FileNotFoundError: [Errno 2] No such file or directory: 'output_0_500/density.dat'`
yomichi commented 2 years ago

TeNeS always treats tensors on a square lattice. Each tensor has four legs; left, top, right, and bottom. self.sublattice.append(SubLattice([1, vd, vd, 1])) means that the bond dimension of this site tensor is as follows:

This error is occurred due to the mismatch of dimensions, for example, the first site (left-bottom of a plaquette) has the right bond (the third bond) with the bond dimension vd, but the second one (right-bottom) has the left bond (the first bond) with the bond dimension 1. (Probably we can make tenes_std say more detailed information about this error. )

Additionally, tenes_std split an imaginary time evolution tensor on a next-nearest neighbor bond on a square lattice into a series of tensors on the two nearest-neighbor bonds. Therefore, I'd recommend that you set the right bond of the right-top tensor (and the left bond of the left-top tensor, of course) has finite dimension (vd).

By the way, some of the bonds in your code seem wrong;

HamidArianZad commented 2 years ago

Thank you very much for your response. I checked the correlation length of this lattice and found that in the +x direction this quantity is zero. For example for a low magnetic field I found below results in the corresponding output folder:

` 0 0 0.00000000000000000e+00 inf inf inf

0 1 0.00000000000000000e+00 inf inf inf

0 2 0.00000000000000000e+00 inf inf inf

0 3 0.00000000000000000e+00 inf inf inf

1 0 6.91811812190026715e-02 1.44547980011263562e+01 1.44547980011263562e+01 1.54931776659866092e+01

1 1 4.48277119609480468e-01 2.23076297284848390e+00 2.23130324778387390e+00 4.46091126212284461e+00

1 2 6.82987455583639186e-02 1.46415573496216158e+01 1.46415573496216158e+01 1.54260987895730555e+01

1 3 4.48311619591070243e-01 2.23059130368326208e+00 2.23112080295601611e+00 4.46057997789315852e+00 `

yomichi commented 2 years ago

It seems to me that correlations along x-direction are absent. Could you show the bond dimensions of virtual bonds? If you set all the bond dimensions to vd (finite), what happens?

HamidArianZad commented 2 years ago

Please find in below the bond dimensions of virtual bonds that recorded in output files (I considered {L = 3 W = 3} to get accurate results for ground-state magnetization):

[tensor] L_sub = [6, 6] skew = 0 [[tensor.unitcell]] index = [0, 2, 4, 12, 14, 16, 24, 26, 28] physical_dim = 2 virtual_dim = [1, 2, 2, 1] initial_state = [0.0, 0.0] noise = 0.01 [[tensor.unitcell]] index = [1, 3, 5, 13, 15, 17, 25, 27, 29] physical_dim = 2 virtual_dim = [2, 1, 1, 2] initial_state = [0.0, 0.0] noise = 0.01 [[tensor.unitcell]] index = [6, 8, 10, 18, 20, 22, 30, 32, 34] physical_dim = 2 virtual_dim = [2, 1, 2, 2] initial_state = [0.0, 0.0] noise = 0.01 [[tensor.unitcell]] index = [7, 9, 11, 19, 21, 23, 31, 33, 35] physical_dim = 2 virtual_dim = [2, 2, 2, 1] initial_state = [0.0, 0.0] noise = 0.01

[parameter] [parameter.general]

is_real = true

[parameter.simple_update] num_step = 1000 tau = 0.01

[parameter.full_update] num_step = 0 tau = 0.01

[parameter.ctm] iteration_max = 100 dimension = 10

[lattice] type = "kagome lattice" L = 2 W = 2 initial = "ferro" virtual_dim = 2

[model] type = "spin" J0 = 1 J1 = 1

  1. Should I keep fixed values {W=2, L=2} and just play with D and ctm parameters {iteration_max, dimension} to get acceptable results for the magnetization? Or W>2 and L>2 can be accepted with physical interpretation in tensor-network method employed by TeNeS?

If you set all the bond dimensions to vd (finite), what happens?

I set all bond dimensions to vd (3) and found that the correlation length has not zero value (i.e., see some results in below).

0 0 8.85343634758468889e-01 1.12950492976979566e+00 1.22009533765149270e+00 1.22009533765149270e+00 0 1 8.52127712339509458e-01 1.17353301097849338e+00 1.21659023827259860e+00 1.21659023827259860e+00 0 2 9.99073631673219831e-01 1.00092722728076478e+00 1.21804145723678792e+00 1.21804145723678792e+00 0 3 8.37026728586644175e-01 1.19470497876279680e+00 1.21698025199151272e+00 1.24108067549016332e+00 1 0 9.67810368052768433e-01 1.03326026772372459e+00 1.07047372564791088e+00 1.11897021034661326e+00 1 1 9.54141627364600953e-01 1.04806243781865249e+00 1.15188174191459525e+00 1.66412271197779771e+00 1 2 9.68407120565518253e-01 1.03262355135930073e+00 1.07675699301875882e+00 1.15089824525182238e+00 1 3 9.46600088200868717e-01 1.05641232497730320e+00 1.13492249797285116e+00 1.64773035040992100e+00

yomichi commented 2 years ago

I set all bond dimensions to vd (3) and found that the correlation length has not zero value

Great.

Does the value D=2 (that is the lowest value of virtual dim) support the accuracy of the ground-state energy results?

It is the users' responsibility to check the convergence with respect to D.

Should I keep fixed values {W=2, L=2} and just play with D and ctm parameters {iteration_max, dimension} to get acceptable results for the magnetization? Or W>2 and L>2 can be accepted with physical interpretation in tensor-network method employed by TeNeS?

An iTPS with {W, L} can represent states with a spatial periodicity of W by L. Of course, if the ground state has a longer period, you should enlarge the value of W and L.

To solve problems by iTPS+CTMRG, we need many approximations; periodicity (W, L), bond-dimension (D, chi), Suzuki-Trotter decomposition (tau, number of steps), ... Users should check the convergence of these controlled parameters (W, L, D, ...) step by step.

HamidArianZad commented 2 years ago

I changed all mentioned parameters to converge the results to the accurate values. I eventually found that the parameters in below simple.toml file could act efficiently to reach reasonable convergence:


[parameter] [parameter.general]

is_real = true

[parameter.simple_update] num_step = 1000 tau = 0.01

[parameter.full_update] num_step = 0 tau = 0.01

[parameter.ctm] iteration_max = 100 dimension = 5 # (4<chi<10)

[lattice] type = "kagome lattice" L = 3 W = 3 initial = "ferro" virtual_dim = 2

[model] type = "spin" J0 = 1 J1 = 1

Ultimately I could obtain below results for the magnetization.

mag_martini lattice 1_JH1

TeNeS nicely reproduces all plateaus (M/M_s = {1/12, 1/6, 1/4}) and the corresponding jumps at the accurate critical magnetic fields. The problem is why at some values of the magnetic field, magnetization behaves anomalously? I tried to reproduce all magnetization plateaus and jumps normally by changing all controlled parameters (W, L, D, chi ...) step by step, but whenever a magnetization jump occurs at some points (indicated by circles) the TeNeS's result deviates from the normal increasing mode.
This problem is obvious even in figure 8 (b) of your publication (see below figure). Is there any technical interpretation for this phenomenon? Or, if you know any way to address this problem please let me know, too.

Triangular_Tenes_Mag

yomichi commented 1 year ago

I'm very sorry for the late reply. TeNeS searches for the ground state by using an iterative method (imaginary time evolution) and hence the initial state affects the result, particularly near the transition point. One of the remedies is to take the obtained state at the deep of the phase as an initial state.