diff --git a/source/api_cc/include/DataModifierTF.h b/source/api_cc/include/DataModifierTF.h index 5c44322c0c..2ca3729525 100644 --- a/source/api_cc/include/DataModifierTF.h +++ b/source/api_cc/include/DataModifierTF.h @@ -34,7 +34,7 @@ class DipoleChargeModifierTF : public DipoleChargeModifierBase { const int& gpu_rank = 0, const std::string& name_scope = ""); - public: + private: /** * @brief Evaluate the force and virial correction by using this dipole charge *modifier. @@ -61,6 +61,8 @@ class DipoleChargeModifierTF : public DipoleChargeModifierBase { const std::vector& delef_, const int nghost, const InputNlist& lmp_list); + + public: /** * @brief Get cutoff radius. * @return double cutoff radius. diff --git a/source/api_cc/include/DeepPot.h b/source/api_cc/include/DeepPot.h index e8e64e31c0..a8aedde510 100644 --- a/source/api_cc/include/DeepPot.h +++ b/source/api_cc/include/DeepPot.h @@ -38,141 +38,11 @@ class DeepPotBase { const int& gpu_rank = 0, const std::string& file_content = "") = 0; - /** - * @brief Evaluate the energy, force and virial by using this DP. - * @param[out] ener The system energy. - * @param[out] force The force on each atom. - * @param[out] virial The virial. - * @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. - * @{ - **/ - virtual void computew( - double& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()) = 0; - - virtual void computew( - double& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()) = 0; - virtual void computew( - std::vector& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()) = 0; - virtual void computew( - std::vector& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()) = 0; - /** @} */ - /** - * @brief Evaluate the energy, force and virial by using this DP. - * @param[out] ener The system energy. - * @param[out] force The force on each atom. - * @param[out] virial The virial. - * @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] nghost The number of ghost atoms. - * @param[in] inlist The input neighbour list. - * @param[in] ago Update the internal neighbour list if ago is 0. - * @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. - * @{ - **/ - virtual void computew( - double& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - 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()) = 0; - - virtual void computew( - double& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - 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()) = 0; - virtual void computew( - std::vector& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - 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()) = 0; - virtual void computew( - std::vector& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - 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()) = 0; - /** @} */ - /** * @brief Evaluate the energy, force, virial, atomic energy, and atomic virial *by using this DP. + * @note The double precision interface is used by i-PI, GROMACS, ABACUS, and + *CP2k. * @param[out] ener The system energy. * @param[out] force The force on each atom. * @param[out] virial The virial. @@ -193,29 +63,6 @@ class DeepPotBase { *same aparam. * @{ **/ - virtual void computew( - double& ener, - std::vector& force, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()) = 0; - - virtual void computew( - double& ener, - std::vector& force, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()) = 0; virtual void computew( std::vector& ener, std::vector& force, @@ -242,6 +89,7 @@ class DeepPotBase { /** * @brief Evaluate the energy, force, virial, atomic energy, and atomic virial *by using this DP. + * @note The double precision interface is used by LAMMPS and AMBER. * @param[out] ener The system energy. * @param[out] force The force on each atom. * @param[out] virial The virial. @@ -265,35 +113,6 @@ class DeepPotBase { *same aparam. * @{ **/ - virtual void computew( - double& ener, - std::vector& force, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const std::vector& coord, - 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()) = 0; - - virtual void computew( - double& ener, - std::vector& force, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const std::vector& coord, - 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()) = 0; virtual void computew( std::vector& ener, std::vector& force, @@ -323,73 +142,11 @@ class DeepPotBase { const std::vector& fparam = std::vector(), const std::vector& aparam = std::vector()) = 0; /** @} */ + /** * @brief Evaluate the energy, force, and virial with the mixed type *by using this DP. - * @param[out] ener The system energy. - * @param[out] force The force on each atom. - * @param[out] virial The virial. - * @param[in] nframes The number of frames. - * @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 array should be of size nframes x - *natoms. - * @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. - * @{ - **/ - virtual void computew_mixed_type( - double& ener, - std::vector& force, - std::vector& virial, - const int& nframes, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()) = 0; - virtual void computew_mixed_type( - double& ener, - std::vector& force, - std::vector& virial, - const int& nframes, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()) = 0; - virtual void computew_mixed_type( - std::vector& ener, - std::vector& force, - std::vector& virial, - const int& nframes, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()) = 0; - virtual void computew_mixed_type( - std::vector& ener, - std::vector& force, - std::vector& virial, - const int& nframes, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()) = 0; - /** @} */ - /** - * @brief Evaluate the energy, force, and virial with the mixed type - *by using this DP. + * @note At this time, no external program uses this interface. * @param[out] ener The system energy. * @param[out] force The force on each atom. * @param[out] virial The virial. @@ -412,30 +169,6 @@ class DeepPotBase { *same aparam. * @{ **/ - virtual void computew_mixed_type( - double& ener, - std::vector& force, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const int& nframes, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()) = 0; - virtual void computew_mixed_type( - double& ener, - std::vector& force, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const int& nframes, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()) = 0; virtual void computew_mixed_type( std::vector& ener, std::vector& force, @@ -554,9 +287,19 @@ class DeepPot { * nframes x natoms x dim_aparam. * natoms x dim_aparam. Then all frames are assumed to be provided with the *same aparam. + * @{ **/ - template - void compute(ENERGYVTYPE& ener, + template + void compute(ENERGYTYPE& ener, + std::vector& force, + std::vector& virial, + const std::vector& coord, + const std::vector& atype, + const std::vector& box, + const std::vector& fparam = std::vector(), + const std::vector& aparam = std::vector()); + template + void compute(std::vector& ener, std::vector& force, std::vector& virial, const std::vector& coord, @@ -564,6 +307,7 @@ class DeepPot { const std::vector& box, const std::vector& fparam = std::vector(), const std::vector& aparam = std::vector()); + /** @} */ /** * @brief Evaluate the energy, force and virial by using this DP. * @param[out] ener The system energy. @@ -585,9 +329,10 @@ class DeepPot { * nframes x natoms x dim_aparam. * natoms x dim_aparam. Then all frames are assumed to be provided with the *same aparam. + * @{ **/ - template - void compute(ENERGYVTYPE& ener, + template + void compute(ENERGYTYPE& ener, std::vector& force, std::vector& virial, const std::vector& coord, @@ -598,6 +343,19 @@ class DeepPot { const int& ago, const std::vector& fparam = std::vector(), const std::vector& aparam = std::vector()); + template + void compute(std::vector& ener, + std::vector& force, + std::vector& virial, + const std::vector& coord, + 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 *by using this DP. @@ -619,9 +377,10 @@ class DeepPot { * nframes x natoms x dim_aparam. * natoms x dim_aparam. Then all frames are assumed to be provided with the *same aparam. + * @{ **/ - template - void compute(ENERGYVTYPE& ener, + template + void compute(ENERGYTYPE& ener, std::vector& force, std::vector& virial, std::vector& atom_energy, @@ -631,6 +390,19 @@ class DeepPot { const std::vector& box, const std::vector& fparam = std::vector(), const std::vector& aparam = std::vector()); + template + void compute(std::vector& ener, + std::vector& force, + std::vector& virial, + std::vector& atom_energy, + std::vector& atom_virial, + const std::vector& coord, + const std::vector& atype, + const std::vector& box, + 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 this DP. @@ -655,9 +427,24 @@ class DeepPot { * nframes x natoms x dim_aparam. * natoms x dim_aparam. Then all frames are assumed to be provided with the *same aparam. + * @{ **/ - template - void compute(ENERGYVTYPE& ener, + template + void compute(ENERGYTYPE& ener, + std::vector& force, + std::vector& virial, + std::vector& atom_energy, + std::vector& atom_virial, + const std::vector& coord, + 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(std::vector& ener, std::vector& force, std::vector& virial, std::vector& atom_energy, @@ -670,6 +457,7 @@ class DeepPot { 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 *by using this DP. @@ -691,10 +479,11 @@ class DeepPot { * nframes x natoms x dim_aparam. * natoms x dim_aparam. Then all frames are assumed to be provided with the *same aparam. + * @{ **/ - template + template void compute_mixed_type( - ENERGYVTYPE& ener, + ENERGYTYPE& ener, std::vector& force, std::vector& virial, const int& nframes, @@ -703,6 +492,18 @@ class DeepPot { const std::vector& box, const std::vector& fparam = std::vector(), const std::vector& aparam = std::vector()); + template + void compute_mixed_type( + std::vector& ener, + std::vector& force, + std::vector& virial, + const int& nframes, + const std::vector& coord, + const std::vector& atype, + const std::vector& box, + const std::vector& fparam = std::vector(), + const std::vector& aparam = std::vector()); + /** @} */ /** * @brief Evaluate the energy, force, and virial with the mixed type *by using this DP. @@ -726,10 +527,11 @@ class DeepPot { * nframes x natoms x dim_aparam. * natoms x dim_aparam. Then all frames are assumed to be provided with the *same aparam. + * @{ **/ - template + template void compute_mixed_type( - ENERGYVTYPE& ener, + ENERGYTYPE& ener, std::vector& force, std::vector& virial, std::vector& atom_energy, @@ -740,6 +542,20 @@ class DeepPot { const std::vector& box, const std::vector& fparam = std::vector(), const std::vector& aparam = std::vector()); + template + void compute_mixed_type( + std::vector& ener, + std::vector& force, + std::vector& virial, + std::vector& atom_energy, + std::vector& atom_virial, + const int& nframes, + const std::vector& coord, + const std::vector& atype, + const std::vector& box, + 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/include/DeepPotTF.h b/source/api_cc/include/DeepPotTF.h index 59bd5f476f..0580c61da5 100644 --- a/source/api_cc/include/DeepPotTF.h +++ b/source/api_cc/include/DeepPotTF.h @@ -37,68 +37,7 @@ class DeepPotTF : public DeepPotBase { const int& gpu_rank = 0, const std::string& file_content = ""); - /** - * @brief Evaluate the energy, force and virial by using this DP. - * @param[out] ener The system energy. - * @param[out] force The force on each atom. - * @param[out] virial The virial. - * @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. - **/ - template - void compute(ENERGYVTYPE& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); - /** - * @brief Evaluate the energy, force and virial by using this DP. - * @param[out] ener The system energy. - * @param[out] force The force on each atom. - * @param[out] virial The virial. - * @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] nghost The number of ghost atoms. - * @param[in] inlist The input neighbour list. - * @param[in] ago Update the internal neighbour list if ago is 0. - * @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. - **/ - template - void compute(ENERGYVTYPE& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - 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()); + private: /** * @brief Evaluate the energy, force, virial, atomic energy, and atomic virial *by using this DP. @@ -241,6 +180,8 @@ class DeepPotTF : public DeepPotBase { const std::vector& box, const std::vector& fparam = std::vector(), const std::vector& aparam = std::vector()); + + public: /** * @brief Get the cutoff radius. * @return The cutoff radius. @@ -298,85 +239,7 @@ class DeepPotTF : public DeepPotBase { }; // forward to template class - void computew(double& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); - - void computew(double& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); - void computew(std::vector& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); - void computew(std::vector& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); - void computew(double& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - 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 computew(double& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - 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 computew(std::vector& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - 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 computew(std::vector& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - 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 computew(double& ener, std::vector& force, std::vector& virial, std::vector& atom_energy, @@ -386,52 +249,7 @@ class DeepPotTF : public DeepPotBase { const std::vector& box, const std::vector& fparam = std::vector(), const std::vector& aparam = std::vector()); - - void computew(double& ener, - std::vector& force, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); void computew(std::vector& ener, - std::vector& force, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); - void computew(std::vector& ener, - std::vector& force, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); - void computew(double& ener, - std::vector& force, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const std::vector& coord, - 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 computew(double& ener, std::vector& force, std::vector& virial, std::vector& atom_energy, @@ -439,9 +257,6 @@ class DeepPotTF : public DeepPotBase { const std::vector& coord, 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 computew(std::vector& ener, @@ -470,70 +285,6 @@ class DeepPotTF : public DeepPotBase { const int& ago, const std::vector& fparam = std::vector(), const std::vector& aparam = std::vector()); - void computew_mixed_type( - double& ener, - std::vector& force, - std::vector& virial, - const int& nframes, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); - void computew_mixed_type( - double& ener, - std::vector& force, - std::vector& virial, - const int& nframes, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); - void computew_mixed_type( - std::vector& ener, - std::vector& force, - std::vector& virial, - const int& nframes, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); - void computew_mixed_type( - std::vector& ener, - std::vector& force, - std::vector& virial, - const int& nframes, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); - void computew_mixed_type( - double& ener, - std::vector& force, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const int& nframes, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); - void computew_mixed_type( - double& ener, - std::vector& force, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const int& nframes, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); void computew_mixed_type( std::vector& ener, std::vector& force, @@ -604,19 +355,6 @@ class DeepPotTF : public DeepPotBase { const int& nframes, const int& dparam, const std::vector& param) const; - template - void compute_inner( - ENERGYVTYPE& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const int nghost, - const int& ago, - const std::vector& fparam = std::vector(), - const std::vector& aparam = std::vector()); - // copy neighbor list info from host bool init_nbor; std::vector sec_a; diff --git a/source/api_cc/include/DeepTensor.h b/source/api_cc/include/DeepTensor.h index 6150eca970..5592942d87 100644 --- a/source/api_cc/include/DeepTensor.h +++ b/source/api_cc/include/DeepTensor.h @@ -35,49 +35,6 @@ class DeepTensorBase { virtual void init(const std::string& model, const int& gpu_rank = 0, const std::string& name_scope = "") = 0; - - /** - * @brief Evaluate the value by using this model. - * @param[out] value The value to evalute, usually would be the atomic tensor. - * @param[in] coord The coordinates of atoms. The array should be of size - *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 9. - * @{ - **/ - virtual void computew(std::vector& value, - const std::vector& coord, - const std::vector& atype, - const std::vector& box) = 0; - virtual void computew(std::vector& value, - const std::vector& coord, - const std::vector& atype, - const std::vector& box) = 0; - /** @} */ - /** - * @brief Evaluate the value by using this model. - * @param[out] value The value to evalute, usually would be the atomic tensor. - * @param[in] coord The coordinates of atoms. The array should be of size - *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 9. - * @param[in] nghost The number of ghost atoms. - * @param[in] inlist The input neighbour list. - * @{ - **/ - virtual void computew(std::vector& value, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const int nghost, - const InputNlist& inlist) = 0; - virtual void computew(std::vector& value, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const int nghost, - const InputNlist& inlist) = 0; - /** @} */ /** * @brief Evaluate the global tensor and component-wise force and virial. * @param[out] global_tensor The global tensor to evalute. @@ -93,6 +50,8 @@ class DeepTensorBase { *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 9. + * @param[in] request_deriv Whether to request the derivative of the global + * tensor, including force and virial. * @{ **/ virtual void computew(std::vector& global_tensor, @@ -102,7 +61,8 @@ class DeepTensorBase { std::vector& atom_virial, const std::vector& coord, const std::vector& atype, - const std::vector& box) = 0; + const std::vector& box, + const bool request_deriv) = 0; virtual void computew(std::vector& global_tensor, std::vector& force, std::vector& virial, @@ -110,7 +70,8 @@ class DeepTensorBase { std::vector& atom_virial, const std::vector& coord, const std::vector& atype, - const std::vector& box) = 0; + const std::vector& box, + const bool request_deriv) = 0; /** @} */ /** * @brief Evaluate the global tensor and component-wise force and virial. @@ -129,6 +90,8 @@ class DeepTensorBase { * @param[in] box The cell of the region. The array should be of size 9. * @param[in] nghost The number of ghost atoms. * @param[in] inlist The input neighbour list. + * @param[in] request_deriv Whether to request the derivative of the global + * tensor, including force and virial. * @{ **/ virtual void computew(std::vector& global_tensor, @@ -140,7 +103,8 @@ class DeepTensorBase { const std::vector& atype, const std::vector& box, const int nghost, - const InputNlist& inlist) = 0; + const InputNlist& inlist, + const bool request_deriv) = 0; virtual void computew(std::vector& global_tensor, std::vector& force, std::vector& virial, @@ -150,7 +114,8 @@ class DeepTensorBase { const std::vector& atype, const std::vector& box, const int nghost, - const InputNlist& inlist) = 0; + const InputNlist& inlist, + const bool request_deriv) = 0; /** @} */ /** * @brief Get the cutoff radius. diff --git a/source/api_cc/include/DeepTensorTF.h b/source/api_cc/include/DeepTensorTF.h index 2ba7697076..3c724dce88 100644 --- a/source/api_cc/include/DeepTensorTF.h +++ b/source/api_cc/include/DeepTensorTF.h @@ -34,12 +34,8 @@ class DeepTensorTF : public DeepTensorBase { void init(const std::string& model, const int& gpu_rank = 0, const std::string& name_scope = ""); - /** - * @brief Print the DP summary to the screen. - * @param[in] pre The prefix to each line. - **/ - void print_summary(const std::string& pre) const; + private: /** * @brief Evaluate the value by using this model. * @param[out] value The value to evalute, usually would be the atomic tensor. @@ -70,48 +66,6 @@ class DeepTensorTF : public DeepTensorBase { const std::vector& box, const int nghost, const InputNlist& inlist); - /** - * @brief Evaluate the global tensor and component-wise force and virial. - * @param[out] global_tensor The global tensor to evalute. - * @param[out] force The component-wise force of the global tensor, size odim - *x natoms x 3. - * @param[out] virial The component-wise virial of the global tensor, size - *odim x 9. - * @param[in] coord The coordinates of atoms. The array should be of size - *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 9. - **/ - template - void compute(std::vector& global_tensor, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box); - /** - * @brief Evaluate the global tensor and component-wise force and virial. - * @param[out] global_tensor The global tensor to evalute. - * @param[out] force The component-wise force of the global tensor, size odim - *x natoms x 3. - * @param[out] virial The component-wise virial of the global tensor, size - *odim x 9. - * @param[in] coord The coordinates of atoms. The array should be of size - *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 9. - * @param[in] nghost The number of ghost atoms. - * @param[in] inlist The input neighbour list. - **/ - template - void compute(std::vector& global_tensor, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const int nghost, - const InputNlist& inlist); /** * @brief Evaluate the global tensor and component-wise force and virial. * @param[out] global_tensor The global tensor to evalute. @@ -166,6 +120,8 @@ class DeepTensorTF : public DeepTensorBase { const std::vector& box, const int nghost, const InputNlist& inlist); + + public: /** * @brief Get the cutoff radius. * @return The cutoff radius. @@ -204,48 +160,6 @@ class DeepTensorTF : public DeepTensorBase { **/ void get_type_map(std::string& type_map); - /** - * @brief Evaluate the value by using this model. - * @param[out] value The value to evalute, usually would be the atomic tensor. - * @param[in] coord The coordinates of atoms. The array should be of size - *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 9. - * @{ - **/ - void computew(std::vector& value, - const std::vector& coord, - const std::vector& atype, - const std::vector& box); - void computew(std::vector& value, - const std::vector& coord, - const std::vector& atype, - const std::vector& box); - /** @} */ - /** - * @brief Evaluate the value by using this model. - * @param[out] value The value to evalute, usually would be the atomic tensor. - * @param[in] coord The coordinates of atoms. The array should be of size - *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 9. - * @param[in] nghost The number of ghost atoms. - * @param[in] inlist The input neighbour list. - * @{ - **/ - void computew(std::vector& value, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const int nghost, - const InputNlist& inlist); - void computew(std::vector& value, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const int nghost, - const InputNlist& inlist); - /** @} */ /** * @brief Evaluate the global tensor and component-wise force and virial. * @param[out] global_tensor The global tensor to evalute. @@ -261,6 +175,8 @@ class DeepTensorTF : public DeepTensorBase { *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 9. + * @param[in] request_deriv Whether to request the derivative of the global + * tensor, including force and virial. * @{ **/ void computew(std::vector& global_tensor, @@ -270,7 +186,8 @@ class DeepTensorTF : public DeepTensorBase { std::vector& atom_virial, const std::vector& coord, const std::vector& atype, - const std::vector& box); + const std::vector& box, + const bool request_deriv); void computew(std::vector& global_tensor, std::vector& force, std::vector& virial, @@ -278,7 +195,8 @@ class DeepTensorTF : public DeepTensorBase { std::vector& atom_virial, const std::vector& coord, const std::vector& atype, - const std::vector& box); + const std::vector& box, + const bool request_deriv); /** @} */ /** * @brief Evaluate the global tensor and component-wise force and virial. @@ -297,6 +215,8 @@ class DeepTensorTF : public DeepTensorBase { * @param[in] box The cell of the region. The array should be of size 9. * @param[in] nghost The number of ghost atoms. * @param[in] inlist The input neighbour list. + * @param[in] request_deriv Whether to request the derivative of the global + * tensor, including force and virial. * @{ **/ void computew(std::vector& global_tensor, @@ -308,7 +228,8 @@ class DeepTensorTF : public DeepTensorBase { const std::vector& atype, const std::vector& box, const int nghost, - const InputNlist& inlist); + const InputNlist& inlist, + const bool request_deriv); void computew(std::vector& global_tensor, std::vector& force, std::vector& virial, @@ -318,7 +239,8 @@ class DeepTensorTF : public DeepTensorBase { const std::vector& atype, const std::vector& box, const int nghost, - const InputNlist& inlist); + const InputNlist& inlist, + const bool request_deriv); /** @} */ private: diff --git a/source/api_cc/src/DeepPot.cc b/source/api_cc/src/DeepPot.cc index d290565c2b..feb0f283b1 100644 --- a/source/api_cc/src/DeepPot.cc +++ b/source/api_cc/src/DeepPot.cc @@ -51,8 +51,8 @@ void DeepPot::print_summary(const std::string& pre) const { deepmd::print_summary(pre); } -template -void DeepPot::compute(ENERGYVTYPE& dener, +template +void DeepPot::compute(ENERGYTYPE& dener, std::vector& dforce_, std::vector& dvirial, const std::vector& dcoord_, @@ -60,52 +60,65 @@ void DeepPot::compute(ENERGYVTYPE& dener, const std::vector& dbox, const std::vector& fparam_, const std::vector& aparam_) { - dp->computew(dener, dforce_, dvirial, dcoord_, datype_, dbox, fparam_, - aparam_); + std::vector dener_; + std::vector datom_energy_, datom_virial_; + dp->computew(dener_, dforce_, dvirial, datom_energy_, datom_virial_, dcoord_, + datype_, dbox, fparam_, aparam_); + dener = dener_[0]; } -template void DeepPot::compute( - ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); - -template void DeepPot::compute( - ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); - -template void DeepPot::compute>( - std::vector& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); +template +void DeepPot::compute(std::vector& dener, + std::vector& dforce_, + std::vector& dvirial, + const std::vector& dcoord_, + 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_, dvirial, datom_energy_, datom_virial_, dcoord_, + datype_, dbox, fparam_, aparam_); +} -template void DeepPot::compute>( - std::vector& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); +template void DeepPot::compute(ENERGYTYPE& dener, + std::vector& dforce_, + std::vector& dvirial, + const std::vector& dcoord_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam, + const std::vector& aparam); + +template void DeepPot::compute(ENERGYTYPE& dener, + std::vector& dforce_, + std::vector& dvirial, + const std::vector& dcoord_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam, + const std::vector& aparam); + +template void DeepPot::compute(std::vector& dener, + std::vector& dforce_, + std::vector& dvirial, + const std::vector& dcoord_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam, + const std::vector& aparam); + +template void DeepPot::compute(std::vector& dener, + std::vector& dforce_, + std::vector& dvirial, + const std::vector& dcoord_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam, + const std::vector& aparam); -template -void DeepPot::compute(ENERGYVTYPE& dener, +template +void DeepPot::compute(ENERGYTYPE& dener, std::vector& dforce_, std::vector& dvirial, const std::vector& dcoord_, @@ -116,64 +129,96 @@ void DeepPot::compute(ENERGYVTYPE& dener, const int& ago, const std::vector& fparam_, const std::vector& aparam__) { - dp->computew(dener, dforce_, dvirial, dcoord_, datype_, dbox, nghost, - lmp_list, ago, fparam_, aparam__); + std::vector dener_; + std::vector datom_energy_, datom_virial_; + dp->computew(dener_, dforce_, dvirial, datom_energy_, datom_virial_, dcoord_, + datype_, dbox, nghost, lmp_list, ago, fparam_, aparam__); + dener = dener_[0]; } -template void DeepPot::compute( - ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - 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, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - 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(std::vector& dener, + std::vector& dforce_, + std::vector& dvirial, + const std::vector& dcoord_, + 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_, dvirial, datom_energy_, datom_virial_, dcoord_, + datype_, dbox, nghost, lmp_list, ago, fparam_, aparam__); +} -template void DeepPot::compute>( - std::vector& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - 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, + std::vector& dforce_, + std::vector& dvirial, + const std::vector& dcoord_, + 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, + std::vector& dforce_, + std::vector& dvirial, + const std::vector& dcoord_, + 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(std::vector& dener, + std::vector& dforce_, + std::vector& dvirial, + const std::vector& dcoord_, + 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(std::vector& dener, + std::vector& dforce_, + std::vector& dvirial, + const std::vector& dcoord_, + 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>( - std::vector& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - 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(ENERGYVTYPE& dener, +template +void DeepPot::compute(ENERGYTYPE& dener, + std::vector& dforce_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam_, + const std::vector& aparam_) { + std::vector dener_; + dp->computew(dener_, dforce_, dvirial, datom_energy_, datom_virial_, dcoord_, + datype_, dbox, fparam_, aparam_); + dener = dener_[0]; +} +template +void DeepPot::compute(std::vector& dener, std::vector& dforce_, std::vector& dvirial, std::vector& datom_energy_, @@ -187,56 +232,71 @@ void DeepPot::compute(ENERGYVTYPE& dener, datype_, dbox, fparam_, aparam_); } -template void DeepPot::compute( - ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); - -template void DeepPot::compute( - ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); - -template void DeepPot::compute>( - std::vector& dener, - std::vector& dforce_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); - -template void DeepPot::compute>( - std::vector& dener, - std::vector& dforce_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); +template void DeepPot::compute(ENERGYTYPE& dener, + std::vector& dforce_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam, + const std::vector& aparam); + +template void DeepPot::compute(ENERGYTYPE& dener, + std::vector& dforce_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam, + const std::vector& aparam); + +template void DeepPot::compute(std::vector& dener, + std::vector& dforce_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam, + const std::vector& aparam); + +template void DeepPot::compute(std::vector& dener, + std::vector& dforce_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam, + const std::vector& aparam); -template -void DeepPot::compute(ENERGYVTYPE& dener, +template +void DeepPot::compute(ENERGYTYPE& dener, + std::vector& dforce_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + 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_, dvirial, datom_energy_, datom_virial_, dcoord_, + datype_, dbox, nghost, lmp_list, ago, fparam_, aparam__); + dener = dener_[0]; +} +template +void DeepPot::compute(std::vector& dener, std::vector& dforce_, std::vector& dvirial, std::vector& datom_energy_, @@ -253,69 +313,65 @@ void DeepPot::compute(ENERGYVTYPE& dener, datype_, dbox, nghost, lmp_list, ago, fparam_, aparam__); } -template void DeepPot::compute( - ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - 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, - std::vector& dforce_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - 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>( - std::vector& dener, - std::vector& dforce_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - 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>( - std::vector& dener, - std::vector& dforce_, - std::vector& dvirial, - std::vector& datom_energy_, - std::vector& datom_virial_, - const std::vector& dcoord_, - 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, + std::vector& dforce_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + 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, + std::vector& dforce_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + 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(std::vector& dener, + std::vector& dforce_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + 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(std::vector& dener, + std::vector& dforce_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const std::vector& dcoord_, + 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 -void DeepPot::compute_mixed_type(ENERGYVTYPE& dener, +template +void DeepPot::compute_mixed_type(ENERGYTYPE& dener, std::vector& dforce_, std::vector& dvirial, const int& nframes, @@ -324,11 +380,29 @@ void DeepPot::compute_mixed_type(ENERGYVTYPE& dener, const std::vector& dbox, const std::vector& fparam_, const std::vector& aparam_) { - dp->computew_mixed_type(dener, dforce_, dvirial, nframes, dcoord_, datype_, - dbox, fparam_, aparam_); + std::vector dener_; + std::vector datom_energy_, datom_virial_; + dp->computew_mixed_type(dener_, dforce_, dvirial, datom_energy_, + datom_virial_, nframes, dcoord_, datype_, dbox, + fparam_, aparam_); + dener = dener_[0]; +} +template +void DeepPot::compute_mixed_type(std::vector& dener, + std::vector& dforce_, + std::vector& dvirial, + const int& nframes, + const std::vector& dcoord_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam_, + const std::vector& aparam_) { + std::vector datom_energy_, datom_virial_; + dp->computew_mixed_type(dener, dforce_, dvirial, datom_energy_, datom_virial_, + nframes, dcoord_, datype_, dbox, fparam_, aparam_); } -template void DeepPot::compute_mixed_type( +template void DeepPot::compute_mixed_type( ENERGYTYPE& dener, std::vector& dforce_, std::vector& dvirial, @@ -339,7 +413,7 @@ template void DeepPot::compute_mixed_type( const std::vector& fparam, const std::vector& aparam); -template void DeepPot::compute_mixed_type( +template void DeepPot::compute_mixed_type( ENERGYTYPE& dener, std::vector& dforce_, std::vector& dvirial, @@ -350,7 +424,7 @@ template void DeepPot::compute_mixed_type( const std::vector& fparam, const std::vector& aparam); -template void DeepPot::compute_mixed_type>( +template void DeepPot::compute_mixed_type( std::vector& dener, std::vector& dforce_, std::vector& dvirial, @@ -361,7 +435,7 @@ template void DeepPot::compute_mixed_type>( const std::vector& fparam, const std::vector& aparam); -template void DeepPot::compute_mixed_type>( +template void DeepPot::compute_mixed_type( std::vector& dener, std::vector& dforce_, std::vector& dvirial, @@ -372,8 +446,26 @@ template void DeepPot::compute_mixed_type>( const std::vector& fparam, const std::vector& aparam); -template -void DeepPot::compute_mixed_type(ENERGYVTYPE& dener, +template +void DeepPot::compute_mixed_type(ENERGYTYPE& dener, + std::vector& dforce_, + std::vector& dvirial, + std::vector& datom_energy_, + std::vector& datom_virial_, + const int& nframes, + const std::vector& dcoord_, + const std::vector& datype_, + const std::vector& dbox, + const std::vector& fparam_, + const std::vector& aparam_) { + std::vector dener_; + dp->computew_mixed_type(dener_, dforce_, dvirial, datom_energy_, + datom_virial_, nframes, dcoord_, datype_, dbox, + fparam_, aparam_); + dener = dener_[0]; +} +template +void DeepPot::compute_mixed_type(std::vector& dener, std::vector& dforce_, std::vector& dvirial, std::vector& datom_energy_, @@ -388,7 +480,7 @@ void DeepPot::compute_mixed_type(ENERGYVTYPE& dener, nframes, dcoord_, datype_, dbox, fparam_, aparam_); } -template void DeepPot::compute_mixed_type( +template void DeepPot::compute_mixed_type( ENERGYTYPE& dener, std::vector& dforce_, std::vector& dvirial, @@ -401,7 +493,7 @@ template void DeepPot::compute_mixed_type( const std::vector& fparam, const std::vector& aparam); -template void DeepPot::compute_mixed_type( +template void DeepPot::compute_mixed_type( ENERGYTYPE& dener, std::vector& dforce_, std::vector& dvirial, @@ -414,7 +506,7 @@ template void DeepPot::compute_mixed_type( const std::vector& fparam, const std::vector& aparam); -template void DeepPot::compute_mixed_type>( +template void DeepPot::compute_mixed_type( std::vector& dener, std::vector& dforce_, std::vector& dvirial, @@ -427,7 +519,7 @@ template void DeepPot::compute_mixed_type>( const std::vector& fparam, const std::vector& aparam); -template void DeepPot::compute_mixed_type>( +template void DeepPot::compute_mixed_type( std::vector& dener, std::vector& dforce_, std::vector& dvirial, diff --git a/source/api_cc/src/DeepPotTF.cc b/source/api_cc/src/DeepPotTF.cc index ed3bede4df..ef348fe14c 100644 --- a/source/api_cc/src/DeepPotTF.cc +++ b/source/api_cc/src/DeepPotTF.cc @@ -569,275 +569,6 @@ template void DeepPotTF::tile_fparam_aparam( // ENERGYVTYPE: std::vector or ENERGYTYPE -template -void DeepPotTF::compute(ENERGYVTYPE& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam_, - const std::vector& aparam_) { - int nall = datype_.size(); - // if nall==0, unclear nframes, but 1 is ok - int nframes = nall > 0 ? (dcoord_.size() / nall / 3) : 1; - int nloc = nall; - atommap = deepmd::AtomMap(datype_.begin(), datype_.begin() + nloc); - assert(nloc == atommap.get_type().size()); - std::vector fparam; - std::vector aparam; - validate_fparam_aparam(nframes, (aparam_nall ? nall : nloc), fparam_, - aparam_); - tile_fparam_aparam(fparam, nframes, dfparam, fparam_); - tile_fparam_aparam(aparam, nframes, (aparam_nall ? nall : nloc) * daparam, - aparam_); - - std::vector> input_tensors; - - if (dtype == tensorflow::DT_DOUBLE) { - int ret = session_input_tensors(input_tensors, dcoord_, ntypes, - datype_, dbox, cell_size, fparam, - aparam, atommap, "", aparam_nall); - assert(ret == nloc); - run_model(dener, dforce_, dvirial, session, input_tensors, atommap, - nframes); - } else { - int ret = session_input_tensors(input_tensors, dcoord_, ntypes, - datype_, dbox, cell_size, fparam, - aparam, atommap, "", aparam_nall); - assert(ret == nloc); - run_model(dener, dforce_, dvirial, session, input_tensors, atommap, - nframes); - } -} - -template void DeepPotTF::compute( - ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); - -template void DeepPotTF::compute( - ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); - -template void DeepPotTF::compute>( - std::vector& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); - -template void DeepPotTF::compute>( - std::vector& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& datype_, - const std::vector& dbox, - const std::vector& fparam, - const std::vector& aparam); - -template -void DeepPotTF::compute(ENERGYVTYPE& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - 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__) { - int nall = datype_.size(); - // if nall==0, unclear nframes, but 1 is ok - int nframes = nall > 0 ? (dcoord_.size() / nall / 3) : 1; - std::vector fparam; - std::vector aparam_; - validate_fparam_aparam(nframes, (aparam_nall ? nall : (nall - nghost)), - fparam_, aparam__); - tile_fparam_aparam(fparam, nframes, dfparam, fparam_); - tile_fparam_aparam(aparam_, nframes, - (aparam_nall ? nall : (nall - nghost)) * daparam, - aparam__); - - // select real atoms - std::vector dcoord, dforce, aparam; - std::vector datype, fwd_map, bkw_map; - int nghost_real, nall_real, nloc_real; - select_real_atoms_coord(dcoord, datype, aparam, nghost_real, fwd_map, bkw_map, - nall_real, nloc_real, dcoord_, datype_, aparam_, - nghost, ntypes, nframes, daparam, nall, aparam_nall); - - // internal nlist - if (ago == 0) { - nlist_data.copy_from_nlist(lmp_list); - nlist_data.shuffle_exclude_empty(fwd_map); - } - compute_inner(dener, dforce, dvirial, dcoord, datype, dbox, nghost_real, ago, - fparam, aparam); - // bkw map - dforce_.resize(static_cast(nframes) * fwd_map.size() * 3); - select_map(dforce_, dforce, bkw_map, 3, nframes, fwd_map.size(), - bkw_map.size()); -} - -template void DeepPotTF::compute( - ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - 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 DeepPotTF::compute( - ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - 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 DeepPotTF::compute>( - std::vector& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - 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 DeepPotTF::compute>( - std::vector& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - 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 DeepPotTF::compute_inner(ENERGYVTYPE& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& datype_, - const std::vector& dbox, - const int nghost, - const int& ago, - const std::vector& fparam, - const std::vector& aparam) { - int nall = datype_.size(); - // if nall==0, unclear nframes, but 1 is ok - int nframes = nall > 0 ? (dcoord_.size() / nall / 3) : 1; - int nloc = nall - nghost; - - std::vector> input_tensors; - - // agp == 0 means that the LAMMPS nbor list has been updated - if (ago == 0) { - atommap = deepmd::AtomMap(datype_.begin(), datype_.begin() + nloc); - assert(nloc == atommap.get_type().size()); - nlist_data.shuffle(atommap); - nlist_data.make_inlist(nlist); - } - if (dtype == tensorflow::DT_DOUBLE) { - int ret = session_input_tensors( - input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, - atommap, nghost, ago, "", aparam_nall); - assert(nloc == ret); - run_model(dener, dforce_, dvirial, session, input_tensors, atommap, - nframes, nghost); - } else { - int ret = session_input_tensors( - input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, - atommap, nghost, ago, "", aparam_nall); - assert(nloc == ret); - run_model(dener, dforce_, dvirial, session, input_tensors, atommap, - nframes, nghost); - } -} - -template void DeepPotTF::compute_inner( - ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& datype_, - const std::vector& dbox, - const int nghost, - const int& ago, - const std::vector& fparam, - const std::vector& aparam); - -template void DeepPotTF::compute_inner( - ENERGYTYPE& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& datype_, - const std::vector& dbox, - const int nghost, - const int& ago, - const std::vector& fparam, - const std::vector& aparam); - -template void DeepPotTF::compute_inner>( - std::vector& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& datype_, - const std::vector& dbox, - const int nghost, - const int& ago, - const std::vector& fparam, - const std::vector& aparam); - -template void DeepPotTF::compute_inner>( - std::vector& dener, - std::vector& dforce_, - std::vector& dvirial, - const std::vector& dcoord_, - const std::vector& datype_, - const std::vector& dbox, - const int nghost, - const int& ago, - const std::vector& fparam, - const std::vector& aparam); - template void DeepPotTF::compute(ENERGYVTYPE& dener, std::vector& dforce_, @@ -1234,131 +965,6 @@ void DeepPotTF::get_type_map(std::string& type_map) { } // forward to template method -void DeepPotTF::computew(double& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam, - const std::vector& aparam) { - compute(ener, force, virial, coord, atype, box, fparam, aparam); -} - -void DeepPotTF::computew(double& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam, - const std::vector& aparam) { - compute(ener, force, virial, coord, atype, box, fparam, aparam); -} -void DeepPotTF::computew(std::vector& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam, - const std::vector& aparam) { - compute(ener, force, virial, coord, atype, box, fparam, aparam); -} -void DeepPotTF::computew(std::vector& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam, - const std::vector& aparam) { - compute(ener, force, virial, coord, atype, box, fparam, aparam); -} -void DeepPotTF::computew(double& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const int nghost, - const InputNlist& inlist, - const int& ago, - const std::vector& fparam, - const std::vector& aparam) { - compute(ener, force, virial, coord, atype, box, nghost, inlist, ago, fparam, - aparam); -} - -void DeepPotTF::computew(double& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const int nghost, - const InputNlist& inlist, - const int& ago, - const std::vector& fparam, - const std::vector& aparam) { - compute(ener, force, virial, coord, atype, box, nghost, inlist, ago, fparam, - aparam); -} -void DeepPotTF::computew(std::vector& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const int nghost, - const InputNlist& inlist, - const int& ago, - const std::vector& fparam, - const std::vector& aparam) { - compute(ener, force, virial, coord, atype, box, nghost, inlist, ago, fparam, - aparam); -} -void DeepPotTF::computew(std::vector& ener, - std::vector& force, - std::vector& virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const int nghost, - const InputNlist& inlist, - const int& ago, - const std::vector& fparam, - const std::vector& aparam) { - compute(ener, force, virial, coord, atype, box, nghost, inlist, ago, fparam, - aparam); -} -void DeepPotTF::computew(double& ener, - std::vector& force, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam, - const std::vector& aparam) { - compute(ener, force, virial, atom_energy, atom_virial, coord, atype, box, - fparam, aparam); -} - -void DeepPotTF::computew(double& ener, - std::vector& force, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam, - const std::vector& aparam) { - compute(ener, force, virial, atom_energy, atom_virial, coord, atype, box, - fparam, aparam); -} void DeepPotTF::computew(std::vector& ener, std::vector& force, std::vector& virial, @@ -1385,39 +991,6 @@ void DeepPotTF::computew(std::vector& ener, compute(ener, force, virial, atom_energy, atom_virial, coord, atype, box, fparam, aparam); } -void DeepPotTF::computew(double& ener, - std::vector& force, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const int nghost, - const InputNlist& inlist, - const int& ago, - const std::vector& fparam, - const std::vector& aparam) { - compute(ener, force, virial, atom_energy, atom_virial, coord, atype, box, - nghost, inlist, ago, fparam, aparam); -} - -void DeepPotTF::computew(double& ener, - std::vector& force, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const int nghost, - const InputNlist& inlist, - const int& ago, - const std::vector& fparam, - const std::vector& aparam) { - compute(ener, force, virial, atom_energy, atom_virial, coord, atype, box, - nghost, inlist, ago, fparam, aparam); -} void DeepPotTF::computew(std::vector& ener, std::vector& force, std::vector& virial, @@ -1450,82 +1023,6 @@ void DeepPotTF::computew(std::vector& ener, compute(ener, force, virial, atom_energy, atom_virial, coord, atype, box, nghost, inlist, ago, fparam, aparam); } -void DeepPotTF::computew_mixed_type(double& ener, - std::vector& force, - std::vector& virial, - const int& nframes, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam, - const std::vector& aparam) { - compute_mixed_type(ener, force, virial, nframes, coord, atype, box, fparam, - aparam); -} -void DeepPotTF::computew_mixed_type(double& ener, - std::vector& force, - std::vector& virial, - const int& nframes, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam, - const std::vector& aparam) { - compute_mixed_type(ener, force, virial, nframes, coord, atype, box, fparam, - aparam); -} -void DeepPotTF::computew_mixed_type(std::vector& ener, - std::vector& force, - std::vector& virial, - const int& nframes, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam, - const std::vector& aparam) { - compute_mixed_type(ener, force, virial, nframes, coord, atype, box, fparam, - aparam); -} -void DeepPotTF::computew_mixed_type(std::vector& ener, - std::vector& force, - std::vector& virial, - const int& nframes, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam, - const std::vector& aparam) { - compute_mixed_type(ener, force, virial, nframes, coord, atype, box, fparam, - aparam); -} -void DeepPotTF::computew_mixed_type(double& ener, - std::vector& force, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const int& nframes, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam, - const std::vector& aparam) { - compute_mixed_type(ener, force, virial, atom_energy, atom_virial, nframes, - coord, atype, box, fparam, aparam); -} -void DeepPotTF::computew_mixed_type(double& ener, - std::vector& force, - std::vector& virial, - std::vector& atom_energy, - std::vector& atom_virial, - const int& nframes, - const std::vector& coord, - const std::vector& atype, - const std::vector& box, - const std::vector& fparam, - const std::vector& aparam) { - compute_mixed_type(ener, force, virial, atom_energy, atom_virial, nframes, - coord, atype, box, fparam, aparam); -} void DeepPotTF::computew_mixed_type(std::vector& ener, std::vector& force, std::vector& virial, diff --git a/source/api_cc/src/DeepTensor.cc b/source/api_cc/src/DeepTensor.cc index 9d4e71c3d3..2c88ab2f4b 100644 --- a/source/api_cc/src/DeepTensor.cc +++ b/source/api_cc/src/DeepTensor.cc @@ -52,7 +52,9 @@ void DeepTensor::compute(std::vector &dtensor_, const std::vector &dcoord_, const std::vector &datype_, const std::vector &dbox) { - dt->computew(dtensor_, dcoord_, datype_, dbox); + std::vector force_, virial_, datom_tensor_, datom_virial_; + dt->computew(dtensor_, force_, virial_, datom_tensor_, datom_virial_, dcoord_, + datype_, dbox, false); } template void DeepTensor::compute(std::vector &dtensor_, @@ -72,7 +74,9 @@ void DeepTensor::compute(std::vector &dtensor_, const std::vector &dbox, const int nghost, const InputNlist &lmp_list) { - dt->computew(dtensor_, dcoord_, datype_, dbox, nghost, lmp_list); + std::vector force_, virial_, datom_tensor_, datom_virial_; + dt->computew(dtensor_, force_, virial_, datom_tensor_, datom_virial_, dcoord_, + datype_, dbox, nghost, lmp_list, false); } template void DeepTensor::compute(std::vector &dtensor_, @@ -98,7 +102,7 @@ void DeepTensor::compute(std::vector &dglobal_tensor_, const std::vector &dbox) { std::vector datom_tensor_, datom_virial_; dt->computew(dglobal_tensor_, dforce_, dvirial_, datom_tensor_, datom_virial_, - dcoord_, datype_, dbox); + dcoord_, datype_, dbox, true); } template void DeepTensor::compute(std::vector &dglobal_tensor_, @@ -126,7 +130,7 @@ void DeepTensor::compute(std::vector &dglobal_tensor_, const InputNlist &lmp_list) { std::vector datom_tensor_, datom_virial_; dt->computew(dglobal_tensor_, dforce_, dvirial_, datom_tensor_, datom_virial_, - dcoord_, datype_, dbox, nghost, lmp_list); + dcoord_, datype_, dbox, nghost, lmp_list, true); } template void DeepTensor::compute(std::vector &dglobal_tensor_, @@ -157,7 +161,7 @@ void DeepTensor::compute(std::vector &dglobal_tensor_, const std::vector &datype_, const std::vector &dbox) { dt->computew(dglobal_tensor_, dforce_, dvirial_, datom_tensor_, datom_virial_, - dcoord_, datype_, dbox); + dcoord_, datype_, dbox, true); } template void DeepTensor::compute(std::vector &dglobal_tensor_, @@ -190,7 +194,7 @@ void DeepTensor::compute(std::vector &dglobal_tensor_, const int nghost, const InputNlist &lmp_list) { dt->computew(dglobal_tensor_, dforce_, dvirial_, datom_tensor_, datom_virial_, - dcoord_, datype_, dbox, nghost, lmp_list); + dcoord_, datype_, dbox, nghost, lmp_list, true); } template void DeepTensor::compute(std::vector &dglobal_tensor_, diff --git a/source/api_cc/src/DeepTensorTF.cc b/source/api_cc/src/DeepTensorTF.cc index 75399e9f39..436e389ad2 100644 --- a/source/api_cc/src/DeepTensorTF.cc +++ b/source/api_cc/src/DeepTensorTF.cc @@ -390,66 +390,6 @@ template void DeepTensorTF::compute(std::vector &dtensor_, const int nghost, const InputNlist &lmp_list); -template -void DeepTensorTF::compute(std::vector &dglobal_tensor_, - std::vector &dforce_, - std::vector &dvirial_, - const std::vector &dcoord_, - const std::vector &datype_, - const std::vector &dbox) { - std::vector tmp_at_, tmp_av_; - compute(dglobal_tensor_, dforce_, dvirial_, tmp_at_, tmp_av_, dcoord_, - datype_, dbox); -} - -template void DeepTensorTF::compute( - std::vector &dglobal_tensor_, - std::vector &dforce_, - std::vector &dvirial_, - const std::vector &dcoord_, - const std::vector &datype_, - const std::vector &dbox); - -template void DeepTensorTF::compute(std::vector &dglobal_tensor_, - std::vector &dforce_, - std::vector &dvirial_, - const std::vector &dcoord_, - const std::vector &datype_, - const std::vector &dbox); - -template -void DeepTensorTF::compute(std::vector &dglobal_tensor_, - std::vector &dforce_, - std::vector &dvirial_, - const std::vector &dcoord_, - const std::vector &datype_, - const std::vector &dbox, - const int nghost, - const InputNlist &lmp_list) { - std::vector tmp_at_, tmp_av_; - compute(dglobal_tensor_, dforce_, dvirial_, tmp_at_, tmp_av_, dcoord_, - datype_, dbox, nghost, lmp_list); -} - -template void DeepTensorTF::compute( - std::vector &dglobal_tensor_, - std::vector &dforce_, - std::vector &dvirial_, - const std::vector &dcoord_, - const std::vector &datype_, - const std::vector &dbox, - const int nghost, - const InputNlist &lmp_list); - -template void DeepTensorTF::compute(std::vector &dglobal_tensor_, - std::vector &dforce_, - std::vector &dvirial_, - const std::vector &dcoord_, - const std::vector &datype_, - const std::vector &dbox, - const int nghost, - const InputNlist &lmp_list); - template void DeepTensorTF::compute(std::vector &dglobal_tensor_, std::vector &dforce_, @@ -819,36 +759,6 @@ void DeepTensorTF::get_type_map(std::string &type_map) { type_map = get_scalar("model_attr/tmap"); } -void DeepTensorTF::computew(std::vector &value, - const std::vector &coord, - const std::vector &atype, - const std::vector &box) { - compute(value, coord, atype, box); -} -void DeepTensorTF::computew(std::vector &value, - const std::vector &coord, - const std::vector &atype, - const std::vector &box) { - compute(value, coord, atype, box); -} - -void DeepTensorTF::computew(std::vector &value, - const std::vector &coord, - const std::vector &atype, - const std::vector &box, - const int nghost, - const InputNlist &inlist) { - compute(value, coord, atype, box, nghost, inlist); -} -void DeepTensorTF::computew(std::vector &value, - const std::vector &coord, - const std::vector &atype, - const std::vector &box, - const int nghost, - const InputNlist &inlist) { - compute(value, coord, atype, box, nghost, inlist); -} - void DeepTensorTF::computew(std::vector &global_tensor, std::vector &force, std::vector &virial, @@ -856,9 +766,18 @@ void DeepTensorTF::computew(std::vector &global_tensor, std::vector &atom_virial, const std::vector &coord, const std::vector &atype, - const std::vector &box) { - compute(global_tensor, force, virial, atom_tensor, atom_virial, coord, atype, - box); + const std::vector &box, + const bool request_deriv) { + if (request_deriv) { + compute(global_tensor, force, virial, atom_tensor, atom_virial, coord, + atype, box); + } else { + compute(global_tensor, coord, atype, box); + force.clear(); + virial.clear(); + atom_tensor.clear(); + atom_virial.clear(); + } } void DeepTensorTF::computew(std::vector &global_tensor, std::vector &force, @@ -867,9 +786,18 @@ void DeepTensorTF::computew(std::vector &global_tensor, std::vector &atom_virial, const std::vector &coord, const std::vector &atype, - const std::vector &box) { - compute(global_tensor, force, virial, atom_tensor, atom_virial, coord, atype, - box); + const std::vector &box, + const bool request_deriv) { + if (request_deriv) { + compute(global_tensor, force, virial, atom_tensor, atom_virial, coord, + atype, box); + } else { + compute(global_tensor, coord, atype, box); + force.clear(); + virial.clear(); + atom_tensor.clear(); + atom_virial.clear(); + } } void DeepTensorTF::computew(std::vector &global_tensor, @@ -881,9 +809,18 @@ void DeepTensorTF::computew(std::vector &global_tensor, const std::vector &atype, const std::vector &box, const int nghost, - const InputNlist &inlist) { - compute(global_tensor, force, virial, atom_tensor, atom_virial, coord, atype, - box, nghost, inlist); + const InputNlist &inlist, + const bool request_deriv) { + if (request_deriv) { + compute(global_tensor, force, virial, atom_tensor, atom_virial, coord, + atype, box, nghost, inlist); + } else { + compute(global_tensor, coord, atype, box, nghost, inlist); + force.clear(); + virial.clear(); + atom_tensor.clear(); + atom_virial.clear(); + } } void DeepTensorTF::computew(std::vector &global_tensor, std::vector &force, @@ -894,7 +831,16 @@ void DeepTensorTF::computew(std::vector &global_tensor, const std::vector &atype, const std::vector &box, const int nghost, - const InputNlist &inlist) { - compute(global_tensor, force, virial, atom_tensor, atom_virial, coord, atype, - box, nghost, inlist); + const InputNlist &inlist, + const bool request_deriv) { + if (request_deriv) { + compute(global_tensor, force, virial, atom_tensor, atom_virial, coord, + atype, box, nghost, inlist); + } else { + compute(global_tensor, coord, atype, box, nghost, inlist); + force.clear(); + virial.clear(); + atom_tensor.clear(); + atom_virial.clear(); + } }