[wien2k] complete the port to machine precision: shared module, fromfile, proj_mode, outband#12
Open
krystophny wants to merge 13 commits into
Open
[wien2k] complete the port to machine precision: shared module, fromfile, proj_mode, outband#12krystophny wants to merge 13 commits into
krystophny wants to merge 13 commits into
Conversation
…CaOs2) dftkit's Wien2k converter is only covered by the non-SOC SrVO3 case. This adds a SOC + spin-polarized golden test: CaOs2, a cubic fluorite cell with two symmetry-equivalent correlated Os atoms whose magnetic point group has 16 operations, 8 of them time-reversal. It exercises the combined-spin 'ud' block and the time-reversal symmetry path of dmftproj + the converter on a small 8-k-point fixture, validated by h5diff against a reference produced by this converter.
triqs_dftkit.wien2k.symqmc.write_symqmc builds the correlated-shell spinor symmetry matrices (case.symqmc) from case.dmftsym + case.indmftpr + case.struct, reproducing the dmftproj Fortran construction (Wigner D, orbital and spinor time-reversal operators, angular-harmonics basis transform, spin-1/2 phase blocks). It is a full replacement of the symqmc-writing, covering every path: - non-mixing spin-diagonal bases (complex, cubic): the up/up block scaled by the +-(a+g)/2 phase, with the orbital time-reversal operator on the magnetic operations; - mixing fromfile bases that couple spin (the |j,m_j> basis): the full 2(2l+1) spinor representation P spinrot P^dag with the spinor time-reversal -i sigma_y (x) T on the magnetic operations; - l=0 (s) shells: the 2x2 spin phase block. Verified against the dmftproj Fortran output for all three paths on CaOs2 (16 operations, 8 time-reversal): the cubic converter HDF5 is identical (h5diff) and every matrix matches to machine precision. The mixing fromfile path is the one dft_tools #148 singles out; dmftproj reads that basis with a single-precision CMPLX cast and a 250-column line cap (set_ang_trans.f), so its case.symqmc carries a ~1e-7 error there while this generator is full double precision. Tests: the cubic path reuses the SOC golden h5; the mixing and l=0 paths compare to the dmftproj matrix data (single precision, ~26 kB) and assert unitarity.
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. Proven byte-identical to the Fortran output on
CaOs2 (proj_mode 0; band-index modes raise NotImplementedError pending a
fixture). Part of TRIQS#7.
Port the dmftproj projector core to numpy: read the almblm Alm/Clm coefficients, build the raw correlated projector over the in-window bands, apply the local rotation and cubic basis transform, Loewdin-orthonormalize the stacked shells (orthogonal_wannier_SO), and write case.ctqmcout. Matches the dmftproj CaOs2 reference to 4.3e-7 (the single-precision basis-transform floor); integer fields identical. cubic/complex bases; fromfile raises NotImplementedError pending a fixture. almblm fixtures switched to gzip (shared with the oubwin test). Part of TRIQS#7.
Port the dmftproj case.sympar writer to numpy: the symmetry matrices for all included shells (correlated + partial), the partial-charge analog of symqmc. Matches the dmftproj CaOs2_partial reference (an added uncorrelated Ca d-shell) to 4.4e-8. cubic/complex bases; fromfile raises NotImplementedError. Part of TRIQS#7.
Port the dmftproj case.parproj writer to numpy: the partial projectors and density matrices for all included orbitals (radial s12 normalization, the point-integrated density matrix, the Rloc spinor rotations). Matches the dmftproj CaOs2_partial reference to 1.2e-8. cubic/complex bases; fromfile raises NotImplementedError. Part of TRIQS#7.
The five case.* generators each carried their own copy of the almblm reader, Wigner-D, angular-basis transform, indmftpr/dmftsym parsers, band-window selection and formatters. Extract them once into _dmftproj and make every generator a thin consumer: 2260 -> 1699 lines, no shared function defined twice. Add isolated unit tests for the shared primitives. Generators byte/1e-6 identical to before (all golden tests unchanged). Part of TRIQS#7.
This was referenced Jun 16, 2026
…sion fix)
Use the exact analytic cubic harmonics (no float32 cast) and call the same
LAPACK/BLAS routines the Fortran does for the Loewdin step (scipy ZHEEV('V','U')
and ZGEMM with the matching trans flags, not numpy's ZHEEVD / conj-transpose
copies). Regenerate references from the precision-fixed dmftproj (PR TRIQS#14) with
full-precision templates.
The port is now exact to machine precision on every output:
oubwin byte-identical
symqmc 1.5e-14
sympar 1.9e-14
parproj 1.5e-14
ctqmcout 1.5e-14 (full-rank window: 50 bands > 20 correlated spin-orbitals,
so the Loewdin overlap O is non-singular and its
eigenvectors are unique. The physical narrow-window CaOs2
makes O rank-deficient; O^{-1/2} then amplifies the
last-ULP libm difference, a property of that degenerate
case, not the port.)
Tolerances tightened to 1e-11. Part of TRIQS#7.
Author
|
Updated to machine precision on every output (with the Fortran precision fix #14): ctqmcout uses the same LAPACK/BLAS routines the Fortran does (scipy |
cd177f8 to
36b8868
Compare
…window Replace the NotImplementedError guards in ctqmcout/sympar/parproj (fromfile) and oubwin/ctqmcout (proj_mode). fromfile reuses symqmc's spinor machinery (now shared in _dmftproj: mixing_rotrep, rotloc_rotl_so); proj_mode 1/2 add the band-index window selection (set_projections.f). All exercised by full-rank fixtures from the precision-fixed dmftproj and matched to machine precision (fromfile 1.9e-14, proj_mode 1.5e-14, oubwin byte-identical). Part of TRIQS#7.
The band-structure analog of case.ctqmcout, feeding the converter's convert_bands_input. Same correlated-projector machinery on a band k-path; reads nkband from case.klist_band and the Fermi energy from the last line of case.indmftpr (band-mode convention). Fixture generated by a Wien2k band run (lapw1/lapwso/lapw2 -band) + the precision-fixed dmftproj -band on a wide (full-rank) window; the port matches to 2.8e-16. Completes the converter's dmftproj inputs. Part of TRIQS#7.
The Fortran stays on the generator stack; only the capstone removes it.
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.
Part of #7. The machine-precision layer of the port (builds on the precision fix #14).
_dmftproj(the almblm reader, Wigner-D, angular transforms, parsers, window selection, formatters); each generator becomes a thin consumer, no shared function defined twice. Adds isolated unit tests.ZHEEV('V','U')+ZGEMM). References regenerated from the precision-fixed dmftproj ([dmftproj] eliminate single-precision loss in the projector construction #14) with full-precision templates.convert_bands_input; fixture from a Wien2k band run +dmftproj -band.Verification (vs the precision-fixed dmftproj #14, full-rank windows)
All numpy tests pass at 1e-11; the symqmc converter h5 test runs under TRIQS in CI.