Giter Club home page Giter Club logo

Comments (3)

tcompa avatar tcompa commented on August 19, 2024

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".

from gutzwillerdynamics.

mhasanatgithub avatar mhasanatgithub commented on August 19, 2024

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

from gutzwillerdynamics.

tcompa avatar tcompa commented on August 19, 2024

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).

from gutzwillerdynamics.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.