Skip to content

Draft: Reorder charge density components

giannozz requested to merge giannozz/q-e:reorder into develop

Charge density components written to file should have a "reproducible" order, irrespective of the number of MPI processors and of the cutoff, in theory. In practice, when primitive lattice vectors are close to but not exactly equal to Bravais ones (case ibrav=0 and lattice vectors from input), the "reproducible" order turns out not to be reproducible. THis is what causes issue #230, and maybe many more obscure cases. This problem exists since may 2017 (commit b4c76d02), when I changed the way charge density is written to file from real to G space, but I suspect that the same problem may have always existed, and still exists, for Kohn-Sham orbitals as well.

This problem is related to, but not the same of, the one fixed in MR !1761 (merged): in that case, the "reproducible" order is in some cases ill-defined and changes if one re-orders an already ordered k+G-vector list with k=0.

This patch extends and simplifies recently introduced code, converting the charge density from half G-vectors (Gamma-only case) to full G-vectors, so that G-vector components read from file are re-ordered according to the ordering of the reading code. It is somewhat wasteful and a potential bottleneck (requires operations over all G-vectors, done by a single process) but in practice nobody should notice the difference.

Edited by giannozz

Merge request reports