From e48e5ad965c5044ab9759218e6649d517c0cd341 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 3 Jan 2023 14:16:28 -0500 Subject: [PATCH] update suffix handling to be consistent (also with pending fix pair changes) --- doc/src/fix_adapt.rst | 2 +- src/FEP/compute_fep.cpp | 17 ++++++----------- src/fix_adapt.cpp | 12 +++++++----- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/doc/src/fix_adapt.rst b/doc/src/fix_adapt.rst index 18caa3d54f..a3e851faf0 100644 --- a/doc/src/fix_adapt.rst +++ b/doc/src/fix_adapt.rst @@ -120,7 +120,7 @@ The *pstyle* argument is the name of the pair style. If :doc:`pair_style hybrid or hybrid/overlay ` is used, *pstyle* should be a sub-style name. If there are multiple sub-styles using the same pair style, then *pstyle* should be specified -as "style:N", where :math:`N` is which instance of the pair style you wish to +as "style:N", where *N* is which instance of the pair style you wish to adapt (e.g., the first or second). For example, *pstyle* could be specified as "soft" or "lubricate" or "lj/cut:1" or "lj/cut:2". The *pparam* argument is the name of the parameter to change. This is the diff --git a/src/FEP/compute_fep.cpp b/src/FEP/compute_fep.cpp index 995e2f9f3d..5dcb6c51d2 100644 --- a/src/FEP/compute_fep.cpp +++ b/src/FEP/compute_fep.cpp @@ -201,23 +201,18 @@ void ComputeFEP::init() pairflag = 1; Pair *pair = nullptr; if (lmp->suffix_enable) { - if (lmp->suffix) { - auto pstyle = fmt::format("{}/{}", pert->pstyle, lmp->suffix); - pair = force->pair_match(pstyle, 1); - } - if ((pair == nullptr) && lmp->suffix2) { - auto pstyle = fmt::format("{}/{}", pert->pstyle, lmp->suffix2); - pair = force->pair_match(pstyle, 1); - } + if (lmp->suffix) + pair = force->pair_match(fmt::format("{}/{}", pert->pstyle, lmp->suffix), 1); + if ((pair == nullptr) && lmp->suffix2) + pair = force->pair_match(fmt::format("{}/{}", pert->pstyle, lmp->suffix2), 1); } if (pair == nullptr) pair = force->pair_match(pert->pstyle, 1); - if (pair == nullptr) - error->all(FLERR, "compute fep pair style {} does not exist", pert->pstyle); + if (pair == nullptr) error->all(FLERR, "Compute fep pair style {} not found", pert->pstyle); void *ptr = pair->extract(pert->pparam, pert->pdim); if (ptr == nullptr) - error->all(FLERR, "compute fep pair style param {} not supported", pert->pparam); + error->all(FLERR, "Compute fep pair style param {} not supported", pert->pparam); pert->array = (double **) ptr; diff --git a/src/fix_adapt.cpp b/src/fix_adapt.cpp index f82e5a644a..794fde1f50 100644 --- a/src/fix_adapt.cpp +++ b/src/fix_adapt.cpp @@ -357,12 +357,14 @@ void FixAdapt::init() nsub = utils::inumeric(FLERR,cptr+1,false,lmp); } - if (lmp->suffix_enable) - ad->pair = force->pair_match(fmt::format("{}/{}",pstyle,lmp->suffix),1,nsub); - + if (lmp->suffix_enable) { + if (lmp->suffix) + ad->pair = force->pair_match(fmt::format("{}/{}",pstyle,lmp->suffix),1,nsub); + if ((ad->pair == nullptr) && lmp->suffix2) + ad->pair = force->pair_match(fmt::format("{}/{}",pstyle,lmp->suffix2),1,nsub); + } if (ad->pair == nullptr) ad->pair = force->pair_match(pstyle,1,nsub); - if (ad->pair == nullptr) - error->all(FLERR,"Fix adapt pair style does not exist"); + if (ad->pair == nullptr) error->all(FLERR,"Fix adapt pair style {} not found", pstyle); void *ptr = ad->pair->extract(ad->pparam,ad->pdim); if (ptr == nullptr)