# Welcome to the documentation of Lattice.jl

This is a Julia package for defining lattices in Julia.

All lattice type in this package is **duck typed**. Any Julia type with the **(Geometric) Region/Lattice Interface** can be considered as a (geometric) region/lattice.

## Interfaces

#### Conversion between lattice position and serial number

#### Site iterator

**function**: `sites`

#### Edge iterator

**function**: `edges`

#### Surround iterator (Optional)

**function**: `surround`

#### Face iterator (Optional)

**function**: `faces`

#### Neighbor sites iterator (Optional)

**function** `neighbors`

## Lattices

`Lattices.BoundedLattice`

— Type.`BoundedLattice{N, BC} <: AbstractLattice{N}`

A lattice with boundary conditions `BC`

on `N`

dimension.

`Lattices.Fixed`

— Type.`Fixed <: BoundaryCondition`

Fixed boundary condition.

`Lattices.HyperRect`

— Type.`HyperRect{N, Shape, BC} <: BoundedLattice{N, BC}`

Hyper Rectangle lattice on `N`

dimension with size `Shape`

.

`Lattices.Periodic`

— Type.`Periodic <: BoundaryCondition`

Periodic boundary condition.

`Lattices.boundary`

— Function.`boundary(lattice) -> BoundaryCondition`

Returns lattice's boundary condition.

`Lattices.edges`

— Function.`edges(lattice; [order=1]) -> iterator`

Returns an iterator for all edges of the lattice of a given `order`

. For example, `order = 1`

means nearest neighbor edges and `order = 2`

means next-nearest neighbors edges.

`Lattices.faces`

— Function.`faces(lattice) -> iterator`

Returns an iterator of all faces.

`Lattices.isperiodic`

— Function.`isperiodic(lattice) -> Bool`

Check if this lattice's boundary condition is periodic.

`Lattices.neighbors`

— Function.`neighbors(lattice, s; order=1) -> iterator`

Returns an iterator of the surrounding sites of given site `s`

.

`Lattices.sites`

— Function.`sites(lattice) -> iterator`

Returns an iterator for all sites on the lattice.

`Lattices.surround`

— Function.`surround(lattice) -> iterator`

Returns an iterator of surroundings of all sites.

`surround(lattice, site) -> iterator`

Returns an iterator of surrounding sites of given `site`

.

`Lattices.AbstractLattice`

— Type.`AbstractLattice{N}`

Abstract type for general lattices. `N`

indicates the dimension. For a more concrete definition please refer the following material:

- Lattice (group): https://en.wikipedia.org/wiki/Lattice_(group)
- Lattice Model: https://en.wikipedia.org/wiki/Lattice
*model*(physics) - Lattice Graph: https://en.wikipedia.org/wiki/Lattice_graph

`Lattices.BoundaryCondition`

— Type.`BoundaryCondition`

Boundary conditions for lattices. There usually has two:

```
- Fixed boundary
- Periodic boundary
```

Ref: https://nanohub.org/resources/7577/download/Martini*L5*BoundaryConditions.pdf

`Base.length`

— Method.`length(lattice) -> Int`

Returns the length of this lattice, or the production of each dimension size.

`Base.nameof`

— Method.`name(lattice) -> String`

Returns the name of this lattice.

`Base.ndims`

— Method.`ndims(lattice) -> N`

Returns number of dimensions of the lattice.

`Base.size`

— Method.`size(lattice) -> Tuple`

Returns the size of this `lattice`

.

`Lattices.fastmod1`

— Method.`fastmod1(::Val{X}, ::Val{Y})`

`mod1`

in compile time, 40x faster if the value can be determined