Skip to content

Commit

Permalink
made all the plotting and util tests
Browse files Browse the repository at this point in the history
  • Loading branch information
louisponet committed Oct 15, 2017
1 parent 4dfb147 commit 7cdb1a1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ Input: band::Band,
function apply_fermi_level!(band::Band,fermi::Union{String,AbstractFloat})
if typeof(fermi)==String
fermi = read_fermi_from_qe_file(fermi)
else
for i=1:size(band.eigvals)[1]
band.eigvals[i] -= fermi
end
end
for i=1:size(band.eigvals)[1]
band.eigvals[i] -= fermi
end
end

Expand All @@ -54,13 +53,13 @@ end
Same as above but not mutatatively.
"""
function apply_fermi_level(band::Band,fermi)
T = typeof(band.eigvals[1])
if typeof(fermi)==String
fermi = read_fermi_from_SCF_file(fermi)
fermi = read_fermi_from_qe_file(fermi)
end
out=deepcopy(band)
for i1=1:size(band.eigvals)[1]
out.k_points[i1,:] = band.k_points[i1,:]
out.eigvals[i1] = band.eigvals[i1]-fermi
out.eigvals[i1] = band.eigvals[i1]-T(fermi)
end
return out
end
Expand Down
6 changes: 6 additions & 0 deletions test/job_control_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using DFControl, Base.Test
TT = STDOUT
redirect_stdout()

df_job = load_qe_job("test_job",joinpath(@__DIR__,"../assets/inputs/qe"))
df_job2 = load_qe_job("test_job",joinpath(@__DIR__,"../assets/inputs/qe"),new_homedir="blabla")
@test df_job2.home_dir == "blabla/"
Expand Down Expand Up @@ -48,3 +51,6 @@ set_job_data!(df_job,["bands","scf"],:control_blocks,set_data2)
@test df_job.calculations["bands"].control_blocks[:control][:test]
@test df_job.calculations["scf"].control_blocks[:control][:pseudo_dir] == "'./'"
@test df_job.calculations["scf"].atoms[:Ze] == Point3D(1.2,3.2,1.2)

redirect_stdout(TT)
println("")
23 changes: 23 additions & 0 deletions test/plotting_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using DFControl, Base.Test

@test plot_qe_bands(joinpath(@__DIR__,"../assets/outputs/bands.out")) != nothing
@test plot_qe_kpdos(joinpath(@__DIR__,"../assets/outputs/kpdos.out")) != nothing

test_bands = read_qe_bands_file(joinpath(@__DIR__,"../assets/outputs/bands.out"))
@test plot(test_bands[1],fermi=3) != nothing
@test plot(test_bands[3],:relative_cart) != nothing
@test plot(test_bands[4],:relative_cryst) != nothing
@test plot(test_bands) != nothing

t_fermi = read_fermi_from_qe_file(joinpath(@__DIR__,"../assets/outputs/scf.out"))
t_eigval = test_bands[1].eigvals[1]
@test apply_fermi_level(test_bands,3.2)[1].eigvals[1] == t_eigval - 3.2f0
@test apply_fermi_level(test_bands,joinpath(@__DIR__,"../assets/outputs/scf.out"))[1].eigvals[1] == t_eigval - t_fermi
apply_fermi_level!(test_bands,3.2)
@test test_bands[1].eigvals[1] == t_eigval - 3.2f0
t_eigval = test_bands[1].eigvals[1]
apply_fermi_level!(test_bands,joinpath(@__DIR__,"../assets/outputs/scf.out"))
@test test_bands[1].eigvals[1] == t_eigval - t_fermi



5 changes: 4 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ using Base.Test

tic()
@testset "File processing tests" begin include("file_processing_tests.jl") end
@testset "Job control tests" begin include("job_control_tests.jl") end
@testset "Job control tests" begin
include("job_control_tests.jl")
end
@testset "Plotting tests" begin include("plotting_tests.jl") end
toc()

0 comments on commit 7cdb1a1

Please sign in to comment.