diff --git a/src/force.cpp b/src/force.cpp index aa70874adf..f51b0c1818 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -198,10 +198,11 @@ Pair *Force::pair_creator(LAMMPS *lmp) return ptr to Pair class if matches word or matches hybrid sub-style if exact, then style name must be exact match to word if not exact, style name must contain word - return NULL if no match or multiple sub-styles match + if nsub > 0, match Nth hybrid sub-style + return NULL if no match or if nsub=0 and multiple sub-styles match ------------------------------------------------------------------------- */ -Pair *Force::pair_match(const char *word, int exact) +Pair *Force::pair_match(const char *word, int exact, int nsub) { int iwhich,count; @@ -216,6 +217,7 @@ Pair *Force::pair_match(const char *word, int exact) (!exact && strstr(hybrid->keywords[i],word))) { iwhich = i; count++; + if (nsub == count) return hybrid->styles[iwhich]; } if (count == 1) return hybrid->styles[iwhich]; @@ -227,6 +229,7 @@ Pair *Force::pair_match(const char *word, int exact) (!exact && strstr(hybrid->keywords[i],word))) { iwhich = i; count++; + if (nsub == count) return hybrid->styles[iwhich]; } if (count == 1) return hybrid->styles[iwhich]; } diff --git a/src/force.h b/src/force.h index a3fca51020..54b6612689 100644 --- a/src/force.h +++ b/src/force.h @@ -80,7 +80,7 @@ class Force : protected Pointers { void create_pair(const char *, int); class Pair *new_pair(const char *, int, int &); - class Pair *pair_match(const char *, int); + class Pair *pair_match(const char *, int, int nsub=0); void create_bond(const char *, int); class Bond *new_bond(const char *, int, int &);