Skip to content

qforge(3d-scf): true 3-D real-space SCF density ρ(r) — pow2-FFT wall broken, screening root re-diagnosed#3003

Open
dancinlife wants to merge 5 commits into
mainfrom
qforge-3d-realspace-scf
Open

qforge(3d-scf): true 3-D real-space SCF density ρ(r) — pow2-FFT wall broken, screening root re-diagnosed#3003
dancinlife wants to merge 5 commits into
mainfrom
qforge-3d-realspace-scf

Conversation

@dancinlife

Copy link
Copy Markdown
Contributor

Summary

Implements the true 3-D real-space SCF density ρ(r) rebuild named as the next lever by the RTSC A1 PBE-SCF verdict — replacing the degenerate (1,1,n) 1-D G-index density with a pow2-PADDED 3-D cube so spectral GGA ∇ρ sees a genuine 3-D gradient and n=645 ≠ pow2 maps onto a valid FFT grid.

New / changed

  • stdlib/qforge/scf_pw_realspace.hexa (NEW): pow2-padded 3-D cube from integer Miller indices; ρ(r)=Σocc|ψ(r)|² via ψ(G)→ifft3; per-axis spectral ∇ρ (iG_x/iG_y/iG_z); spectral PBE V_xc[ρ,|∇ρ|] + F_x(s) + 3-D Hartree; reusable scratch buffers (jetsam guard). Correct G-diagonal projection = spatial average V̄ + off-diagonal RMS witness.
  • stdlib/qforge/scf_pw_realspace_selftest.hexa (NEW): g5 10/10 PASS on analytic plane-wave/cosine targets (incl. cos(G·x)⇒peak|∇ρ|=A·|G| exact — the genuine 3-D gradient).
  • stdlib/qforge/scf_pw.hexa: qforge_scf_pw_h_multi_smeared_rs3d opt-in 3-D screening route; LDA path untouched (scf_pw_selftest 20/20 PASS regression).
  • stdlib/qforge/pw_frontend.hexa: qpw_set_rs3d toggle.

Result (CaH6, d6 — 4.376 NOT forced)

  • Headline: PBE V_xc[ρ,∇ρ] now ENGAGES + the SCF CONVERGES at the physical n=645 basis (first time — the A1-named pow2-FFT wall is removed; 32³ pow2-padded cube).
  • λ VERBATIM: LDA(1,1,n)=0.609 → PBE-3D n=645 λ=1.43e-88 ≈ 0.
  • Root RE-DIAGNOSED: the wall is the diagonal-only assembler, not the density. A correct local V_scr(r) contributes only its spatial average V̄ to the diagonal; the el-ph screening (offdiag RMS/|V̄| = 0.69 V_xc, 5.56 V_scr at n=645) is off-diagonal and discarded. The (1,1,n) λ=0.609 was an artifact of an unphysical per-G diagonal.
  • GATE NOT MET; hybrid (rel-ε 1.65e-7) remains production; dispatch=qe. Next lever = off-diagonal V_scr(G_a−G_b) assembly (the 3-D ρ(r) built here is exactly its input).

Full verdict: demiurge/.verdicts/qforge-3d-realspace-scf/. Cost $0 (0-pod local).

🤖 Generated with Claude Code

nbcorr-agent and others added 5 commits June 9, 2026 20:46
…dded cube, spectral GGA ∇ρ

Replaces the (1,1,n) 1-D G-index density (scf_pw.hexa root named in A1 PBE-SCF
verdict) with a true 3-D real-space ρ(r) on a pow2-PADDED cube (each axis a power
of two, sized from the actual Miller (h,k,l) range) so n=645 always maps onto a
valid FFT grid. ψ(G) scatter → ifft3 → ψ(r) → ρ(r)=Σocc|ψ(r)|²; ∇ρ via per-axis
iG_x/iG_y/iG_z spectral gradient (a genuine 3-D gradient norm); spectral PBE
V_xc[ρ,|∇ρ|] + 3-D Hartree; sample V_scr(r) back onto the PW-G diagonal.

d4-generic (gvecs+Miller+basis = data), LDA path untouched (opt-in xc_mode=3).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ace fft3

Two fixes found via the analytic g5 gate:
- _rs_grad_component now copies its input before fft3 (core_fft's 3-D transform
  mutates real/imag inputs IN PLACE; passing the density directly corrupted it
  across successive gradient-component calls → spurious nonzero divergence on a
  uniform ρ). Confirmed: re[0] 0.30→1.2 after fft3 without the copy.
- selftest freezes vxc_u[0] into a scalar immediately (the interpreter reuses FFT
  buffers across later cases; a deferred array read aliased).

g5 (analytic plane-wave/cosine targets, no number-forcing): pow2-padding (n=7
odd → 32³), uniform→|∇ρ|=0, PBE→LDA reduction exact, cos→peak|∇ρ|=A·|G| (the
genuine 3-D gradient a (1,1,n) line cannot produce), 3-D Hartree=4π/|G|² exact,
∫ρ=nelec, GGA-live, F_x bounds. 10/10 PASS.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… smeared SCF

New qforge_scf_pw_h_multi_smeared_rs3d entry: stages a pow2-padded 3-D cube from
integer Miller indices (n=645≠pow2 maps onto a valid FFT grid) and routes the SCF
screening V_scr through a true 3-D real-space ρ(r) (ψ(G)→ifft3→ψ(r)→ρ(r), V_H +
PBE V_xc[ρ,∇ρ] with genuine 3-D spectral gradient). The capture rho_of_psi stores
ψ columns for the reconstruction while returning the standard G-diagonal so the
driver's mixing/convergence is unchanged. Opt-in (PW_RS3D_ON default OFF), honest
fallback to the (1,1,n) path if the 3-D build returns []. LDA path untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…s3d wiring

- scf_pw_realspace: module-level PWRS_SCAT/ZIM/REAL/RHOACC reusable buffers cleared
  (not reallocated) per use — kills the per-SCF-iteration push-alloc churn that
  SIGKILLed (137/jetsam) the CaH6 3-D run. Selftest 10/10 still PASS (reuse-safe).
- pw_frontend: qpw_set_rs3d toggle routes the SCF through the 3-D real-space path
  (qpw_gvectors_miller for the singular-B-safe integer Miller indices).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…off-diagonal witness

The assembler adds vscr_diag ONLY to the diagonal H[a][a]. For a LOCAL potential V(r)
the exact diagonal element is ⟨G_a|V|G_a⟩ = (1/Ω)∫V dr = V(G=0) = V̄, identical for
every a; the per-G variation lives in the off-diagonal V(G_a−G_b) the diagonal-only
assembler discards. Earlier per-grid-point sampling put arbitrary real-space values on
the diagonal (broke SCF convergence). Now project to V̄ (SCF converges) + expose
qforge_v3d_offdiag_rms — the honest witness of how much 3-D structure the diagonal drops.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant