diff --git a/source/source_pw/module_stodft/sto_wf.cpp b/source/source_pw/module_stodft/sto_wf.cpp index e844503a11..d2e9c5113d 100644 --- a/source/source_pw/module_stodft/sto_wf.cpp +++ b/source/source_pw/module_stodft/sto_wf.cpp @@ -68,11 +68,13 @@ void Stochastic_WF::init_sto_orbitals(const int seed_in) { 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 * GlobalConst::RANDOM_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((unsigned)std::abs(seed_in) + + (GlobalV::MY_BNDGROUP * GlobalV::NPROC_IN_BNDGROUP + GlobalV::RANK_IN_BPGROUP) * 10000); } this->allocate_chi0(); @@ -374,9 +376,7 @@ void Stochastic_WF::sync_chi0() Device* ctx = {}; if (base_device::get_device_type(ctx) == base_device::GpuDevice) { - syncmem_h2d_op()(this->chi0->get_pointer(), - this->chi0_cpu->get_pointer(), - this->chi0_cpu->size()); + syncmem_h2d_op()(this->chi0->get_pointer(), this->chi0_cpu->get_pointer(), this->chi0_cpu->size()); } } diff --git a/source/source_pw/module_stodft/sto_wf.h b/source/source_pw/module_stodft/sto_wf.h index 5146ff7f56..db5e0f2558 100644 --- a/source/source_pw/module_stodft/sto_wf.h +++ b/source/source_pw/module_stodft/sto_wf.h @@ -9,6 +9,10 @@ // Generate stochastic wave functions //---------------------------------------------- template +namespace GlobalConst +{ + constexpr int RANDOM_SEED_OFFSET = 10000; +} class Stochastic_WF { public: @@ -33,7 +37,7 @@ class Stochastic_WF int npwx = 0; ///< max ngk[ik] in all processors int nbands_diag = 0; ///< number of bands obtained from diagonalization int nbands_total = 0; ///< number of bands in total, nbands_total=nchi+nbands_diag; - std::vector ngk; ///< ngk in klist + std::vector ngk; ///< ngk in klist public: // Tn(H)|chi> psi::Psi* chiallorder = nullptr;