Skip to content

nspin=2 + out_mat_hs2 writes empty hrs1/hrs2 CSR files while srs1 and dmrs are valid #7535

Description

@ReyMGil

Describe the bug

For a collinear spin-polarized LCAO calculation (nspin = 2), out_mat_hs2 generates hrs1_nao.csr and hrs2_nao.csr, but both Hamiltonian files contain only empty CSR blocks (data_size = 0). Consequently, the Hamiltonian cannot be used by post-processing codes such as TB2J.

In contrast:

  • srs1_nao.csr is correctly populated.
  • dmrs1_nao.csr and dmrs2_nao.csr are correctly generated and differ from each other.
  • Mulliken analysis shows finite magnetic moments, indicating that the SCF converged to a magnetic solution.

This suggests that the issue is specific to writing the real-space Hamiltonian for nspin = 2.

Expected behavior

hrs1_nao.csr and hrs2_nao.csr should contain the spin-up and spin-down real-space Hamiltonians, respectively, similarly to how srs1_nao.csr contains the overlap matrix.

To Reproduce

Use a collinear spin-polarized LCAO calculation with

basis_type lcao
nspin 2
out_mat_hs2 1 16
out_dmr 1
gamma_only 0
vl_in_h 1

After the SCF finishes, inspect

OUT./hrs1_nao.csr
OUT./hrs2_nao.csr

Both files contain only empty CSR blocks.

Environment

No response

Additional Context

  • ABACUS version: v3.11.0-beta.3
  • Basis: LCAO
  • Spin mode: nspin = 2 (collinear AFM)
  • out_mat_hs2 precision: 16 digits
  • The same material calculated with noncollinear (nspin = 4) correctly produces a populated hrs1_nao.csr.
  • dmrs1_nao.csr, dmrs2_nao.csr, and mulliken.txt confirm that the magnetic solution is not trivial.

I also inspected the implementation in ctrl_scf_lcao.cpp, where ModuleIO::write_hsr() receives

std::vector<hamilt::HContainer*> hr_vec = p_hamilt->getHR_vector();

I tested a local patch that explicitly called refresh(true) and updateHk() before getHR_vector(), but this did not change the output: hrs1_nao.csr and hrs2_nao.csr remained empty.

Questions

  1. Is out_mat_hs2 currently expected to work for collinear (nspin = 2) LCAO calculations?
  2. Are there additional input parameters required to populate hrs1_nao.csr and hrs2_nao.csr?
  3. Could this be a regression introduced in recent versions of ABACUS?

Task list for Issue attackers (only for developers)

  • Verify the issue is not a duplicate.
  • Describe the bug.
  • Steps to reproduce.
  • Expected behavior.
  • Error message.
  • Environment details.
  • Additional context.
  • Assign a priority level (low, medium, high, urgent).
  • Assign the issue to a team member.
  • Label the issue with relevant tags.
  • Identify possible related issues.
  • Create a unit test or automated test to reproduce the bug (if applicable).
  • Fix the bug.
  • Test the fix.
  • Update documentation (if necessary).
  • Close the issue and inform the reporter (if applicable).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions