From 0a8b2286c2e45318a7bd5042761ef1b8a931ffe5 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Tue, 21 May 2024 18:01:45 -0400 Subject: [PATCH 1/2] lmp: improve error message when compute/fix is not found Signed-off-by: Jinzhe Zeng --- source/lmp/pair_deepmd.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/source/lmp/pair_deepmd.cpp b/source/lmp/pair_deepmd.cpp index 027b42825b..0ec57265dc 100644 --- a/source/lmp/pair_deepmd.cpp +++ b/source/lmp/pair_deepmd.cpp @@ -219,7 +219,10 @@ void PairDeepMD::make_fparam_from_compute(vector &fparam) { int icompute = modify->find_compute(compute_fparam_id); Compute *compute = modify->compute[icompute]; - assert(compute); + if (!compute) { + error->all(FLERR, + "compute id is not found: " + compute_fparam_id); + } fparam.resize(dim_fparam); if (dim_fparam == 1) { @@ -246,7 +249,10 @@ void PairDeepMD::make_aparam_from_compute(vector &aparam) { int icompute = modify->find_compute(compute_aparam_id); Compute *compute = modify->compute[icompute]; - assert(compute); + if (!compute) { + error->all(FLERR, + "compute id is not found: " + compute_aparam_id); + } int nlocal = atom->nlocal; aparam.resize(static_cast(dim_aparam) * nlocal); @@ -277,7 +283,10 @@ void PairDeepMD::make_ttm_fparam(vector &fparam) { ttm_fix = dynamic_cast(modify->fix[ii]); } } - assert(ttm_fix); + if (!ttm_fix) { + error->all(FLERR, + "fix ttm id is not found: " + ttm_fix_id); + } fparam.resize(dim_fparam); @@ -316,7 +325,10 @@ void PairDeepMD::make_ttm_aparam(vector &daparam) { ttm_fix = dynamic_cast(modify->fix[ii]); } } - assert(ttm_fix); + if (!ttm_fix) { + error->all(FLERR, + "fix ttm id is not found: " + ttm_fix_id); + } // modify double **x = atom->x; int *mask = atom->mask; From 3bce171940be93aa713a2ebad05c4ebf5ddafba2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 22:02:22 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- source/lmp/pair_deepmd.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/source/lmp/pair_deepmd.cpp b/source/lmp/pair_deepmd.cpp index 0ec57265dc..d4fbdd3363 100644 --- a/source/lmp/pair_deepmd.cpp +++ b/source/lmp/pair_deepmd.cpp @@ -220,8 +220,7 @@ void PairDeepMD::make_fparam_from_compute(vector &fparam) { Compute *compute = modify->compute[icompute]; if (!compute) { - error->all(FLERR, - "compute id is not found: " + compute_fparam_id); + error->all(FLERR, "compute id is not found: " + compute_fparam_id); } fparam.resize(dim_fparam); @@ -250,8 +249,7 @@ void PairDeepMD::make_aparam_from_compute(vector &aparam) { Compute *compute = modify->compute[icompute]; if (!compute) { - error->all(FLERR, - "compute id is not found: " + compute_aparam_id); + error->all(FLERR, "compute id is not found: " + compute_aparam_id); } int nlocal = atom->nlocal; aparam.resize(static_cast(dim_aparam) * nlocal); @@ -284,8 +282,7 @@ void PairDeepMD::make_ttm_fparam(vector &fparam) { } } if (!ttm_fix) { - error->all(FLERR, - "fix ttm id is not found: " + ttm_fix_id); + error->all(FLERR, "fix ttm id is not found: " + ttm_fix_id); } fparam.resize(dim_fparam); @@ -326,8 +323,7 @@ void PairDeepMD::make_ttm_aparam(vector &daparam) { } } if (!ttm_fix) { - error->all(FLERR, - "fix ttm id is not found: " + ttm_fix_id); + error->all(FLERR, "fix ttm id is not found: " + ttm_fix_id); } // modify double **x = atom->x;