Skip to content

Commit 62894b1

Browse files
samomoyedmohanchen
andauthored
refactor: replace magic numbers in sto_wf.cpp (#7043)
Co-authored-by: Mohan Chen <mohanchen@pku.edu.cn>
1 parent eb1665c commit 62894b1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

source/source_pw/module_stodft/sto_wf.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ void Stochastic_WF<T, Device>::clean_chiallorder()
6060
delete[] chiallorder;
6161
chiallorder = nullptr;
6262
}
63-
6463
template <typename T, typename Device>
6564
void Stochastic_WF<T, Device>::init_sto_orbitals(const int seed_in)
6665
{
66+
const unsigned int rank_seed_offset = 10000;
6767
if (seed_in == 0 || seed_in == -1)
6868
{
69-
srand((unsigned)time(nullptr) + GlobalV::MY_RANK * 10000); // GlobalV global variables are reserved
69+
srand(static_cast<unsigned int>(time(nullptr)) + GlobalV::MY_RANK * rank_seed_offset); // GlobalV global variables are reserved
7070
}
7171
else
7272
{
73-
srand((unsigned)std::abs(seed_in) + (GlobalV::MY_BNDGROUP * GlobalV::NPROC_IN_BNDGROUP + GlobalV::RANK_IN_BPGROUP) * 10000);
73+
srand(static_cast<unsigned int>(std::abs(seed_in)) + (GlobalV::MY_BNDGROUP * GlobalV::NPROC_IN_BNDGROUP + GlobalV::RANK_IN_BPGROUP) * rank_seed_offset);
7474
}
7575

7676
this->allocate_chi0();

0 commit comments

Comments
 (0)