6868 end
6969end
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_)))))
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
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"
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
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.4 w} b{0.4 w} c{0.2 w}]
266+ else
267+ doswindow = 2
268+ layout --> @layout [a{0.8 w} c{0.2 w}]
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
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
0 commit comments