<html><head><meta http-equiv="content-type" content="text/html; charset=us-ascii"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div>Dear Matthew,</div><div><br></div><div>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. </div><div>The finite Wannier centers are consistent with this diagnosis.</div><div><br></div><div>After forming the moment matrix product, CP2K summed the entire local allocation of a distributed matrix. This allocation can contain unused padding rows or </div><div>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 </div><div>contaminate all molecular moments.</div><div><br></div><div>I have opened a fix:</div><div>https://github.com/cp2k/cp2k/pull/5680</div><div><br></div><div>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 </div><div>matcher reject NaN and Inf explicitly.</div><div><br></div><div>I tested the UKS case with 1, 2, and 4 MPI ranks. All runs produced identical finite molecular moments.</div><div><br></div><div>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 </div><div>rank may also happen to avoid the NaNs, but that is not a reliable fix.</div><div><br></div><div>Best regards,</div><div>Thomas</div><div><br><blockquote type="cite"><div>Am 04.08.2026 um 16:41 schrieb 'Matthew Emerson' via cp2k <cp2k@googlegroups.com>:</div><br class="Apple-interchange-newline"><div>Dear CP2K developers and users,<br><div><p>I'm running into an issue with <span dir="ltr">MOLECULAR_MOMENTS</span> after Wannier localization and was wondering if anyone has seen something similar.</p><p>I'm using UKS (also reproduced with DFT+U enabled) together with:</p><span dir="ltr"><span dir="ltr">&LOCALIZE
<br> METHOD JACOBI
<br> USE_HISTORY F
<br> &PRINT
    &MOLECULAR_MOMENTS LOW
<br>    ORDER 1
<br> &END MOLECULAR_MOMENTS
<br>   &WANNIER_CENTERS
<br>     IONS+CENTERS
<br>   &END WANNIER_CENTERS
<br> &END PRINT
&END LOCALIZE</span></span><p>The SCF converges normally, the Jacobi localization converges, and the printed Wannier centers for both spin channels are finite and appear reasonable. However, the <span dir="ltr">MOLECULAR_MOMENTS</span> output consists entirely of <span dir="ltr">NaN</span> values for every atom/molecule.</p><p>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.</p><p>Has anyone encountered this before, or is there a known issue with <span dir="ltr">MOLECULAR_MOMENTS</span> for localized UKS wavefunctions? </p></div><div><br class="webkit-block-placeholder"></div>

-- <br>
You received this message because you are subscribed to the Google Groups "cp2k" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:cp2k+unsubscribe@googlegroups.com">cp2k+unsubscribe@googlegroups.com</a>.<br>
To view this discussion visit <a href="https://groups.google.com/d/msgid/cp2k/92857f51-b8d0-4551-8467-e45d87cd39can%40googlegroups.com?utm_medium=email&utm_source=footer">https://groups.google.com/d/msgid/cp2k/92857f51-b8d0-4551-8467-e45d87cd39can%40googlegroups.com</a>.<br>
</div></blockquote></div><br></body></html>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups "cp2k" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:cp2k+unsubscribe@googlegroups.com">cp2k+unsubscribe@googlegroups.com</a>.<br />
To view this discussion visit <a href="https://groups.google.com/d/msgid/cp2k/D1864E0A-EF08-44F2-9985-49E51305C01B%40gmail.com?utm_medium=email&utm_source=footer">https://groups.google.com/d/msgid/cp2k/D1864E0A-EF08-44F2-9985-49E51305C01B%40gmail.com</a>.<br />