deepmd.tf.infer
Submodule containing all the implemented potentials. Deep dipole model. Deep density of states model. TensorFlow backend implementation for DeepEval. Deep Tensor Model. Deep polar model. Potential energy model. Deep WFC model. Evaluate the reciprocal part of the Ewald sum. Factory function that forwards to DeepEval (for compatbility). Python interface to calculate model deviation. Factory function that forwards to DeepEval (for compatbility). positional arguments keyword arguments potentials Bases: The model file for the DeepDipole model Gives the amount of charge for the wfcc Gives the amount of charge for the real atoms Grid spacing of the reciprocal part of Ewald sum. Unit: A Splitting parameter of the Ewald sum. Unit: A^{-1} Build the computational graph for the force and virial inference. Evaluate the modification. The coordinates of atoms The simulation region. PBC is assumed The atom types Evaluate force and virial The energy modification The force modification The virial modification Modify data. Internal data of DeepmdData. Be a dict, has the following keys - coord coordinates - box simulation box - type atom types - find_energy tells if data has energy - find_force tells if data has force - find_virial tells if data has virial - energy energy - force force - virial virial The data system. Bases: Deep dipole model. The name of the frozen model file. Positional arguments. If True, automatic batch size will be used. If int, it will be used as the initial batch size. The ASE neighbor list class to produce the neighbor list. If None, the neighbor list will be built natively in the model. Keyword arguments. Bases: Deep density of states model. The name of the frozen model file. Positional arguments. If True, automatic batch size will be used. If int, it will be used as the initial batch size. The ASE neighbor list class to produce the neighbor list. If None, the neighbor list will be built natively in the model. Keyword arguments. Get the output definition of this model. Evaluate energy, force, and virial. If atomic is True, also return atomic energy and atomic virial. The coordinates of the atoms, in shape (nframes, natoms, 3). The cell vectors of the system, in shape (nframes, 9). If the system is not periodic, set it to None. The types of the atoms. If mixed_type is False, the shape is (natoms,); otherwise, the shape is (nframes, natoms). Whether to return atomic energy and atomic virial, by default False. The frame parameters, by default None. The atomic parameters, by default None. Whether the atom_types is mixed type, by default False. Keyword arguments. The energy of the system, in shape (nframes,). The force of the system, in shape (nframes, natoms, 3). The virial of the system, in shape (nframes, 9). The atomic energy of the system, in shape (nframes, natoms). Only returned when atomic is True. The atomic virial of the system, in shape (nframes, natoms, 9). Only returned when atomic is True. Bases: TensorFlow backend implementation for DeepEval. The name of the frozen model file. The output definition of the model. Positional arguments. The prefix in the load computational graph If uses the default tf graph, otherwise build a new tf graph for evaluation If True, automatic batch size will be used. If int, it will be used as the initial batch size. The input map for tf.import_graph_def. Only work with default tf graph The ASE neighbor list class to produce the neighbor list. If None, the neighbor list will be built natively in the model. Keyword arguments. Get type of model. :type:str Get TF session. Check the model compatability. If the model stored in the graph file is compatable with the current code Sort atoms in the system according their types. The coordinates of atoms. Should be of shape [nframes, natoms, 3] The type of atoms Should be of shape [natoms] The selected atoms by type The coordinates after sorting The atom types after sorting The index mapping from the input to the output. For example coord_out = coord[:,idx_map,:] Only output if sel_atoms is not None The sorted selected atom types Only output if sel_atoms is not None The index mapping from the selected atoms to sorted selected atoms. Reverse mapping of a vector according to the index map. Input vector. Be of shape [nframes, natoms, -1] Index map. Be of shape [natoms] Reverse mapped vector. Make the natom vector used by deepmd-kit. The type of atoms The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms Evaluate output of type embedding network by using this model. The output of type embedding network. The shape is [ntypes, o_size], where ntypes is the number of types, and o_size is the number of nodes in the output layer. If the model does not enable type embedding. See also The type embedding network. Examples Get the output of type embedding network of graph.pb: Make the mesh with neighbor list for a single frame. The coordinates of atoms. Should be of shape [natoms, 3] The cell of the system. Should be of shape [3, 3] The type of atoms. Should be of shape [natoms] The index map of atoms. Should be of shape [natoms] ASE neighbor list. The following method or attribute will be used/set: bothways, self_interaction, update, build, first_neigh, pair_second, offset_vec. The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: nloc natoms[1]: nall natoms[i]: 2 <= i < Ntypes+2, number of type i atoms for nloc The coordinates of atoms, including ghost atoms. Should be of shape [nframes, nall, 3] The type of atoms, including ghost atoms. Should be of shape [nall] The mesh in nei_mode=4. The index map of atoms. Should be of shape [nall] The index map of ghost atoms. Should be of shape [nghost] Get the selected atom types of this model. Only atoms with selected atom types have atomic contribution to the result of the model. If returning an empty list, all atom types are selected. Wrapper method with auto batch size. Evaluate the energy, force and virial by using this DP. The coordinates of atoms. The array should be of size nframes x natoms x 3 The cell of the region. If None then non-PBC is assumed, otherwise using PBC. The array should be of size nframes x 9 The atom types The list should contain natoms ints Calculate the atomic energy and virial 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. 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. - dim_aparam. Then all frames and atoms are provided with the same aparam. The external field on atoms. The array should be of size nframes x natoms x 3 Other parameters The output of the evaluation. The keys are the names of the output variables, and the values are the corresponding output arrays. Evaluate descriptors by using this DP. The coordinates of atoms. The array should be of size nframes x natoms x 3 The cell of the region. If None then non-PBC is assumed, otherwise using PBC. The array should be of size nframes x 9 The atom types The list should contain natoms ints 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. 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. - dim_aparam. Then all frames and atoms are provided with the same aparam. The external field on atoms. The array should be of size nframes x natoms x 3 Descriptors. Bases: Deep Tensor Model. The name of the frozen model file. Positional arguments. If True, automatic batch size will be used. If int, it will be used as the initial batch size. The ASE neighbor list class to produce the neighbor list. If None, the neighbor list will be built natively in the model. Keyword arguments. Evaluate the model. The coordinates of atoms. The array should be of size nframes x natoms x 3 The cell of the region. If None then non-PBC is assumed, otherwise using PBC. The array should be of size nframes x 9 The atom types The list should contain natoms ints If True (default), return the atomic tensor Otherwise return the global tensor Not used in this model Not used in this model Whether to perform the mixed_type mode. If True, the input data has the mixed_type format (see doc/model/train_se_atten.md), in which frames in a system may have different natoms_vec(s), with the same nloc. The returned tensor If atomic == False then of size nframes x output_dim else of size nframes x natoms x output_dim Bases: Deep polar model. The name of the frozen model file. Positional arguments. If True, automatic batch size will be used. If int, it will be used as the initial batch size. The ASE neighbor list class to produce the neighbor list. If None, the neighbor list will be built natively in the model. Keyword arguments. Bases: Potential energy model. The name of the frozen model file. Positional arguments. If True, automatic batch size will be used. If int, it will be used as the initial batch size. The ASE neighbor list class to produce the neighbor list. If None, the neighbor list will be built natively in the model. Keyword arguments. Examples where e, f and v are predicted energy, force and virial of the system, respectively. Get the output definition of this model. Get the output definition of this model with magnetic parts. Evaluate energy, force, and virial. If atomic is True, also return atomic energy and atomic virial. The coordinates of the atoms, in shape (nframes, natoms, 3). The cell vectors of the system, in shape (nframes, 9). If the system is not periodic, set it to None. The types of the atoms. If mixed_type is False, the shape is (natoms,); otherwise, the shape is (nframes, natoms). Whether to return atomic energy and atomic virial, by default False. The frame parameters, by default None. The atomic parameters, by default None. Whether the atom_types is mixed type, by default False. Keyword arguments. The energy of the system, in shape (nframes,). The force of the system, in shape (nframes, natoms, 3). The virial of the system, in shape (nframes, 9). The atomic energy of the system, in shape (nframes, natoms). Only returned when atomic is True. The atomic virial of the system, in shape (nframes, natoms, 9). Only returned when atomic is True. Bases: Deep WFC model. The name of the frozen model file. Positional arguments. If True, automatic batch size will be used. If int, it will be used as the initial batch size. The ASE neighbor list class to produce the neighbor list. If None, the neighbor list will be built natively in the model. Keyword arguments. Evaluate the reciprocal part of the Ewald sum. Evaluate. The coordinates of atoms The atomic charge The simulation region. PBC is assumed The energy The force The virial Python interface to calculate model deviation. Coordinates of system to calculate Box to specify periodic boundary condition. If None, no pbc will be used Atom types Models used to evaluate deviation File to dump results, default None Steps between frames (if the system is given by molecular dynamics engine), default 1 Whether the input atype is in mixed_type format or not frame specific parameters atomic specific parameters real data to calculate RMS real error If True, calculate the force model deviation of each atom. If given, calculate the relative model deviation of force. The value is the level parameter for computing the relative model deviation of the force. If given, calculate the relative model deviation of virial. The value is the level parameter for computing the relative model deviation of the virial. Model deviation results. The first column is index of steps, the other 7 columns are max_devi_v, min_devi_v, avg_devi_v, max_devi_f, min_devi_f, avg_devi_f, devi_e. ExamplesSubmodules
Package Contents
Classes
Functions
DeepPotential
(→ deep_eval.DeepEval)calc_model_devi
(coord, box, atype, models[, fname, ...])DeepEval
deepmd.tf.infer.deep_dipole.DeepDipoleOld
tot_e
tot_f
tot_v
DeepmdData
deepmd.infer.deep_tensor.DeepTensor
Path
list
int
or AutoBatchSize
, default: True
ase.neighborlist.NewPrimitiveNeighborList
, optional
dict
deepmd.infer.deep_eval.DeepEval
Path
list
int
or AutoBatchSize
, default: True
ase.neighborlist.NewPrimitiveNeighborList
, optional
dict
np.ndarray
np.ndarray
List
[int
] or
np.ndarray
optional
np.ndarray
, optional
np.ndarray
, optional
optional
Dict
[str
, Any
]energy
force
virial
atomic_energy
atomic_virial
deepmd.infer.deep_eval.DeepEvalBackend
Path
ModelOutputDef
list
int
or AutomaticBatchSize
, default: False
dict
, optional
ase.neighborlist.NewPrimitiveNeighborList
, optional
dict
coord_out
atom_type_out
idx_map
sel_atom_type
sel_idx_map
vec_out
natoms
np.ndarray
KeyError
deepmd.tf.utils.type_embed.TypeEmbedNet
>>> from deepmd.tf.infer import DeepPotential
>>> dp = DeepPotential("graph.pb")
>>> dp.eval_typeebd()
np.ndarray
Optional
[np.ndarray
]np.ndarray
np.ndarray
ase.neighborlist.NewPrimitiveNeighborList
np.ndarray
np.ndarray
np.ndarray
np.ndarray
np.ndarray
np.ndarray
dict
descriptor
deepmd.infer.deep_tensor.DeepTensor
Path
list
int
or AutoBatchSize
, default: True
ase.neighborlist.NewPrimitiveNeighborList
, optional
dict
list
[int
] or
np.ndarray
tensor
deepmd.infer.deep_tensor.DeepTensor
Path
list
int
or AutoBatchSize
, default: True
ase.neighborlist.NewPrimitiveNeighborList
, optional
dict
deepmd.infer.deep_eval.DeepEval
Path
list
int
or AutoBatchSize
, default: True
ase.neighborlist.NewPrimitiveNeighborList
, optional
dict
>>> 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)
np.ndarray
np.ndarray
List
[int
] or
np.ndarray
optional
np.ndarray
, optional
np.ndarray
, optional
optional
Dict
[str
, Any
]energy
force
virial
atomic_energy
atomic_virial
deepmd.infer.deep_tensor.DeepTensor
Path
list
int
or AutoBatchSize
, default: True
ase.neighborlist.NewPrimitiveNeighborList
, optional
dict
e
f
v
numpy.ndarray
, n_frames x n_atoms x 3numpy.ndarray
or None
, n_frames x 3 x 3numpy.ndarray
, n_atoms x 1list
of
DeepPot
models
str
or None
int
numpy.ndarray
numpy.ndarray
dict
, optional
False
float
, default: None
float
, default: None
numpy.ndarray
, n_frames x 8>>> from deepmd.tf.infer import calc_model_devi
>>> from deepmd.tf.infer import DeepPot as DP
>>> import numpy as np
>>> 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]
>>> graphs = [DP("graph.000.pb"), DP("graph.001.pb")]
>>> model_devi = calc_model_devi(coord, cell, atype, graphs)