-
Notifications
You must be signed in to change notification settings - Fork 145
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
Two bugs in pw90common_fourier_R_to_k* #273
Two bugs in pw90common_fourier_R_to_k* #273
Conversation
Thanks! Indeed the loops seem wrong. Do you have an example where the interpolation is wrong because of this bug and gets much better after the fix? |
The attachment is a zip file including the input and output files of QE & wannier90. The structure of the zip is:
To reduce computational time, I have decreased energy cutoff, kmesh in QE run, and the number of iterations in wannierisation step, so the spreads of MLWF are not very good, around The file Since the For your convenience, the figures are pasted here: Note added: Actually, these weird interpolations were identified by my colleague, Jiaqi Zhou. After carefully digging into the source code I found it was these tiny mistakes that resulted in the wrong interpolation. Moreover, if the spreads of MLWF are larger, the interpolation is much worse, totally different from the ab initio results. |
Dear Junfeng, thank you for pointing to this bug. I also suspect there is another bug with ws_distance in postw90_common.F90 line 732 ( subroutine pw90common_fourier_R_to_k ) which I believe is correct. However in the other versions of this subroutine the array crvec is used instead of crdist_ws, also when use_ws_distance=True see lines 732, 820-825, 881, 888, 995, 1093-1101, 1182, 1318 e.g line 820: Am I right, that those lines also need to be corrected (crvec-> crdist_ws) ? This does not change the interpolated energies, but plays a role when interpolating velocities, Berry curvatures, etc |
Dear Junfeng, thanks for spotting this. I also totally agree that both 1. and 2. are bugs and I believe that your commits are the right solution. For 1. indeed the indices For 2. I think the re-definition of |
Dear Stepan, It think you are right. There was initially an issue with the interpolation of band velocity that was solved in #53 . Thanks you for spotting this! |
Good, How do we proceed? |
Dear Marco Gibertini, Thanks! I have removed those comments. |
Dear Stepan S. Tsirkin, Thanks! I think it should be |
Dear Junfeng, |
Dear Stepan, I have corrected the
|
Hi Jungeng, Thank you, the correction look fine. Just now after a careful look, in lines 1302 |
If I am not mistaken, those lines are introduced here by @Julen-ia but they have comments with Could @Julen-ia and @paulatz comment on these points/possible bugs? (We are having a coding day on the 24th and if we figure out everything before then we can review and merge). Thanks! |
Dear all, Thank you for spotting the bugs, and also these two lines that I introduced and need to be changed. I think that the safest solution is to specify that both irdist_ws and irvec need to be zero in the if statement Stepan spotted. In principle, the if statement should only apply to one R vector, namely \vec{R}=0 (the origin). In ws_distance.f90, line 136, I see irdist_ws(:, ideg, iw, jw, ir) = irvec(:, ir) + shifts(:, ideg) if we switch irvec --> irdist_ws in the if statement Stepan spotted, irdist_ws = 0 could be triggered even if irvec(:,ir) \neq 0 provided irvec = - shifts , and this is not what we want. I dont have much experience with irdist_ws, so what I just said may never take place. Unfortunately I am on travel at the moment and I have limited availability for doing numerical checks. Any feedback is appreciated, thank you all Best regards Julen |
It's been a while, and I'm not sure I remember everything correctly. From what I see, the "old" subroutine pw90common_fourier_R_to_k should be correct, except for the exchange of i with j in wdist_ndeg. I think this is not really a bug since wdist_ndeg(i,j,ir) is symmetric in i,j (I cannot think of any case where it could be non-symmetric, but I may be wrong). On the other hand, the "new" subroutine pw90common_fourier_R_to_k_new was actually still using the "old" interpolation, without using the minimum distance. All the changes look correct to me and should fix the problem. In pw90common_fourier_R_to_k_vec (line ~1087) the re-definition of the phase factor also looks quite clearly like a bug to me and I think the new code fixes it. cheers |
Dear Julen, Thanks for the response! From Eq.(21) in your paper, the TB convention is In the Wigner Seitz interpolation, we replace the ordinary interpolation Since Thus, if Please point out my mistakes if I misunderstand anything. Thanks, |
Hello Junfeg, |
Dear Lorenzo, Thanks for the comment. I forgot the condition In terms of your previous comment on the symmetry of |
Dear Junfeng and Lorenzo Thank you for your replies. You obviously have more experience than me with this interpolation procedure. From your discussion, I agree that the right thing to do is leaving the if statement as it is. Thanks again |
I've been thinking about wdist_ndeg being symmetric in i,j and I'm no more convinced that it is. I would say that if i_m+R is on the face (or edge, or vertex) of the super-WS cell of i_n, that i_n must be on the face (or edge, or vertex) of the super-WS of i_m+R. But we are not doing this, we are exchanging i_n-(i_m+R) with i_m-(i_n+R), which is not the same. There must however exist on R' that it is super-periodically equivalent to -R, and wdist_nedg(i,j,R) = wdist_ndeg(j,i,R'), which is a much weaker condition |
Dear Lorenzo, Thanks! I agree with your arguments so Lines 123 to 134 in 6f61f72
Maybe it is better to write function JW translated in the Wigner-Seitz around function IW ?This is more consistent with the code and other comments: Lines 33 to 35 in 6f61f72
Lines 146 to 148 in 6f61f72
|
Yes, you are right, also the general grammar and spelling of the comment is worse than my usual, I'll let you fix it if you want |
Codecov Report
@@ Coverage Diff @@
## develop #273 +/- ##
===========================================
- Coverage 63.33% 63.31% -0.03%
===========================================
Files 29 29
Lines 17975 17979 +4
===========================================
- Hits 11385 11383 -2
- Misses 6590 6596 +6
Continue to review full report at Codecov.
|
Great, I think all the problems have been solved. I have regenerated the benchmark in |
Thanks a lot @qiaojunfeng for spotting this bug and providing a fix, and all for the very useful discussions and bug scavenging :-) We were discussing earlier today with @mostofi, @jryates and @ivosouza0 and we just had a doubt because of the relatively large change of the eigenvalues for the silicon interpolation with geninterp, so we decided to do additional tests before merging. I just did them for Si (example 11). Indeed, the code before and after this PR returns the same band structure when interpolated with Wannier90, but the previous code (current develop, before these fixes) returned a different band structure between wannier90 and postw90 (with geninterp). So, I think that the fix is correct and I'm going to merge it. |
…tance Two bugs in pw90common_fourier_R_to_k*
There are 2 major bugs in routines
pw90common_fourier_R_to_k*
The loop index
i, j
onwdist_ndeg
is wrong, and this will cause wrong interpolation results of all the calculations. In some bandstructure calculations, the Wannier interpolated bands significantly deviate from ab initio bands. Applying fixes of this commit can correctly interpolate bandstructure.The repeated calculations of
rdotk
andphase_fac
can lead to wrong results, as pointed out in issue 271.Fixes #271.