Skip to content

Commit

Permalink
bug in label generation
Browse files Browse the repository at this point in the history
  • Loading branch information
louisponet committed Oct 25, 2019
1 parent 8861fbf commit 6daeb65
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions src/job.jl
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,32 @@ function sanitize_magnetization!(job::DFJob)
if !any(x->package(x) == QE, inputs(job))
return
end
magnetic_uats = filter(ismagnetic, unique(atoms(job)))
element_to_magnetization = Dict([element(at) => Vec3{Float64}[] for at in magnetic_uats]...)
for at in magnetic_uats
magvec = element_to_magnetization[element(at)]
mag = magnetization(at)
if !in(mag, magvec)
push!(magvec, mag)
magnetic_ats = filter(ismagnetic, atoms(job))
magnetic_elements = map(element, magnetic_ats)
for e in magnetic_elements
magnetizations = Vec3[]
dftus = DFTU[]
for a in magnetic_ats
if e == element(a)
magid = findfirst(x -> x == magnetization(a), magnetizations)
dftuid = findfirst(x-> x == dftu(a), dftus)
if magid === nothing
push!(magnetizations, magnetization(a))
tid1 = length(magnetizations)
else
tid1 = magid
end
if dftuid === nothing
push!(dftus, dftu(a))
tid2 = length(dftus)
else
tid2 = dftuid
end
atid = max(tid1, tid2)
a.name = Symbol(string(e.symbol)*"$atid")
end
end
end

for at in filter(ismagnetic, atoms(job))
el = element(at)
id = findfirst(x -> x==magnetization(at), element_to_magnetization[el])
at.name = Symbol(string(el.symbol)*"$id")
end
end

function sanitize_projections!(job::DFJob)
Expand Down

0 comments on commit 6daeb65

Please sign in to comment.