Skip to content

Commit

Permalink
Merge pull request #100 from numericalEFT/dev
Browse files Browse the repository at this point in the history
fix a bug
  • Loading branch information
kunyuan authored Dec 30, 2022
2 parents 51afd39 + babad1c commit 4e7226c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GreenFunc"
uuid = "9efc7ea6-d529-4241-ab29-dcf68b94af7c"
authors = ["Tao Wang", "Xiansheng Cai", "Pengcheng Hou", "Zhiyi Li", "Kun Chen"]
version = "0.2.3"
version = "0.2.4"

[deps]
BrillouinZoneMeshes = "9f696214-9961-49f3-89a2-cb1ea204eb6e"
Expand Down
6 changes: 5 additions & 1 deletion src/mesharrays/MeshArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Return the type of the elements contained in `obj.data`.
"""
Base.eltype(::Type{AbstractMeshArray{T,N}}) where {T,N} = T

Base.zero(obj::AbstractMeshArray) = Base.zero(obj.data)
function Base.zero(obj::AbstractMeshArray{T,N}) where {T,N}
_obj = similar(obj)
_obj.data .= zero(T)
return _obj
end

end
9 changes: 5 additions & 4 deletions src/meshgrids/imfreq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ function ImFreq(β, isFermi::Bool=false;
)
dlr = DLRGrid(Euv, β, rtol, isFermi, symmetry)

rev = issorted(grid, rev=true)
if rev
grid = reverse(grid)
end
if isnothing(grid)
# TODO: replace the dlr.n with a non-dlr grid. User don't want dlr if it is not initialized with a dlr
grid = SimpleG.Arbitrary{Int}(dlr.n)
rev = false
elseif (grid isa AbstractVector)
rev = issorted(grid, rev=true)
if rev
grid = reverse(grid)
end
grid = SimpleG.Arbitrary{Int}(Int.(grid))
else
error("Proper grid or basis are required.")
Expand Down
11 changes: 6 additions & 5 deletions src/meshgrids/imtime.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,17 @@ function ImTime(β, isFermi::Bool=false;
)
dlr = DLRGrid(Euv, β, rtol, isFermi, symmetry)

rev = issorted(grid, rev=true)
if rev
grid = reverse(grid)
end

if isnothing(grid)
rev = false
grid = SimpleG.Arbitrary{dtype}(dlr.τ)
# grid = SimpleG.Uniform{dtype}([0, β], Int(round(β / resolution)))
# grid = CompositeGrid.LogDensedGrid(:uniform, [0.0, β], [0.0, β], 8, 1 / Euv, 8) #roughly ~100 points if resolution = β/128
elseif (grid isa AbstractVector)
rev = issorted(grid, rev=true)
if rev
grid = reverse(grid)
end

grid = SimpleG.Arbitrary{dtype}(grid)
else
error("Proper grid and basis are required!")
Expand Down
2 changes: 2 additions & 0 deletions test/test_MeshArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ using Random
g ./= 2.0
@test _g.data ./ 2.0 g.data

zg = zero(g)
@test zg.data zero(g.data)
end

test_shape(5, 7, ())
Expand Down
13 changes: 11 additions & 2 deletions test/test_MeshGrids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
DLR = DLRGrid(Euv, β, rtol, isFermi, tsym)

@testset "ImTime Grid" begin

tg2 = MeshGrids.ImTime(β, isFermi) # check default reverse
@test length(tg2) > 0

tg2 = MeshGrids.ImTime(β, isFermi; grid=DLR.τ)

@test length(tg2) == length(DLR)
Expand Down Expand Up @@ -75,6 +79,10 @@
end

@testset "ImFreq Grid" begin

tg2 = MeshGrids.ImFreq(β, isFermi) # check default reverse
@test length(tg2) > 0

tg2 = MeshGrids.ImFreq(β, isFermi; grid=DLR.n)
println(tg2)

Expand Down Expand Up @@ -111,9 +119,10 @@
end

@testset "ImFreq Grid Reversed" begin

tg2 = MeshGrids.ImFreq(β, isFermi; grid=reverse(DLR.n))
println(typeof(tg2))
println(tg2)
# println(typeof(tg2))
# println(tg2)

@test length(tg2) == length(DLR)
@test size(tg2) == (length(DLR),)
Expand Down

2 comments on commit 4e7226c

@kunyuan
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/74836

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.4 -m "<description of version>" 4e7226c5a30307b9202dd5a3d6f85b01d8ad92d5
git push origin v0.2.4

Please sign in to comment.