Skip to content

[wien2k] Pure-Python case.symqmc generator (first dmftproj port step)#5

Open
krystophny wants to merge 2 commits into
TRIQS:unstablefrom
krystophny:port/dmftproj-symqmc-python
Open

[wien2k] Pure-Python case.symqmc generator (first dmftproj port step)#5
krystophny wants to merge 2 commits into
TRIQS:unstablefrom
krystophny:port/dmftproj-symqmc-python

Conversation

@krystophny

@krystophny krystophny commented Jun 15, 2026

Copy link
Copy Markdown

Part of #7 (dmftproj Fortran-to-Python port).

First step of porting the dmftproj Fortran to Python: a pure-Python generator for case.symqmc (the correlated-shell symmetry matrices).

triqs_dftkit.wien2k.symqmc.write_symqmc(case) reads case.dmftsym + case.indmftpr + case.struct and writes case.symqmc, 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 dmftproj emits:

  • 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;
  • spin-mixing fromfile bases (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.

This is the first of the "tail-backward" series that incrementally replaces fortran/dmftproj with Python, each step proven against the Fortran output via the SOC golden test (#4).

While validating the mixing path I found dmftproj reads the fromfile basis in single precision (a CMPLX cast without KIND=8) and through a 250-column line cap, so its case.symqmc there carries a ~1e-7 error; the Python generator is full double precision. That dmftproj bug is fixed separately in #6.

Verification

Validated against the dmftproj Fortran output on CaOs2 (16 operations, 8 time-reversal) for all three paths:

non-mixing (cubic): max|py - fortran| = 6.8e-8,  unitarity dev = 4e-16
mixing (|j,m_j>):   max|py - fortran| = 6.0e-8,  unitarity dev = 9e-9   (8-digit input floor)
l=0 (s):            max|py - fortran| = 4.4e-8,  unitarity dev = 0

The residuals are dmftproj's own limited precision (8-digit cubic templates, single-precision fromfile); the Python construction is exact (machine-precision unitarity). With #6 applied, the mixing path matches dmftproj to 1.9e-14.

End to end, the cubic converter HDF5 is identical (h5diff). 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. Built against TRIQS with Build_Tests=ON: 4/4 wien2k tests pass.

…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.
@krystophny

Copy link
Copy Markdown
Author

Accuracy: reproduces the released (single-precision) dmftproj case.symqmc to 6.8e-8. With the Fortran precision fix #14 + exact Python #12 this becomes 1.5e-14 (machine precision).

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