Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions source/source_lcao/module_operator_lcao/dspin_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,21 @@ void hamilt::DeltaSpin<hamilt::OperatorLCAO<TK, TR>>::cal_pre_HR()
}
this->paraV = this->hR->get_paraV();
ModuleBase::timer::start("DeltaSpin", "cal_pre_HR");
// Reset the caches from a possible previous initialization:
// pre_hr holds raw HContainer pointers, so clear() alone would leak them,
// and stale B_I_data would survive for atoms that are no longer constrained.
for (auto& hr : this->pre_hr)
{
delete hr;
}
this->pre_hr.clear();
this->pre_hr.resize(this->ucell->nat, nullptr);
for (auto& b : this->B_I_data)
{
b.clear();
}
this->B_I_data.clear();
this->B_I_data.resize(this->ucell->nat);

const int npol = this->ucell->get_npol();
size_t memory_cost = 0;
Expand Down
Loading