diff --git a/source/api_c/src/c_api.cc b/source/api_c/src/c_api.cc index 9dae45eb92..992fb8404a 100644 --- a/source/api_c/src/c_api.cc +++ b/source/api_c/src/c_api.cc @@ -289,8 +289,8 @@ inline void DP_DeepPotCompute_variant_sp(DP_DeepPot* dp, std::vector e; std::vector f, fm, v, ae, av; - DP_REQUIRES_OK(dp, dp->dp.compute_spin(e, f, fm, v, ae, av, coord_, spin_, atype_, - cell_, fparam_, aparam_)); + DP_REQUIRES_OK(dp, dp->dp.compute_spin(e, f, fm, v, ae, av, coord_, spin_, + atype_, cell_, fparam_, aparam_)); // copy from C++ vectors to C arrays, if not NULL pointer if (energy) { std::copy(e.begin(), e.end(), energy); @@ -487,7 +487,7 @@ inline void DP_DeepPotComputeNList_variant_sp(DP_DeepPot* dp, std::vector f, fm, v, ae, av; DP_REQUIRES_OK( dp, dp->dp.compute_spin(e, f, fm, v, ae, av, coord_, spin_, atype_, cell_, - nghost, nlist->nl, ago, fparam_, aparam_)); + nghost, nlist->nl, ago, fparam_, aparam_)); // copy from C++ vectors to C arrays, if not NULL pointer if (energy) { std::copy(e.begin(), e.end(), energy); @@ -893,13 +893,13 @@ void DP_DeepPotModelDeviComputeNList_variant_sp(DP_DeepPotModelDevi* dp, std::vector e; std::vector> f, fm, v, ae, av; if (atomic_energy || atomic_virial) { - DP_REQUIRES_OK( - dp, dp->dp.compute_spin(e, f, fm, v, ae, av, coord_, spin_, atype_, cell_, - nghost, nlist->nl, ago, fparam_, aparam_)); + DP_REQUIRES_OK(dp, dp->dp.compute_spin(e, f, fm, v, ae, av, coord_, spin_, + atype_, cell_, nghost, nlist->nl, + ago, fparam_, aparam_)); } else { DP_REQUIRES_OK( - dp, dp->dp.compute_spin(e, f, fm, v, coord_, spin_, atype_, cell_, nghost, - nlist->nl, ago, fparam_, aparam_)); + dp, dp->dp.compute_spin(e, f, fm, v, coord_, spin_, atype_, cell_, + nghost, nlist->nl, ago, fparam_, aparam_)); } // 2D vector to 2D array, flatten first if (energy) { diff --git a/source/api_cc/include/DeepPot.h b/source/api_cc/include/DeepPot.h index 34a5f530d9..d5f3f7d0da 100644 --- a/source/api_cc/include/DeepPot.h +++ b/source/api_cc/include/DeepPot.h @@ -459,27 +459,29 @@ class DeepPot { * @{ **/ template - void compute_spin(ENERGYTYPE& ener, - std::vector& force, - std::vector& force_mag, - std::vector& virial, - const std::vector& coord, - const std::vector& spin, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); + void compute_spin( + ENERGYTYPE& ener, + std::vector& force, + std::vector& force_mag, + std::vector& virial, + const std::vector& coord, + const std::vector& spin, + const std::vector& atype, + const std::vector& box, + const std::vector& fparam = std::vector(), + const std::vector& aparam = std::vector()); template - void compute_spin(std::vector& ener, - std::vector& force, - std::vector& force_mag, - std::vector& virial, - const std::vector& coord, - const std::vector& spin, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); + void compute_spin( + std::vector& ener, + std::vector& force, + std::vector& force_mag, + std::vector& virial, + const std::vector& coord, + const std::vector& spin, + const std::vector& atype, + const std::vector& box, + const std::vector& fparam = std::vector(), + const std::vector& aparam = std::vector()); /** @} */ /** @@ -558,33 +560,35 @@ class DeepPot { * @{ **/ template - void compute_spin(ENERGYTYPE& ener, - std::vector& force, - std::vector& force_mag, - std::vector& virial, - const std::vector& coord, - const std::vector& spin, - const std::vector& atype, - const std::vector& box, - const int nghost, - const InputNlist& inlist, - const int& ago, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); + void compute_spin( + ENERGYTYPE& ener, + std::vector& force, + std::vector& force_mag, + std::vector& virial, + const std::vector& coord, + const std::vector& spin, + const std::vector& atype, + const std::vector& box, + const int nghost, + const InputNlist& inlist, + const int& ago, + const std::vector& fparam = std::vector(), + const std::vector& aparam = std::vector()); template - void compute_spin(std::vector& ener, - std::vector& force, - std::vector& force_mag, - std::vector& virial, - const std::vector& coord, - const std::vector& spin, - const std::vector& atype, - const std::vector& box, - const int nghost, - const InputNlist& inlist, - const int& ago, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); + void compute_spin( + std::vector& ener, + std::vector& force, + std::vector& force_mag, + std::vector& virial, + const std::vector& coord, + const std::vector& spin, + const std::vector& atype, + const std::vector& box, + const int nghost, + const InputNlist& inlist, + const int& ago, + const std::vector& fparam = std::vector(), + const std::vector& aparam = std::vector()); /** @} */ /** * @brief Evaluate the energy, force, virial, atomic energy, and atomic virial @@ -660,31 +664,33 @@ class DeepPot { * @{ **/ template - void compute_spin(ENERGYTYPE& ener, - std::vector& force, - std::vector& force_mag, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const std::vector& coord, - const std::vector& spin, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); + void compute_spin( + ENERGYTYPE& ener, + std::vector& force, + std::vector& force_mag, + std::vector& virial, + std::vector& atom_energy, + std::vector& atom_virial, + const std::vector& coord, + const std::vector& spin, + const std::vector& atype, + const std::vector& box, + const std::vector& fparam = std::vector(), + const std::vector& aparam = std::vector()); template - void compute_spin(std::vector& ener, - std::vector& force, - std::vector& force_mag, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const std::vector& coord, - const std::vector& spin, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); + void compute_spin( + std::vector& ener, + std::vector& force, + std::vector& force_mag, + std::vector& virial, + std::vector& atom_energy, + std::vector& atom_virial, + const std::vector& coord, + const std::vector& spin, + const std::vector& atype, + const std::vector& box, + const std::vector& fparam = std::vector(), + const std::vector& aparam = std::vector()); /** @} */ /** @@ -773,37 +779,39 @@ class DeepPot { * @{ **/ template - void compute_spin(ENERGYTYPE& ener, - std::vector& force, - std::vector& force_mag, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const std::vector& coord, - const std::vector& spin, - const std::vector& atype, - const std::vector& box, - const int nghost, - const InputNlist& lmp_list, - const int& ago, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); + void compute_spin( + ENERGYTYPE& ener, + std::vector& force, + std::vector& force_mag, + std::vector& virial, + std::vector& atom_energy, + std::vector& atom_virial, + const std::vector& coord, + const std::vector& spin, + const std::vector& atype, + const std::vector& box, + const int nghost, + const InputNlist& lmp_list, + const int& ago, + const std::vector& fparam = std::vector(), + const std::vector& aparam = std::vector()); template - void compute_spin(std::vector& ener, - std::vector& force, - std::vector& force_mag, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const std::vector& coord, - const std::vector& spin, - const std::vector& atype, - const std::vector& box, - const int nghost, - const InputNlist& lmp_list, - const int& ago, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); + void compute_spin( + std::vector& ener, + std::vector& force, + std::vector& force_mag, + std::vector& virial, + std::vector& atom_energy, + std::vector& atom_virial, + const std::vector& coord, + const std::vector& spin, + const std::vector& atype, + const std::vector& box, + const int nghost, + const InputNlist& lmp_list, + const int& ago, + const std::vector& fparam = std::vector(), + const std::vector& aparam = std::vector()); /** @} */ /** * @brief Evaluate the energy, force, and virial with the mixed type @@ -1105,19 +1113,20 @@ class DeepPotModelDevi { *same aparam. **/ template - void compute_spin(std::vector& all_ener, - std::vector >& all_force, - std::vector >& all_force_mag, - std::vector >& all_virial, - const std::vector& coord, - const std::vector& spin, - const std::vector& atype, - const std::vector& box, - const int nghost, - const InputNlist& lmp_list, - const int& ago, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); + void compute_spin( + std::vector& all_ener, + std::vector >& all_force, + std::vector >& all_force_mag, + std::vector >& all_virial, + const std::vector& coord, + const std::vector& spin, + const std::vector& atype, + const std::vector& box, + const int nghost, + const InputNlist& lmp_list, + const int& ago, + const std::vector& fparam = std::vector(), + const std::vector& aparam = std::vector()); /** * @brief Evaluate the energy, force, virial, atomic energy, and atomic virial *by using these DP models. @@ -1189,21 +1198,22 @@ class DeepPotModelDevi { *same aparam. **/ template - void compute_spin(std::vector& all_ener, - std::vector >& all_force, - std::vector >& all_force_mag, - std::vector >& all_virial, - std::vector >& all_atom_energy, - std::vector >& all_atom_virial, - const std::vector& coord, - const std::vector& spin, - const std::vector& atype, - const std::vector& box, - const int nghost, - const InputNlist& lmp_list, - const int& ago, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); + void compute_spin( + std::vector& all_ener, + std::vector >& all_force, + std::vector >& all_force_mag, + std::vector >& all_virial, + std::vector >& all_atom_energy, + std::vector >& all_atom_virial, + const std::vector& coord, + const std::vector& spin, + const std::vector& atype, + const std::vector& box, + const int nghost, + const InputNlist& lmp_list, + const int& ago, + const std::vector& fparam = std::vector(), + const std::vector& aparam = std::vector()); /** * @brief Get the cutoff radius. * @return The cutoff radius. diff --git a/source/api_cc/src/DeepPot.cc b/source/api_cc/src/DeepPot.cc index 4afdf6442e..7bad4108ed 100644 --- a/source/api_cc/src/DeepPot.cc +++ b/source/api_cc/src/DeepPot.cc @@ -137,15 +137,15 @@ template void DeepPot::compute(std::vector& dener, // support spin template void DeepPot::compute_spin(ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam_, - const std::vector& aparam_) { + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam_, + const std::vector& aparam_) { std::vector dener_; std::vector datom_energy_, datom_virial_; dp->computew(dener_, dforce_, dforce_mag_, dvirial, datom_energy_, @@ -156,15 +156,15 @@ void DeepPot::compute_spin(ENERGYTYPE& dener, template void DeepPot::compute_spin(std::vector& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam_, - const std::vector& aparam_) { + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam_, + const std::vector& aparam_) { std::vector datom_energy_, datom_virial_; dp->computew(dener, dforce_, dforce_mag_, dvirial, datom_energy_, datom_virial_, dcoord_, dspin_, datype_, dbox, fparam_, aparam_, @@ -172,48 +172,48 @@ void DeepPot::compute_spin(std::vector& dener, } template void DeepPot::compute_spin(ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam, + const std::vector& aparam); template void DeepPot::compute_spin(ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam, + const std::vector& aparam); template void DeepPot::compute_spin(std::vector& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam, + const std::vector& aparam); template void DeepPot::compute_spin(std::vector& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam, + const std::vector& aparam); template void DeepPot::compute(ENERGYTYPE& dener, @@ -302,18 +302,18 @@ template void DeepPot::compute(std::vector& dener, // support spin template void DeepPot::compute_spin(ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const int nghost, - const InputNlist& lmp_list, - const int& ago, - const std::vector& fparam_, - const std::vector& aparam__) { + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const int nghost, + const InputNlist& lmp_list, + const int& ago, + const std::vector& fparam_, + const std::vector& aparam__) { std::vector dener_; std::vector datom_energy_, datom_virial_; dp->computew(dener_, dforce_, dforce_mag_, dvirial, datom_energy_, @@ -324,18 +324,18 @@ void DeepPot::compute_spin(ENERGYTYPE& dener, template void DeepPot::compute_spin(std::vector& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const int nghost, - const InputNlist& lmp_list, - const int& ago, - const std::vector& fparam_, - const std::vector& aparam__) { + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const int nghost, + const InputNlist& lmp_list, + const int& ago, + const std::vector& fparam_, + const std::vector& aparam__) { std::vector datom_energy_, datom_virial_; dp->computew(dener, dforce_, dforce_mag_, dvirial, datom_energy_, datom_virial_, dcoord_, dspin_, datype_, dbox, nghost, lmp_list, @@ -344,60 +344,60 @@ void DeepPot::compute_spin(std::vector& dener, // nlist, no atomic : nframe * precision template void DeepPot::compute_spin(ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const int nghost, - const InputNlist& lmp_list, - const int& ago, - const std::vector& fparam, - const std::vector& aparam_); + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const int nghost, + const InputNlist& lmp_list, + const int& ago, + const std::vector& fparam, + const std::vector& aparam_); template void DeepPot::compute_spin(ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const int nghost, - const InputNlist& lmp_list, - const int& ago, - const std::vector& fparam, - const std::vector& aparam_); + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const int nghost, + const InputNlist& lmp_list, + const int& ago, + const std::vector& fparam, + const std::vector& aparam_); template void DeepPot::compute_spin(std::vector& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const int nghost, - const InputNlist& lmp_list, - const int& ago, - const std::vector& fparam, - const std::vector& aparam_); + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const int nghost, + const InputNlist& lmp_list, + const int& ago, + const std::vector& fparam, + const std::vector& aparam_); template void DeepPot::compute_spin(std::vector& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const int nghost, - const InputNlist& lmp_list, - const int& ago, - const std::vector& fparam, - const std::vector& aparam_); + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const int nghost, + const InputNlist& lmp_list, + const int& ago, + const std::vector& fparam, + const std::vector& aparam_); template void DeepPot::compute(ENERGYTYPE& dener, @@ -477,17 +477,17 @@ template void DeepPot::compute(std::vector& dener, // support spin template void DeepPot::compute_spin(ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam_, - const std::vector& aparam_) { + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam_, + const std::vector& aparam_) { std::vector dener_; dp->computew(dener_, dforce_, dforce_mag_, dvirial, datom_energy_, datom_virial_, dcoord_, dspin_, datype_, dbox, fparam_, aparam_, @@ -496,72 +496,72 @@ void DeepPot::compute_spin(ENERGYTYPE& dener, } template void DeepPot::compute_spin(std::vector& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam_, - const std::vector& aparam_) { + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam_, + const std::vector& aparam_) { dp->computew(dener, dforce_, dforce_mag_, dvirial, datom_energy_, datom_virial_, dcoord_, dspin_, datype_, dbox, fparam_, aparam_, true); } template void DeepPot::compute_spin(ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam, + const std::vector& aparam); template void DeepPot::compute_spin(ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam, + const std::vector& aparam); template void DeepPot::compute_spin(std::vector& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam, + const std::vector& aparam); template void DeepPot::compute_spin(std::vector& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam, + const std::vector& aparam); template void DeepPot::compute(ENERGYTYPE& dener, @@ -660,20 +660,20 @@ template void DeepPot::compute(std::vector& dener, template void DeepPot::compute_spin(ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const int nghost, - const InputNlist& lmp_list, - const int& ago, - const std::vector& fparam_, - const std::vector& aparam__) { + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const int nghost, + const InputNlist& lmp_list, + const int& ago, + const std::vector& fparam_, + const std::vector& aparam__) { std::vector dener_; dp->computew(dener_, dforce_, dforce_mag_, dvirial, datom_energy_, datom_virial_, dcoord_, dspin_, datype_, dbox, nghost, lmp_list, @@ -682,88 +682,88 @@ void DeepPot::compute_spin(ENERGYTYPE& dener, } template void DeepPot::compute_spin(std::vector& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const int nghost, - const InputNlist& lmp_list, - const int& ago, - const std::vector& fparam_, - const std::vector& aparam__) { + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const int nghost, + const InputNlist& lmp_list, + const int& ago, + const std::vector& fparam_, + const std::vector& aparam__) { dp->computew(dener, dforce_, dforce_mag_, dvirial, datom_energy_, datom_virial_, dcoord_, dspin_, datype_, dbox, nghost, lmp_list, ago, fparam_, aparam__, true); } // nlist, atomic : nframe * precision template void DeepPot::compute_spin(ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const int nghost, - const InputNlist& lmp_list, - const int& ago, - const std::vector& fparam, - const std::vector& aparam_); + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const int nghost, + const InputNlist& lmp_list, + const int& ago, + const std::vector& fparam, + const std::vector& aparam_); template void DeepPot::compute_spin(ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const int nghost, - const InputNlist& lmp_list, - const int& ago, - const std::vector& fparam, - const std::vector& aparam_); + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const int nghost, + const InputNlist& lmp_list, + const int& ago, + const std::vector& fparam, + const std::vector& aparam_); template void DeepPot::compute_spin(std::vector& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const int nghost, - const InputNlist& lmp_list, - const int& ago, - const std::vector& fparam, - const std::vector& aparam_); + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const int nghost, + const InputNlist& lmp_list, + const int& ago, + const std::vector& fparam, + const std::vector& aparam_); template void DeepPot::compute_spin(std::vector& dener, - std::vector& dforce_, - std::vector& dforce_mag_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - const std::vector& dspin_, - const std::vector& datype_, - const std::vector& dbox, - const int nghost, - const InputNlist& lmp_list, - const int& ago, - const std::vector& fparam, - const std::vector& aparam_); + std::vector& dforce_, + std::vector& dforce_mag_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + const std::vector& dspin_, + const std::vector& datype_, + const std::vector& dbox, + const int nghost, + const InputNlist& lmp_list, + const int& ago, + const std::vector& fparam, + const std::vector& aparam_); // mixed type template @@ -1147,8 +1147,8 @@ void DeepPotModelDevi::compute_spin( all_virial.resize(numb_models); for (unsigned ii = 0; ii < numb_models; ++ii) { dps[ii].compute_spin(all_energy[ii], all_force[ii], all_force_mag[ii], - all_virial[ii], dcoord_, dspin_, datype_, dbox, nghost, - lmp_list, ago, fparam, aparam_); + all_virial[ii], dcoord_, dspin_, datype_, dbox, nghost, + lmp_list, ago, fparam, aparam_); } } @@ -1272,9 +1272,9 @@ void DeepPotModelDevi::compute_spin( all_atom_virial.resize(numb_models); for (unsigned ii = 0; ii < numb_models; ++ii) { dps[ii].compute_spin(all_energy[ii], all_force[ii], all_force_mag[ii], - all_virial[ii], all_atom_energy[ii], all_atom_virial[ii], - dcoord_, dspin_, datype_, dbox, nghost, lmp_list, ago, - fparam, aparam_); + all_virial[ii], all_atom_energy[ii], + all_atom_virial[ii], dcoord_, dspin_, datype_, dbox, + nghost, lmp_list, ago, fparam, aparam_); } } diff --git a/source/api_cc/tests/test_deeppot_dpa1_pt_spin.cc b/source/api_cc/tests/test_deeppot_dpa1_pt_spin.cc index c2cb01f6a8..4a40dffde2 100644 --- a/source/api_cc/tests/test_deeppot_dpa1_pt_spin.cc +++ b/source/api_cc/tests/test_deeppot_dpa1_pt_spin.cc @@ -157,8 +157,8 @@ TYPED_TEST(TestInferDeepPotDpaPtSpin, cpu_build_nlist_atomic) { deepmd::DeepPot& dp = this->dp; double ener; std::vector force, force_mag, virial, atom_ener, atom_vir; - dp.compute_spin(ener, force, force_mag, virial, atom_ener, atom_vir, coord, spin, - atype, box); + dp.compute_spin(ener, force, force_mag, virial, atom_ener, atom_vir, coord, + spin, atype, box); EXPECT_EQ(force.size(), natoms * 3); EXPECT_EQ(force_mag.size(), natoms * 3); diff --git a/source/lmp/pair_base.cpp b/source/lmp/pair_base.cpp index e98a4f09f5..cd3f49eb73 100644 --- a/source/lmp/pair_base.cpp +++ b/source/lmp/pair_base.cpp @@ -282,7 +282,7 @@ void PairDeepMDBase::cum_sum(std::map &sum, std::map &vec) { } } -PairDeepMDBase::PairDeepMDBase(LAMMPS *lmp, const char* cite_user_package) +PairDeepMDBase::PairDeepMDBase(LAMMPS *lmp, const char *cite_user_package) : Pair(lmp) { @@ -838,10 +838,10 @@ void *PairDeepMDBase::extract(const char *str, int &dim) { } void ana_st(double &max, - double &min, - double &sum, - const vector &vec, - const int &nloc) { + double &min, + double &sum, + const vector &vec, + const int &nloc) { if (nloc == 0) { return; } @@ -860,8 +860,8 @@ void ana_st(double &max, } void make_uniform_aparam(vector &daparam, - const vector &aparam, - const int &nlocal) { + const vector &aparam, + const int &nlocal) { unsigned dim_aparam = aparam.size(); daparam.resize(static_cast(dim_aparam) * nlocal); for (int ii = 0; ii < nlocal; ++ii) { @@ -869,4 +869,4 @@ void make_uniform_aparam(vector &daparam, daparam[ii * dim_aparam + jj] = aparam[jj]; } } -} \ No newline at end of file +} diff --git a/source/lmp/pair_base.h b/source/lmp/pair_base.h index 06c7a071d6..68fc4c1bde 100644 --- a/source/lmp/pair_base.h +++ b/source/lmp/pair_base.h @@ -103,14 +103,13 @@ class PairDeepMDBase : public Pair { } // namespace LAMMPS_NS - void make_uniform_aparam(std::vector &daparam, - const std::vector &aparam, - const int &nlocal); + const std::vector &aparam, + const int &nlocal); void ana_st(double &max, - double &min, - double &sum, - const std::vector &vec, - const int &nloc); + double &min, + double &sum, + const std::vector &vec, + const int &nloc); #endif diff --git a/source/lmp/pair_deepmd.cpp b/source/lmp/pair_deepmd.cpp index b50fed5094..d05e0df626 100644 --- a/source/lmp/pair_deepmd.cpp +++ b/source/lmp/pair_deepmd.cpp @@ -85,13 +85,12 @@ static const char cite_user_deepmd_package[] = "}\n\n"; PairDeepMD::PairDeepMD(LAMMPS *lmp) - : PairDeepMDBase(lmp, cite_user_deepmd_package) -{ + : PairDeepMDBase(lmp, cite_user_deepmd_package) { // Constructor body can be empty } PairDeepMD::~PairDeepMD() { - // Ensure base class destructor is called + // Ensure base class destructor is called } void PairDeepMD::compute(int eflag, int vflag) { @@ -125,7 +124,9 @@ void PairDeepMD::compute(int eflag, int vflag) { double **sp = atom->sp; double **fm = atom->fm; if (atom->sp_flag) { - std::cout << "Pair style 'deepmd' does not support spin atoms, please use pair style 'deepspin' instead." << std::endl; + std::cout << "Pair style 'deepmd' does not support spin atoms, please use " + "pair style 'deepspin' instead." + << std::endl; } vector dtype(nall); @@ -203,12 +204,12 @@ void PairDeepMD::compute(int eflag, int vflag) { if (single_model || multi_models_no_mod_devi) { // cvflag_atom is the right flag for the cvatom matrix if (!(eflag_atom || cvflag_atom)) { - try { - deep_pot.compute(dener, dforce, dvirial, dcoord, dtype, dbox, - nghost, lmp_list, ago, fparam, daparam); - } catch (deepmd_compat::deepmd_exception &e) { - error->one(FLERR, e.what()); - } + try { + deep_pot.compute(dener, dforce, dvirial, dcoord, dtype, dbox, nghost, + lmp_list, ago, fparam, daparam); + } catch (deepmd_compat::deepmd_exception &e) { + error->one(FLERR, e.what()); + } } // do atomic energy and virial else { @@ -216,8 +217,7 @@ void PairDeepMD::compute(int eflag, int vflag) { vector dvatom(nall * 9, 0); try { deep_pot.compute(dener, dforce, dvirial, deatom, dvatom, dcoord, - dtype, dbox, nghost, lmp_list, ago, fparam, - daparam); + dtype, dbox, nghost, lmp_list, ago, fparam, daparam); } catch (deepmd_compat::deepmd_exception &e) { error->one(FLERR, e.what()); } @@ -267,18 +267,18 @@ void PairDeepMD::compute(int eflag, int vflag) { vector> all_atom_virial; if (!(eflag_atom || cvflag_atom)) { try { - deep_pot_model_devi.compute(all_energy, all_force, all_virial, - dcoord, dtype, dbox, nghost, lmp_list, - ago, fparam, daparam); + deep_pot_model_devi.compute(all_energy, all_force, all_virial, dcoord, + dtype, dbox, nghost, lmp_list, ago, + fparam, daparam); } catch (deepmd_compat::deepmd_exception &e) { error->one(FLERR, e.what()); } } else { try { deep_pot_model_devi.compute(all_energy, all_force, all_virial, - all_atom_energy, all_atom_virial, - dcoord, dtype, dbox, nghost, lmp_list, - ago, fparam, daparam); + all_atom_energy, all_atom_virial, dcoord, + dtype, dbox, nghost, lmp_list, ago, + fparam, daparam); } catch (deepmd_compat::deepmd_exception &e) { error->one(FLERR, e.what()); } @@ -404,9 +404,9 @@ void PairDeepMD::compute(int eflag, int vflag) { all_f_min *= force_unit_cvt_factor; all_f_avg *= force_unit_cvt_factor; fp << setw(12) << update->ntimestep << " " << setw(18) << all_v_max - << " " << setw(18) << all_v_min << " " << setw(18) << all_v_avg - << " " << setw(18) << all_f_max << " " << setw(18) << all_f_min - << " " << setw(18) << all_f_avg; + << " " << setw(18) << all_v_min << " " << setw(18) << all_v_avg + << " " << setw(18) << all_f_max << " " << setw(18) << all_f_min + << " " << setw(18) << all_f_avg; } if (out_each == 1) { // need support for spin atomic force. @@ -474,7 +474,6 @@ void PairDeepMD::compute(int eflag, int vflag) { } } - // accumulate energy and virial if (eflag) { eng_vdwl += scale[1][1] * dener * ener_unit_cvt_factor; @@ -497,7 +496,9 @@ int PairDeepMD::pack_reverse_comm(int n, int first, double *buf) { m = 0; last = first + n; if (atom->sp_flag) { - std::cout << "Pair style 'deepmd' does not support spin atoms, please use pair style 'deepspin' instead." << std::endl; + std::cout << "Pair style 'deepmd' does not support spin atoms, please use " + "pair style 'deepspin' instead." + << std::endl; } else { for (i = first; i < last; i++) { for (int dd = 0; dd < numb_models; ++dd) { @@ -517,7 +518,9 @@ void PairDeepMD::unpack_reverse_comm(int n, int *list, double *buf) { m = 0; if (atom->sp_flag) { - std::cout << "Pair style 'deepmd' does not support spin atoms, please use pair style 'deepspin' instead." << std::endl; + std::cout << "Pair style 'deepmd' does not support spin atoms, please use " + "pair style 'deepspin' instead." + << std::endl; } else { for (i = 0; i < n; i++) { j = list[i]; @@ -528,4 +531,4 @@ void PairDeepMD::unpack_reverse_comm(int n, int *list, double *buf) { } } } -} \ No newline at end of file +} diff --git a/source/lmp/pair_deepmd.h b/source/lmp/pair_deepmd.h index cf97322814..5a9024e3d7 100644 --- a/source/lmp/pair_deepmd.h +++ b/source/lmp/pair_deepmd.h @@ -12,12 +12,12 @@ PairStyle(deepmd, PairDeepMD) #ifndef LMP_PAIR_NNP_H #define LMP_PAIR_NNP_H -#include "pair_base.h" #include #include #include #include "comm_brick.h" +#include "pair_base.h" #define FLOAT_PREC double namespace LAMMPS_NS { diff --git a/source/lmp/pair_deepspin.cpp b/source/lmp/pair_deepspin.cpp index 427bfc012e..226b0e029f 100644 --- a/source/lmp/pair_deepspin.cpp +++ b/source/lmp/pair_deepspin.cpp @@ -85,14 +85,12 @@ static const char cite_user_deepmd_package[] = "}\n\n"; PairDeepSpin::PairDeepSpin(LAMMPS *lmp) - : PairDeepMDBase(lmp, cite_user_deepmd_package) -{ + : PairDeepMDBase(lmp, cite_user_deepmd_package) { // Constructor body can be empty } - PairDeepSpin::~PairDeepSpin() { - // Ensure base class destructor is called + // Ensure base class destructor is called } void PairDeepSpin::compute(int eflag, int vflag) { @@ -134,7 +132,9 @@ void PairDeepSpin::compute(int eflag, int vflag) { } } } else { - std::cout << "Pair style 'deepspin' only supports spin atoms, please use pair style 'deepmd' instead." << std::endl; + std::cout << "Pair style 'deepspin' only supports spin atoms, please use " + "pair style 'deepmd' instead." + << std::endl; } vector dtype(nall); @@ -214,8 +214,8 @@ void PairDeepSpin::compute(int eflag, int vflag) { if (!(eflag_atom || cvflag_atom)) { try { deep_pot.compute_spin(dener, dforce, dforce_mag, dvirial, dcoord, - dspin, dtype, dbox, nghost, lmp_list, ago, - fparam, daparam); + dspin, dtype, dbox, nghost, lmp_list, ago, + fparam, daparam); } catch (deepmd_compat::deepmd_exception &e) { error->one(FLERR, e.what()); } @@ -225,9 +225,9 @@ void PairDeepSpin::compute(int eflag, int vflag) { vector deatom(nall * 1, 0); vector dvatom(nall * 9, 0); try { - deep_pot.compute_spin(dener, dforce, dforce_mag, dvirial, deatom, dvatom, - dcoord, dspin, dtype, dbox, nghost, lmp_list, ago, - fparam, daparam); + deep_pot.compute_spin(dener, dforce, dforce_mag, dvirial, deatom, + dvatom, dcoord, dspin, dtype, dbox, nghost, + lmp_list, ago, fparam, daparam); } catch (deepmd_compat::deepmd_exception &e) { error->one(FLERR, e.what()); } @@ -277,18 +277,18 @@ void PairDeepSpin::compute(int eflag, int vflag) { vector> all_atom_virial; if (!(eflag_atom || cvflag_atom)) { try { - deep_pot_model_devi.compute_spin(all_energy, all_force, all_force_mag, - all_virial, dcoord, dspin, dtype, dbox, - nghost, lmp_list, ago, fparam, daparam); + deep_pot_model_devi.compute_spin( + all_energy, all_force, all_force_mag, all_virial, dcoord, dspin, + dtype, dbox, nghost, lmp_list, ago, fparam, daparam); } catch (deepmd_compat::deepmd_exception &e) { error->one(FLERR, e.what()); } } else { try { deep_pot_model_devi.compute_spin( - all_energy, all_force, all_force_mag, all_virial, - all_atom_energy, all_atom_virial, dcoord, dspin, dtype, dbox, - nghost, lmp_list, ago, fparam, daparam); + all_energy, all_force, all_force_mag, all_virial, all_atom_energy, + all_atom_virial, dcoord, dspin, dtype, dbox, nghost, lmp_list, + ago, fparam, daparam); } catch (deepmd_compat::deepmd_exception &e) { error->one(FLERR, e.what()); } @@ -429,11 +429,10 @@ void PairDeepSpin::compute(int eflag, int vflag) { all_fm_min *= force_unit_cvt_factor; all_fm_avg *= force_unit_cvt_factor; fp << setw(12) << update->ntimestep << " " << setw(18) << all_v_max - << " " << setw(18) << all_v_min << " " << setw(18) << all_v_avg - << " " << setw(18) << all_f_max << " " << setw(18) << all_f_min - << " " << setw(18) << all_f_avg << " " << setw(18) << all_fm_max - << " " << setw(18) << all_fm_min << " " << setw(18) - << all_fm_avg; + << " " << setw(18) << all_v_min << " " << setw(18) << all_v_avg + << " " << setw(18) << all_f_max << " " << setw(18) << all_f_min + << " " << setw(18) << all_f_avg << " " << setw(18) << all_fm_max + << " " << setw(18) << all_fm_min << " " << setw(18) << all_fm_avg; } if (out_each == 1) { // need support for spin atomic force. @@ -485,8 +484,8 @@ void PairDeepSpin::compute(int eflag, int vflag) { } else { if (numb_models == 1) { try { - deep_pot.compute_spin(dener, dforce, dforce_mag, dvirial, dcoord, - dspin, dtype, dbox); + deep_pot.compute_spin(dener, dforce, dforce_mag, dvirial, dcoord, dspin, + dtype, dbox); } catch (deepmd_compat::deepmd_exception &e) { error->one(FLERR, e.what()); } @@ -501,8 +500,8 @@ void PairDeepSpin::compute(int eflag, int vflag) { for (int ii = 0; ii < nall; ++ii) { for (int dd = 0; dd < 3; ++dd) { f[ii][dd] += scale[1][1] * dforce[3 * ii + dd] * force_unit_cvt_factor; - fm[ii][dd] += scale[1][1] * dforce_mag[3 * ii + dd] / - (hbar / sp[ii][3]) * force_unit_cvt_factor; + fm[ii][dd] += scale[1][1] * dforce_mag[3 * ii + dd] / (hbar / sp[ii][3]) * + force_unit_cvt_factor; } } @@ -532,7 +531,9 @@ int PairDeepSpin::pack_reverse_comm(int n, int first, double *buf) { m = 0; last = first + n; if (!atom->sp_flag) { - std::cout << "Pair style 'deepspin' only supports spin atoms, please use pair style 'deepmd' instead." << std::endl; + std::cout << "Pair style 'deepspin' only supports spin atoms, please use " + "pair style 'deepmd' instead." + << std::endl; } else { for (i = first; i < last; i++) { for (int dd = 0; dd < numb_models; ++dd) { @@ -555,7 +556,9 @@ void PairDeepSpin::unpack_reverse_comm(int n, int *list, double *buf) { m = 0; if (!atom->sp_flag) { - std::cout << "Pair style 'deepspin' only supports spin atoms, please use pair style 'deepmd' instead." << std::endl; + std::cout << "Pair style 'deepspin' only supports spin atoms, please use " + "pair style 'deepmd' instead." + << std::endl; } else { for (i = 0; i < n; i++) { j = list[i]; @@ -569,4 +572,4 @@ void PairDeepSpin::unpack_reverse_comm(int n, int *list, double *buf) { } } } -} \ No newline at end of file +} diff --git a/source/lmp/pair_deepspin.h b/source/lmp/pair_deepspin.h index c7a29e46e5..125caa1b9a 100644 --- a/source/lmp/pair_deepspin.h +++ b/source/lmp/pair_deepspin.h @@ -12,12 +12,12 @@ PairStyle(deepspin, PairDeepSpin) #ifndef LMP_PAIR_NNP_SPIN_H #define LMP_PAIR_NNP_SPIN_H -#include "pair_base.h" #include #include #include #include "comm_brick.h" +#include "pair_base.h" #define FLOAT_PREC double namespace LAMMPS_NS { @@ -31,7 +31,7 @@ class PairDeepSpin : public PairDeepMDBase { void compute(int, int) override; int pack_reverse_comm(int, int, double *) override; void unpack_reverse_comm(int, int *, double *) override; - + private: CommBrickDeepSpin *commdata_; };