Skip to content

Commit 3d79dcc

Browse files
authored
Add a warning when the NLCC causes negative Fermi hole curvature (#1184)
1 parent c6d1e83 commit 3d79dcc

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/terms/xc.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,25 @@ function xc_potential_real(term::TermXc, basis::PlaneWaveBasis{T}, ψ, occupatio
8484
max_ρ_derivs = maximum(max_required_derivative, term.functionals)
8585
density = LibxcDensities(basis, max_ρ_derivs, ρ, τ)
8686

87+
if !isnothing(term.ρcore) && !isnothing(τ)
88+
negative_α = @views any(1:n_spin) do
89+
# α = (τ - τ_W) / τ_unif should be positive with τ_W = |∇ρ|² / 8ρ
90+
# equivalently, check 8ρτ - |∇ρ|² ≥ 0
91+
α_check = (8 .* density.ρ_real[iσ, :, :, :] .* density.τ_real[iσ, :, :, :]
92+
.- density.σ_real[DftFunctionals.spinindex_σ(iσ, iσ), :, :, :])
93+
any(α_check .<= -sqrt(eps(T)))
94+
end
95+
if negative_α
96+
@warn "Exchange-correlation term: the kinetic energy density τ is smaller " *
97+
"than the von Weizsäcker kinetic energy density τ_W somewhere. " *
98+
"This can lead to unphysical results. " *
99+
"This is typically caused by the non-linear core correction, " *
100+
"which is currently not applied for the kinetic energy density τ. " *
101+
"See also https://github.com/JuliaMolSim/DFTK.jl/issues/1180. " *
102+
"This message is only logged once." maxlog=1
103+
end
104+
end
105+
87106
# Evaluate terms and energy contribution
88107
# If the XC functional is not supported for an architecture, terms is on the CPU
89108
terms = potential_terms(term.functionals, density)

0 commit comments

Comments
 (0)