Skip to content

Commit

Permalink
fix runtests
Browse files Browse the repository at this point in the history
  • Loading branch information
ytdHuang committed Nov 8, 2023
1 parent c16d16a commit 70562d6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/Spectrum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ end

@doc raw"""
PowerSpectrum(M, ρ, Q_op, ωlist, reverse; solver, verbose, filename, SOLVEROptions...)
Calculate spectrum for the system where `P_op` will be automatically set as the adjoint of `Q_op`.
Calculate power spectrum for the system where `P_op` will be automatically set as the adjoint of `Q_op`.
This function is equivalent to:
`PowerSpectrum(M, ρ, Q_op', Q_op, ωlist, reverse; solver, verbose, filename, SOLVEROptions...)`
Expand Down Expand Up @@ -139,7 +139,7 @@ function PowerSpectrum(
= Vector{Float64}(undef, Length)

if verbose
print("Calculating spectrum (with EVEN-parity operators)...\n")
print("Calculating power spectrum...\n")

Check warning on line 142 in src/Spectrum.jl

View check run for this annotation

Codecov / codecov/patch

src/Spectrum.jl#L142

Added line #L142 was not covered by tests
flush(stdout)
prog = Progress(Length; desc="Progress : ", PROGBAR_OPTIONS...)
end
Expand Down
30 changes: 20 additions & 10 deletions test/phys_analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ end
# using the method based on propagator
ados_list = evolution(L, ρ0, Δt, steps; verbose=false, filename="evolution_p")
ados_wrong1 = ADOs(zeros(8), 2)
ados_wrong2 = ADOs((ados_list[1]).data, (ados_list[1]).N, ODD)
ados_wrong2 = ADOs(zeros(32), 2)
ados_wrong3 = ADOs((ados_list[1]).data, (ados_list[1]).N, ODD)
ρ_list_p = getRho.(ados_list)
@test_throws ErrorException evolution(L, ρ0, Δt, steps; verbose=false, filename="evolution_p")
@test_throws ErrorException evolution(L, ρ_wrong, Δt, steps; verbose=false)
@test_throws ErrorException evolution(L, ados_wrong1, Δt, steps)
@test_throws ErrorException evolution(L, ados_wrong2, Δt, steps)
@test_throws ErrorException evolution(L, ados_wrong1, Δt, steps; verbose=false)
@test_throws ErrorException evolution(L, ados_wrong2, Δt, steps; verbose=false)
@test_throws ErrorException evolution(L, ados_wrong3, Δt, steps; verbose=false)

if isfile("evolution_o.jld2")
rm("evolution_o.jld2")
Expand All @@ -63,8 +65,9 @@ end
ρ_list_e = getRho.(evolution(L, ρ0, tlist; verbose=false, filename="evolution_o"))
@test_throws ErrorException evolution(L, ρ0, tlist; verbose=false, filename="evolution_o")
@test_throws ErrorException evolution(L, ρ_wrong, tlist; verbose=false)
@test_throws ErrorException evolution(L, ados_wrong1, tlist)
@test_throws ErrorException evolution(L, ados_wrong2, tlist)
@test_throws ErrorException evolution(L, ados_wrong1, tlist; verbose=false)
@test_throws ErrorException evolution(L, ados_wrong2, tlist; verbose=false)
@test_throws ErrorException evolution(L, ados_wrong3, tlist; verbose=false)

for i in 1:(steps + 1)
@test _is_Matrix_approx(ρ_list_p[i], ρ_list_e[i])
Expand Down Expand Up @@ -209,10 +212,14 @@ end
zeros(3, 3)
end
end
@test_throws ErrorException evolution(L, ρ0, tlist, H_wrong1; verbose=false);
@test_throws ErrorException evolution(L, ρ0, tlist, H_wrong2; verbose=false);
@test_throws ErrorException evolution(L, ados_wrong1, tlist, Ht)
@test_throws ErrorException evolution(L, ados_wrong2, tlist, Ht)
ados_wrong1 = ADOs(zeros(8), 2)
ados_wrong2 = ADOs(zeros(32), 2)
ados_wrong3 = ADOs((slowDD_ados[1]).data, (slowDD_ados[1]).N, ODD)
@test_throws ErrorException evolution(L, ρ0, tlist, H_wrong1; verbose=false)
@test_throws ErrorException evolution(L, ρ0, tlist, H_wrong2; verbose=false)
@test_throws ErrorException evolution(L, ados_wrong1, tlist, Ht; verbose=false)
@test_throws ErrorException evolution(L, ados_wrong2, tlist, Ht; verbose=false)
@test_throws ErrorException evolution(L, ados_wrong3, tlist, Ht; verbose=false)
end

@testset "Power spectrum" begin
Expand Down Expand Up @@ -268,9 +275,11 @@ end
mat = spzeros(ComplexF64, 2, 2)
mat2 = spzeros(ComplexF64, 3, 3)
bathf = Fermion_Lorentz_Pade(mat, 1, 1, 1, 1, 2)
@test_throws ErrorException spectrum(L, ados_s, a, ωlist; verbose=false)
@test_throws ErrorException PowerSpectrum(L, ados_s, a, ωlist; verbose=false, filename="PSD")
@test_throws ErrorException PowerSpectrum(L, ados_s, mat2, ωlist; verbose=false)
@test_throws ErrorException PowerSpectrum(L, ADOs(zeros(8), 2), a, ωlist; verbose=false)
@test_throws ErrorException PowerSpectrum(L, ADOs(zeros(32), 2), a, ωlist; verbose=false)
@test_throws ErrorException PowerSpectrum(L, ADOs(ados_s.data, ados_s.N, ODD), a, ωlist; verbose=false)
end

Expand Down Expand Up @@ -339,9 +348,10 @@ end
mat = spzeros(ComplexF64, 2, 2)
mat2 = spzeros(ComplexF64, 3, 3)
bathb = Boson_DrudeLorentz_Pade(mat, 1, 1, 1, 2)
@test_throws ErrorException DensityOfStates(Lo, ados_s, d_up, ωlist; verbose=false, filename="DOS")
@test_throws ErrorException spectrum(Lo, ados_s, d_up, ωlist; verbose=false)
@test_throws ErrorException DensityOfStates(Lo, ados_s, mat2, ωlist; verbose=false)
@test_throws ErrorException DensityOfStates(Lo, ADOs(zeros(8), 2), d_up, ωlist; verbose=false)
@test_throws ErrorException DensityOfStates(Lo, ADOs(zeros(32), 2), d_up, ωlist; verbose=false)
@test_throws ErrorException DensityOfStates(Lo, ADOs(ados_s.data, ados_s.N, ODD), d_up, ωlist; verbose=false)
@test_throws ErrorException DensityOfStates(M_Boson(mat, 2, bathb; verbose=false), mat, mat, [0])
@test_throws ErrorException DensityOfStates(M_Fermion(mat, 2, fuL; verbose=false), mat, mat, [0])
Expand Down

0 comments on commit 70562d6

Please sign in to comment.