Skip to content

Commit 41789df

Browse files
authored
Merge pull request #23 from numericalEFT/dev
Dev
2 parents 366237c + 10bed40 commit 41789df

6 files changed

+56
-56
lines changed

src/interaction.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ end
6161

6262
function bubbledyson(V::Float64, F::Float64, Π::Float64, n::Int)
6363
# V:bare interaction
64-
# G:G^{+-} is local field factor,0 for RPA
64+
# F:F^{+-} is local field factor,0 for RPA
6565
# Π:Polarization. 2*Polarization0 for spin 1/2
6666
# n:matfreq. special case for n=0
6767
# comparing to previous convention, an additional V is multiplied

src/parameter.jl

+8-8
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,17 @@ generate Para with a complete set of parameters, no value presumed.
6767
- EF: Fermi energy
6868
- β: inverse temperature
6969
"""
70-
@inline function fullUnit(ϵ0, e0, me, EF, β, dim = 3, spin = 2)
71-
return Para(
72-
dim = dim,
70+
@inline function fullUnit(ϵ0, e0, me, EF, β, dim = 3, spin = 2; kwargs...)
71+
para = Para(dim = dim,
7372
spin = spin,
7473
ϵ0 = ϵ0,
7574
e0 = e0,
7675
me = me,
7776
EF = EF,
7877
β = β,
79-
μ = EF,
78+
μ = EF
8079
)
80+
return reconstruct(para, kwargs...)
8181
end
8282

8383
"""
@@ -89,13 +89,13 @@ assume 4πϵ0=1, me=0.5, EF=1
8989
- Θ: dimensionless temperature. Since EF=1 we have β=beta
9090
- rs: Wigner-Seitz radius over Bohr radius.
9191
"""
92-
@inline function defaultUnit(Θ, rs, dim = 3, spin = 2)
92+
@inline function defaultUnit(Θ, rs, dim = 3, spin = 2; kwargs...)
9393
ϵ0 = 1 / (4π)
9494
e0 = (dim == 3) ? sqrt(2 * rs / (9π / (2spin))^(1 / 3)) : sqrt(sqrt(2) * rs)
9595
me = 0.5
9696
EF = 1
9797
β = 1 / Θ / EF
98-
return fullUnit(ϵ0, e0, me, EF, β, dim, spin)
98+
return fullUnit(ϵ0, e0, me, EF, β, dim, spin; kwargs...)
9999
end
100100

101101

@@ -108,14 +108,14 @@ assume 4πϵ0=1, me=0.5, e0=sqrt(2)
108108
- Θ: dimensionless temperature. beta could be different from β
109109
- rs: Wigner-Seitz radius over Bohr radius.
110110
"""
111-
@inline function rydbergUnit(Θ, rs, dim = 3, spin = 2)
111+
@inline function rydbergUnit(Θ, rs, dim = 3, spin = 2; kwargs...)
112112
ϵ0 = 1 / (4π)
113113
e0 = sqrt(2)
114114
me = 0.5
115115
kF = (dim == 3) ? (9π / (2spin))^(1 / 3) / rs : sqrt(4 / spin) / rs
116116
EF = kF^2 / (2me)
117117
β = 1 / Θ / EF
118-
return fullUnit(ϵ0, e0, me, EF, β, dim, spin)
118+
return fullUnit(ϵ0, e0, me, EF, β, dim, spin; kwargs...)
119119
end
120120

121121
export Para, Param

test/interaction.jl

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
@testset "RPA and KO" begin
44
beta = 1e4
55
rs = 2.0
6-
param = Interaction.Parameter.defaultUnit(1/beta,rs)
7-
println(Interaction.RPA(0.01, 1, param))
8-
println(Interaction.KO(0.01, 1, param))
9-
println(Interaction.RPA(1.0, 1, param; pifunc = Interaction.Polarization.Polarization0_FiniteTemp))
10-
println(Interaction.KO(1.0, 1, param; pifunc = Interaction.Polarization.Polarization0_FiniteTemp))
6+
param = Interaction.Parameter.defaultUnit(1 / beta, rs)
7+
# println(Interaction.RPA(0.01, 1, param))
8+
# println(Interaction.KO(0.01, 1, param))
9+
# println(Interaction.RPA(1.0, 1, param; pifunc = Interaction.Polarization.Polarization0_FiniteTemp))
10+
# println(Interaction.KO(1.0, 1, param; pifunc = Interaction.Polarization.Polarization0_FiniteTemp))
1111

1212
RPAs, RPAa = Interaction.RPAwrapped(100 * param.EF, 1e-8, [1e-8, 0.5, 1.0, 2.0, 10.0], param)
13-
println(RPAs.dynamic)
14-
println(RPAs.instant)
13+
# println(RPAs.dynamic)
14+
# println(RPAs.instant)
1515
KOs, KOa = Interaction.KOwrapped(100 * param.EF, 1e-8, [1e-8, 0.5, 1.0, 2.0, 10.0], param)
16-
println(KOs.dynamic)
17-
println(KOs.instant)
16+
# println(KOs.dynamic)
17+
# println(KOs.instant)
1818
end
1919
end

test/legendreinteraction.jl

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
@testset "LegendreInteraction" begin
22

33
# set parameters
4-
param = LegendreInteraction.Parameter.defaultUnit(1/1000.0, 1.0)
4+
param = LegendreInteraction.Parameter.defaultUnit(1 / 1000.0, 1.0)
55
kF = param.kF
66
Nk, minK, order, maxK = 16, 1e-8, 6, 10.0
7-
print(param)
7+
# print(param)
88

99
@testset "Helper function" begin
1010
# test helper function
1111
# test with known result: bare coulomb interaction
12-
H1=LegendreInteraction.helper_function(
13-
1.0, 1, u->LegendreInteraction.interaction_instant(u,param,:sigma), param;
14-
Nk=Nk,minK=minK,order=order
12+
H1 = LegendreInteraction.helper_function(
13+
1.0, 1, u -> LegendreInteraction.interaction_instant(u, param, :sigma), param;
14+
Nk = Nk, minK = minK, order = order
1515
)
16-
H2=LegendreInteraction.helper_function(
17-
2.0, 1, u->LegendreInteraction.interaction_instant(u,param,:sigma), param;
18-
Nk=Nk,minK=minK,order=order
16+
H2 = LegendreInteraction.helper_function(
17+
2.0, 1, u -> LegendreInteraction.interaction_instant(u, param, :sigma), param;
18+
Nk = Nk, minK = minK, order = order
1919
)
2020
# println("$(H2-H1) == $(4*π*param.e0^2*log(2))")
21-
@test isapprox(H2-H1, 4*π*param.e0^2*log(2), rtol = 1e-4)
21+
@test isapprox(H2 - H1, 4 * π * param.e0^2 * log(2), rtol = 1e-4)
2222

23-
helper_grid = CompositeGrid.LogDensedGrid(:cheb, [0.0, 2.1*maxK], [0.0, 2kF], 4, 0.001, 4)
24-
intgrid = CompositeGrid.LogDensedGrid(:cheb, [0.0, helper_grid[end]], [0.0,2kF], 2Nk, 0.01minK, 2order)
25-
helper = LegendreInteraction.helper_function_grid(helper_grid,intgrid, 1, u->LegendreInteraction.interaction_instant(u,param,:sigma),param)
26-
helper_analytic = (4*π*param.e0^2) .* log.(helper_grid.grid)
23+
helper_grid = CompositeGrid.LogDensedGrid(:cheb, [0.0, 2.1 * maxK], [0.0, 2kF], 4, 0.001, 4)
24+
intgrid = CompositeGrid.LogDensedGrid(:cheb, [0.0, helper_grid[end]], [0.0, 2kF], 2Nk, 0.01minK, 2order)
25+
helper = LegendreInteraction.helper_function_grid(helper_grid, intgrid, 1, u -> LegendreInteraction.interaction_instant(u, param, :sigma), param)
26+
helper_analytic = (4 * π * param.e0^2) .* log.(helper_grid.grid)
2727
helper_old = zeros(Float64, helper_grid.size)
2828
for (yi, y) in enumerate(helper_grid)
29-
helper_old[yi] = LegendreInteraction.helper_function(y, 1, u->LegendreInteraction.interaction_instant(u,param,:sigma),param)
29+
helper_old[yi] = LegendreInteraction.helper_function(y, 1, u -> LegendreInteraction.interaction_instant(u, param, :sigma), param)
3030
end
31-
println(helper .- helper[1])
32-
println(helper_old .- helper_old[1])
33-
println(helper_analytic .- helper_analytic[1])
31+
# println(helper .- helper[1])
32+
# println(helper_old .- helper_old[1])
33+
# println(helper_analytic .- helper_analytic[1])
3434
rtol = 1e-6
3535
for (yi, y) in enumerate(helper_grid)
36-
@test isapprox(helper[yi]-helper[1], helper_analytic[yi]-helper_analytic[1], rtol=rtol)
37-
@test isapprox(helper_old[yi]-helper_old[1], helper_analytic[yi]-helper_analytic[1], rtol=rtol)
36+
@test isapprox(helper[yi] - helper[1], helper_analytic[yi] - helper_analytic[1], rtol = rtol)
37+
@test isapprox(helper_old[yi] - helper_old[1], helper_analytic[yi] - helper_analytic[1], rtol = rtol)
3838
end
3939
end
4040

4141
@testset "DCKernel" begin
4242
# test DCKernel
4343

44-
kernel = LegendreInteraction.DCKernel0(param; spin_state=:sigma, Nk=8, rtol=1e-10)
44+
kernel = LegendreInteraction.DCKernel0(param; spin_state = :sigma, Nk = 8, rtol = 1e-10)
4545
# kernel = LegendreInteraction.DCKernel(param, 100*param.EF, 1e-8, 5, 10*param.kF, 1e-7*param.kF, 4, :rpa,0,:sigma)
4646
# kernel2 = LegendreInteraction.DCKernel(kernel, 500.0)
4747
kF_label = searchsortedfirst(kernel.kgrid.grid, kernel.param.kF)
4848
qF_label = searchsortedfirst(kernel.qgrids[kF_label].grid, kernel.param.kF)
49-
println(kernel.kernel[kF_label,qF_label,:])
49+
println(kernel.kernel[kF_label, qF_label, :])
5050
end
5151
end

test/polarization.jl

+13-13
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
println("n = $n, ω_n = $(2π*n/param.β)")
2929
for (qi, q) in enumerate(qgrid)
3030
polar[qi] = Polarization.Polarization0_ZeroTemp(q, n, param)
31-
println("q=$q, Π0=$(polar[qi])")
31+
# println("q=$q, Π0=$(polar[qi])")
3232
end
3333
end
3434

@@ -40,21 +40,21 @@
4040
println("q = $q")
4141
for (i, n) in enumerate(ngrid)
4242
polar[i] = Polarization.Polarization0_ZeroTemp(q, n, param)
43-
println("n=$n, Π0=$(polar[i]) \n")
43+
# println("n=$n, Π0=$(polar[i]) \n")
4444
end
4545
end
4646

47-
while true
48-
print("Please enter a whole number between 1 and 5: ")
49-
input = readline(stdin)
50-
value = tryparse(Int, input)
51-
if value !== nothing && 1 <= value <= 5
52-
println("You entered $(input)")
53-
break
54-
else
55-
@warn "Enter a whole number between 1 and 5"
56-
end
57-
end
47+
# while true
48+
# print("Please enter a whole number between 1 and 5: ")
49+
# input = readline(stdin)
50+
# value = tryparse(Int, input)
51+
# if value !== nothing && 1 <= value <= 5
52+
# println("You entered $(input)")
53+
# break
54+
# else
55+
# @warn "Enter a whole number between 1 and 5"
56+
# end
57+
# end
5858
# plt = plot(qgrid, polar, ytics = -0.08:0.01, ls = 1, Axes(grid = :on, key = "left"))
5959
# display(plt)
6060
# save(term = "png", output = "polar_2d.png",

test/selfenergy.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818

1919
ΣR = real.dynamic)
2020
ΣI = imag.dynamic)
21-
println.instant[1, 1, :])
22-
println(ΣR[1, 1, kF_label, :])
23-
println(ΣI[1, 1, kF_label, :])
21+
# println(Σ.instant[1, 1, :])
22+
# println(ΣR[1, 1, kF_label, :])
23+
# println(ΣI[1, 1, kF_label, :])
2424
Z0 = (SelfEnergy.zfactor(Σ))
2525
# @test isapprox(Z0, 0.862, rtol = 5e-3)
2626

2727
println("θ = , rs= $rs")
2828
println("Z-factor = $Z0")
2929
G = SelfEnergy.Gwrapped(Σ, param)
30-
println(G.dynamic[1, 1, kF_label, :])
30+
# println(G.dynamic[1, 1, kF_label, :])
3131
end
3232
# @testset "default unit" begin
3333
# # make sure everything works for different unit sets

0 commit comments

Comments
 (0)