Skip to content

[wien2k] pure-Python dmftproj driver; remove the Fortran executable - #13

Open
krystophny wants to merge 24 commits into
TRIQS:unstablefrom
krystophny:port/dmftproj-capstone
Open

krystophny wants to merge 24 commits into
TRIQS:unstablefrom
krystophny:port/dmftproj-capstone

Conversation

@krystophny

@krystophny krystophny commented Jun 16, 2026 •

Copy link
Copy Markdown

Final integration of #14, #15, #16, #19, and #18. This replaces the native Fortran producer with the pure-Python implementation while keeping an installed dmftproj compatibility command. The Wien2k workflow driver calls the Python API in process by default; callers can still supply an external executable explicitly.

The build is now C++/Python only, and the obsolete Fortran target and sources are removed. The end-to-end SO and non-SO converter tests compare recursively at 1e-12, including finite-value checks, rather than using triqs.utility.h5diff's fixed array tolerance. A smoke test exercises both the compatibility wrapper and the workflow driver's default in-process path, and verifies all expected outputs. The existing narrow-window native fixture remains a converter regression, while regenerated fixtures use full-rank projector windows as required by the Loewdin orthogonalization.

The capstone also includes the local-solver-frame symmetry conversion from #18, so the final generated archives cover both unitary and antiunitary operations in the correct basis.

Compatibility limits remain explicit: selected irreducible subspaces, cubic f harmonics, multiple local orbitals per angular momentum, spin mixing without SO, differing SO flags across correlated sorts, and non-SO band paths are unsupported. Band paths require projection mode 0, and two-spin projector generation requires matching selected and below-window bands. These inputs raise rather than silently producing a different subspace.

Verification

  • 12 focused NumPy generator and symmetry regressions pass locally.
  • Python compilation passes for the driver, API, and CLI smoke test.
  • Full TRIQS converter and installation coverage runs in CI.

Chris&AI

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 the capstone onto the completed port stack and applied the remaining integration fixes. The update removes an orphaned native CTest, drops the build-time Fortran requirement, restores an installed dmftproj command, switches the workflow driver to the bundled Python API by default, adds a real CLI smoke test, replaces the ineffective HDF array comparison with finite recursive checks at 1e-12, and includes #18's local-frame symmetry correction. All 12 focused generator/symmetry regressions pass locally; the full TRIQS checks are now running in CI.

Chris&AI

@krystophny

Copy link
Copy Markdown
Author

GPT Sol inspected the first capstone CI logs and corrected the two generated converter reference archives to include #18's local-frame symmetry matrices. The failure was limited to those expected mat datasets; the CLI and in-process workflow test already passed. I verified that every unrelated HDF5 dataset and attribute stayed identical, then pushed the corrected references for a fresh CI run.

Chris&AI

@krystophny
krystophny force-pushed the port/dmftproj-capstone branch from 4d7b100 to 1c3b3a6 Compare October 12, 2026 17:35
@krystophny
krystophny force-pushed the port/dmftproj-capstone branch from 1c3b3a6 to 3230e3c 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.
The port was validated only on centrosymmetric, trivial-rotloc, d-shell
fixtures (CaOs2, SrVO3). Non-centrosymmetric spin-orbit cells (the
dft_tools#148 regime) hit three convention bugs in the p-shell and
local-frame paths:

- _CUBIC[1]: the cubic l=1 (p) transform was un-normalized and row-ordered
  pz,py,px instead of the Fortran px,py,pz, so P P^dag != I. _CUBIC[2] (d)
  was correct, so the d-shell tests never caught it.
- The non-mixing magnetic (time-inversion) operations used conj(P.T) where
  the antiunitary basis change needs P.T (symqmc and sympar shell matrices,
  and the ctqmcout Rloc rotrep). The mixing path already used P.T; the
  non-mixing path was inconsistent. It is a no-op for real bases
  (complex-identity, cubic-d), so only the p-shell with its imaginary p_y
  row was affected.
- The non-mixing ctqmcout path dropped the struct reference local rotation
  rotloc_ref (beta=pi/2 for Te) that the mixing path composes via
  rotloc_rotl_so. Both the Rloc rotrep and the projector rotation now
  compose it; the projector uses dmat(R[isym]) @ dmat(rotloc_ref), the
  orbital dmat of the full rotloc (rot_projectmat.f), no spin part, no time
  reversal.

Verified against the dmftproj Fortran on the identical lapw2 -almd output
(tellurium, P3_1 21, SP+SO): case.symqmc and case.sympar match to 6e-8 and
case.ctqmcout (Rloc rotrep + all projectors) to 2e-8, the float32
cubic-template floor; the only larger field is elecn (36 vs 35.999998, a
float32 almblm value). Centrosymmetric CaOs2 is byte-identical.

Adds a non-centrosymmetric tellurium case.symqmc regression test (small
symmetry inputs, no almblm) and a cubic l=1 unitarity check.
run_dmftproj writes every case.* file the Wien2k converter reads, so the
Converter no longer shells out to the dmftproj binary. Delete
fortran/dmftproj and its CMake target; the build no longer needs a
Fortran/LAPACK toolchain.

The driver is verified end to end by two tests that run it through the
converter and h5diff the HDF5 at machine precision (1e-12):
- wien2k_socfull_convert: wide-window SO cell (full-rank Loewdin overlap).
- wien2k_noso_convert: non-SO partial cell, convert_dft_input on the
  SP/non-SO oubwin path plus convert_parproj_input.

Both use a full-rank window. The physical narrow window is rank-deficient
(more correlated spin-orbitals than bands; O^{-1/2} has non-unique null
eigenvectors), so it cannot be a machine-precision regression target; it
stays locked exactly by wien2k_soc_convert (converter on the Fortran
output).
@krystophny
krystophny force-pushed the port/dmftproj-capstone branch from 3230e3c to 22ba9ca Compare October 12, 2026 17:39
@krystophny

Copy link
Copy Markdown
Author

GPT Sol completed the remaining fixes across the stack and restacked this integration PR. All 12 focused regressions pass; partial-projector modes 1/2 match native dmftproj within 1.2e-16. Added an independent symmetry covariance check, made archive comparisons reject infinities, and documented explicit compatibility limits. 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