Skip to content

[wien2k] complete the port to machine precision: shared module, fromfile, proj_mode, outband - #12

Open
krystophny wants to merge 12 commits into
TRIQS:unstablefrom
krystophny:port/dmftproj-dedup-common
Open

krystophny wants to merge 12 commits into
TRIQS:unstablefrom
krystophny:port/dmftproj-dedup-common

Conversation

@krystophny

@krystophny krystophny commented Jun 16, 2026 •

Copy link
Copy Markdown

Part of #7; stacks on reviewed #11 and the native precision fix #14.

Extracts shared parsing, angular transforms, window selection and formatting into _dmftproj. Adds double-precision projector construction, spin-mixing fromfile bases, projection modes 1/2 for oubwin/ctqmcout/parproj, and the SP+SO band-mode outband generator.

Carries forward native terminal-band selection, per-spin offsets, shell-specific tables, odd-l parity and the normalized native p-basis ordering. Mixing density symmetrization now transfers contributions between equivalent atoms. Loewdin rank detection is relative to the overlap scale, preserving small full-rank projectors while rejecting singular overlaps. Shared parsing reads every correlated-shell representation record and every atomic-sort local rotation, and retains arbitrarily small spin mixing. Unsupported selected irreducible subspaces and multiple local orbitals fail explicitly. Existing converter fixtures remain intact; separate full-rank references test the precision layer.

Validation: all eight local generator tests pass. Native CMake producer comparisons reproduce the full-rank ctqmcout, custom-basis parproj, sympar and outband references within 1e-11 (observed residuals at most 1.4e-15 on this build). Independent regressions cover two shells on one atom, transfer between equivalent atoms, singular overlaps and native window edge cases. Band-mode partial projectors also match the native energy-window reference within 1.2e-16; the one-k-point band fixture and native reference now agree on their path length. CI runs full TRIQS integration.

Chris&AI

@krystophny

Copy link
Copy Markdown
Author

Updated to machine precision on every output (with the Fortran precision fix #14):

oubwin   byte-identical
symqmc   1.5e-14
sympar   1.9e-14
parproj  1.5e-14
ctqmcout 1.5e-14   (full-rank window)

ctqmcout uses the same LAPACK/BLAS routines the Fortran does (scipy ZHEEV('V','U') + ZGEMM). The earlier 6.6e-7 was the rank-deficient narrow-window CaOs2 (20 correlated spin-orbitals, 17 bands): O^{-1/2} of a singular overlap has non-unique null eigenvectors that differ across LAPACK builds. A full-rank window (50 bands) makes the overlap non-singular and the result exact and reproducible. All tolerances are now 1e-11.

@krystophny
krystophny force-pushed the port/dmftproj-dedup-common branch from cd177f8 to 36b8868 Compare June 16, 2026 15:34
krystophny added a commit to krystophny/dftkit that referenced this pull request Jun 16, 2026
…fixtures

The committed CaOs2 dmftproj outputs are now full double precision (precision
fix TRIQS#14 + exact Python TRIQS#12), so the converter golden h5 is regenerated to match.
@krystophny krystophny changed the title [wien2k] extract shared dmftproj machinery into _dmftproj [wien2k] complete the port to machine precision: shared module, fromfile, proj_mode, outband Jun 16, 2026
Port the dmftproj almblm reader and case.oubwin writer to NumPy. Given
case.almblm{up,dn} and the energy window in case.indmftpr, select the
contiguous band range per k-point and spin and write case.oubwin{up,dn}
in the dmftproj format. Support proj_mode 0; band-index modes remain
explicitly unsupported. Part of TRIQS#7.

Keep window-open and window-valid flags separate, as set_projections.f
does. A window opening only at nbmax remains excluded with zero bounds,
including nbmin == nbmax. Preserve this native behavior on both sides.

Reuse the existing compressed CaOs2 almblm fixtures, decompressing into
a temporary directory. Compare both spin outputs with CaOs2.oubwinup,
ignoring only trailing whitespace stripped from the shipped reference.
Add focused checks for the final-band edge cases, energy boundaries,
Fermi shifts, per-k lowest-band weights and excluded output records.

Validation: the generator test passes locally with NumPy, including both
reviewer reproducers and regeneration of the 43-92 CaOs2 band window.
@krystophny

Copy link
Copy Markdown
Author

GPT Sol rebased this onto reviewed #11/#14 and preserved the earlier window, spin-offset, shell-key and parity fixes through deduplication. Fixed equivalent-atom transfer in custom-basis density symmetrization, rejected singular overlaps, and made numeric comparisons NaN-safe. Eight local generator tests pass; native reference checks are within 1.4e-15. CI is running.

Chris&AI

@krystophny
krystophny force-pushed the port/dmftproj-dedup-common branch from 4eeefbd to d9baf96 Compare October 12, 2026 17:38
Read the almblm coefficients, assemble and locally rotate correlated
projectors, apply the cubic/complex basis, and Loewdin-orthonormalize the
stacked shells before writing ctqmcout. Part of TRIQS#7, following TRIQS#8.

Keep the native separate window-open/valid flags. Validate matching SO
spin windows and use each spin's own band offsets. Reject unsupported
non-SO, band-index, cubic p/f and non-identity struct rotation paths
instead of producing misleading files; subsequent port stages add them.

Reuse the current full-rank CaOs2 inputs and TRIQS#8 fixture handling. Compare
integer fields exactly and finite float fields at atol=1e-7, rtol=0.
Add regressions for final-band-only windows and mismatched SO spins.
Local validation gives max native residual 1.3e-8 and full 20x50 projector
orthonormality error 3.2e-15. The old rank-deficient-window claims no
longer apply to this fixture.
Generate symmetry matrices for every included shell, including the uncorrelated Ca d shell in the native partial fixture. Rebase onto the corrected projector stack and reuse source fixtures without unused build-directory copies.

Correct the cubic p normalization/order and use the dmftsym iprop parity for improper rotations. Add independent inversion and basis-normalization regressions. Reject the unsupported non-SO and cubic f paths until their port stages. Compare headers exactly, finite complex matrices at atol=1e-7 with rtol=0, and verify unitarity at the native basis precision floor.
@krystophny
krystophny force-pushed the port/dmftproj-dedup-common branch from d9baf96 to d52a695 Compare October 12, 2026 17:39
@krystophny

Copy link
Copy Markdown
Author

GPT Sol fixed shared parsing, tiny spin mixing, scale-relative Loewdin rank detection, and partial-projector modes 1/2, including below-window validation. Corrected the band-path fixture and regenerated its reference with native dmftproj. All eight generator tests pass; native mode comparisons differ by at most 1.2e-16. Restacked on updated #11 plus the precision fix. Latest-head CI is running/queued.

Chris&AI

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