Graphs
Currently only the square lattice is implemented
Square lattice
Create a square lattice with periodic or open boundary conditions:
julia> using LatticeModels
julia> lato = SQLattice_open{Int}(5,5)
5×5 SQLattice_open{Int64}: 3 5 … 139974786229392 10 3 139974786229072 9 10 139974786228944 139974786229136 9 139974786229584 139974786229008 6 139974786229456 139974786229648 4 6 139974786229520 139972984176641
julia> latp = SQLattice_periodic{Int}(5,5)
5×5 SQLattice_periodic{Int64}: 139974822420488 139974822420488 … 139974822420488 139974822420488 139974822420488 139974822420488 139974822420488 139974822420488 139974822420488 139974822420488 139974822420488 139974822420488 139974822420488 139974822420488 139974822420488 139974822420488 139974822420488 139974822420488 139974822420488 139974822420488
Index with integers, CartesianIndex
or with a Site
object. The latter knows about boundary conditions and lattice topology.
julia> lato .= reshape(1:length(lato),size(lato))
5×5 SQLattice_open{Int64}: 1 6 11 16 21 2 7 12 17 22 3 8 13 18 23 4 9 14 19 24 5 10 15 20 25
julia> latp .= reshape(1:length(lato),size(latp))
5×5 SQLattice_periodic{Int64}: 1 6 11 16 21 2 7 12 17 22 3 8 13 18 23 4 9 14 19 24 5 10 15 20 25
julia> lato[1,1] + latp[1,1]
2
julia> I = SQLattice_site(lato,1,1)
SQLattice_site{SQLattice_open{Int64}}([1 6 … 16 21; 2 7 … 17 22; … ; 4 9 … 19 24; 5 10 … 20 25], CartesianIndex(1, 1))
julia> J = SQLattice_site(latp,1,1)
SQLattice_site{SQLattice_periodic{Int64}}([1 6 … 16 21; 2 7 … 17 22; … ; 4 9 … 19 24; 5 10 … 20 25], CartesianIndex(1, 1))
julia> foreach_neighbour(I) do s println(s) end
2 6
julia> foreach_neighbour(J) do s println(s) end
5 2 21 6