Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistently employ n_bands_converge #940

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/external/wannier_shared.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
3 changes: 2 additions & 1 deletion src/input_output.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/postprocess/band_structure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

"""
Expand Down
3 changes: 2 additions & 1 deletion src/scf/newton.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading