From b3c8f85ff910231074c84031aa8cf975c9f37abd Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 28 Sep 2021 04:39:46 -0400 Subject: [PATCH] make sure the one_coeff flag is applied to sub-styles since the check for Pair::one_coeff was moved to the Input class (to reduce redundant code), hybrid substyles could "escape" that requirement. Thus checks have to be added to the hybrid coeff() methods. --- src/pair_hybrid.cpp | 5 ++++- src/pair_hybrid_overlay.cpp | 6 ++++++ src/pair_hybrid_scaled.cpp | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index 67e0a70249..582cebdfb5 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -512,13 +512,16 @@ void PairHybrid::coeff(int narg, char **arg) // then unset setflag/map assigned to that style before setting it below // in case pair coeff for this sub-style is being called for 2nd time - if (!none && styles[m]->one_coeff) + if (!none && styles[m]->one_coeff) { + if ((strcmp(arg[0],"*") != 0) || (strcmp(arg[1],"*") != 0)) + error->all(FLERR,"Incorrect args for pair coefficients"); for (int i = 1; i <= atom->ntypes; i++) for (int j = i; j <= atom->ntypes; j++) if (nmap[i][j] && map[i][j][0] == m) { setflag[i][j] = 0; nmap[i][j] = 0; } + } // set setflag and which type pairs map to which sub-style // if sub-style is none: set hybrid setflag, wipe out map diff --git a/src/pair_hybrid_overlay.cpp b/src/pair_hybrid_overlay.cpp index db12750f40..e93473e3c9 100644 --- a/src/pair_hybrid_overlay.cpp +++ b/src/pair_hybrid_overlay.cpp @@ -70,6 +70,12 @@ void PairHybridOverlay::coeff(int narg, char **arg) arg[2+multflag] = arg[1]; arg[1+multflag] = arg[0]; + // ensure that one_coeff flag is honored + + if (!none && styles[m]->one_coeff) + if ((strcmp(arg[0],"*") != 0) || (strcmp(arg[1],"*") != 0)) + error->all(FLERR,"Incorrect args for pair coefficients"); + // invoke sub-style coeff() starting with 1st remaining arg if (!none) styles[m]->coeff(narg-1-multflag,arg+1+multflag); diff --git a/src/pair_hybrid_scaled.cpp b/src/pair_hybrid_scaled.cpp index 90e30dd9b2..5bf593d147 100644 --- a/src/pair_hybrid_scaled.cpp +++ b/src/pair_hybrid_scaled.cpp @@ -474,6 +474,12 @@ void PairHybridScaled::coeff(int narg, char **arg) arg[2 + multflag] = arg[1]; arg[1 + multflag] = arg[0]; + // ensure that one_coeff flag is honored + + if (!none && styles[m]->one_coeff) + if ((strcmp(arg[0],"*") != 0) || (strcmp(arg[1],"*") != 0)) + error->all(FLERR,"Incorrect args for pair coefficients"); + // invoke sub-style coeff() starting with 1st remaining arg if (!none) styles[m]->coeff(narg - 1 - multflag, &arg[1 + multflag]);