From ec3e687b0c07ccb7a36f4136a2341dd0c88d82c9 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 10 Feb 2020 16:22:23 -0500 Subject: [PATCH] fix bug in set type/ratio when operating on subsets --- src/set.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/set.cpp b/src/set.cpp index 9807b07ea4..d61ffae6ae 100644 --- a/src/set.cpp +++ b/src/set.cpp @@ -1084,13 +1084,18 @@ void Set::setrandom(int keyword) ranmars->select_subset(nsubset,count,flag,work); // change types of selected atoms + // flag vecftor from select_subset() is only for eligible atoms count = 0; - for (i = 0; i < nlocal; i++) - if (select[i] && flag[i]) { + int eligible = 0; + for (i = 0; i < nlocal; i++) { + if (!select[i]) continue; + if (flag[eligible]) { atom->type[i] = newtype; count++; } + eligible++; + } // clean up