From cbc5c0f61b9ebfd478be8f64dbdbfb25b3d637a3 Mon Sep 17 00:00:00 2001 From: dyzheng Date: Mon, 17 Aug 2026 19:20:08 +0800 Subject: [PATCH] Fix(dftu): write dm_onsite.txt format matching read_occup_m parser write_occup_m emits tokens like "Atom=1" (no space after '='), but read_occup_m reads with >> and strcmp against "Atom=". The mismatch causes NSCF runs reading dm_onsite.txt to fail with "WRONG IN READING LOCAL OCCUPATION NUMBER MATRIX FROM Plus_U FILE". Add a space after '=' for Atom, L, ORBITAL, and spin tokens so the written format matches what read_occup_m expects. Verified with the examples/19_dftu/01_lcao_NiO DFT+U case: SCF converges and the subsequent NSCF step completes successfully. --- source/source_lcao/module_dftu/dftu_io.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/source_lcao/module_dftu/dftu_io.cpp b/source/source_lcao/module_dftu/dftu_io.cpp index 9be899e244f..9d80cc64c6c 100644 --- a/source/source_lcao/module_dftu/dftu_io.cpp +++ b/source/source_lcao/module_dftu/dftu_io.cpp @@ -125,9 +125,9 @@ void Plus_U::write_occup_m(const UnitCell& ucell, continue; } - ofs << "\n Atom=" << iat+1; - ofs << " L=" << l; - ofs << " ORBITAL=" << n << std::endl; + ofs << "\n Atom= " << iat+1; + ofs << " L= " << l; + ofs << " ORBITAL= " << n << std::endl; if (nspin == 1 || nspin == 2) { @@ -156,7 +156,7 @@ void Plus_U::write_occup_m(const UnitCell& ucell, ofs << std::endl; ofs << " sum is " << std::setw(12) << sum0[is] << std::endl; } - ofs << " spin=" << is+1 << std::endl; + ofs << " spin= " << is+1 << std::endl; ofs << std::setprecision(8) << std::fixed; for (int m0 = 0; m0 < 2 * l + 1; m0++) {