Coder Social home page Coder Social logo

juliaphysics / lattices.jl Goto Github PK

View Code? Open in Web Editor NEW
35.0 7.0 6.0 126 KB

A Lattice Library for Julia

Home Page: https://juliaphysics.github.io/Lattices.jl

License: Apache License 2.0

Julia 100.00%
lattices geometry tiling julia hacktoberfest

lattices.jl's People

Contributors

carstenbauer avatar emerali avatar juliatagbot avatar roger-luo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

lattices.jl's Issues

Helical/Snake Boundaries

Helical BCs are a fast approximation to Periodic BCs which make use of the linear storage of arrays to scrape off some computational overhead associated with accessing N-dimensional arrays. See Chapter 13 of Newman and Barkema's book: "Monte Carlo Methods in Statistical Physics" for an overview, or Wikipedia for a very brief summary of the HyperCubic case. People familiar with DMRG will recognize this as something similar to the "Snake" boundary condition.

It is, however, difficult to implement in a clean way:

  • For one, there isn't an easy way to mix Helical BCs with other boundary conditions since it's a "global" boundary condition, as opposed to Periodic or Open BCs which can be applied to each dimension independently (though you probably don't want to mix Helical with anything else anyway).
  • Methods dealing with Helical BCs will treat lattice sites as single integers, while methods for Open/Periodic BCs treat lattice sites a Coordinates. This isn't a type-stability issue (since we're dispatching on the BC type anyway), more of a user-experience one.
  • When using Helical BCs we often only want to specify the number of sites in a lattice directly, however, we don't necessarily set this number to be equal to the product of the dimensions. For example, one could represent a 2D square lattice of size 5x4 with only 18 sites. This conflicts with the fact that we're storing the lengths of each dimension separately in the Lattice struct.

So my question is: will people use Helical BCs? Please comment below if you believe you will.

Implement a complex lattice to check scaling

I wonder if the approach taken in this package "scales" to larger, complex, higher-dimensional lattices. Currently, there is no explicit unit cell concept, all sites are at integer positions (#10) and boundary conditions are implemented explicitly.

Perhaps, we should try implementing a complex lattice, where generating all the lattice iterators is non-trivial to convince ourselves that the abstract concepts hold in such a case. What do you think? @mbeach42 @Roger-luo

(EDIT: We could consider the monster lattice (10,3,c), for example: https://github.com/janattig/LatPhysUnitcellLibrary.jl/blob/master/src/unitcells_3d/10_3_c.jl)

Implement bonds iterator

Now that the neighbors iterator is set-up, we can define the bonds iterator

For now we'll focus just on 2-local bonds, but should at least leave the implementation general enough to implement n-local bonds in the future.

Fixed or Open

I think in a lot places it is called open boundary instead of fixed? But it might be too general to use Open as the name of boundary type.

and I'm wondering if the default boundary condition should be open?

[Feature] Type for site coordinates

2018-12-26 Updated

Use CartesianIndex instead of Tuple, this will make the returned site position became real indices while indexing real lattice configurations.

new lattice design

I'd like to move discussions around the new lattice design here. So we have something to keep track of.

move to JuliaPhysics

a few things need to be revised after the move:

  • change README
  • check CI & doc builds

Update: link to docs is broken...somehow

Implement k-th Nearest Neighbors for HyperCubic Lattices

Naive-but-General Nearest Neighbor Strategy:

  • Generate all lattice vectors with maximum component = k
  • Compute their lengths wrt some norm
    • for a square lattice, this is the euclidean norm
    • for a rectangular lattice we'd need to take the lattice constants into account
    • other lattices (hexagon, triangular, etc) would involve different metrics
  • Select all lattice vectors which correspond to the k smallest (unique) norms

There's optimizations which can be made at each step which can reduce the search space, but I think the asymptotic time complexity can't really get much better than O(k^d) where d is the number of dimensions in the lattice.

It's therefore a good idea to make use of memoization when dealing with translation vectors. I'm thinking of making a function precompute_translation_vectors!(lattice, maximum_k) which computes all the k'th Nearest Neighbor translation vectors up to k = maximum_k and then caches those for later use in a dictionary stored within the lattice struct. I'll require this to be explicitly called for now: neighbors will error out in most cases if you haven't already called the precompute function beforehand, but we can streamline this a bit later.

Name convention and structure change

Iterator API

  • surround -> neighbors

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

  • all boundary condition will be defined inside module Boundary
  • Fixed -> Boundary.Open
  • Periodic -> Boundary.Periodic
  • boundary condition will has alias (NOTE: alias are always the lower case of the type name)
  • boundary keyword can use symbols

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.