Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
louisponet committed Jun 7, 2018
1 parent 9c2ee12 commit ba8b28a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 31 deletions.
6 changes: 2 additions & 4 deletions src/DFControl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,8 @@ module DFControl
export read_wannier_input

include("plotting.jl")
export plot_qe_bands
export plot_qe_kpdos

include("server_comm.jl")
export read_errors
export outputs
export pullfile
export pullfiles
Expand All @@ -84,10 +81,11 @@ module DFControl
export getdefault_pseudodir
export getdefault_pseudodirs
export removedefault

include("display/overloads.jl")
if Pkg.installed("Atom") != nothing
include("display/printing_juno.jl")
end
dfprintln(io::IO, s::String) = println(io, s)
dfprintln(s::String) = println(s)
function __init__()
init_defaults(default_file)
Expand Down
30 changes: 16 additions & 14 deletions src/display/overloads.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#printing that is not needed in Atom

function Base.show(io::IO, info::InputData)
println("Info name: $(info.name)\n flags:")
for (flag, value) in info.flags
println(" $flag => $value")
end
println("")
end

function Base.display(block::DataBlock)
function Base.show(block::InputData)
s = """Block name: $(block.name)
Block option: $(block.option)
Block data:
"""
dfprintln(s)
dfprintln(string(block.data) * "\n\n")
end
function Base.display(block::InputData)
s = """Block name: $(block.name)
Block option: $(block.option)
Block data:
Expand All @@ -17,7 +18,7 @@ function Base.display(block::DataBlock)
dfprintln(string(block.data) * "\n\n")
end

function Base.display(data::Array{<:Block})
function Base.display(data::Vector{InputData})
map(display, data)
end

Expand All @@ -36,12 +37,13 @@ function Base.display(band::DFBand{T}) where T <: AbstractFloat
dfprintln(string)
end

function Base.display(bands::Array{<:DFBand})
function Base.display(bands::Vector{<:DFBand})
map(display,bands)
end

function Base.show(job::DFJob)
try
print_info(job)
end
function Base.show(io::IO, job::DFJob)
print_info(job, io)
end
function Base.display(io::IO, job::DFJob)
print_info(job, io)
end
2 changes: 1 addition & 1 deletion src/input.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function DFInput(template::DFInput, filename, newflags...; excs=execs(template),
input = deepcopy(template)
input.filename = filename
input.execs = excs
input.run = run
setflags!(input, newflags..., print=false)

if data != nothing
Expand All @@ -49,7 +50,6 @@ package(::DFInput{P}) where P = P
data(input::DFInput) = input.data
data(input::DFInput, name) = getfirst(x-> x.name == name, input.data)
data(input::Vector{InputData}, name) = getfirst(x-> x.name == name, input.data)
data(input, name) = data(input, name).data

exec(input::DFInput, exec::String) = getfirst(x -> contains(x.exec, exec), input.execs)
execs(input::DFInput) = input.execs
Expand Down
8 changes: 3 additions & 5 deletions src/job.jl
Original file line number Diff line number Diff line change
Expand Up @@ -842,11 +842,11 @@ end


"""
print_info(job::DFJob, filenames::Vector{String})
print_info(job::DFJob, io=STDIN)
Prints general info of the job.
"""
function print_info(job::DFJob, filenames::Vector{String})
function print_info(job::DFJob,io=STDIN)
s = """--------------------
DFJob: $(job.name)
Local_dir: $(job.local_dir)
Expand All @@ -855,10 +855,8 @@ function print_info(job::DFJob, filenames::Vector{String})
$(length(job.inputs)) calculations
--------------------
"""
dfprintln(s)
dfprintln(io, s)
end
print_info(job::DFJob) = print_info(job, [calc.filename for calc in job.inputs])
print_info(job::DFJob, filename::String) = print_info(job, [filename])

hasoutput(job::DFJob, input) = ispath(outpath(job, input))

Expand Down
10 changes: 3 additions & 7 deletions src/qe/fileio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,16 @@ function read_qe_output(filename::String, T=Float64)
while !contains(line, "End final coordinates")

if contains(line, "CELL_PARAMETERS")
out[:alat] = parse(T, split(line)[end][1:end-1])
out[:alat] = contains(line, "angstrom") ? :angstrom : parse(T, split(line)[end][1:end-1])
out[:cell_parameters] = reshape(T[parse.(T, split(readline(f))); parse.(T, split(readline(f))); parse.(T, split(readline(f)))], (3,3))
elseif contains(line, "ATOMIC_POSITIONS")
out[:pos_option] = cardoption(line)
line = readline(f)
atoms = Dict{Symbol,Array{Point3{T},1}}()
atoms = []
while !contains(line, "End")
s_line = split(line)
key = Symbol(s_line[1])
if key in keys(atoms)
push!(atoms[key], Point3{T}(parse.(T, s_line[2:end])...))
else
atoms[key] = [Point3{T}(parse.(T, s_line[2:end])...)]
end
push!(atoms, key=>Point3{T}(parse.(T, s_line[2:end])...))
line = readline(f)
end
out[:atomic_positions] = atoms
Expand Down

0 comments on commit ba8b28a

Please sign in to comment.