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
Open
qforge(3d-scf): true 3-D real-space SCF density ρ(r) — pow2-FFT wall broken, screening root re-diagnosed#3003dancinlife wants to merge 5 commits into
dancinlife wants to merge 5 commits into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_rs3dopt-in 3-D screening route; LDA path untouched (scf_pw_selftest 20/20 PASS regression).stdlib/qforge/pw_frontend.hexa:qpw_set_rs3dtoggle.Result (CaH6, d6 — 4.376 NOT forced)
Full verdict:
demiurge/.verdicts/qforge-3d-realspace-scf/. Cost $0 (0-pod local).🤖 Generated with Claude Code