Skip to content

Commit c1a6eb2

Browse files
committed
added JLD2 conversion from old dftu
1 parent dc2338c commit c1a6eb2

File tree

5 files changed

+86
-8
lines changed

5 files changed

+86
-8
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name = "DFControl"
22
uuid = "1e31e15d-4957-550d-a244-318eced754ae"
33
authors = ["Louis Ponet <[email protected]>"]
44
repo = "https://github.com/louisponet/DFControl.jl.git"
5-
version = "0.6.0"
5+
version = "0.6.1"
66

77
[deps]
88
ANSIColoredPrinters = "a4c015fc-c6ff-483c-b24f-f7ea428134e9"

src/Display/plotting.jl

Lines changed: 81 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ end
6868
end
6969
end
7070

71-
@recipe function f(job::Job, ymin, ymax, occupy_ratio = 0.2; overlap_spin = false, plot_pdos=true, outdat=Client.outputdata(job))
71+
@recipe function f(job::Job, ymin, ymax, occupy_ratio = 0.2; overlap_spin = false, plot_pdos=true, outdat=Client.outputdata(job), tot_dos=false, energy_guide = true)
7272
palette_ = ismissing(Plots.default(:palette)) ? :default : Plots.default(:palette)
7373
tc = Plots.plot_color(pop!(plotattributes, :seriescolor,
7474
RGB.(Plots.color_list(Plots.palette(palette_)))))
@@ -126,7 +126,7 @@ end
126126
end
127127
window_ids === nothing && error("No bands inside window")
128128
# We define a single band plotting series here
129-
function plot_band(band, color, label, subplot)
129+
function plot_band(band, color, label, subplot, linestyle=:solid)
130130
if overlap_spin
131131
tit = ""
132132
else
@@ -136,10 +136,11 @@ end
136136
@series begin
137137
xticks --> (tick_vals, tick_syms)
138138
title --> tit
139-
yguide := subplot == 1 ? "Energy (eV)" : ""
139+
yguide := subplot == 1 && energy_guide ? "Energy (eV)" : ""
140140
serieslabel := label
141141
subplot := subplot
142142
seriescolor := color
143+
linestyle := linestyle
143144
legend --> false
144145
1:length(kpoints), band.eigvals .- frmi
145146
end
@@ -148,7 +149,7 @@ end
148149
# PDOS part
149150
projwfc = Utils.getfirst(x -> Calculations.isprojwfc(x) && haskey(outdat, x.name), job.calculations)
150151
plot_pdos = plot_pdos && projwfc !== nothing && haskey(outdat[projwfc.name], :energies)
151-
if plot_pdos
152+
if plot_pdos && !tot_dos
152153
if bands isa NamedTuple && !overlap_spin
153154
doswindow = 3
154155
layout --> (1, 3)
@@ -198,13 +199,15 @@ end
198199
label --> "$(atsym)_$(orb.name)_up"
199200
yguide --> ""
200201
subplot := doswindow
202+
xguide --> ""
201203
seriescolor := atom_colors[1][ia]
202204
title := "DOS"
203205
pd[:, 1], energies .- frmi
204206
end
205207
@series begin
206208
label --> "$(atsym)_$(orb.name)_down"
207209
yguide --> ""
210+
xguide --> ""
208211
subplot := doswindow
209212
seriescolor := atom_colors[2][ia]
210213
title := "DOS"
@@ -215,6 +218,7 @@ end
215218
label --> "$(atsym)_$(orb.name)"
216219
yguide --> ""
217220
subplot := doswindow
221+
xguide --> ""
218222
seriescolor := atom_colors[1][ia]
219223
title := "DOS"
220224
pd, energies .- frmi
@@ -255,6 +259,77 @@ end
255259
end
256260
end
257261

262+
elseif plot_pdos && tot_dos
263+
if bands isa NamedTuple && !overlap_spin
264+
doswindow = 3
265+
layout --> @layout [a{0.4w} b{0.4w} c{0.2w}]
266+
else
267+
doswindow = 2
268+
layout --> @layout [a{0.8w} c{0.2w}]
269+
end
270+
energies = outdat[projwfc.name][:energies]
271+
dos = nothing
272+
for projs in values(outdat[projwfc.name][:pdos])
273+
for proj_dos in values(projs)
274+
if dos === nothing
275+
dos = proj_dos
276+
else
277+
dos .+= proj_dos
278+
end
279+
end
280+
end
281+
if dos isa Vector
282+
@series begin
283+
label --> ""
284+
yguide --> ""
285+
xguide --> ""
286+
subplot := doswindow
287+
seriescolor := :black
288+
xticks --> nothing
289+
title := "DOS"
290+
dos, energies .- frmi
291+
end
292+
else
293+
@series begin
294+
label --> "up"
295+
yguide --> ""
296+
xguide --> ""
297+
subplot := doswindow
298+
seriescolor := :blue
299+
xticks --> nothing
300+
title := "DOS"
301+
dos[:, 1], energies .- frmi
302+
end
303+
@series begin
304+
label --> "down"
305+
yguide --> ""
306+
subplot := doswindow
307+
xguide --> ""
308+
xticks --> nothing
309+
seriescolor := :red
310+
title := "DOS"
311+
-1.0*dos[:, 2], energies .- frmi
312+
end
313+
end
314+
315+
@info "Plotting bands..."
316+
if bands isa NamedTuple
317+
#loop over up down
318+
for (iplt, bnds) in enumerate(bands)
319+
lab = iplt == 1 ? "up" : "down"
320+
color = iplt == 1 ? :blue : :red
321+
linestyle = overlap_spin ? (iplt == 1 ? :solid : :dot) : :solid
322+
#loop over bands inside window
323+
for (ib, b) in enumerate(bnds[window_ids[iplt]])
324+
plot_band(b, color, ib == 1 ? lab : "", overlap_spin ? 1 : iplt, linestyle)
325+
end
326+
end
327+
else
328+
for (ib, b) in enumerate(bands[window_ids[1]])
329+
plot_band(b, plt_colors[mod1(ib, length(plt_colors))], "", 1)
330+
end
331+
end
332+
258333
# If no pdos is present
259334
else
260335
if bands isa NamedTuple && !overlap_spin
@@ -268,9 +343,10 @@ end
268343
for (iplt, bnds) in enumerate(bands)
269344
lab = iplt == 1 ? "up" : "down"
270345
color = iplt == 1 ? :blue : :red
346+
linestyle = overlap_spin ? (iplt == 1 ? :solid : :dot) : :solid
271347
#loop over bands inside window
272348
for (ib, b) in enumerate(bnds[window_ids[iplt]])
273-
plot_band(b, color, ib == 1 ? lab : "", overlap_spin ? 1 : iplt)
349+
plot_band(b, color, ib == 1 ? lab : "", overlap_spin ? 1 : iplt, linestyle)
274350
end
275351
end
276352
else

src/Jobs/job.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ StructTypes.StructType(::Type{Job}) = StructTypes.Mutable()
7373
scriptpath(job::Job) = joinpath(job, "job.sh")
7474
submission_time(job::Job) = mtime(scriptpath(job))
7575

76-
runslocal(job::Job) = job.server == "localhost"
76+
runslocal(job::Job) = job.server == RemoteHPC.local_server().name
7777
isarchived(job::Job) = occursin("archived", job.dir)
7878

7979
"""

src/Structures/atom.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ end
3434

3535
StructTypes.StructType(::Type{DFTU}) = StructTypes.Struct()
3636

37+
Base.convert(::Type{DFTU}, x::JLD2.ReconstructedMutable{:DFTU, (:l, :U, :J0, :α, :β, :J)}) = DFTU(x.l, x.U, x.J0, x.α, x.β, x.J, "ortho-atomic")
38+
3739
"""
3840
Element(symbol::Symbol, Z::Int, name::String, atomic_weight::Float64, color::NTuple{3, Float64})
3941

src/Structures/structure.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function mergestructures(structures::Vector{Structure})
6262
position_cryst = zero(Point3{Float64}))
6363
for structure in nonvoid[2:end]
6464
for at1 in out.atoms, at2 in structure.atoms
65-
if at1.position_cryst == at2.position_cryst
65+
if isapprox(at1.position_cryst, at2.position_cryst, atol=1e-5)
6666
for fname in fieldnames(typeof(at1))
6767
if fname in [:name, :element, :position_cart, :position_cryst]
6868
continue

0 commit comments

Comments
 (0)