Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 22, 2024
1 parent 6c5cb1d commit 474a2b0
Show file tree
Hide file tree
Showing 9 changed files with 331 additions and 304 deletions.
130 changes: 68 additions & 62 deletions source/api_c/include/c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,22 @@ extern void DP_DeepPotCompute(DP_DeepPot* dp,
double* atomic_virial);

/**
* @brief Evaluate the energy, force, magnetic force and virial by using a DP with spin input. (double version)
* @brief Evaluate the energy, force, magnetic force and virial by using a DP
*with spin input. (double version)
* @attention The number of frames is assumed to be 1.
* @param[in] dp The DP to use.
* @param[in] natoms The number of atoms.
* @param[in] coord The coordinates of atoms. The array should be of size natoms
*x 3.
* @param[in] spin The spins of atoms, [0, 0, 0] if no spin. The array should be
* @param[in] spin The spins of atoms, [0, 0, 0] if no spin. The array should be
*of size natoms x 3.
* @param[in] atype The atom types. The array should contain natoms ints.
* @param[in] box The cell of the region. The array should be of size 9. Pass
*NULL if pbc is not used.
* @param[out] energy Output energy.
* @param[out] force Output force. The array should be of size natoms x 3.
* @param[out] force_mag Output magnetic force. The array should be of size natoms x 3.
* @param[out] force_mag Output magnetic force. The array should be of size
*natoms x 3.
* @param[out] virial Output virial. The array should be of size 9.
* @param[out] atomic_energy Output atomic energy. The array should be of size
*natoms.
Expand All @@ -185,17 +187,17 @@ extern void DP_DeepPotCompute(DP_DeepPot* dp,
*Pass NULL if not required.
**/
extern void DP_DeepPotComputeSP(DP_DeepPot* dp,
const int natom,
const double* coord,
const double* spin,
const int* atype,
const double* cell,
double* energy,
double* force,
double* force_mag,
double* virial,
double* atomic_energy,
double* atomic_virial);
const int natom,
const double* coord,
const double* spin,
const int* atype,
const double* cell,
double* energy,
double* force,
double* force_mag,
double* virial,
double* atomic_energy,
double* atomic_virial);

/**
* @brief Evaluate the energy, force and virial by using a DP. (float version)
Expand Down Expand Up @@ -229,20 +231,22 @@ extern void DP_DeepPotComputef(DP_DeepPot* dp,
float* atomic_virial);

/**
* @brief Evaluate the energy, force, magnetic force and virial by using a DP with spin input. (float version)
* @brief Evaluate the energy, force, magnetic force and virial by using a DP
*with spin input. (float version)
* @attention The number of frames is assumed to be 1.
* @param[in] dp The DP to use.
* @param[in] natoms The number of atoms.
* @param[in] coord The coordinates of atoms. The array should be of size natoms
*x 3.
* @param[in] spin The spins of atoms, [0, 0, 0] if no spin. The array should be
* @param[in] spin The spins of atoms, [0, 0, 0] if no spin. The array should be
*of size natoms x 3.
* @param[in] atype The atom types. The array should contain natoms ints.
* @param[in] box The cell of the region. The array should be of size 9. Pass
*NULL if pbc is not used.
* @param[out] energy Output energy.
* @param[out] force Output force. The array should be of size natoms x 3.
* @param[out] force_mag Output magnetic force. The array should be of size natoms x 3.
* @param[out] force_mag Output magnetic force. The array should be of size
*natoms x 3.
* @param[out] virial Output virial. The array should be of size 9.
* @param[out] atomic_energy Output atomic energy. The array should be of size
*natoms.
Expand All @@ -252,17 +256,17 @@ extern void DP_DeepPotComputef(DP_DeepPot* dp,
*Pass NULL if not required.
**/
extern void DP_DeepPotComputefSP(DP_DeepPot* dp,
const int natom,
const float* coord,
const float* spin,
const int* atype,
const float* cell,
double* energy,
float* force,
float* force_mag,
float* virial,
float* atomic_energy,
float* atomic_virial);
const int natom,
const float* coord,
const float* spin,
const int* atype,
const float* cell,
double* energy,
float* force,
float* force_mag,
float* virial,
float* atomic_energy,
float* atomic_virial);

/**
* @brief Evaluate the energy, force and virial by using a DP with the neighbor
Expand Down Expand Up @@ -412,15 +416,16 @@ extern void DP_DeepPotCompute2(DP_DeepPot* dp,
double* atomic_virial);

/**
* @brief Evaluate the energy, force, magnetic force and virial by using a DP with spin input. (double version)
* @brief Evaluate the energy, force, magnetic force and virial by using a DP
*with spin input. (double version)
* @version 2
* @param[in] dp The DP to use.
* @param[in] nframes The number of frames.
* @param[in] natoms The number of atoms.
* @param[in] coord The coordinates of atoms. The array should be of size natoms
*x 3.
* @param[in] spin The spins of atoms, [0, 0, 0] if no spin. The array should be of size
*nframes x natoms x 3.
* @param[in] spin The spins of atoms, [0, 0, 0] if no spin. The array should be
*of size nframes x natoms x 3.
* @param[in] atype The atom types. The array should contain natoms ints.
* @param[in] box The cell of the region. The array should be of size 9. Pass
*NULL if pbc is not used.
Expand All @@ -440,20 +445,20 @@ extern void DP_DeepPotCompute2(DP_DeepPot* dp,
*Pass NULL if not required.
**/
extern void DP_DeepPotCompute2SP(DP_DeepPot* dp,
const int nframes,
const int natom,
const double* coord,
const double* spin,
const int* atype,
const double* cell,
const double* fparam,
const double* aparam,
double* energy,
double* force,
double* force_mag,
double* virial,
double* atomic_energy,
double* atomic_virial);
const int nframes,
const int natom,
const double* coord,
const double* spin,
const int* atype,
const double* cell,
const double* fparam,
const double* aparam,
double* energy,
double* force,
double* force_mag,
double* virial,
double* atomic_energy,
double* atomic_virial);

/**
* @brief Evaluate the energy, force and virial by using a DP. (float version)
Expand Down Expand Up @@ -495,15 +500,16 @@ extern void DP_DeepPotComputef2(DP_DeepPot* dp,
float* atomic_virial);

/**
* @brief Evaluate the energy, force, magnetic force and virial by using a DP with spin input. (float version)
* @brief Evaluate the energy, force, magnetic force and virial by using a DP
*with spin input. (float version)
* @version 2
* @param[in] dp The DP to use.
* @param[in] nframes The number of frames.
* @param[in] natoms The number of atoms.
* @param[in] coord The coordinates of atoms. The array should be of size natoms
*x 3.
* @param[in] spin The spins of atoms, [0, 0, 0] if no spin. The array should be of size
*nframes x natoms x 3.
* @param[in] spin The spins of atoms, [0, 0, 0] if no spin. The array should be
*of size nframes x natoms x 3.
* @param[in] atype The atom types. The array should contain natoms ints.
* @param[in] box The cell of the region. The array should be of size 9. Pass
*NULL if pbc is not used.
Expand All @@ -523,20 +529,20 @@ extern void DP_DeepPotComputef2(DP_DeepPot* dp,
*Pass NULL if not required.
**/
extern void DP_DeepPotComputef2SP(DP_DeepPot* dp,
const int nframes,
const int natom,
const float* coord,
const float* spin,
const int* atype,
const float* cell,
const float* fparam,
const float* aparam,
double* energy,
float* force,
float* force_mag,
float* virial,
float* atomic_energy,
float* atomic_virial);
const int nframes,
const int natom,
const float* coord,
const float* spin,
const int* atype,
const float* cell,
const float* fparam,
const float* aparam,
double* energy,
float* force,
float* force_mag,
float* virial,
float* atomic_energy,
float* atomic_virial);

/**
* @brief Evaluate the energy, force and virial by using a DP with the neighbor
Expand Down
121 changes: 62 additions & 59 deletions source/api_c/include/deepmd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,59 +98,61 @@ inline void _DP_DeepPotCompute<float>(DP_DeepPot *dp,
// support spin
template <typename FPTYPE>
inline void _DP_DeepPotComputeSP(DP_DeepPot *dp,
const int nframes,
const int natom,
const FPTYPE *coord,
const FPTYPE *spin,
const int *atype,
const FPTYPE *cell,
const FPTYPE *fparam,
const FPTYPE *aparam,
double *energy,
FPTYPE *force,
FPTYPE *force_mag,
FPTYPE *virial,
FPTYPE *atomic_energy,
FPTYPE *atomic_virial);
const int nframes,
const int natom,
const FPTYPE *coord,
const FPTYPE *spin,
const int *atype,
const FPTYPE *cell,
const FPTYPE *fparam,
const FPTYPE *aparam,
double *energy,
FPTYPE *force,
FPTYPE *force_mag,
FPTYPE *virial,
FPTYPE *atomic_energy,
FPTYPE *atomic_virial);

template <>
inline void _DP_DeepPotComputeSP<double>(DP_DeepPot *dp,
const int nframes,
const int natom,
const double *coord,
const double *spin,
const int *atype,
const double *cell,
const double *fparam,
const double *aparam,
double *energy,
double *force,
double *force_mag,
double *virial,
double *atomic_energy,
double *atomic_virial) {
DP_DeepPotCompute2SP(dp, nframes, natom, coord, spin, atype, cell, fparam, aparam,
energy, force, force_mag, virial, atomic_energy, atomic_virial);
const int nframes,
const int natom,
const double *coord,
const double *spin,
const int *atype,
const double *cell,
const double *fparam,
const double *aparam,
double *energy,
double *force,
double *force_mag,
double *virial,
double *atomic_energy,
double *atomic_virial) {
DP_DeepPotCompute2SP(dp, nframes, natom, coord, spin, atype, cell, fparam,
aparam, energy, force, force_mag, virial, atomic_energy,
atomic_virial);
}

template <>
inline void _DP_DeepPotComputeSP<float>(DP_DeepPot *dp,
const int nframes,
const int natom,
const float *coord,
const float *spin,
const int *atype,
const float *cell,
const float *fparam,
const float *aparam,
double *energy,
float *force,
float *force_mag,
float *virial,
float *atomic_energy,
float *atomic_virial) {
DP_DeepPotComputef2SP(dp, nframes, natom, coord, spin, atype, cell, fparam, aparam,
energy, force, force_mag, virial, atomic_energy, atomic_virial);
const int nframes,
const int natom,
const float *coord,
const float *spin,
const int *atype,
const float *cell,
const float *fparam,
const float *aparam,
double *energy,
float *force,
float *force_mag,
float *virial,
float *atomic_energy,
float *atomic_virial) {
DP_DeepPotComputef2SP(dp, nframes, natom, coord, spin, atype, cell, fparam,
aparam, energy, force, force_mag, virial, atomic_energy,
atomic_virial);
}

template <typename FPTYPE>
Expand Down Expand Up @@ -941,15 +943,16 @@ class DeepPot {
};
// support spin
/**
* @brief Evaluate the energy, force, magnetic force and virial by using this DP with spin input.
* @brief Evaluate the energy, force, magnetic force and virial by using this
*DP with spin input.
* @param[out] ener The system energy.
* @param[out] force The force on each atom.
* @param[out] force_mag The magnetic 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] spin The spins of atoms, [0, 0, 0] if no spin. The array should be of size
*nframes x natoms x 3.
* @param[in] spin The spins of atoms, [0, 0, 0] if no spin. 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 (PBC) or empty (no PBC).
Expand Down Expand Up @@ -999,9 +1002,9 @@ class DeepPot {
const VALUETYPE *fparam__ = !fparam_.empty() ? &fparam_[0] : nullptr;
const VALUETYPE *aparam__ = !aparam_.empty() ? &aparam_[0] : nullptr;

_DP_DeepPotComputeSP<VALUETYPE>(dp, nframes, natoms, coord_, spin_, atype_, box_,
fparam__, aparam__, ener_, force_, force_mag_, virial_,
nullptr, nullptr);
_DP_DeepPotComputeSP<VALUETYPE>(dp, nframes, natoms, coord_, spin_, atype_,
box_, fparam__, aparam__, ener_, force_,
force_mag_, virial_, nullptr, nullptr);
DP_CHECK_OK(DP_DeepPotCheckOK, dp);
};
/**
Expand Down Expand Up @@ -1072,8 +1075,8 @@ class DeepPot {
};

/**
* @brief Evaluate the energy, force, magnetic force, virial, atomic energy, and atomic virial
*by using this DP with spin input.
* @brief Evaluate the energy, force, magnetic force, virial, atomic energy,
*and atomic virial by using this DP with spin input.
* @param[out] ener The system energy.
* @param[out] force The force on each atom.
* @param[out] force_mag The magnetic force on each atom.
Expand All @@ -1082,8 +1085,8 @@ class DeepPot {
* @param[out] atom_virial The atomic virial.
* @param[in] coord The coordinates of atoms. The array should be of size
*nframes x natoms x 3.
* @param[in] spin The spins of atoms, [0, 0, 0] if no spin. The array should be of size
*nframes x natoms x 3.
* @param[in] spin The spins of atoms, [0, 0, 0] if no spin. 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 (PBC) or empty (no PBC).
Expand Down Expand Up @@ -1140,9 +1143,9 @@ class DeepPot {
const VALUETYPE *fparam__ = !fparam_.empty() ? &fparam_[0] : nullptr;
const VALUETYPE *aparam__ = !aparam_.empty() ? &aparam_[0] : nullptr;

_DP_DeepPotCompute<VALUETYPE>(dp, nframes, natoms, coord_, spin_, atype_, box_,
fparam__, aparam__, ener_, force_, force_mag_, virial_,
atomic_ener_, atomic_virial_);
_DP_DeepPotCompute<VALUETYPE>(
dp, nframes, natoms, coord_, spin_, atype_, box_, fparam__, aparam__,
ener_, force_, force_mag_, virial_, atomic_ener_, atomic_virial_);
DP_CHECK_OK(DP_DeepPotCheckOK, dp);
};

Expand Down
Loading

0 comments on commit 474a2b0

Please sign in to comment.