diff --git a/include/fiction/technology/charge_distribution_surface.hpp b/include/fiction/technology/charge_distribution_surface.hpp index 808052de6..af1799bd9 100644 --- a/include/fiction/technology/charge_distribution_surface.hpp +++ b/include/fiction/technology/charge_distribution_surface.hpp @@ -758,13 +758,10 @@ class charge_distribution_surface : public Lyt if (!candidates.empty()) { - const auto random_index = - static_cast(std::rand()) % // NOLINT: we use rand() due to its performance advantage; we do - // not need cryptographic security here - candidates.size(); - - const auto random_element = index_vector[candidates[random_index]]; - strg->cell_charge[random_element] = sidb_charge_state::NEGATIVE; + static std::mt19937_64 generator(std::random_device{}()); + std::uniform_int_distribution dist(0, candidates.size() - 1); + const auto random_element = index_vector[candidates[dist(generator)]]; + strg->cell_charge[random_element] = sidb_charge_state::NEGATIVE; negative_indices.push_back(random_element); strg->system_energy += -(this->get_local_potential_by_index(random_element).value());