MOLECULAR_MOMENTS localization with DFT+U and UKS - CP2K 2026.1

26 views
Skip to first unread message

Matthew Emerson

unread,
Aug 4, 2026, 10:48:00 AM (9 days ago) Aug 4
to cp2k
Dear CP2K developers and users,

I'm running into an issue with MOLECULAR_MOMENTS after Wannier localization and was wondering if anyone has seen something similar.

I'm using UKS (also reproduced with DFT+U enabled) together with:

&LOCALIZE
 METHOD JACOBI
 USE_HISTORY F
 &PRINT &MOLECULAR_MOMENTS LOW
    ORDER 1
 &END MOLECULAR_MOMENTS
   &WANNIER_CENTERS
     IONS+CENTERS
   &END WANNIER_CENTERS
 &END PRINT &END LOCALIZE

The SCF converges normally, the Jacobi localization converges, and the printed Wannier centers for both spin channels are finite and appear reasonable. However, the MOLECULAR_MOMENTS output consists entirely of NaN values for every atom/molecule.

As a sanity check, I wrote a small post-processing script that assigns the printed Wannier centers to the nearest atom (using minimum-image PBC) and reconstructs per-atom electronic dipoles which are all reasonable.

Has anyone encountered this before, or is there a known issue with MOLECULAR_MOMENTS for localized UKS wavefunctions? 

Thomas Kühne

unread,
Aug 5, 2026, 3:17:40 PM (7 days ago) Aug 5
to cp...@googlegroups.com
Dear Matthew,

I found a bug in the MOLECULAR_MOMENTS code path that explains this behavior. It is not caused by UKS, DFT+U, the SCF, or the Jacobi localization itself. 
The finite Wannier centers are consistent with this diagnosis.

After forming the moment matrix product, CP2K summed the entire local allocation of a distributed matrix. This allocation can contain unused padding rows or 
columns that are not initialized or written by the matrix operation. Depending on the MPI distribution and memory contents, a NaN in this padding can therefore 
contaminate all molecular moments.

I have opened a fix:

The fix restricts the sum to the actual local matrix dimensions. It also extends the existing UKS molecular-moments regression test and makes the numerical test 
matcher reject NaN and Inf explicitly.

I tested the UKS case with 1, 2, and 4 MPI ranks. All runs produced identical finite molecular moments.

Your post-processing of the finite Wannier centers is a reasonable temporary workaround for first moments. Running with a different MPI layout or a single MPI 
rank may also happen to avoid the NaNs, but that is not a reliable fix.

Best regards,
Thomas

--
You received this message because you are subscribed to the Google Groups "cp2k" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cp2k+uns...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/cp2k/92857f51-b8d0-4551-8467-e45d87cd39can%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages