Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
njzjz committed Jan 11, 2024
1 parent 6c73100 commit 5c3b01b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
12 changes: 6 additions & 6 deletions source/api_cc/include/DeepPot.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,39 +480,39 @@ class DeepPotModelDevi {
**/
double cutoff() const {
assert(inited);
return rcut;
return dps[0].cutoff();
};
/**
* @brief Get the number of types.
* @return The number of types.
**/
int numb_types() const {
assert(inited);
return ntypes;
return dps[0].numb_types();
};
/**
* @brief Get the number of types with spin.
* @return The number of types with spin.
**/
int numb_types_spin() const {
assert(inited);
return ntypes_spin;
return dps[0].numb_types_spin();
};
/**
* @brief Get the dimension of the frame parameter.
* @return The dimension of the frame parameter.
**/
int dim_fparam() const {
assert(inited);
return dfparam;
return dps[0].dim_fparam();
};
/**
* @brief Get the dimension of the atomic parameter.
* @return The dimension of the atomic parameter.
**/
int dim_aparam() const {
assert(inited);
return daparam;
return dps[0].dim_aparam();
};
/**
* @brief Compute the average energy.
Expand Down Expand Up @@ -590,7 +590,7 @@ class DeepPotModelDevi {
**/
bool is_aparam_nall() const {
assert(inited);
return aparam_nall;
return dps[0].is_aparam_nall();
};

private:
Expand Down
19 changes: 5 additions & 14 deletions source/api_cc/src/DeepPot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1242,22 +1242,10 @@ DeepPotModelDevi::DeepPotModelDevi(
const int& gpu_rank,
const std::vector<std::string>& file_contents)
: inited(false), init_nbor(false), numb_models(0) {
try {
init(models, gpu_rank, file_contents);
} catch (...) {
// Clean up and rethrow, as the destructor will not be called
for (unsigned ii = 0; ii < numb_models; ++ii) {
delete graph_defs[ii];
}
throw;
}
init(models, gpu_rank, file_contents);
}

DeepPotModelDevi::~DeepPotModelDevi() {
for (unsigned ii = 0; ii < numb_models; ++ii) {
delete graph_defs[ii];
}
}
DeepPotModelDevi::~DeepPotModelDevi() {}

void DeepPotModelDevi::init(const std::vector<std::string>& models,
const int& gpu_rank,
Expand All @@ -1269,6 +1257,9 @@ void DeepPotModelDevi::init(const std::vector<std::string>& models,
return;
}
numb_models = models.size();
if (numb_models == 0) {
throw deepmd::deepmd_exception("no model is specified");
}
for (unsigned int ii = 0; ii < numb_models; ++ii) {
dps[ii] = DeepPot(models[ii], gpu_rank, file_contents[ii]);
}
Expand Down

0 comments on commit 5c3b01b

Please sign in to comment.