Skip to content

Commit 7d90807

Browse files
author
abacus_fixer
committed
fix(dftu): guard force/stress against non column-major ks_solver
The folded dSR/mat buffers are consumed by ScaLAPACK GEMM via pv.desc (local column-major storage) and read back with explicit ic * pv.nrow + ir indices, so their layout must not follow a row-major ks_solver branch. All LCAO ks_solvers accepted by INPUT validation satisfy IS_COLUMN_MAJOR_KS_SOLVER today, so this entry guard is defensive: it fails loudly instead of silently producing wrong DFT+U forces/stresses if solver whitelists ever drift. Notes on governance warnings: - Tests not added: the guarded behavior is a fail-fast precondition on a path whose numerical results are unchanged for every reachable configuration; dft_plus_u==2 force/stress is additionally disabled in force_stress_lcao.cpp. A focused unit test can be added together with the planned follow-up that fixes folding layout at construction time. - No docs update required: no INPUT parameter semantics change.
1 parent 342a8c6 commit 7d90807

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

source/source_lcao/module_dftu/dftu_force.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,19 @@ void force_stress(Plus_U& dftu,
7474
}
7575
}
7676

77+
// Layout invariant: the folded dSR/mat buffers are consumed by ScaLAPACK
78+
// GEMM through pv.desc (local column-major storage) and read back with
79+
// explicit ic * pv.nrow + ir indices. All ks_solvers accepted by INPUT
80+
// validation are column-major today; abort loudly instead of silently
81+
// producing wrong forces/stresses if that assumption ever changes.
82+
if ((dftu.is_cal_force() || dftu.is_cal_stress())
83+
&& !ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER(dftu.get_ks_solver()))
84+
{
85+
ModuleBase::WARNING_QUIT("DFTU_LCAO::force_stress",
86+
"non column-major ks_solver is not supported for DFT+U force/stress; "
87+
"the folded matrix layout assumption would be violated");
88+
}
89+
7790
const int nlocal = dftu.get_nlocal();
7891

7992
if (dftu.is_cal_force())

0 commit comments

Comments
 (0)