|
1 | 1 | @testset "LegendreInteraction" begin
|
2 | 2 |
|
3 | 3 | # set parameters
|
4 |
| - param = LegendreInteraction.Parameter.defaultUnit(1/1000.0, 1.0) |
| 4 | + param = LegendreInteraction.Parameter.defaultUnit(1 / 1000.0, 1.0) |
5 | 5 | kF = param.kF
|
6 | 6 | Nk, minK, order, maxK = 16, 1e-8, 6, 10.0
|
7 |
| - print(param) |
| 7 | + # print(param) |
8 | 8 |
|
9 | 9 | @testset "Helper function" begin
|
10 | 10 | # test helper function
|
11 | 11 | # 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 |
15 | 15 | )
|
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 |
19 | 19 | )
|
20 | 20 | # 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) |
22 | 22 |
|
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) |
27 | 27 | helper_old = zeros(Float64, helper_grid.size)
|
28 | 28 | 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) |
30 | 30 | 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]) |
34 | 34 | rtol = 1e-6
|
35 | 35 | 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) |
38 | 38 | end
|
39 | 39 | end
|
40 | 40 |
|
41 | 41 | @testset "DCKernel" begin
|
42 | 42 | # test DCKernel
|
43 | 43 |
|
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) |
45 | 45 | # kernel = LegendreInteraction.DCKernel(param, 100*param.EF, 1e-8, 5, 10*param.kF, 1e-7*param.kF, 4, :rpa,0,:sigma)
|
46 | 46 | # kernel2 = LegendreInteraction.DCKernel(kernel, 500.0)
|
47 | 47 | kF_label = searchsortedfirst(kernel.kgrid.grid, kernel.param.kF)
|
48 | 48 | 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, :]) |
50 | 50 | end
|
51 | 51 | end
|
0 commit comments