Skip to content

Commit

Permalink
lmp: improve error message when compute/fix is not found
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
njzjz authored May 21, 2024
1 parent 81b5949 commit 0a8b228
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions source/lmp/pair_deepmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,10 @@ void PairDeepMD::make_fparam_from_compute(vector<double> &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) {
Expand All @@ -246,7 +249,10 @@ void PairDeepMD::make_aparam_from_compute(vector<double> &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<size_t>(dim_aparam) * nlocal);

Expand Down Expand Up @@ -277,7 +283,10 @@ void PairDeepMD::make_ttm_fparam(vector<double> &fparam) {
ttm_fix = dynamic_cast<FixTTMDP *>(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);

Expand Down Expand Up @@ -316,7 +325,10 @@ void PairDeepMD::make_ttm_aparam(vector<double> &daparam) {
ttm_fix = dynamic_cast<FixTTMDP *>(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;
Expand Down

0 comments on commit 0a8b228

Please sign in to comment.