Lattice2D.jl

A Julia package for constructing and visualizing 2D lattices for quantum many-body physics simulations.

Installation

using Pkg
Pkg.add("Lattice2D")

Models

The models implemented in this module is below.

Lattice2D.BondType
Bond

struct for a bond (edge) in the lattice.

  • src::Int: start site index
  • dst::Int: destination site index
  • type::Int: type of the bond for categorization
  • vector::Vector{Float64}: expresses the bond vector from src to dst
source
Lattice2D.ConnectionType
Connection

Connection rules within or between unit cells.

  • src_sub: sublattice index of the start point (1, 2, ...)
  • dst_sub: sublattice index of the end point
  • dx, dy: relative cell position of the end point (0,0 means within the same unit cell)
  • type: type of the connection
source
Lattice2D.DiceType
Dice <: AbstractTopology{2}

struct which represents Dice lattice (T3 lattice) Bipartite lattice with coordination numbers 6 (Hub) and 3 (Rim).

source
Lattice2D.LatticeType

Lattice{Topology<:AbstractTopology, T, B<:AbstractBoundaryCondition, I<:AbstractIndexing} It mainly represents 2-dimiensional lattice, but it can be used as 1-dimensional lattice as well.

  • Lx::Int: x direction lattice size
  • Ly::Int: y direction lattice size
  • N::Int: total number of sites
  • positions::Vector{Vector{T}}: position vectors of each site
  • nearest_neighbors::Vector{Vector{Int}}: nearest neighbor indices for each site
  • bonds::Vector{Bond}: list of bonds (edges) in the lattice
  • basis_vectors::Vector{Vector{T}}: lattice basis vectors
  • reciprocal_vectors::Union{Vector{Vector{T}}, Nothing}: reciprocal lattice vectors
  • sublattice_ids::Vector{Int}: sublattice IDs of each site
  • is_bipartite::Bool: whether the lattice is bipartite
  • site_map::Union{Matrix{Int}, Nothing}: mapping of site indices on the lattice
  • translation_x::Vector{Int}: x direction translation vector
  • translation_y::Vector{Int}: y direction translation vector
  • boundary::B: boundary condition
  • index_method::I: indexing method
source
Lattice2D.UnionJackType
UnionJack <: AbstractTopology{2}

struct which represents Union Jack (Centered Square) lattice.

source
Lattice2D.UnitCellType
UnitCell{D, T}

Geometric definition data of the lattice. Basically, the lattice is constructed based on this information. The get_unit_cell(::Type{T}) function retrieves the unit cell data corresponding to each topology.

source
Lattice2D._coord_to_indexMethod
_coord_to_index(lat::Lattice, x::Int, y::Int, s::Int)

this function converts lattice coordinates to a linear index based on the lattice's indexing method.

  • ColMajorIndexing
  • RowMajorIndexing
  • SnakeIndexing

are available indexing methods.

source
Lattice2D.build_latticeMethod
build_lattice(Topology::Type{<:AbstractTopology}, Lx::Int, Ly::Int; boundary::AbstractBoundaryCondition=PBC())

Construct a lattice with the specified topology, size, and boundary conditions. this function is available if unitcell information is defined.

source
Lattice2D.get_coordinatesMethod
get_coordinates(lat::Lattice, idx::Int)

Get the lattice coordinates (x, y, sublattice) from a linear site index.

Arguments

  • lat::Lattice: The lattice structure
  • idx::Int: The linear site index

Returns

  • Tuple{Int, Int, Int}: A tuple (x, y, s) where x, y are unit cell coordinates and s is sublattice index

Examples

lat = build_lattice(Honeycomb, 4, 4)
x, y, s = get_coordinates(lat, 10)
source
Lattice2D.get_positionMethod
get_position(lat::Lattice, idx::Int)

Get the spatial position (coordinates) of a site given its linear index.

Arguments

  • lat::Lattice: The lattice structure
  • idx::Int: The linear site index

Returns

  • Vector{Float64}: The position vector [x, y] in real space

Examples

lat = build_lattice(Square, 4, 4)
pos = get_position(lat, 5)  # Get position of site 5
source
Lattice2D.get_site_indexFunction
get_site_index(lat::Lattice, x::Int, y::Int, s::Int=1)

Get the linear site index from lattice coordinates (x, y) and sublattice index s. For single-sublattice lattices, s defaults to 1.

Arguments

  • lat::Lattice: The lattice structure
  • x::Int: x-coordinate (1 to Lx)
  • y::Int: y-coordinate (1 to Ly)
  • s::Int: sublattice index (1 to number of sublattices), defaults to 1

Returns

  • Int: The linear site index

Examples

lat = build_lattice(Square, 4, 4)
idx = get_site_index(lat, 2, 3)  # Get index at (2,3)

lat = build_lattice(Honeycomb, 4, 4)
idx_A = get_site_index(lat, 1, 1, 1)  # Get sublattice A at (1,1)
idx_B = get_site_index(lat, 1, 1, 2)  # Get sublattice B at (1,1)
source
Lattice2D.get_unit_cellMethod
get_unit_cell(::Type{T}) where T <: AbstractTopology

this function returns the UnitCell associated with the given Topology type. If the Topology type is not recognized, it throws an error.

source