From 3168c1116f928a96e6c6827455ae9c471a6c9fe8 Mon Sep 17 00:00:00 2001 From: pmla Date: Tue, 25 Feb 2020 14:16:21 +0100 Subject: [PATCH 1/5] fixed group selection --- src/USER-PTM/compute_ptm_atom.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/USER-PTM/compute_ptm_atom.cpp b/src/USER-PTM/compute_ptm_atom.cpp index 3a2c8daac4..5c20467a9f 100644 --- a/src/USER-PTM/compute_ptm_atom.cpp +++ b/src/USER-PTM/compute_ptm_atom.cpp @@ -168,6 +168,8 @@ typedef struct int **firstneigh; int *ilist; int nlocal; + int *mask; + int groupbit; } ptmnbrdata_t; @@ -184,6 +186,8 @@ static bool sorthelper_compare(ptmnbr_t const &a, ptmnbr_t const &b) { static int get_neighbours(void* vdata, size_t central_index, size_t atom_index, int num, size_t* nbr_indices, int32_t* numbers, double (*nbr_pos)[3]) { ptmnbrdata_t* data = (ptmnbrdata_t*)vdata; + int *mask = data->mask; + int groupbit = data->groupbit; double **x = data->x; double *pos = x[atom_index]; @@ -203,6 +207,9 @@ 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)) + continue; + j &= NEIGHMASK; if (j == atom_index) continue; @@ -265,7 +272,7 @@ void ComputePTMAtom::compute_peratom() { double **x = atom->x; int *mask = atom->mask; - ptmnbrdata_t nbrlist = {x, numneigh, firstneigh, ilist, atom->nlocal}; + ptmnbrdata_t nbrlist = {x, numneigh, firstneigh, ilist, atom->nlocal, mask, groupbit}; for (int ii = 0; ii < inum; ii++) { From 7acba4584dc5cb83fd7d4ee58f1173ed431414dd Mon Sep 17 00:00:00 2001 From: pmla Date: Tue, 25 Feb 2020 18:05:36 +0100 Subject: [PATCH 2/5] added group2ID --- doc/src/compute_ptm_atom.rst | 7 ++++--- src/USER-PTM/compute_ptm_atom.cpp | 19 ++++++++++++++----- src/USER-PTM/compute_ptm_atom.h | 1 + 3 files changed, 19 insertions(+), 8 deletions(-) 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; }; } From 1fc4dc151f977bda94311ced6e0a49b1037c5db5 Mon Sep 17 00:00:00 2001 From: pmla Date: Tue, 25 Feb 2020 18:11:31 +0100 Subject: [PATCH 3/5] typo --- doc/src/compute_ptm_atom.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/compute_ptm_atom.rst b/doc/src/compute_ptm_atom.rst index 806b11d040..f4493e34d2 100644 --- a/doc/src/compute_ptm_atom.rst +++ b/doc/src/compute_ptm_atom.rst @@ -15,7 +15,7 @@ Syntax * 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") +* group2-ID determines which groups are used for neighbor selection (optional, default "all") Examples """""""" From c92378eacaf64c3a7ed1002f741446cfb297d71f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 26 Feb 2020 13:12:14 +0100 Subject: [PATCH 4/5] add explanation of use of group2 and document effect of compute group --- doc/src/compute_ptm_atom.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/src/compute_ptm_atom.rst b/doc/src/compute_ptm_atom.rst index f4493e34d2..503c8df168 100644 --- a/doc/src/compute_ptm_atom.rst +++ b/doc/src/compute_ptm_atom.rst @@ -15,7 +15,7 @@ Syntax * ptm/atom = style name of this compute command * structures = structure types to search for * threshold = lattice distortion threshold (RMSD) -* group2-ID determines which groups are used for neighbor selection (optional, default "all") +* group2-ID determines which group is used for neighbor selection (optional, default "all") Examples """""""" @@ -83,7 +83,9 @@ The neighbor list needed to compute this quantity is constructed each time the calculation is performed (e.g. each time a snapshot of atoms is dumped). Thus it can be inefficient to compute/dump this quantity too frequently or to have multiple compute/dump commands, each with a -*ptm/atom* style. +*ptm/atom* style. By default the compute processes **all** neighbors +unless the optional *group2-ID* argument is given, then only members +of that group are considered as neighbors. **Output info:** @@ -107,6 +109,7 @@ The interatomic distance is computed from the scale factor in the RMSD equation. The (qw,qx,qy,qz) parameters represent the orientation of the local structure in quaternion form. The reference coordinates for each template (from which the orientation is determined) can be found in the *ptm\_constants.h* file in the PTM source directory. +For atoms that are not within the compute group-ID, all values are set to zero. Restrictions """""""""""" From f81b963a8aed439e0556cacbe86a712659d658bd Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 26 Feb 2020 13:12:39 +0100 Subject: [PATCH 5/5] more strict argument checking and initializing output data to zero --- src/USER-PTM/compute_ptm_atom.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/USER-PTM/compute_ptm_atom.cpp b/src/USER-PTM/compute_ptm_atom.cpp index 8a64e5c29d..df6a01e6c6 100644 --- a/src/USER-PTM/compute_ptm_atom.cpp +++ b/src/USER-PTM/compute_ptm_atom.cpp @@ -62,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 || narg > 6) error->all(FLERR, "Illegal compute ptm/atom command"); char *structures = arg[3]; @@ -283,6 +283,10 @@ void ComputePTMAtom::compute_peratom() { int *mask = atom->mask; ptmnbrdata_t nbrlist = {x, numneigh, firstneigh, ilist, atom->nlocal, mask, group2bit}; + // zero output + + memset(output,0,nmax*NUM_COLUMNS*sizeof(double)); + for (int ii = 0; ii < inum; ii++) { int i = ilist[ii];