Skip to content

Commit 8c838a2

Browse files
author
dyzheng
committed
Fix(deltaspin): propagate current_spin through operator chain in init()
In HamiltLCAO::updateHk, current_spin is set on the root operator via set_current_spin(isk[ik]), but was never propagated to child operators in the chain. Each operator independently managed its own current_spin via toggling (DFTU, Veff, DeePKS). DeltaSpin did not toggle, so its current_spin was always 0, using the wrong sign for spin-down contributions (+lambda_z instead of -lambda_z). Fix: propagate current_spin to the next operator in init() before processing this node's contributeHR, matching the existing hr_done propagation pattern. This ensures all operators share the same spin state set by the k-point loop.
1 parent edbf29c commit 8c838a2

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

source/source_lcao/module_operator_lcao/operator_lcao.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ void OperatorLCAO<TK, TR>::init(const int ik_in) {
9393
this->hR->set_zero();
9494
}
9595
}
96+
// propagate current_spin to next operator so all nodes in the chain
97+
// share the same spin state, set by HamiltLCAO::updateHk via set_current_spin.
98+
// This is done before processing this node so that children receive the
99+
// correct spin regardless of any local toggling that may happen inside
100+
// this operator's contributeHR().
101+
if (this->next_op != nullptr) {
102+
dynamic_cast<OperatorLCAO<TK, TR>*>(this->next_op)->current_spin = this->current_spin;
103+
}
96104
switch (this->cal_type) {
97105
case calculation_type::lcao_overlap: {
98106
// cal_type=lcao_overlap refer to overlap matrix operators, which are

0 commit comments

Comments
 (0)