Open mhasanatgithub opened 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".
Hi, Thank you very much for the answer. Would you please give an example of how can we implement triangular lattice here!
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:
self.site_coords
: an array with the (x,y) coordinates of each site,self.N_nbr
: an array with the number of nearest neighbors for each site,self.nbr
: an array which lists the nearest neighbors of each site.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).
Hi, If I set D=2, how do I set my type of lattice?