From b6128c91f9b34a2bd7e6523bad9a8ad1b44d2678 Mon Sep 17 00:00:00 2001 From: samomoyed <1176316683@qq.com> Date: Wed, 18 Mar 2026 21:24:15 +0800 Subject: [PATCH] refactor: replace magic numbers in sto_wf.cpp --- source/source_pw/module_stodft/sto_wf.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/source_pw/module_stodft/sto_wf.cpp b/source/source_pw/module_stodft/sto_wf.cpp index 2ba8db29086..1ef2efad9dd 100644 --- a/source/source_pw/module_stodft/sto_wf.cpp +++ b/source/source_pw/module_stodft/sto_wf.cpp @@ -60,17 +60,17 @@ void Stochastic_WF::clean_chiallorder() delete[] chiallorder; chiallorder = nullptr; } - template void Stochastic_WF::init_sto_orbitals(const int seed_in) { + const unsigned int rank_seed_offset = 10000; if (seed_in == 0 || seed_in == -1) { - srand((unsigned)time(nullptr) + GlobalV::MY_RANK * 10000); // GlobalV global variables are reserved + srand(static_cast(time(nullptr)) + GlobalV::MY_RANK * rank_seed_offset); // GlobalV global variables are reserved } else { - srand((unsigned)std::abs(seed_in) + (GlobalV::MY_BNDGROUP * GlobalV::NPROC_IN_BNDGROUP + GlobalV::RANK_IN_BPGROUP) * 10000); + srand(static_cast(std::abs(seed_in)) + (GlobalV::MY_BNDGROUP * GlobalV::NPROC_IN_BNDGROUP + GlobalV::RANK_IN_BPGROUP) * rank_seed_offset); } this->allocate_chi0();