-
Notifications
You must be signed in to change notification settings - Fork 93
Float instability of Fermi-level derivative of Chi0 for temperature & large band gap #1089
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
Comments
Well this is a convention, not so much a real requirement for insulating systems. Also if I think we should introduce a threshold (probably related to the occupation threshold) which determines at which point we simply count the |
So we want to compute sum of fp(lambdak) / sum f(lambdak), which we should do by computing logs with a logsumexp-type trick and then exponentiating. Returning zero is not valid, but probably we don't care that much, at least for first order. I don't think the Fermi level of the primal is even correct in this case anyway because of the way we compute the eps_f (a bisection on a function that is probably numerically zero over a range of eps_f anyway) So as a quick fix, either we set everybody to zero, or we detect the "effective insulator case" (gap >> temperature) and switch to insulator routines. |
We had an offline discussion and I agree, just returning the primal is not the right thing to do.
That would be my thinking, too. |
This came up now with me computing DFPT for various structures (metals, semiconductors, insulators) with temperature=1e-3 irrespective of the structure. It worked fine on Al and Si, but NaCl (salt) failed once it got to the response solver. Here's a cooked down self-contained reproducer:
Tracking this NaN down, I think I found the issue in chi0.jl:
DFTK.jl/src/response/chi0.jl
Line 277 in fa29008
For an insulator with a large band gap (such as NaCl with ~5.0 eV at PBE), we get numerical underflow in all the occupation derivatives, which in this case indeed leads to exact zeros
δocc_tot = 0.0
andD = 0.0
thusδocc_tot / D = NaN
.It seems the quickest fix is just to check
iszero(D)
before that division. What I am not sure about is whether returning zero as the Fermi level derivative in this case is even valid.With fixed temperature, but increasing band gap the Fermi level should be converging to the center of the gap, right? That would mean that it should asymptotically observe half the derivative of the gap. Does this make sense?
The text was updated successfully, but these errors were encountered: