Skip to content

out_wfc_lcao 2 appends output wavefunction data to initial LCAO wavefunction file read by init_wfc nao #5913

Closed
@ahxbcn

Description

@ahxbcn

Details

Improved SCF Convergence with Proper Initial Charge and Wavefunction Handling

Reading a good initial charge density and wavefunction significantly aids in achieving SCF convergence. However, I encountered an issue when using init_wfc nao to read the LCAO wavefunction file (WFC_NAO_K*.dat) from a previously converged calculation and out_wfc_lcao 2 to write the converged LCAO wavefunction back into the same WFC_NAO_K*.dat file. The output data is written in append mode ("a"), resulting in the WFC_NAO_K*.dat file being concatenated with the new wavefunction data. This behavior prevents the effective use of init_wfc nao and out_wfc_lcao 2 to accelerate SCF convergence when working with ase-abacus and ATST-tools.

Reproducible Example

A minimal example demonstrating this issue is provided here. It includes two calculations for a Si crystal with the same structure:

  1. The first calculation, 1-out_wfc_lcao_2, generates the LCAO wavefunction file WFC_NAO_K1.dat and the charge density file Si-CHARGE-DENSITY.restart.
  2. These files are then copied to 2_read_chg_wfc/OUT.Si, and the calculation in 2_read_chg_wfc is executed. After completion, the size of WFC_NAO_K1.dat in 2_read_chg_wfc is 30744 bytes, exactly twice the size of the file in 1-out_wfc_lcao_2.

Proposed Fix

After reviewing the source code of ABACUS v3.9.0, I believe this issue stems from the use of Binstream ofs(name, "a"); in module_io/write_wfc_nao.cpp (lines 60 and 136). Would it be appropriate to modify this to Binstream ofs(name, "w"); to overwrite the initial LCAO wavefunction file (WFC_NAO_K*.dat) instead of appending to it?

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionsRaise your quesiton! We will answer it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions