fix bug in set type/ratio when operating on subsets

This commit is contained in:
Axel Kohlmeyer
2020-02-10 16:22:23 -05:00
parent f0935feabe
commit ec3e687b0c

View File

@ -1084,13 +1084,18 @@ void Set::setrandom(int keyword)
ranmars->select_subset(nsubset,count,flag,work); ranmars->select_subset(nsubset,count,flag,work);
// change types of selected atoms // change types of selected atoms
// flag vecftor from select_subset() is only for eligible atoms
count = 0; count = 0;
for (i = 0; i < nlocal; i++) int eligible = 0;
if (select[i] && flag[i]) { for (i = 0; i < nlocal; i++) {
if (!select[i]) continue;
if (flag[eligible]) {
atom->type[i] = newtype; atom->type[i] = newtype;
count++; count++;
} }
eligible++;
}
// clean up // clean up