void FixClientGCMC::attempt_atomic_deletion_full() { ndeletion_attempts += 1.0; if (ngas == 0 || ngas <= min_ngas) return; double energy_before = energy_stored; int i = pick_random_gas_atom(); double **x = atom->x; double xtmp[3]; xtmp[0] = xtmp[1] = xtmp[2] = 0.0; if (atom->natoms == 1) { error->warning(FLERR,"natoms = 1, will not perform deletion"); energy_stored = energy_before; } else { int tmpmask; if (i >= 0) { xtmp[0] = x[i][0]; //storing coords in case trial is not accepted and need put atom back in its coords xtmp[1] = x[i][1]; xtmp[2] = x[i][2]; tmpmask = atom->mask[i]; //atom->mask array contains the bits that identify to which group an atom belongs to atom->avec->copy(atom->nlocal-1,i,1); //deletes atom i atom->nlocal--; } atom->natoms--; if (atom->map_style) atom->map_init(); double energy_after = energy_full(); if (random_equal->uniform() < ngas*exp(beta*(energy_before - energy_after))/(zz*volume)) { ndeletion_successes += 1.0; energy_stored = energy_after; } else { atom->avec->create_atom(ngcmc_type,xtmp); //create atom of type ngcmc_type at coords xtmp (works only if ngcmc_type is deleted) int m = atom->nlocal -1; atom->mask[m] = groupbitall; atom->mask[m] |= tmpmask; //atom->mask array contains the bits that identify to which group an atom belongs to atom->natoms++; if (atom->tag_enable){ atom->tag_extend(); if (atom->map_style) atom->map_init(); } energy_stored = energy_before; } } update_gas_atoms_list(); }