Skip to content

Commit

Permalink
improve bath tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ytdHuang committed Dec 5, 2024
1 parent a1337df commit a0d9b40
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 deletions.
43 changes: 24 additions & 19 deletions test/bath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@

## check for combine
b = BosonBath(op, η1, γ1)
types = ["bRI", "bRI", "bRI", "bRI"]
@test length(b) == 4

## check for η and γ list, and coupling operator
η = ComplexF64[]
γ = ComplexF64[]
for e in b
push!(η, e.η)
push!(γ, e.γ)
η = Vector{ComplexF64}(undef, length(b))
γ = Vector{ComplexF64}(undef, length(b))
for (i, e) in enumerate(b)
η[i] = e.η
γ[i] = e.γ
@test e.op == op
@test e.types == types[i]
end
@test η == [1.0 + 0.0im, 10.0 + 0.0im, 5.0 + 0.0im, 9.0 + 0.0im]
@test γ == [0.1 + 0.0im, 0.3 + 0.0im, 0.5 + 0.0im, 0.7 + 0.0im]
Expand All @@ -37,17 +39,18 @@

## check for combine
b = BosonBath(op, η1, γ1, η2, γ2)
types = ["bRI", "bRI", "bR", "bR", "bI", "bI", "bI"]
@test length(b) == 7
@test C(b, [0.183183])[1] C(bs, [0.183183])[1]

## check for η and γ list, and coupling operator
η = ComplexF64[]
γ = ComplexF64[]
for e in b
push!(η, e.η)
push!(γ, e.γ)
η = Vector{ComplexF64}(undef, length(b))
γ = Vector{ComplexF64}(undef, length(b))
for (i, e) in enumerate(b)
η[i] = e.η
γ[i] = e.γ
@test e.op == op
@test (e.types == "bR") || (e.types == "bI") || (e.types == "bRI")
@test e.types == types[i]
end
@test η == [1.0 + 2.0im, 5.0 + 6.0im, 10.0 + 0.0im, 9.0 + 0.0im, 4.0 + 0.0im, 8.0 + 0.0im, 10.0 + 0.0im]
@test γ == [0.1 + 0.0im, 0.5 + 0.0im, 0.3 + 0.0im, 0.7 + 0.0im, 0.2 + 0.0im, 0.6 + 0.0im, 0.9 + 0.0im]
Expand Down Expand Up @@ -75,19 +78,20 @@
################################################
# Boson bath (RWA)
b = BosonBathRWA(op, η1, γ3, η2, γ4)
types = ["bA", "bA", "bA", "bA", "bA", "bE", "bE", "bE", "bE", "bE"]
@test length(bs) == 10
cp, cm = C(b, [0.183183])
@test cp[1] 22.384506765987076 + 0.7399082821797519im
@test cm[1] 26.994911851482776 - 0.799138487523946im

## check for η and γ list, and coupling operator
η = ComplexF64[]
γ = ComplexF64[]
for e in b
push!(η, e.η)
push!(γ, e.γ)
η = Vector{ComplexF64}(undef, length(b))
γ = Vector{ComplexF64}(undef, length(b))
for (i, e) in enumerate(b)
η[i] = e.η
γ[i] = e.γ
@test e.op == op
@test (e.types == "bA") || (e.types == "bE")
@test e.types == types[i]
end
@test η == [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]
@test γ == [
Expand Down Expand Up @@ -127,13 +131,14 @@
################################################
# Fermion bath
b = FermionBath(op, η1, γ3, η2, γ4)
types = ["fA", "fA", "fA", "fA", "fA", "fE", "fE", "fE", "fE", "fE"]
@test length(b) == 10
cp, cm = C(b, [0.183183])
@test cp[1] 22.384506765987076 + 0.7399082821797519im
@test cm[1] 26.994911851482776 - 0.799138487523946im
for e in b
for (i, e) in enumerate(b)
@test e.op == op
@test (e.types == "fA") || (e.types == "fE")
@test e.types == types[i]
end
@test show(devnull, MIME("text/plain"), b) === nothing

Expand Down
8 changes: 8 additions & 0 deletions test/bath_corr_func.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
13.975060760228835 + 0.0im,
18.63341434697178 + 0.0im,
]
types = ["bRI", "bRI", "bRI", "bRI", "bRI"]
@test length(b) == 5
for (i, e) in enumerate(b)
@test e.η η[i] atol = 1.0e-10
@test e.γ γ[i] atol = 1.0e-10
@test e.types == types[i]
end

# Boson DrudeLorentz Pade
Expand All @@ -44,10 +46,12 @@
15.245109836566387 + 0.0im,
42.84397872069647 + 0.0im,
]
types = ["bRI", "bRI", "bRI", "bRI", "bRI"]
@test length(b) == 5
for (i, e) in enumerate(b)
@test e.η η[i] atol = 1.0e-10
@test e.γ γ[i] atol = 1.0e-10
@test e.types == types[i]
end

# Boson Underdamped Matsubara
Expand Down Expand Up @@ -102,10 +106,12 @@
11.645883966857362 + 0.8787im,
16.304237553600306 + 0.8787im,
]
types = ["fA", "fA", "fA", "fA", "fA", "fE", "fE", "fE", "fE", "fE"]
@test length(b) == 10
for (i, e) in enumerate(b)
@test e.η η[i] atol = 1.0e-10
@test e.γ γ[i] atol = 1.0e-10
@test e.types == types[i]
end

# Fermion Lorentz Pade
Expand Down Expand Up @@ -134,9 +140,11 @@
12.311922289624265 + 0.8787im,
34.341283736701214 + 0.8787im,
]
types = ["fA", "fA", "fA", "fA", "fA", "fE", "fE", "fE", "fE", "fE"]
@test length(b) == 10
for (i, e) in enumerate(b)
@test e.η η[i] atol = 1.0e-10
@test e.γ γ[i] atol = 1.0e-10
@test e.types == types[i]
end
end

0 comments on commit a0d9b40

Please sign in to comment.