numericaleft / greenfunc.jl Goto Github PK
View Code? Open in Web Editor NEWToolbox to study quantum many-body problem at the treelevel
Home Page: https://numericaleft.github.io/GreenFunc.jl/
License: MIT License
Toolbox to study quantum many-body problem at the treelevel
Home Page: https://numericaleft.github.io/GreenFunc.jl/
License: MIT License
Deal with \delta(\tau) components.
-Complete the TODO list for basic functions in GreenDLR, including:
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.
Reload Base.Broadcast.broadcast for GreenDLR.
Use it to accomplish inplace mathmetic operator like .+=
-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.
Pipe operations allow something like
julia> 1:3 .|> (x -> x^2) |> sum |> sqrt
3.7416573867739413
See here for details: https://docs.julialang.org/en/v1/manual/interfaces/#man-interface-array
Make the GreenFunc operations to support pipe operations. For example,
julia> GreenObj |> to_dlr |> to_imtime
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!
Add Readme.md for GreenDLR.
Guide the user to all basic functions, interfaces of GreenDLR, with some simple examples.
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)
GreenFunc.jl/src/mesharrays/dense.jl
Line 95 in eed3560
After created, we can report a warning message if isconcretetype(typeof(mesh))
returns false
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.
Not all Green's functions can be represented with DLR.
Then it will be great to support generic nonlinear fourier transform for the imtime and imfreq, and for retime and refreq for the future.
This package will be useful: https://finufft.readthedocs.io/en/latest/
Overload the system call to customize the output format of the Green's function
Base.show(IO, green) = print(IO, "....")
Finish functionality of Base.<< to convert triqs Green to mesharray
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
Support view(m::MeshArray, index...). It should return a SubMeshArray struct.
More details need to be discussed.
GreenFunc should provide API to save/load Green's function to/from disk.
The API should provide two options:
Since the package CompositeGrids doesn't support reversed order, it makes sense for GreenFunc.jl to support it.
We suggest to do the following,
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.
return if Instant or Dynamic array has set or not.
implement fourier transform functions such as imtime2dlr, imfreq2imtime with dispatch of the same function
something like transfrom(data, meshA::XXXMesh, meshB::YYYMesh)
Type instability of mesh leads to too large allocation.
TODO: generated functions to find: tuple elements' type in mesh, replace elements in mesh, etc.
transform_4305mem.txt
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}}
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.
When trying to run test/test_transform.jl
I get the error
UndefVarError:
SimpleGrid
not defined in test
even when GreenFunc.jl is included and other functions are defined.
e.g. green.tgrid == dlr,
but green.T == dlr.\tau and green.n == dlr.n
Add examples:
When create MeshGrid ImFreq, etc., the current implementation doesn't allow AbstractGrids type.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.