Quantum-Many-Body / QuantumLattices.jl

Julia package for the construction of quantum lattice systems.
https://quantum-many-body.github.io/QuantumLattices.jl
Other
108 stars 9 forks source link

Plot of lattice is incorrect #29

Closed Yaraslaut closed 1 year ago

Yaraslaut commented 1 year ago

Hi, I was trying to plot some simple lattices, such as l = Lattice((0.0, 0.0), (0.5, 0.5); vectors=[[1.0, 0.0], [0.0, 1.0]], name=:Square) with plot(l,4) And I see following picture image

waltergu commented 1 year ago

Hi, I was trying to plot some simple lattices, such as l = Lattice((0.0, 0.0), (0.5, 0.5); vectors=[[1.0, 0.0], [0.0, 1.0]], name=:Square) with plot(l,4) And I see following picture image

This is the "correct" picture of the lattice you just defined. Of course some explanations are needed: the small solid circles are the two points of the lattice in the unit cell, and lines denote the bonds that are within and beyond the unit cell.

waltergu commented 1 year ago

To get an ordinary view of the bonds on a finite lattice, you should not use a lattice that is defined only in a unit cell with periodic boundary conditions such as

Lattice((0.0, 0.0), (0.5, 0.5); vectors=[[1.0, 0.0], [0.0, 1.0]])

This kind of lattice is a representation of the infinite translation-invariant lattice.

On the contrary, it is recommended to define a lattice containing several unit cells with the open boundary condition:

# construct the unit cell first
unitcell = Lattice((0.0, 0.0); vectors=[[1.0, 0.0], [0.0, 1.0]], name=:Square)

# construct a finite lattice containing several unit cells with the open boundary condition
finitelattice = Lattice(unitcell, (4, 4))

Then the plot of this finite lattice would be just fine:

plot(finitelattice, 2)

lattice

The above code displays the points (0th order bonds), the nearest-neighbor bonds and the next-nearest-neighbor bonds. That it to say, up to the 2nd nearest neighbor of bonds are shown. When only some specific orders of nearest-neighbor bonds are wanted, a filter can be passed to the plot function:

plot(finitelattice, 4, bond::Bond->bond.kind in (0, 2))

lattice

Yaraslaut commented 1 year ago

Oh, I see Thanks a lot for explanation Maybe I can write something in documentation for that :)