JuliaPhysics / Lattices.jl

A Lattice Library for Julia
https://juliaphysics.github.io/Lattices.jl
Apache License 2.0
34 stars 6 forks source link

Name convention and structure change #4

Open Roger-luo opened 5 years ago

Roger-luo commented 5 years ago

Iterator API

Iterator wrapper type

Currently, when use sites/edges/etc. an iterator without any information of the lattice will be returned. This makes it less general and may cause type privacy while supporting the follow interface (useful when generating couplings):

ltc = Chain(10)
rand(Float64, edges(ltc))

ltc = Square(10, 10)
rand(edges(ltc))

We can have a wrapper iterator type for LatticeIterators

struct LatticeIterator{LTC, Iterator}
     lattice::LTC
     it::Iterator
end

and it will directly forward Base.iterate, Base.length, Base.size, etc. to LatticeIterator.it, but we can define rand(::Type{T}, ltc::LatticeIterator) = rand(T, size(ltc)) in general without any type privacy.

Boundary Conditions

This will allow the follow syntax:

# module Boundary is exported, but not used
using Lattices

ltc = Chain(10; boundary=:open)
ltc = Chain(10; boundary=:periodic)

@mbeach42 @crstnbr comments?

mbeach42 commented 5 years ago

LatticeIterators sounds good, that way we can include info about the lattice, like boundary conditions, when generating couplings or on-site field terms.

carstenbauer commented 5 years ago

I agree with basically everything you wrote :)