diff --git a/doc/src/compute_ptm_atom.rst b/doc/src/compute_ptm_atom.rst index 1b5066e473..806b11d040 100644 --- a/doc/src/compute_ptm_atom.rst +++ b/doc/src/compute_ptm_atom.rst @@ -9,12 +9,13 @@ Syntax .. parsed-literal:: - compute ID group-ID ptm/atom structures threshold + compute ID group-ID ptm/atom structures threshold group2-ID * ID, group-ID are documented in :doc:`compute ` command * ptm/atom = style name of this compute command * structures = structure types to search for * threshold = lattice distortion threshold (RMSD) +* group2-ID determines which group are used for neighbor selection (optional, default "all") Examples """""""" @@ -22,8 +23,8 @@ Examples .. parsed-literal:: - compute 1 all ptm/atom default 0.1 - compute 1 all ptm/atom fcc-hcp-dcub-dhex 0.15 + compute 1 all ptm/atom default 0.1 all + compute 1 all ptm/atom fcc-hcp-dcub-dhex 0.15 all compute 1 all ptm/atom all 0 Description diff --git a/src/USER-PTM/compute_ptm_atom.cpp b/src/USER-PTM/compute_ptm_atom.cpp index 5c20467a9f..8a64e5c29d 100644 --- a/src/USER-PTM/compute_ptm_atom.cpp +++ b/src/USER-PTM/compute_ptm_atom.cpp @@ -33,6 +33,7 @@ under #include "neigh_request.h" #include "neighbor.h" #include "update.h" +#include "group.h" #include "ptm_functions.h" @@ -61,7 +62,7 @@ static const char cite_user_ptm_package[] = ComputePTMAtom::ComputePTMAtom(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), list(NULL), output(NULL) { - if (narg != 5) + if (narg < 5) error->all(FLERR, "Illegal compute ptm/atom command"); char *structures = arg[3]; @@ -122,6 +123,14 @@ ComputePTMAtom::ComputePTMAtom(LAMMPS *lmp, int narg, char **arg) if (rmsd_threshold == 0) rmsd_threshold = INFINITY; + char* group_name = (char *)"all"; + if (narg > 5) { + group_name = arg[5]; + } + int igroup = group->find(group_name); + if (igroup == -1) error->all(FLERR,"Could not find fix group ID"); + group2bit = group->bitmask[igroup]; + peratom_flag = 1; size_peratom_cols = NUM_COLUMNS; create_attribute = 1; @@ -169,7 +178,7 @@ typedef struct int *ilist; int nlocal; int *mask; - int groupbit; + int group2bit; } ptmnbrdata_t; @@ -187,7 +196,7 @@ static int get_neighbours(void* vdata, size_t central_index, size_t atom_index, { ptmnbrdata_t* data = (ptmnbrdata_t*)vdata; int *mask = data->mask; - int groupbit = data->groupbit; + int group2bit = data->group2bit; double **x = data->x; double *pos = x[atom_index]; @@ -207,7 +216,7 @@ static int get_neighbours(void* vdata, size_t central_index, size_t atom_index, for (int jj = 0; jj < jnum; jj++) { int j = jlist[jj]; - if (!(mask[j] & groupbit)) + if (!(mask[j] & group2bit)) continue; j &= NEIGHMASK; @@ -272,7 +281,7 @@ void ComputePTMAtom::compute_peratom() { double **x = atom->x; int *mask = atom->mask; - ptmnbrdata_t nbrlist = {x, numneigh, firstneigh, ilist, atom->nlocal, mask, groupbit}; + ptmnbrdata_t nbrlist = {x, numneigh, firstneigh, ilist, atom->nlocal, mask, group2bit}; for (int ii = 0; ii < inum; ii++) { diff --git a/src/USER-PTM/compute_ptm_atom.h b/src/USER-PTM/compute_ptm_atom.h index 586d7a44cd..d7373a0763 100644 --- a/src/USER-PTM/compute_ptm_atom.h +++ b/src/USER-PTM/compute_ptm_atom.h @@ -39,6 +39,7 @@ class ComputePTMAtom : public Compute { double rmsd_threshold; class NeighList *list; double **output; + int group2bit; }; }