Class DeepPot#

Inheritance Relationships#

Base Type#

Class Documentation#

class DeepPot : public deepmd::DeepBaseModel#

Deep Potential to automatically switch backends.

Unnamed Group

template<typename VALUETYPE>
void compute(ENERGYTYPE &ener, std::vector<VALUETYPE> &force, std::vector<VALUETYPE> &virial, const std::vector<VALUETYPE> &coord, const std::vector<int> &atype, const std::vector<VALUETYPE> &box, const std::vector<VALUETYPE> &fparam = std::vector<VALUETYPE>(), const std::vector<VALUETYPE> &aparam = std::vector<VALUETYPE>(), const std::vector<double> &charge_spin = std::vector<double>())#

Evaluate the energy, force and virial by using this DP.

Parameters:
  • ener[out] The system energy.

  • force[out] The force on each atom.

  • virial[out] The virial.

  • coord[in] The coordinates of atoms. The array should be of size nframes x natoms x 3.

  • atype[in] The atom types. The list should contain natoms ints.

  • box[in] The cell of the region. The array should be of size nframes x 9.

  • fparam[in] 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.

  • aparam[in] 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.

  • charge_spin[in] The charge/spin parameter. The array can be of size nframes x dim_chg_spin. dim_chg_spin. Then all frames are assumed to be provided with the same charge_spin. Leave it empty to use the model’s stored default_chg_spin.

template<typename VALUETYPE>
void compute(std::vector<ENERGYTYPE> &ener, std::vector<VALUETYPE> &force, std::vector<VALUETYPE> &virial, const std::vector<VALUETYPE> &coord, const std::vector<int> &atype, const std::vector<VALUETYPE> &box, const std::vector<VALUETYPE> &fparam = std::vector<VALUETYPE>(), const std::vector<VALUETYPE> &aparam = std::vector<VALUETYPE>(), const std::vector<double> &charge_spin = std::vector<double>())#

Unnamed Group

template<typename VALUETYPE>
void compute(ENERGYTYPE &ener, std::vector<VALUETYPE> &force, std::vector<VALUETYPE> &virial, const std::vector<VALUETYPE> &coord, const std::vector<int> &atype, const std::vector<VALUETYPE> &box, const int nghost, const InputNlist &inlist, const int &ago, const std::vector<VALUETYPE> &fparam = std::vector<VALUETYPE>(), const std::vector<VALUETYPE> &aparam = std::vector<VALUETYPE>(), const std::vector<double> &charge_spin = std::vector<double>())#

Evaluate the energy, force and virial by using this DP.

Parameters:
  • ener[out] The system energy.

  • force[out] The force on each atom.

  • virial[out] The virial.

  • coord[in] The coordinates of atoms. The array should be of size nframes x natoms x 3.

  • atype[in] The atom types. The list should contain natoms ints.

  • box[in] The cell of the region. The array should be of size nframes x 9.

  • nghost[in] The number of ghost atoms.

  • inlist[in] The input neighbour list.

  • ago[in] Update the internal neighbour list if ago is 0.

  • fparam[in] 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.

  • aparam[in] 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.

  • charge_spin[in] The charge/spin parameter. The array can be of size nframes x dim_chg_spin. dim_chg_spin. Then all frames are assumed to be provided with the same charge_spin. Leave it empty to use the model’s stored default_chg_spin.

template<typename VALUETYPE>
void compute(std::vector<ENERGYTYPE> &ener, std::vector<VALUETYPE> &force, std::vector<VALUETYPE> &virial, const std::vector<VALUETYPE> &coord, const std::vector<int> &atype, const std::vector<VALUETYPE> &box, const int nghost, const InputNlist &inlist, const int &ago, const std::vector<VALUETYPE> &fparam = std::vector<VALUETYPE>(), const std::vector<VALUETYPE> &aparam = std::vector<VALUETYPE>(), const std::vector<double> &charge_spin = std::vector<double>())#

Unnamed Group

template<typename VALUETYPE>
void compute(ENERGYTYPE &ener, std::vector<VALUETYPE> &force, std::vector<VALUETYPE> &virial, std::vector<VALUETYPE> &atom_energy, std::vector<VALUETYPE> &atom_virial, const std::vector<VALUETYPE> &coord, const std::vector<int> &atype, const std::vector<VALUETYPE> &box, const std::vector<VALUETYPE> &fparam = std::vector<VALUETYPE>(), const std::vector<VALUETYPE> &aparam = std::vector<VALUETYPE>(), const std::vector<double> &charge_spin = std::vector<double>())#

Evaluate the energy, force, virial, atomic energy, and atomic virial by using this DP.

Parameters:
  • ener[out] The system energy.

  • force[out] The force on each atom.

  • virial[out] The virial.

  • atom_energy[out] The atomic energy.

  • atom_virial[out] The atomic virial.

  • coord[in] The coordinates of atoms. The array should be of size nframes x natoms x 3.

  • atype[in] The atom types. The list should contain natoms ints.

  • box[in] The cell of the region. The array should be of size nframes x 9.

  • fparam[in] 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.

  • aparam[in] 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.

  • charge_spin[in] The charge/spin parameter. The array can be of size nframes x dim_chg_spin. dim_chg_spin. Then all frames are assumed to be provided with the same charge_spin. Leave it empty to use the model’s stored default_chg_spin.

template<typename VALUETYPE>
void compute(std::vector<ENERGYTYPE> &ener, std::vector<VALUETYPE> &force, std::vector<VALUETYPE> &virial, std::vector<VALUETYPE> &atom_energy, std::vector<VALUETYPE> &atom_virial, const std::vector<VALUETYPE> &coord, const std::vector<int> &atype, const std::vector<VALUETYPE> &box, const std::vector<VALUETYPE> &fparam = std::vector<VALUETYPE>(), const std::vector<VALUETYPE> &aparam = std::vector<VALUETYPE>(), const std::vector<double> &charge_spin = std::vector<double>())#

Unnamed Group

template<typename VALUETYPE>
void compute(ENERGYTYPE &ener, std::vector<VALUETYPE> &force, std::vector<VALUETYPE> &virial, std::vector<VALUETYPE> &atom_energy, std::vector<VALUETYPE> &atom_virial, const std::vector<VALUETYPE> &coord, const std::vector<int> &atype, const std::vector<VALUETYPE> &box, const int nghost, const InputNlist &lmp_list, const int &ago, const std::vector<VALUETYPE> &fparam = std::vector<VALUETYPE>(), const std::vector<VALUETYPE> &aparam = std::vector<VALUETYPE>(), const std::vector<double> &charge_spin = std::vector<double>())#

Evaluate the energy, force, virial, atomic energy, and atomic virial by using this DP.

Parameters:
  • ener[out] The system energy.

  • force[out] The force on each atom.

  • virial[out] The virial.

  • atom_energy[out] The atomic energy.

  • atom_virial[out] The atomic virial.

  • coord[in] The coordinates of atoms. The array should be of size nframes x natoms x 3.

  • atype[in] The atom types. The list should contain natoms ints.

  • box[in] The cell of the region. The array should be of size nframes x 9.

  • nghost[in] The number of ghost atoms.

  • lmp_list[in] The input neighbour list.

  • ago[in] Update the internal neighbour list if ago is 0.

  • fparam[in] 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.

  • aparam[in] 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.

  • charge_spin[in] The charge/spin parameter. The array can be of size nframes x dim_chg_spin. dim_chg_spin. Then all frames are assumed to be provided with the same charge_spin. Leave it empty to use the model’s stored default_chg_spin.

template<typename VALUETYPE>
void compute(std::vector<ENERGYTYPE> &ener, std::vector<VALUETYPE> &force, std::vector<VALUETYPE> &virial, std::vector<VALUETYPE> &atom_energy, std::vector<VALUETYPE> &atom_virial, const std::vector<VALUETYPE> &coord, const std::vector<int> &atype, const std::vector<VALUETYPE> &box, const int nghost, const InputNlist &lmp_list, const int &ago, const std::vector<VALUETYPE> &fparam = std::vector<VALUETYPE>(), const std::vector<VALUETYPE> &aparam = std::vector<VALUETYPE>(), const std::vector<double> &charge_spin = std::vector<double>())#

Unnamed Group

template<typename VALUETYPE>
void compute_mixed_type(ENERGYTYPE &ener, std::vector<VALUETYPE> &force, std::vector<VALUETYPE> &virial, const int &nframes, const std::vector<VALUETYPE> &coord, const std::vector<int> &atype, const std::vector<VALUETYPE> &box, const std::vector<VALUETYPE> &fparam = std::vector<VALUETYPE>(), const std::vector<VALUETYPE> &aparam = std::vector<VALUETYPE>(), const std::vector<double> &charge_spin = std::vector<double>())#

Evaluate the energy, force, and virial with the mixed type by using this DP.

Parameters:
  • ener[out] The system energy.

  • force[out] The force on each atom.

  • virial[out] The virial.

  • nframes[in] The number of frames.

  • coord[in] The coordinates of atoms. The array should be of size nframes x natoms x 3.

  • atype[in] The atom types. The array should be of size nframes x natoms.

  • box[in] The cell of the region. The array should be of size nframes x 9.

  • fparam[in] 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.

  • aparam[in] 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.

  • charge_spin[in] The charge/spin parameter. The array can be of size nframes x dim_chg_spin. dim_chg_spin. Then all frames are assumed to be provided with the same charge_spin. Leave it empty to use the model’s stored default_chg_spin.

template<typename VALUETYPE>
void compute_mixed_type(std::vector<ENERGYTYPE> &ener, std::vector<VALUETYPE> &force, std::vector<VALUETYPE> &virial, const int &nframes, const std::vector<VALUETYPE> &coord, const std::vector<int> &atype, const std::vector<VALUETYPE> &box, const std::vector<VALUETYPE> &fparam = std::vector<VALUETYPE>(), const std::vector<VALUETYPE> &aparam = std::vector<VALUETYPE>(), const std::vector<double> &charge_spin = std::vector<double>())#

Unnamed Group

template<typename VALUETYPE>
void compute_mixed_type(ENERGYTYPE &ener, std::vector<VALUETYPE> &force, std::vector<VALUETYPE> &virial, std::vector<VALUETYPE> &atom_energy, std::vector<VALUETYPE> &atom_virial, const int &nframes, const std::vector<VALUETYPE> &coord, const std::vector<int> &atype, const std::vector<VALUETYPE> &box, const std::vector<VALUETYPE> &fparam = std::vector<VALUETYPE>(), const std::vector<VALUETYPE> &aparam = std::vector<VALUETYPE>(), const std::vector<double> &charge_spin = std::vector<double>())#

Evaluate the energy, force, and virial with the mixed type by using this DP.

Parameters:
  • ener[out] The system energy.

  • force[out] The force on each atom.

  • virial[out] The virial.

  • atom_energy[out] The atomic energy.

  • atom_virial[out] The atomic virial.

  • nframes[in] The number of frames.

  • coord[in] The coordinates of atoms. The array should be of size nframes x natoms x 3.

  • atype[in] The atom types. The array should be of size nframes x natoms.

  • box[in] The cell of the region. The array should be of size nframes x 9.

  • fparam[in] 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.

  • aparam[in] 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.

  • charge_spin[in] The charge/spin parameter. The array can be of size nframes x dim_chg_spin. dim_chg_spin. Then all frames are assumed to be provided with the same charge_spin. Leave it empty to use the model’s stored default_chg_spin.

template<typename VALUETYPE>
void compute_mixed_type(std::vector<ENERGYTYPE> &ener, std::vector<VALUETYPE> &force, std::vector<VALUETYPE> &virial, std::vector<VALUETYPE> &atom_energy, std::vector<VALUETYPE> &atom_virial, const int &nframes, const std::vector<VALUETYPE> &coord, const std::vector<int> &atype, const std::vector<VALUETYPE> &box, const std::vector<VALUETYPE> &fparam = std::vector<VALUETYPE>(), const std::vector<VALUETYPE> &aparam = std::vector<VALUETYPE>(), const std::vector<double> &charge_spin = std::vector<double>())#

Public Functions

DeepPot()#

DP constructor without initialization.

virtual ~DeepPot()#
DeepPot(const std::string &model, const int &gpu_rank = 0, const std::string &file_content = "")#

DP constructor with initialization.

Parameters:
  • model[in] The name of the frozen model file.

  • gpu_rank[in] The GPU rank. Default is 0.

  • file_content[in] The content of the model file. If it is not empty, DP will read from the string instead of the file.

void init(const std::string &model, const int &gpu_rank = 0, const std::string &file_content = "")#

Initialize the DP.

Parameters:
  • model[in] The name of the frozen model file.

  • gpu_rank[in] The GPU rank. Default is 0.

  • file_content[in] The content of the model file. If it is not empty, DP will read from the string instead of the file.

void compute_edges_gpu(double *d_atom_energy, double *d_force, double *d_atom_virial, const double *d_coord, const int *d_atype, const int *d_edge_index, const double *d_edge_vec, const int nloc, const int nedge)#

Fully device-resident inference for exported edge-input or graph-input .pt2 models.

Forwards to the PyTorch Exportable (.pt2) backend’s GPU edge path; raising if the active backend is not DeepPotPTExpt. All pointers reference GPU memory on the model’s device. See DeepPotPTExpt::compute_edges_gpu for the edge contract. This signature is intentionally torch-free so MD-engine call sites need no PyTorch headers.

Parameters:
  • d_atom_energy[out] Per-atom energy, GPU [nloc].

  • d_force[out] Per-atom force, GPU [nloc * 3] row-major.

  • d_atom_virial[out] Per-atom virial, GPU [nloc * 9] row-major.

  • d_coord[in] Local coordinates, GPU [nloc * 3] row-major.

  • d_atype[in] Local atom types, GPU [nloc].

  • d_edge_index[in] Destination-major local edge graph, GPU [2 * nedge].

  • d_edge_vec[in] Minimum-image bond vectors, GPU [nedge * 3].

  • nloc[in] Number of local atoms.

  • nedge[in] Number of physical edges.

void compute_edges_gpu(double *d_atom_energy, double *d_force, double *d_atom_virial, const double *d_coord, const int *d_atype, const int *d_edge_index, const double *d_edge_vec, const int nloc, const int nedge, const std::vector<double> &fparam, const std::vector<double> &aparam, const int nall_nodes = 0, const InputNlist *comm_nlist = nullptr)#

GPU-resident edge inference with runtime frame / atomic parameters.

As the parameter-free overload, but fparam (global, dfparam values) and aparam (per-atom, nloc * daparam values) override the model’s stored defaults. Empty vectors fall back to the stored default fparam and to no aparam, so the two overloads coincide.

Parameters:
  • fparam[in] Host-resident runtime frame parameters, or empty for the model default.

  • aparam[in] Host-resident runtime per-atom parameters (row-major [nloc, daparam]), or empty for none.

  • nall_nodes[in] Total graph node count; 0 (or nloc) folds ghosts onto local owners (single domain), while nall_nodes > nloc keeps the extended (local + ghost) node set for a domain-decomposed run.

  • comm_nlist[in] Communication neighbor list (send/recv swaps) for the extended node set. Required for a message-passing model under domain decomposition, where ghost features are exchanged across ranks inside the forward pass; nullptr otherwise.

void compute_edges_gpu(double *d_atom_energy, double *d_force, double *d_atom_virial, const double *d_coord, const int *d_atype, const int *d_edge_index, const float *d_edge_vec, const int nloc, const int nedge, const std::vector<double> &fparam, const std::vector<double> &aparam, const int nall_nodes = 0, const InputNlist *comm_nlist = nullptr)#

Device-edge inference with FP32 edge vectors.

Call this overload only when uses_fp32_edge_vectors() is true.

bool supports_device_edge_inference() const#

Whether the loaded artifact supports device-edge inference.

bool uses_fp32_edge_vectors() const#

Whether the loaded artifact expects FP32 device edge vectors.

bool uses_canonical_graph_inference() const#

Whether the loaded artifact uses the compact canonical graph ABI.

void compute_canonical_graph_gpu(double *d_atom_energy, double *d_force, double *d_atom_virial, const std::int64_t *d_atype, const std::uint32_t *d_source, const float *d_edge_vec, const std::int64_t *d_destination_row_ptr, const std::int64_t *d_source_row_ptr, const std::uint32_t *d_source_order, const int nloc, const int nall_nodes, const std::int64_t edge_storage)#
int dim_chg_spin() const#
void set_charge_spin(const std::vector<double> &charge_spin)#

Fix the charge/spin condition served for the rest of the run.

Parameters:

charge_spin[in] The condition, of length dim_chg_spin().

Protected Attributes

std::shared_ptr<deepmd::DeepPotBackend> dp#