Skip to content

Commit 049e406

Browse files
committed
fix: allocate 4x uom_array/uom_save size for nspin=4
Root cause: In dftu.cpp::init(), pot_index was not multiplied for nspin=4. This caused eff_pot_pw, uom_array, and uom_save to be allocated with size for nspin=1, while cal_occ_pw and copy_locale tried to write 4x that amount. Fix: Add 'else if (nspin == 4) pot_index *= 4;' to match the interleaved spinor storage requirement. Also confirmed MPI-2 runs for 223/224/265 are stable (no crashes).
1 parent 55b7dac commit 049e406

3 files changed

Lines changed: 504 additions & 1 deletion

File tree

source/source_lcao/module_dftu/dftu.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ void Plus_U::init(UnitCell& cell, // unitcell class
170170
}
171171
}
172172
// allocate memory for eff_pot_pw
173-
if(PARAM.inp.nspin == 2) pot_index *= 2; // for spin polarized case, we need to double the size
173+
if (PARAM.inp.nspin == 2) pot_index *= 2; // for spin polarized case, we need to double the size
174+
else if (PARAM.inp.nspin == 4) pot_index *= 4; // for noncollinear case, need 4x size for interleaved spinors
175+
174176
this->eff_pot_pw.resize(pot_index, 0.0);
175177
this->uom_array.resize(pot_index, 0.0);
176178
this->uom_save.resize(pot_index, 0.0);

0 commit comments

Comments
 (0)