Skip to content

Commit

Permalink
added tests and fixed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
louisponet committed Nov 7, 2017
1 parent fc42f29 commit bbb1641
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/DFControl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module DFControl
export add_flags!
export remove_flags!
export change_flow!
export set_flow!
export add_calculation!
export get_run_command
export change_run_command!
Expand Down
10 changes: 5 additions & 5 deletions src/job_control.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function add_calculation!(df_job::DFJob, input::DFInput, run_index::Int=length(d
input.filename = filename
input.run_command = run_command
insert!(df_job.calculations,run_index,input)
print_info(calculation)
print_info(input)
print_flow(df_job)
end

Expand Down Expand Up @@ -194,7 +194,7 @@ Looks through the given calculations for the specified flags. If any that match
function change_flags!(df_job::DFJob, calc_filenames, new_flag_data::Dict{Symbol,<:Any})
found_keys = Symbol[]
for calc in get_inputs(df_job,calc_filenames)
t_found_keys = change_flags!(calculation,new_flag_data)
t_found_keys = change_flags!(calc,new_flag_data)
for key in t_found_keys
if !(key in found_keys) push!(found_keys,key) end
end
Expand Down Expand Up @@ -428,7 +428,7 @@ Prints the information of the block in a selected file of the job.
"""
function print_block(job::DFJob, filenames, block_symbol::Symbol)
for calc in get_inputs(job,filenames)
print_block(calc,block_name)
print_block(calc,block_symbol)
end
end

Expand Down Expand Up @@ -519,9 +519,9 @@ end
Prints the specified flags running through all the claculations in the job.
"""
function print_flags(job::DFJob, flags)
function print_flags(job::DFJob, flags::Array{Symbol,1})
for flag in flags
print_flags(job,flag)
print_flag(job,flag)
end
end

Expand Down
48 changes: 48 additions & 0 deletions test/job_control_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,54 @@ data = get_data(df_job,"nscf",:atomic_positions)
data[:Te] = data[:Te].+Point3D(0.01f0)
change_data!(df_job,"nscf",:atomic_positions,data)
@test get_block(df_job,"nscf",:atomic_positions).data == data

scf_input = read_qe_input(joinpath(@__DIR__,"../assets/inputs/qe/scf.in"),Float64)
t_l = length(df_job.calculations)
add_calculation!(df_job, scf_input)
@test length(df_job.calculations)==t_l+1
change_flags!(df_job,Dict(:dis_win_min => 9.2f0))
@test get_flag(df_job,"wan.win",:dis_win_min)==9.2f0
change_flags!(df_job,["nscf"],Dict(:calculation => "'scf'"))
@test get_flag(df_job,"nscf",:calculation)== "'scf'"

add_flags!(df_job,:control,Dict(:test => "test"))
@test get_flag(df_job,"nscf",:test) == "test"

add_flags!(df_job,Dict(:test=>"test"))
@test get_flag(df_job,"wan.win",:test)=="test"
remove_flags!(df_job,"wan.win",:test)
remove_flags!(df_job,:test)
@test get_flag(df_job,:test)==nothing

set_flow!(df_job,[false for i=1:length(df_job.calculations)])
@test df_job.calculations[1].run == false
change_flow!(df_job,[(1,true)])
@test df_job.calculations[1].run
change_flow!(df_job,["nscf","bands"],true)
@test df_job.calculations[2].run
change_flow!(df_job,[("pw2wan",true)])
@test df_job.calculations[end-2].run

change_run_command!(df_job,"nscf","test")
@test get_run_command(df_job,"nscf") == "test"

print_run_command(df_job,"nscf")
print_flow(df_job)
@test print_block(df_job,:atomic_positions) == print_block(df_job,"nscf",:atomic_positions)
@test print_blocks(df_job) == print_data(df_job)
@test print_blocks(df_job,"bands") == print_data(df_job,"bands")
print_info(df_job)
print_flags(df_job)
@test print_flags(df_job,"nscf") == print_flags(df_job,["nscf"])
@test print_flags(df_job,[:dis_win_min]) == print_flag(df_job,:dis_win_min)
@test get_inputs(df_job,["nscf"]) == get_inputs(df_job,"nscf")







# @test check_job_data(df_job,check_keys) == Dict(:sk1=>3,:prefix=>"'test'",:noncolin => false, :ecutwfc=> 35)

# set_data1 = Dict(:Ze => [Point3D(1.2,3.2,1.2)])
Expand Down
1 change: 1 addition & 0 deletions test/test_linux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ pull_outputs(BiAlO3, extras = ["*.xsf"])
Pkg.test("DFControl")


qstat

0 comments on commit bbb1641

Please sign in to comment.