deepmd.tf.infer.deep_pot#
Classes#
Potential energy model. |
Module Contents#
- class deepmd.tf.infer.deep_pot.DeepPot(model_file: str, *args: Any, auto_batch_size: bool | int | deepmd.utils.batch_size.AutoBatchSize = True, neighbor_list: ase.neighborlist.NewPrimitiveNeighborList | None = None, **kwargs: Any)[source]#
Bases:
deepmd.infer.deep_eval.DeepEvalPotential energy model.
- Parameters:
- model_file
Path The name of the frozen model file.
- *args
list Positional arguments.
- auto_batch_sizebool or
intorAutoBatchSize, default:True If True, automatic batch size will be used. If int, it will be used as the initial batch size.
- neighbor_list
ase.neighborlist.NewPrimitiveNeighborList,optional The ASE neighbor list class to produce the neighbor list. If None, the neighbor list will be built natively in the model.
- **kwargs
dict Keyword arguments.
- model_file
Examples
>>> from deepmd.infer import DeepPot >>> import numpy as np >>> dp = DeepPot("graph.pb") >>> coord = np.array([[1, 0, 0], [0, 0, 1.5], [1, 0, 3]]).reshape([1, -1]) >>> cell = np.diag(10 * np.ones(3)).reshape([1, -1]) >>> atype = [1, 0, 1] >>> e, f, v = dp.eval(coord, cell, atype)
where e, f and v are predicted energy, force and virial of the system, respectively.
- property output_def: deepmd.dpmodel.output_def.ModelOutputDef#
Get the output definition of this model.
- property output_def_mag: deepmd.dpmodel.output_def.ModelOutputDef#
Get the output definition of this model with magnetic parts.
- eval(coords: numpy.ndarray, cells: numpy.ndarray | None, atom_types: list[int] | numpy.ndarray, atomic: Literal[True], fparam: numpy.ndarray | None, aparam: numpy.ndarray | None, mixed_type: bool, **kwargs: Any) tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray] | tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray][source]#
- eval(coords: numpy.ndarray, cells: numpy.ndarray | None, atom_types: list[int] | numpy.ndarray, atomic: Literal[False], fparam: numpy.ndarray | None, aparam: numpy.ndarray | None, mixed_type: bool, **kwargs: Any) tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray] | tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray]
- eval(coords: numpy.ndarray, cells: numpy.ndarray | None, atom_types: list[int] | numpy.ndarray, atomic: bool, fparam: numpy.ndarray | None, aparam: numpy.ndarray | None, mixed_type: bool, **kwargs: Any) tuple[numpy.ndarray, Ellipsis]
Evaluate energy, force, and virial. If atomic is True, also return atomic energy and atomic virial.
- Parameters:
- coords
np.ndarray The coordinates of the atoms, in shape (nframes, natoms, 3).
- cells
np.ndarray The cell vectors of the system, in shape (nframes, 9). If the system is not periodic, set it to None.
- atom_types
list[int]ornp.ndarray The types of the atoms. If mixed_type is False, the shape is (natoms,); otherwise, the shape is (nframes, natoms).
- atomicbool,
optional Whether to return atomic energy and atomic virial, by default False.
- fparam
np.ndarray,optional The frame parameters, by default None.
- aparam
np.ndarray,optional The atomic parameters, by default None.
- mixed_typebool,
optional Whether the atom_types is mixed type, by default False.
- **kwargs
dict[str,Any] Keyword arguments.
- coords
- Returns:
energyThe energy of the system, in shape (nframes,).
forceThe force of the system, in shape (nframes, natoms, 3).
virialThe virial of the system, in shape (nframes, 9).
atomic_energyThe atomic energy of the system, in shape (nframes, natoms). Only returned when atomic is True.
atomic_virialThe atomic virial of the system, in shape (nframes, natoms, 9). Only returned when atomic is True.
hessianThe Hessian matrix of the system, in shape (nframes, 3 * natoms, 3 * natoms). Returned when available.