Skip to content

Commit

Permalink
Draft a model devi without nlist
Browse files Browse the repository at this point in the history
  • Loading branch information
robinzyb committed Apr 5, 2024
1 parent 073f559 commit c85c38c
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
30 changes: 30 additions & 0 deletions source/api_cc/include/DeepPot.h
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,36 @@ class DeepPotModelDevi {
const std::vector<std::string>& file_contents =
std::vector<std::string>());

/**
* @brief Evaluate the energy, force and virial by using these DP models.
* @param[out] all_ener The system energies of all models.
* @param[out] all_force The forces on each atom of all models.
* @param[out] all_virial The virials of all models.
* @param[in] coord The coordinates of atoms. The array should be of size
*nframes x natoms x 3.
* @param[in] atype The atom types. The list should contain natoms ints.
* @param[in] box The cell of the region. The array should be of size nframes
*x 9.
* @param[in] fparam The frame parameter. The array can be of size :
* nframes x dim_fparam.
* dim_fparam. Then all frames are assumed to be provided with the same
*fparam.
* @param[in] aparam The atomic parameter The array can be of size :
* nframes x natoms x dim_aparam.
* natoms x dim_aparam. Then all frames are assumed to be provided with the
*same aparam. dim_aparam. Then all frames and atoms are provided with the
*same aparam.
**/
template <typename VALUETYPE>
void compute(std::vector<ENERGYTYPE>& all_ener,
std::vector<std::vector<VALUETYPE> >& all_force,
std::vector<std::vector<VALUETYPE> >& all_virial,
const std::vector<VALUETYPE>& coord,
const std::vector<int>& atype,
const std::vector<VALUETYPE>& box,
const std::vector<VALUETYPE>& fparam = std::vector<VALUETYPE>(),
const std::vector<VALUETYPE>& aparam = std::vector<VALUETYPE>());

/**
* @brief Evaluate the energy, force and virial by using these DP models.
* @param[out] all_ener The system energies of all models.
Expand Down
42 changes: 42 additions & 0 deletions source/api_cc/src/DeepPot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,48 @@ void DeepPotModelDevi::init(const std::vector<std::string>& models,
inited = true;
}

template <typename VALUETYPE>
void DeepPotModelDevi::compute(std::vector<ENERGYTYPE>& all_energy,
std::vector<std::vector<VALUETYPE>>& all_force,
std::vector<std::vector<VALUETYPE>>& all_virial,
const std::vector<VALUETYPE>& dcoord_,
const std::vector<int>& datype_,
const std::vector<VALUETYPE>& dbox,
const std::vector<VALUETYPE>& fparam,
const std::vector<VALUETYPE>& aparam_) {
// without nlist
if (numb_models == 0) {
return;
}
all_energy.resize(numb_models);
all_force.resize(numb_models);
all_virial.resize(numb_models);
for (unsigned ii = 0; ii < numb_models; ++ii) {
dps[ii].compute(all_energy[ii], all_force[ii], all_virial[ii], dcoord_,
datype_, dbox, fparam, aparam_);
}
}

template void DeepPotModelDevi::compute<double>(
std::vector<ENERGYTYPE>& all_energy,
std::vector<std::vector<double>>& all_force,
std::vector<std::vector<double>>& all_virial,
const std::vector<double>& dcoord_,
const std::vector<int>& datype_,
const std::vector<double>& dbox,
const std::vector<double>& fparam,
const std::vector<double>& aparam);

template void DeepPotModelDevi::compute<float>(
std::vector<ENERGYTYPE>& all_energy,
std::vector<std::vector<float>>& all_force,
std::vector<std::vector<float>>& all_virial,
const std::vector<float>& dcoord_,
const std::vector<int>& datype_,
const std::vector<float>& dbox,
const std::vector<float>& fparam,
const std::vector<float>& aparam);

template <typename VALUETYPE>
void DeepPotModelDevi::compute(std::vector<ENERGYTYPE>& all_energy,
std::vector<std::vector<VALUETYPE>>& all_force,
Expand Down

0 comments on commit c85c38c

Please sign in to comment.