Code Monkey home page Code Monkey logo

greenfunc.jl's People

Contributors

fsxbhyy avatar houpc avatar iintsjds avatar kunyuan avatar littlebug avatar peter0627ustc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

greenfunc.jl's Issues

Triqs: GreenDLR Basic

-Complete the TODO list for basic functions in GreenDLR, including:

  • 1.new functions:
    • Basic.show for nice print, related to issue #8
    • Basic << for initialization and assign value
    • density for calculating the density from Green'sfunction
  • 2. Assertion and edge cases:
    Add assertions to make sure the user input is eligible for functions
  • 3. Unit test
    Add test in test_GreenDLR.jl

Add Hash for MeshGrids so that one can check mesh equvalence on the fly

  • design a hash function that calculates a hash number for a given mesh type and mesh points.
    - Of course, it will be best for each mesh type to implement their specialized hash function
    - If not, a generic hash function can be used based on the iterator interface.

  • Add meshash field in MeshArray struct

  • Based on meshhash, now one can check meshes of the incoming MeshArrays in +,-,*,/ operations on the fly.

broadcast for GreenDLR

Reload Base.Broadcast.broadcast for GreenDLR.
Use it to accomplish inplace mathmetic operator like .+=

Triqs: MeshProduct

-Complete the TODO list for basic functions in MeshProduct, including:

  • 1.new functions:
    All listed Basic functions which enables the use of julia iterator

  • 2. Assertion and edge cases:
    Add assertions to make sure the user input is eligible for functions

  • 3. Unit test
    Add test in test_MeshProduct.jl.

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

GreenDLR:Documentation

Add Readme.md for GreenDLR.
Guide the user to all basic functions, interfaces of GreenDLR, with some simple examples.

SparseMeshArray

Implement SparseMeshArray, which generalizes BlockGf in Triqs.
Example from https://docs.julialang.org/en/v1/manual/interfaces/#man-interface-array

julia> struct SparseArray{T,N} <: AbstractArray{T,N}
           data::Dict{NTuple{N,Int}, T}
           dims::NTuple{N,Int}
       end

julia> SparseArray(::Type{T}, dims::Int...) where {T} = SparseArray(T, dims);

julia> SparseArray(::Type{T}, dims::NTuple{N,Int}) where {T,N} = SparseArray{T,N}(Dict{NTuple{N,Int}, T}(), dims);

julia> Base.size(A::SparseArray) = A.dims

julia> Base.similar(A::SparseArray, ::Type{T}, dims::Dims) where {T} = SparseArray(T, dims)

julia> Base.getindex(A::SparseArray{T,N}, I::Vararg{Int,N}) where {T,N} = get(A.data, I, zero(T))

julia> Base.setindex!(A::SparseArray{T,N}, v, I::Vararg{Int,N}) where {T,N} = (A.data[I] = v)

type instability

mesh = (m for m in mesh)

(v for v in [...]) returns a generator. But here we want a tuple. So use Tuple(v for v in [...]) instead.

After created, we can report a warning message if isconcretetype(typeof(mesh)) returns false

Mesh validation

The constructors in the MeshGrids and MeshArray don't check if mesh points are in increasing order. User can use something as [0.0, 0.5, 0.2, 1.0] as the mesh, which is not valid.

pretty print

Overload the system call to customize the output format of the Green's function

Base.show(IO, green) = print(IO, "....")

Base.<<

Finish functionality of Base.<< to convert triqs Green to mesharray

  • Implement Imtime and Imfreq converter
  • #66

Triqs example

The following code is an example from Triqs to create a Green's function for the Hubbard model, we may learn from them how to design the Greenfunc API.

from triqs.gf import *
from triqs.lattice import *
from triqs.lattice.tight_binding import *
from numpy import cos, pi

BL = BravaisLattice(units = [(1,0,0) , (0,1,0) ]) #square lattice
nk=20
mk = MeshBrillouinZone(BrillouinZone(BL), nk)
miw=MeshImFreq(beta=1., S="Fermion", n_max=100) #grid number : 201
mprod = MeshProduct(mk, miw) 

G_w = GfImFreq(mesh=miw, target_shape=[1,1]) #G_w.data.shape will be [201, 1, 1]
G_k_w = GfImFreq(mesh=mprod, target_shape=[1,1]) #G_k_w.data.shape will be [400, 201, 1, 1]

t=1.0
U=4.0

####### fill the Green's function with data ################
ik=0
for k in G_k_w.mesh.components[0]:
  G_w << inverse(iOmega_n-2*t*(cos(k[0])+cos(k[1])))
  G_k_w.data[ik,:,0,0]=G_w.data[:,0,0]
  ik+=1

MeshArray view

Support view(m::MeshArray, index...). It should return a SubMeshArray struct.
More details need to be discussed.

disk IO operation

GreenFunc should provide API to save/load Green's function to/from disk.

The API should provide two options:

  1. For small Green's function, simply save/load as plain text
  2. For large Green's function, use hdf5 format to save/load with data compression. The following link could be useful: https://juliaio.github.io/HDF5.jl/stable/

support reversed ImFreq and ImTime grids

Since the package CompositeGrids doesn't support reversed order, it makes sense for GreenFunc.jl to support it.

We suggest to do the following,

  1. Add a new parameter to ImTime{..., reverse} and ImFreq{..., reverse} to indicate if the mesh is reversed or not
  2. When construct the mesh, check if user supplies a reversed grid or not. If reversed, then create ImTime(..., true), otherwise, ImTIme(..., false)
  3. ImTime.grid and ImFreq.grid will always be non-reversed, because they are CompositeGrids object
  4. If reverse is true, then iterator and indexing of the mesh should be reversed, so that time[2] = time[length(time)-2+1]

Write down the API document

Write down the API document either in readme, or in the doc folder.

Alternatively, you could create a series of issues. Each issue will be a specific task for the project. See the issues in the ExpressionTree.jl repo for example.

documentation

  1. a simple demo in Readme
  2. documentation of interface requirement for grids

Implement transform with dispatch

implement fourier transform functions such as imtime2dlr, imfreq2imtime with dispatch of the same function
something like transfrom(data, meshA::XXXMesh, meshB::YYYMesh)

broadcast between MeshArray and Array lead to copies

See the example below, g is a MeshArray of the size 100x60

julia> g
Meshed array with dims = (100, 60) and total length = 6000
- Mesh: Tuple{CompositeGrids.SimpleG.Uniform{Float64}, DLRFreq{Float64}} 


julia> @time g .+= rand(100, 60)
  0.000040 seconds (4 allocations: 46.984 KiB)
Meshed array with dims = (100, 60) and total length = 6000
- Mesh: Tuple{CompositeGrids.SimpleG.Uniform{Float64}, DLRFreq{Float64}} 


julia> @time g .+= g
  0.000032 seconds (2 allocations: 64 bytes)
Meshed array with dims = (100, 60) and total length = 6000
- Mesh: Tuple{CompositeGrids.SimpleG.Uniform{Float64}, DLRFreq{Float64}} 


julia> @time g + rand(100, 60)
  0.000030 seconds (5 allocations: 94.000 KiB)
Meshed array with dims = (100, 60) and total length = 6000
- Mesh: Tuple{CompositeGrids.SimpleG.Uniform{Float64}, DLRFreq{Float64}} 


julia> @time g + g
  0.000029 seconds (3 allocations: 47.078 KiB)
Meshed array with dims = (100, 60) and total length = 6000
- Mesh: Tuple{CompositeGrids.SimpleG.Uniform{Float64}, DLRFreq{Float64}} 

Green's function product problem

Assume G1(tau) is bosonic, and G2(tau) is fermionic. Right now, the code allows G1*G2. The statistics of the resulting product is not well defined in the code.

GreenDLR:Examples

Add examples:

  • SYK model (Follow the example in Lehmann.jl)
  • Calculating self-energy/polarization of yukawa free electron gas
  • Hubbard model

MeshGrid type

When create MeshGrid ImFreq, etc., the current implementation doesn't allow AbstractGrids type.

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.