Skip to content

Commit ca65a72

Browse files
author
dyzheng
committed
Fix(PW DFT+U): add missing member variable assignments in init()
The develop branch refactored DFT+U to use explicit parameter passing, but forgot to assign two member variables in the init() function: 1. this->npol was never set (defaulted to 1), causing incorrect Pauli matrix component iteration for nspin=4 calculations in cal_energy_correction(). 2. this->device was never set (defaulted to empty string), causing the CPU code path in cal_occ_pw() to be skipped entirely. This resulted in the occupation matrix never being computed, leaving a zero/initial locale which produced wildly different PW DFT+U energies (~12-24 eV). After this fix, all enabled 17_DS_DFTU test cases produce results identical to accel-old branch (within numerical precision).
1 parent d3ad308 commit ca65a72

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

source/source_lcao/module_dftu/dftu.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ void Plus_U::init(UnitCell& cell,
8585
#endif
8686

8787
Plus_U::nspin = nspin;
88+
this->npol = npol;
89+
this->device = device;
8890

8991
// mohan update 2025-11-06
9092
Plus_U::energy_u = 0.0;

0 commit comments

Comments
 (0)