Skip to content

LCAO RT out_current=2 reuses one spin Hamiltonian for both channels (nspin=2) #8285

Closed

Description

@memii-x

Summary

For LCAO RT-TDDFT with nspin=2 and out_current=2, the commutator-current path copies the currently active spin's H(R) once and uses it for both spin channels. A fixed-ion HSE test changes its total charge current when only the spin labels are exchanged.

Reproduction

Use the two-atom Si HSE fixture, including its Si pseudopotential/orbital and Gamma-centered 2x1x1 mesh. Replace/add these INPUT values:

out_current   2
out_current_k 1
out_efield    1
out_vecpot    1
scf_thr       1e-10
scf_nmax      150
nbands        8
nupdown       2

Set the Si species' initial magnetization in STRU to 1.0. In a separate fresh directory, change only nupdown to -2 and that initial magnetization to -1.0. Use valid pseudo_dir/orbital_dir paths. Run each with 2 MPI ranks and 1 OpenMP/BLAS thread per rank. The fixture has fixed ions, no SOC, hybrid gauge, a z-directed electric field and two propagation steps (td_dt=0.005 fs).

Without SOC or a spin-dependent external field, exchanging the two collinear spin labels should leave the total charge current unchanged.

Observed result

All three electronic endpoints converge in both runs. The field/vector-potential outputs match. Final magnetizations are +2.00009 and -2.00009 Bohr magnetons/cell, and final energies differ by only 1.14e-13 eV.

The last row of current_tot_comm.txt is:

Initial spin orientation Jx (a.u.) Jy (a.u.) Jz (a.u.)
positive 6.527227820493e-7 -6.527324018700e-7 1.012089061390e-5
negative 6.332051519479e-7 -6.332149201937e-7 9.963723115747e-6

The Jz difference is 1.57167498153e-7 a.u., or 1.55% relative to the positive-orientation value. Repeating the positive-orientation run gives identical current output at printed precision.

Runtime reproduction used the local CPU/OpenMPI build byte-verified against PR #8170 commit 55a0996915cd624c89f26da16b9a70738d54d2d6 (binary SHA-256 eeb66dea464efa5a21522b301b7b1ef87592099b384792799da319150b969f93). The two current-dispatch/calculation files below are byte-identical to upstream develop 819d6ee7b702fc5dce0947054280802623cc3175; that upstream commit was inspected, not separately rebuilt for this test.

Code path

  • ctrl_output_td.cpp passes one p_hamilt->getHR() to the current writer.
  • write_current builds one full_hR before processing all k/spin entries.
  • cal_velocity_basis_k folds that same H(R) for every ik, without selecting the Hamiltonian corresponding to kv.isk[ik].

The current construction should use the matching spin Hamiltonian for each channel. The paired run above can serve as a regression. This report concerns collinear nspin=2; it does not establish the same defect for the full-spinor nspin=4 layout.

Activity

  1. ABACUS-PR-BOT commented on Nov 4, 2026

    @ABACUS-PR-BOT
    Collaborator

    Source review confirms the spin-selection defect at 819d6ee7: getHR() exposes one active H(R), and the commutator writer copies it once for every spin/k entry. The later isk lookup only labels the output. Each channel needs its matching Hamiltonian for both H(k) and its k derivative.

    To validate a later fix, use spin Hamiltonians with different projected velocities and compare each spin/k current with an independent calculation using its matching Hamiltonian. Also check that swapping spin labels preserves total current and swaps the per-spin contributions, and that changing only the active Hamiltonian view before output leaves all results unchanged.

    This is a source/analytic diagnosis. I have not independently reproduced the reported 1.55% difference or verified a patch, and this conclusion does not extend to the nspin=4 representation.

  2. added
    Bugs
    rt-TDDFT
    on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugsrt-TDDFT

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions