Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions source/lmp/compute_deeptensor_atom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ ComputeDeeptensorAtom::ComputeDeeptensorAtom(LAMMPS *lmp, int narg, char **arg)

// initialize deeptensor
int gpu_rank = dp.get_node_rank();
std::string model_file_content = dp.get_file_content(model_file);
dt.init(model_file, gpu_rank);
try {
dt.init(model_file, gpu_rank);
} catch (deepmd_compat::deepmd_exception &e) {
error->one(FLERR, e.what());
}
sel_types = dt.sel_types();
std::sort(sel_types.begin(), sel_types.end());

Expand Down Expand Up @@ -128,7 +131,7 @@ void ComputeDeeptensorAtom::compute_peratom() {
dt.compute(gtensor, force, virial, atensor, avirial, dcoord, dtype, dbox,
nghost, lmp_list);
} catch (deepmd_compat::deepmd_exception &e) {
error->all(FLERR, e.what());
error->one(FLERR, e.what());
}

// store the result in tensor
Expand Down
22 changes: 17 additions & 5 deletions source/lmp/fix_dplr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@ FixDPLR::FixDPLR(LAMMPS *lmp, int narg, char **arg)

// dpt.init(model);
// dtm.init("frozen_model.pb");
dpt.init(model, 0, "dipole_charge");
dtm.init(model, 0, "dipole_charge");
try {
dpt.init(model, 0, "dipole_charge");
dtm.init(model, 0, "dipole_charge");
} catch (deepmd_compat::deepmd_exception &e) {
error->one(FLERR, e.what());
}

sel_type = dpt.sel_types();
sort(sel_type.begin(), sel_type.end());
Expand Down Expand Up @@ -271,7 +275,11 @@ void FixDPLR::pre_force(int vflag) {
// declear output
vector<FLOAT_PREC> tensor;
// compute
dpt.compute(tensor, dcoord, dtype, dbox, nghost, lmp_list);
try {
dpt.compute(tensor, dcoord, dtype, dbox, nghost, lmp_list);
} catch (deepmd_compat::deepmd_exception &e) {
error->one(FLERR, e.what());
}
// cout << "tensor of size " << tensor.size() << endl;
// cout << "nghost " << nghost << endl;
// cout << "nall " << dtype.size() << endl;
Expand Down Expand Up @@ -434,8 +442,12 @@ void FixDPLR::post_force(int vflag) {
// output vects
vector<FLOAT_PREC> dfcorr, dvcorr;
// compute
dtm.compute(dfcorr, dvcorr, dcoord, dtype, dbox, valid_pairs, dfele, nghost,
lmp_list);
try {
dtm.compute(dfcorr, dvcorr, dcoord, dtype, dbox, valid_pairs, dfele, nghost,
lmp_list);
} catch (deepmd_compat::deepmd_exception &e) {
error->one(FLERR, e.what());
}
assert(dfcorr.size() == dcoord.size());
assert(dfcorr.size() == nall * 3);
// backward communication of fcorr
Expand Down
12 changes: 6 additions & 6 deletions source/lmp/pair_deepmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ void PairDeepMD::compute(int eflag, int vflag) {
deep_pot.compute(dener, dforce, dvirial, dcoord, dtype, dbox,
nghost, lmp_list, ago, fparam, daparam);
} catch (deepmd_compat::deepmd_exception &e) {
error->all(FLERR, e.what());
error->one(FLERR, e.what());
}
} else {
dforce.resize((extend_inum + extend_nghost) * 3);
Expand All @@ -510,7 +510,7 @@ void PairDeepMD::compute(int eflag, int vflag) {
extend_dtype, dbox, extend_nghost, extend_lmp_list,
ago, fparam, daparam);
} catch (deepmd_compat::deepmd_exception &e) {
error->all(FLERR, e.what());
error->one(FLERR, e.what());
}
}
}
Expand All @@ -524,7 +524,7 @@ void PairDeepMD::compute(int eflag, int vflag) {
dtype, dbox, nghost, lmp_list, ago, fparam,
daparam);
} catch (deepmd_compat::deepmd_exception &e) {
error->all(FLERR, e.what());
error->one(FLERR, e.what());
}
} else {
dforce.resize((extend_inum + extend_nghost) * 3);
Expand All @@ -533,7 +533,7 @@ void PairDeepMD::compute(int eflag, int vflag) {
extend_dtype, dbox, extend_nghost, extend_lmp_list,
ago, fparam, daparam);
} catch (deepmd_compat::deepmd_exception &e) {
error->all(FLERR, e.what());
error->one(FLERR, e.what());
}
}
if (eflag_atom) {
Expand Down Expand Up @@ -574,7 +574,7 @@ void PairDeepMD::compute(int eflag, int vflag) {
all_energy, all_force, all_virial, all_atom_energy, all_atom_virial,
dcoord, dtype, dbox, nghost, lmp_list, ago, fparam, daparam);
} catch (deepmd_compat::deepmd_exception &e) {
error->all(FLERR, e.what());
error->one(FLERR, e.what());
}
// deep_pot_model_devi.compute_avg (dener, all_energy);
// deep_pot_model_devi.compute_avg (dforce, all_force);
Expand Down Expand Up @@ -720,7 +720,7 @@ void PairDeepMD::compute(int eflag, int vflag) {
try {
deep_pot.compute(dener, dforce, dvirial, dcoord, dtype, dbox);
} catch (deepmd_compat::deepmd_exception &e) {
error->all(FLERR, e.what());
error->one(FLERR, e.what());
}
} else {
error->all(FLERR, "Serial version does not support model devi");
Expand Down