Repository navigation
Charge-density restarts: G-space truncation and different SCF convergence with binary and cube files #7999
Description
Details
I recently read Chen et al.'s paper, Evaluating Predicted Densities, Hamiltonians, and Density Matrices as Periodic SCF Initializers, and became interested in an observation in Table 3: restarting from the converged charge density gives a median of 3 SCF iterations, whereas restarting from the converged density matrix or Hamiltonian gives a median of 1 iteration.
atomic_pair_20260920T103613Z_01-03.zip
After inspecting the ABACUS source and running controlled tests on the authors' agm001003669 example (see above), I found strong evidence that G-space truncation in the standard binary charge-density restart is the main reason for the additional iterations in this case. I would like to discuss the intended roles of the binary and cube restart paths, potential user confusion, and possible improvements.
Reproduction
- ABACUS v3.11.0-beta9, commit
239e8f43e93f720701beee1f3184af74426fb97e; no C++ modifications. - LCAO/PBE,
ecutwfc = 120 Ry,ecutrho = 480 Ry,scf_thr = 1e-7, Broyden mixing,mixing_beta = 0.2. - FFT grid:
45 × 45 × 108; parallel configuration: 8 MPI processes × 1 OpenMP thread. - The same executable, pseudopotentials, orbitals, and SCF settings were used throughout.
First, I performed a complete SCF calculation from an atomic initial guess, using out_chg 1 17 to save both the binary restart and a high-precision cube file. I then ran two separate restarts using these outputs:
init_chg file
read_file_dir ./INIT
out_chg 1 17
The two restart INPUT files were identical. The binary test's INIT directory contained only {suffix}-CHARGE-DENSITY.restart; the cube test's INIT directory contained only chg.cube. The logs confirmed that each run read the intended file.
| Initial guess | SCF iterations | DRHO |
|---|---|---|
| Atomic, full reference calculation | 13 | Final: 3.87606e-8 |
| Binary output from the reference calculation | 3 | 1.38407e-5 → 1.10726e-5 → 5.74538e-9 |
| High-precision cube output from the same calculation | 1 | 3.87606e-8 |
The cube density values were written in scientific notation with 17 digits after the decimal point. The cube produced after the one-step cube restart was byte-for-byte identical to the reference cube.
Source inspection and numerical checks
In the LCAO path inspected, both outputs originate from the same rho_save, but they preserve different representations:
- Binary:
rho_saveis transformed to reciprocal space, and only the G components retained by the charge-density plane-wave basis are written. This cutoff-limited set does not include all Fourier components representable on the full FFT grid. - Cube:
rho_saveis written directly on the full real-space grid.
Relevant code: binary output, G-vector selection, and cube output.
Transforming the full cube density to reciprocal space, retaining only the G set present in the binary file, and transforming back introduces a normalized L1 density difference of approximately 1.38401e-5. This is close to the binary restart's first-iteration DRHO of 1.38407e-5. Meanwhile, the maximum difference between the binary coefficients and the cube's Fourier coefficients on the retained G set is only approximately 1.4e-17.
These results strongly support loss of high-G components, rather than floating-point precision of the stored coefficients, as the dominant cause in this example. I have not verified this explanation across the paper's entire benchmark dataset.
Why the current behavior may be confusing
With init_chg=file, ABACUS attempts to read the binary restart first and falls back to cube if that fails. Consequently, when both files are present in read_file_dir, the binary file takes precedence even if the user explicitly requested a high-precision cube. See the file-selection logic.
Although the selected file is reported in the log, users may reasonably assume that these are simply two storage formats for the same converged density. In practice, they can preserve different information and produce different SCF restart behavior. For oracle tests or evaluations of AI-predicted density initializers, this representation loss can also confound the assessment of initializer quality.
Questions for discussion
- What are the intended use cases for maintaining both reciprocal-space binary and real-space cube charge-density restarts? Are there performance, compatibility, or historical considerations behind the G truncation and binary-first selection policy?
- Could the documentation and initialization logs explain this distinction more explicitly? Would an explicit input option for choosing the restart format be useful, so users do not need to move files to control which one is read?
- Would it be worth supporting a binary format that preserves the complete real-space grid density, or another mode that allows a numerically faithful round trip without additional G-space truncation?
I would appreciate the maintainers' perspective on the current design and whether changes to the interface or default behavior would be appropriate.
Have you read FAQ on the online manual http://abacus.deepmodeling.com/en/latest/community/faq.html
- Yes, I have read the FAQ part on online manual.
Task list for Issue attackers (only for developers)
- Understand the problem or question described by the user.
- Check if the issue is a known problem or has been addressed in the documentation.
- Test the issue or problem on a similar system or environment, if possible.
- Identify the root cause or provide clarification on the user's question.
- Provide a step-by-step guide, including any necessary resources, to resolve the issue or answer the question.
- If the issue is related to documentation, update the documentation to prevent future confusion (optional).
- If the issue is related to code, consider implementing a fix or improvement (optional).
- Review and incorporate any relevant feedback from users or developers.
- Ensure the user's issue is resolved or their question is answered and close the ticket.
Activity
QuantumMisaka commentedon Sep 21, 2026
@kirk0830 May you have a look 👀
Growl1234 commentedon Sep 21, 2026
Growl1234 commentedon Sep 21, 2026
I see the
init_chgis already a reliable parameter. So what is needed about this is just to splitfileoption.Growl1234 commentedon Sep 21, 2026
Btw, I'm curious what's the point of splitting
init_wfcandinit_chg. For example, the currentinit_chg=wfccould cause confusion.Since both of them are taking care of the same thing in practice (SCF initialisation or non-SCF calculation), I think it would be less confusing to merge them into one keyword. If they are really taking care of different things, at least redefine and clarify their semantics.
mohanchen commentedon Sep 24, 2026
Very helpful suggestions from all of you, we will see what we can do to improve these features.
kirk0830 commentedon Oct 11, 2026
Hi @WHUweiqingzhou,
The support for the binary format of charge density is primarily based on two key considerations:
While the behavior of truncating the Fourier components of the charge density is well understood, it remains undeniable that the binary format can preserve the numerical precision of all retained components. The fact that more than one step is required for SCF restart to achieve convergence actually indicates that there are still significant components not included within the sphere of |G| (due to insufficient ecutrho). Consequently, the three-step SCF restart from the binary format of charge density is a necessary trade-off.
The cube file format is primarily designed for visualization purposes rather than for lossless data storage. A three-digit dump is generally sufficiently precise for most qualitative analyses conducted by human observers, such as charge difference analysis. As noted in the report, while a 17-digit cube file can facilitate rapid convergence of SCF restart, it comes at the cost of increased hard disk usage.
Given that it is impossible to ascertain in advance the precision of the cube file provided by the user, the most logical sequence for reading the charge density file is to prioritize the binary format, followed by the cube format. However, this approach is predicated on the assumption that ecutrho has been appropriately parameterized.
Regards,
Yike
kirk0830 commentedon Oct 11, 2026
@Growl1234 Hi, I attach my reply below your words:
Writing the real-space charges in binary format would be a choice, I will evaluate on the necessarity of this furtherly.
Our binary wavefunction dump functionality is already there, and there is also a mechanism |wfc|^2 -> rho if restarting from the wfc.
This is because the restart behavior can be different for PW and LCAO cases. For PW, it is less economic to dump the wfc because the wfc always takes far larger memory/disk space, while for LCAO, yes, it would be the other story that saving the wfc might be more economic than the charge density. But it is still of need to split these two keywords for ABACUS, because this allows user to optimize the structure with NAO basis and calculate the single point energy with PW basis to avoid the BSSE.