Lattice functions in itensor Julia

Hi, ITensor term

I’m learning to use itensor Julia to test some properties of a 2D Rydberg lattice. For some reason, the latticebond of the third nearest neighbor is needed.

But I found that in itensor julia there are only nearest neighbors. I would like to ask, do I need to write the latticebond function of the second nearest neighbor and the third nearest neighbor by myself?
kevinH

Hi KevinH,
Thanks for the question. Yes, unfortunately that would be something you’d need to write yourself because we don’t have it as an option currently. (I assume you meant as an option to the function square_lattice?)

As you may imagine, there are a huge number of possible options we could offer for these lattice functions, going to ever more complicated lattices and bonds of different distances and we haven’t worked out a generic way to do it other than coding up all of the possible casees. So we are relying on our community to tell us of other cases they may need, or even better, contributing improvements to those codes by sending us a pull request on Github.

If you do decide to add the second- and third-neighbor lattice bonds, please let us know if you have any questions about the use of the LatticeBond type or the design of that code.

Best regards,
Miles

If it’s helpful, the code for square_lattice (and the other lattice functions and helper objects) can be found here:

Hi Miles
Thank you very much for your reply. In fact, I found that there is a latticebond function for the second nearest neighbor of square_lattices in itensor c++. This helped me a lot.

But for the third nearest neighbor, I have a naive idea.Do I just need to convert a few terms like latt[b += 1] = LatticeBond(n, n + Ny, x, y, x + 1, y) to latt[b += 1] = LatticeBond(n, n + ny, x, y, x + 2, y) can write the next nearest neighbor latticebond function?

From my answer above, you can probably see that I can understand how latticebond is written, but do not know how to write latticebond myself. Especially the part about yperiodic. I’m not quite sure how to completely loop through all the required latticebond. Perhaps, some experience and methods of writing latticebond function will be very useful to me.

Thanks again for your kind reply.

kevinH

Hi KevinH,
This may not answer all of your questions, but first of all I can tell you a bit more about what the data in a LatticeBond object means so you can be sure to write the third neighbor terms correctly.

A key thing is getting the s1 and s2 arguments (n,n+Ny and things like that) correct when making a LatticeBond. The meaning of these integers are the sites along a one-dimension “zig zag” path going through the lattice. This is because the primary use of LatticeBond is for making MPO tensor networks which are one-dimensional.

First, I’m providing a drawing of what I mean by a zig-zag path through an (Nx=4,Ny=4) square lattice. Note how the site numbers go up the first column (1,2,3,4), then jump to the bottom again (5,6,7,8) and so on.

I’ve drawn all of the first and second neighbor bonds, for the case of yperiodic=false and I drew two of the third-neighbor bonds that you want to make.

Now let’s take the first-neighbor bonds coming out of site 6 as an example. You can see that the one going up connects to a site number that is one higher, so then we would make the LatticeBond for this bond as

LatticeBond(n,n+1,x,y,x,y+1)

Then let’s take the bond going to the right out of site 6. This one connects to site 10 which is 6+4 or 6+Ny where Ny=4 in this example. So for that kind of bond, we make a LatticeBond like

LatticeBond(n,n+Ny,x,y,x+1,y)

So for third-neighbor bonds, the pattern you will need is something like n,n+2 for the vertical bonds going up and n,n+2*Ny for the horizontal bonds going to the right. But then in the code you can see additional care is needed to make these bonds only when there is actually a valid site to connect to. So for the example of first-neighbor bonds going up, we only make them when y < Ny otherwise we are at the top of the lattice and there are no more sites above to connect to.

I hope that helps explain most of the non-periodic bonds and how to make them.

For the y-periodic bonds, what you do is imagine another copy of the system above, with the same site numberings and everything. So in the drawing above (though I don’t show any periodic bonds explicitly there), if yperiodic=true then there would be a first-neighbor bond coming out of the top of site 4 connecting to the site “above” which is actually site 1 again. So we need a bond connecting site 1 to site 4 and that is what is made in the code for the case of if yperiodic && y == 1. You would do something similar for second- and third-neighbor bonds, drawing a second copy of the system above and working out the connections of the bonds that come out of the top of the lattice.’’

Here is a drawing of how to see the case of yperiodic=true and the first-neighbor bonds sticking out of the top:

Hope that helps!

Finally, I would suggest putting your function through a lot of tests. Count the number of bonds it returns: is it the right number for a bunch of different lattices? Maybe you can also run DMRG on an MPO made from your modified lattice function for a solvable case of your Hamiltonian (like say if it is a fermion system and there is a non-interacting limit) so you can compare your DMRG result to a numerically exact result.

Hi,miles

Thank you very much for your reply to this question. After reading your answer, combined with the relevant code of itensor c++. I have learned, and have successfully written a latticebond function for the third nearest neighbor bonds of a square_lattice.

The answers from you and all the members of the itensor team are very useful for the beginner like me.Thank you for your dedication.

1 Like

Glad it was helpful!