tcompa / GutzwillerDynamics

Gutzwiller state for the Bose-Hubbard model, with complex and site-dependent coefficients
MIT License
8 stars 2 forks source link

Two-dimensional Lattice Example #1

Open mhasanatgithub opened 3 years ago

mhasanatgithub commented 3 years ago

Hi, If I set D=2, how do I set my type of lattice?

tcompa commented 3 years ago

Hi, By setting D=2, you have a two-dimensional square lattice, with either open boundary conditions (for OBC=1) or periodic boundary conditions (for OBC=0). If you want to use a different two-dimensional lattice (for instance a triangular one), you should modify the method "initialize_lattice".

mhasanatgithub commented 3 years ago

Hi, Thank you very much for the answer. Would you please give an example of how can we implement triangular lattice here!

tcompa commented 3 years ago

Hi, What "initialize_lattice" does, for D=2, is the following

            for i_site in range(self.N_sites):
                self.i2xy(i_site, xy)
                x = xy[0]
                y = xy[1]
                self.site_coords[i_site, :] = xy[:]
                # Case 1: Periodic boundary conditions (PBC):
                if self.OBC == 0:
                    self.N_nbr[i_site] = 4
                    self.nbr[i_site, 0] = self.xy2i((x - 1 + self.L) % self.L, y)
                    self.nbr[i_site, 1] = self.xy2i(x, (y - 1 + self.L) % self.L)
                    self.nbr[i_site, 2] = self.xy2i((x + 1) % self.L, y)
                    self.nbr[i_site, 3] = self.xy2i(x, (y + 1) % self.L)
                # Case 2: Open boundary conditions (OBC):
                else:
                    self.N_nbr[i_site] = 0
                    if x > 0:
                        self.nbr[i_site, self.N_nbr[i_site]] = self.xy2i((x - 1 + self.L) % self.L, y)
                        self.N_nbr[i_site] += 1
                    if y > 0:
                        self.nbr[i_site, self.N_nbr[i_site]] = self.xy2i(x, (y - 1 + self.L) % self.L)
                        self.N_nbr[i_site] += 1
                    if x < self.L - 1:
                        self.nbr[i_site, self.N_nbr[i_site]] = self.xy2i((x + 1) % self.L, y)
                        self.N_nbr[i_site] += 1
                    if y < self.L - 1:
                        self.nbr[i_site, self.N_nbr[i_site]] = self.xy2i(x, (y + 1) % self.L)
                        self.N_nbr[i_site] += 1

that is, it sets the values of:

To do so, it makes use of the methods xy2i (which transforms an (x,y) pair into a single integer) and i2xy (which implements the inverse transformation).

This is all for a square lattice. To implement a triangular lattice, you should at least find out how to identify the neighbors of each site (which will have to be six, instead of the four neighbors on a square lattice) - see lines 177-181 or 184-196. On top of that, you may also want to change site_coords (don't forget to make it a float variable, if needed).