From 78a7a72605794dbde20aabb287a77d9af7c94ae3 Mon Sep 17 00:00:00 2001 From: "Michael F. Herbst" Date: Thu, 28 Dec 2023 10:27:40 +0100 Subject: [PATCH 1/2] Consistently indicate n_bands_converge --- src/input_output.jl | 3 ++- src/postprocess/band_structure.jl | 2 +- src/scf/newton.jl | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/input_output.jl b/src/input_output.jl index 98619ac477..af60ad8b84 100644 --- a/src/input_output.jl +++ b/src/input_output.jl @@ -211,6 +211,7 @@ function band_data_to_dict!(dict, band_data::NamedTuple; save_ψ=false, save_ρ= n_bands = length(band_data.eigenvalues[1]) dict["n_bands"] = n_bands # n_spin_components and n_kpoints already stored + dict["n_bands_converge"] = band_data.n_bands_converge if !isnothing(band_data.εF) haskey(dict, "εF") && delete!(dict, "εF") @@ -306,7 +307,7 @@ function scfres_to_dict!(dict, scfres::NamedTuple; save_ψ=true, save_ρ=true) band_data_to_dict!(dict, scfres; save_ψ) # These are either already done above or will be ignored or dealt with below. - special = (:ham, :basis, :energies, :stage, + special = (:ham, :basis, :energies, :stage, :n_bands_converge, :ρ, :ψ, :eigenvalues, :occupation, :εF, :diagonalization) propmap = Dict(:α => :damping_value, ) # compatibility mapping if mpi_master() diff --git a/src/postprocess/band_structure.jl b/src/postprocess/band_structure.jl index 279600fa10..af38acc84c 100644 --- a/src/postprocess/band_structure.jl +++ b/src/postprocess/band_structure.jl @@ -48,7 +48,7 @@ All kwargs not specified below are passed to [`diagonalize_all_kblocks`](@ref): # types subtype. In a first version the ScfResult could just contain # the currently used named tuple and forward all operations to it. (; basis=bs_basis, ψ=eigres.X, eigenvalues=eigres.λ, ρ, εF, occupation, - diagonalization=[eigres]) + diagonalization=[eigres], n_bands_converge=n_bands) end """ diff --git a/src/scf/newton.jl b/src/scf/newton.jl index 144599999d..6206b2d78c 100644 --- a/src/scf/newton.jl +++ b/src/scf/newton.jl @@ -150,7 +150,8 @@ function newton(basis::PlaneWaveBasis{T}, ψ0; # return results and call callback one last time with final state for clean # up info = (; ham=H, basis, energies, converged, ρ, eigenvalues, occupation, εF, n_iter, ψ, - stage=:finalize, algorithm="Newton", runtime_ns=time_ns() - start_ns) + stage=:finalize, algorithm="Newton", runtime_ns=time_ns() - start_ns, + n_bands_converge=n_bands) callback(info) info end From 517861133ac1eeba001c97e47f884f134cfe6989 Mon Sep 17 00:00:00 2001 From: "Michael F. Herbst" Date: Thu, 28 Dec 2023 10:38:17 +0100 Subject: [PATCH 2/2] Wannier fix --- src/external/wannier_shared.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/external/wannier_shared.jl b/src/external/wannier_shared.jl index 0aa90bf2bf..58c3ee1bc0 100644 --- a/src/external/wannier_shared.jl +++ b/src/external/wannier_shared.jl @@ -340,6 +340,10 @@ Shared file writing code for Wannier.jl and Wannier90. # TODO None of the routines consider spin at the moment @assert scfres.basis.model.spin_polarization in (:none, :spinless) @assert length(projections) == n_wannier + if n_bands > scfres.n_bands_converge + @warn("n_bands (=$n_bands) > scfres.n_bands_converge (=$(scfres.n_bands_converge)). " * + "This could make the wannierisation unclean. Reduce `n_bands` to prevent this.") + end # TODO Use band_data_to_dict to get this easily MPI compatible.