Skip to content

Commit 233133c

Browse files
committed
some patches and bugfixes
1 parent 50a6f4b commit 233133c

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

src/Calculations/qe.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ end
186186

187187
function outfiles(c::Calculation{QE})
188188
files = [c.outfile]
189-
for (is, fuzzies) in zip(("projwfc.x", "hp.x"), (("pdos",), ("Hubbard_parameters",)))
189+
for (is, fuzzies) in zip(("projwfc.x", "hp.x", "pp.x"), (("pdos",), ("Hubbard_parameters",), ("filplot", "fileout")))
190190
if c.exec.exec == is
191191
append!(files, fuzzies)
192192
end
@@ -337,13 +337,17 @@ function gencalc_projwfc(template::Calculation{QE}, Emin, Emax, DeltaE, extrafla
337337
end
338338
tdegaussflag = get(template, :degauss, nothing)
339339
degauss = tdegaussflag !== nothing ? tdegaussflag : 0.0
340-
exec = Exec(path=joinpath(dirname(template.exec.path), "projwfc.x"), modules = deepcopy(template.exec.modules), flags = deepcopy(template.exec.flags))
341-
empty!(exec.flags)
340+
exec = Exec(path=joinpath(dirname(template.exec), "projwfc.x"), modules = deepcopy(template.exec.modules))
341+
342342
out = Calculation(deepcopy(template); name = name, exec = exec, data = InputData[])
343+
343344
set_name!(out, "projwfc")
345+
344346
empty!(out.flags)
347+
345348
set_flags!(out, :Emin => Emin, :Emax => Emax, :DeltaE => DeltaE, :ngauss => ngauss,
346349
:degauss => degauss; print = false)
350+
347351
set_flags!(out, extraflags...)
348352
return out
349353
end

src/Client/job.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ function outputdata(job::Job; calcs=map(x->x.name, job.calculations), extra_pars
386386
end
387387
end
388388
catch e
389-
@warn "Error while reading output of calculation: $(c)\n" e
389+
@warn "Error while reading output of calculation: $(c)\n" showerror(stdout, e,stacktrace(catch_backtrace()))
390390
end
391391
end
392392
end
@@ -413,7 +413,7 @@ function bandgap(job::Job, nelec = nothing, outdat = outputdata(job))
413413
if isempty(n_calcs)
414414
error("No valid calculation found to extract the number of electrons.\nPlease supply nelec manually.")
415415
end
416-
nelec = maximum(x->get(get(outdat, x.name, Dict()), :fermi, -Inf), n_calcs)
416+
nelec = maximum(x->get(get(outdat, x.name, Dict()), :n_electrons, 0), n_calcs)
417417
end
418418

419419
bands = map(x->outdat[x.name][:bands], filter(x -> haskey(outdat, x.name), band_calcs))

src/FileIO/qe.jl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -716,9 +716,10 @@ function qe_parse_projwfc_output(files...)
716716
end
717717

718718
function pdos(files, kresolved=false)
719-
720719
dir = splitdir(files[1])[1]
721-
atsyms = Symbol.(unique(map(x -> x[findfirst("(", x)[1]+1:findfirst(")", x)[1]-1],files)))
720+
atfiles = filter(x -> occursin("atm", x), files)
721+
722+
atsyms = Symbol.(unique(map(x -> x[findfirst("(", x)[1]+1:findfirst(")", x)[1]-1], atfiles)))
722723
magnetic = (x->occursin("ldosup",x) && occursin("ldosdw",x))(readline(files[1]))
723724
soc = occursin(".5", files[1])
724725
files = joinpath.((dir,), files)
@@ -1287,8 +1288,8 @@ end
12871288
12881289
Writes a string represenation to `f`.
12891290
"""
1290-
function Base.write(f::IO, calculation::Calculation{QE}, structure)
1291-
cursize = f.size
1291+
function Base.write(f::IO, calculation::Calculation{QE}, structure=nothing)
1292+
cursize = f isa IOBuffer ? f.size : 0
12921293
if Calculations.hasflag(calculation, :calculation)
12931294
Calculations.set_flags!(calculation,
12941295
:calculation => replace(calculation[:calculation],
@@ -1312,13 +1313,20 @@ function Base.write(f::IO, calculation::Calculation{QE}, structure)
13121313
# write(f," A = $A\n")
13131314
write(f, " nat = $nat\n")
13141315
write(f, " ntyp = $ntyp\n")
1316+
elseif name == :projwfc
1317+
prefix = calculation[:prefix]
1318+
outdir = calculation[:outdir]
1319+
write(f, " prefix = $prefix\n")
1320+
write(f, " outdir = $outdir\n")
13151321
end
1322+
13161323
map(writeflag, [(flag, data) for (flag, data) in flags])
13171324
write(f, "/\n\n")
13181325
end
13191326
end
13201327

13211328
if exec(calculation.exec) == "pw.x"
1329+
@assert structure !== nothing "Supply a structure to write pw.x input"
13221330
write_structure(f, calculation, structure)
13231331
end
13241332
for dat in calculation.data
@@ -1343,8 +1351,9 @@ function Base.write(f::IO, calculation::Calculation{QE}, structure)
13431351
delete!.((calculation,),
13441352
(:Hubbard_U, :Hubbard_J0, :Hubbard_J, :Hubbard_alpha, :Hubbard_beta,
13451353
:starting_magnetization, :angle1, :angle2, :pseudo_dir))
1346-
return f.size - cursize
1354+
return f isa IOBuffer ? f.size - cursize : 0
13471355
end
1356+
13481357
function Base.write(f::AbstractString, c::Calculation{QE}, structure)
13491358
open(f, "w") do file
13501359
write(file, c, structure)

src/FileIO/wannier.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function wan_parse_calculation(file)
116116
else
117117
m = match(r"\b([\w\d]+):", line)
118118
atom = Symbol(m.captures[1])
119-
projections = map(x->x.captures[1], eachmatch(r"[\s,;]([\w\d]+)", line))
119+
projections = map(x->x.captures[1], eachmatch(r"[:\s,;]([\w\d]+)", line))
120120
push!(proj_dict, (atom, projections))
121121
end
122122
i += 1

0 commit comments

Comments
 (0)