deepmd.pt.model.atomic_model
The atomic model provides the prediction of some property on each atom. All the atomic models are not supposed to be directly accessed by users, but it provides a convenient interface for the implementation of models.
Taking the energy models for example, the developeres only needs to implement the atomic energy prediction via an atomic model, and the model can be automatically made by the deepmd.dpmodel.make_model method. The DPModel is made by The base of atomic model. Model give atomic prediction of some physical property. Model give atomic prediction of some physical property. Model give atomic prediction of some physical property. Model give atomic prediction of some physical property. Model linearly combine a list of AtomicModels. Linear model make linear combinations of several existing models. Pairwise tabulation energy model. Model give atomic prediction of some physical property. Bases: The base of atomic model. Mapping atom type to the name (str) of the type. For example type_map[1] gives the name of the type 1. Exclude the atomic contribution of the given types Exclude the pair of atoms of the given types from computing the output of the atomic model. Implemented by removing the pairs from the nlist. The condition number for the regression of atomic energy. Specifying atomic energy contribution in vacuum. Given by key:value pairs. The value is a list specifying the bias. the elements can be None or np.array of output shape. For example: [None, [2.]] means type 0 is not set, type 1 is set to [2.] The set_davg_zero key in the descrptor should be set. The atoms with type < 0 are treated as virutal atoms, which serves as place-holders for multi-frame calculations with different number of atoms in different frames. Atom types. >= 0 for real atoms <0 for virtual atoms. True for real atoms and False for virutal atoms. Get the output def of the atomic model. By default it is the same as FittingOutputDef, but it allows model level wrapper of the output defined by the developer. Common interface for atomic inference. This method accept extended coordinates, extended atom typs, neighbor list, and predict the atomic contribution of the fit property. extended coodinates, shape: nf x (nall x 3) extended atom typs, shape: nf x nall for a type < 0 indicating the atomic is virtual. neighbor list, shape: nf x nloc x nsel extended to local index mapping, shape: nf x nall frame parameters, shape: nf x dim_fparam atomic parameter, shape: nf x nloc x dim_aparam The data needed for communication for parallel inference. dict of output atomic properties. should implement the definition of fitting_output_def. ret_dict[“mask”] of shape nf x nloc will be provided. ret_dict[“mask”][ff,ii] == 1 indicating the ii-th atom of the ff-th frame is real. ret_dict[“mask”][ff,ii] == 0 indicating the ii-th atom of the ff-th frame is virtual. Compute the output statistics (e.g. energy bias) for the fitting net from packed data. Each element, merged[i], is a data dictionary containing keys: torch.Tensor originating from the i-th data system. only when needed. Since the sampling process can be slow and memory-intensive, the lazy function helps by only sampling once. The path to the stat file. Compute the output statistics (e.g. energy bias) for the fitting net from packed data. Each element, merged[i], is a data dictionary containing keys: torch.Tensor originating from the i-th data system. only when needed. Since the sampling process can be slow and memory-intensive, the lazy function helps by only sampling once. The path to the stat file. Apply the stat to each atomic output. The developer may override the method to define how the bias is applied to the atomic output of the model. The returned dict by the forward_atomic method The atom types. nf x nloc Change the output bias according to the input data and the pretrained model. Each element, merged[i], is a data dictionary containing keys: torch.Tensor originating from the i-th data system. only when needed. Since the sampling process can be slow and memory-intensive, the lazy function helps by only sampling once. The mode for changing output bias : [‘change-by-statistic’, ‘set-by-statistic’] ‘change-by-statistic’ : perform predictions on labels of target dataset, and do least square on the errors to obtain the target shift as bias. ‘set-by-statistic’ : directly use the statistic output bias in the target dataset. The path to the stat file. Get a forward wrapper of the atomic model for output bias calculation. Bases: Model give atomic prediction of some physical property. Descriptor Fitting net Mapping atom type to the name (str) of the type. For example type_map[1] gives the name of the type 1. Apply the stat to each atomic output. The developer may override the method to define how the bias is applied to the atomic output of the model. The returned dict by the forward_atomic method The atom types. nf x nloc Bases: Model give atomic prediction of some physical property. Descriptor Fitting net Mapping atom type to the name (str) of the type. For example type_map[1] gives the name of the type 1. Bases: Model give atomic prediction of some physical property. Descriptor Fitting net Mapping atom type to the name (str) of the type. For example type_map[1] gives the name of the type 1. Get the output def of the fitting net. If true, the model 1. assumes total number of atoms aligned across frames; 2. uses a neighbor list that does not distinguish different atomic types. If false, the model 1. assumes total number of atoms of each atom type aligned across frames; 2. uses a neighbor list that distinguishes different atomic types. Return atomic prediction. coodinates in extended region atomic type in extended region neighbor list. nf x nloc x nsel mapps the extended indices to local indices frame parameter. nf x ndf atomic parameter. nf x nloc x nda the result dict, defined by the FittingOutputDef. Compute or load the statistics parameters of the model, such as mean and standard deviation of descriptors or the energy bias of the fitting net. When sampled is provided, all the statistics parameters will be calculated (or re-calculated for update), and saved in the stat_file_path`(s). When `sampled is not provided, it will check the existence of `stat_file_path`(s) and load the calculated statistics parameters. The lazy sampled function to get data frames from different data systems. The dictionary of paths to the statistics files. Bases: Model give atomic prediction of some physical property. Descriptor Fitting net Mapping atom type to the name (str) of the type. For example type_map[1] gives the name of the type 1. Bases: Model linearly combine a list of AtomicModels. The DPAtomicModel being combined. The PairTable model being combined. The lower boundary of the interpolation between short-range tabulated interaction and DP. The upper boundary of the interpolation between short-range tabulated interaction and DP. Mapping atom type to the name (str) of the type. For example type_map[1] gives the name of the type 1. The short-range tabulated interaction will be swithed according to the distance of the nearest neighbor. This distance is calculated by softmin. Bases: Linear model make linear combinations of several existing models. A list of models to be combined. PairTabAtomicModel must be used together with a DPAtomicModel. Mapping atom type to the name (str) of the type. For example type_map[1] gives the name of the type 1. If true, the model 1. assumes total number of atoms aligned across frames; 2. uses a neighbor list that does not distinguish different atomic types. If false, the model 1. assumes total number of atoms of each atom type aligned across frames; 2. uses a neighbor list that distinguishes different atomic types. Get the processed sels for each individual models. Not distinguishing types. Return atomic prediction. coodinates in extended region, (nframes, nall * 3) atomic type in extended region, (nframes, nall) neighbor list, (nframes, nloc, nsel). mapps the extended indices to local indices. frame parameter. (nframes, ndf) atomic parameter. (nframes, nloc, nda) the result dict, defined by the fitting net output def. Apply the stat to each atomic output. The developer may override the method to define how the bias is applied to the atomic output of the model. The returned dict by the forward_atomic method The atom types. nf x nloc This method is used to map the atype from the common type_map to the original type_map of indivial AtomicModels. It creates a index mapping for the conversion. Get the output def of developer implemented atomic models. This should be a list of user defined weights that matches the number of models to be combined. 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. Check whether the shape of atomic parameters is (nframes, nall, ndim). If False, the shape is (nframes, nloc, ndim). Compute the output statistics (e.g. energy bias) for the fitting net from packed data. Each element, merged[i], is a data dictionary containing keys: torch.Tensor originating from the i-th data system. only when needed. Since the sampling process can be slow and memory-intensive, the lazy function helps by only sampling once. The path to the stat file. Compute or load the statistics parameters of the model, such as mean and standard deviation of descriptors or the energy bias of the fitting net. When sampled is provided, all the statistics parameters will be calculated (or re-calculated for update), and saved in the stat_file_path`(s). When `sampled is not provided, it will check the existence of `stat_file_path`(s) and load the calculated statistics parameters. The lazy sampled function to get data frames from different data systems. The dictionary of paths to the statistics files. Bases: Pairwise tabulation energy model. This model can be used to tabulate the pairwise energy between atoms for either short-range or long-range interactions, such as D3, LJ, ZBL, etc. It should not be used alone, but rather as one submodel of a linear (sum) model, such as DP+D3. Do not put the model on the first model of a linear model, since the linear model fetches the type map from the first model. At this moment, the model does not smooth the energy at the cutoff radius, so one needs to make sure the energy has been smoothed to zero. The path to the tabulation file. The cutoff radius. The maxmum number of atoms in the cut-off radius. Mapping atom type to the name (str) of the type. For example type_map[1] gives the name of the type 1. The condition number for the regression of atomic energy. Specifying atomic energy contribution in vacuum. The set_davg_zero key in the descrptor should be set. Get the output def of developer implemented atomic models. Returns the total number of selected neighboring atoms in the cut-off radius. If true, the model 1. assumes total number of atoms aligned across frames; 2. uses a neighbor list that does not distinguish different atomic types. If false, the model 1. assumes total number of atoms of each atom type aligned across frames; 2. uses a neighbor list that distinguishes different atomic types. Compute the output statistics (e.g. energy bias) for the fitting net from packed data. Each element, merged[i], is a data dictionary containing keys: torch.Tensor originating from the i-th data system. only when needed. Since the sampling process can be slow and memory-intensive, the lazy function helps by only sampling once. The path to the stat file. Pairwise tabulated energy. The unmasked neighbour list. (nframes, nloc) The integer representation of atom type for all local atoms for all frames. (nframes, nloc) The integer representation of atom type for all neighbour atoms of all local atoms for all frames. (nframes, nloc, nnei) The salar distance vector between two atoms. (nframes, nloc, nnei) The masked atomic energy for all local atoms for all frames. (nframes, nloc, nnei) If the distance is beyond the table. Notes This function is used to calculate the pairwise energy between two atoms. It uses a table containing cubic spline coefficients calculated in PairTab. Get pairwise distance dr. The coordinate of the atoms, shape of (nframes, nall, 3). The masked nlist, shape of (nframes, nloc, nnei) The pairwise distance between the atoms (nframes, nloc, nnei). Extract the spline coefficient from the table. The integer representation of atom type for all local atoms for all frames. (nframes, nloc) The integer representation of atom type for all neighbour atoms of all local atoms for all frames. (nframes, nloc, nnei) The index of the spline coefficient. (nframes, nloc, nnei) The table storing all the spline coefficient. (ntype, ntype, nspline, 4) The number of splines in the table. The spline coefficient. (nframes, nloc, nnei, 4), shape may be squeezed. Calculate energy using spline coeeficients. The spline coefficients. (nframes, nloc, nnei, 4) The atom displancemnt used in interpolation and extrapolation (nframes, nloc, nnei) The atomic energy for all local atoms for all frames. (nframes, nloc, nnei) Bases: Model give atomic prediction of some physical property. Descriptor Fitting net Mapping atom type to the name (str) of the type. For example type_map[1] gives the name of the type 1.`
DPModel = make_model(DPAtomicModel)
`
Submodules
deepmd.pt.model.atomic_model.base_atomic_model
deepmd.pt.model.atomic_model.dipole_atomic_model
deepmd.pt.model.atomic_model.dos_atomic_model
deepmd.pt.model.atomic_model.dp_atomic_model
deepmd.pt.model.atomic_model.energy_atomic_model
deepmd.pt.model.atomic_model.linear_atomic_model
deepmd.pt.model.atomic_model.pairtab_atomic_model
deepmd.pt.model.atomic_model.polar_atomic_model
Package Contents
Classes
torch.nn.Module
, BaseAtomicModel_
float
, optional
Dict
[str
, List
[Optional
[torch.Tensor
]]], optional
mask
ret_dict
Union
[Callable
[[], List
[dict
]], List
[dict
]]Optional
[DPPath
]Union
[Callable
[[], List
[dict
]], List
[dict
]]Optional
[DPPath
]Union
[Callable
[[], List
[dict
]], List
[dict
]]str
Optional
[DPPath
]deepmd.pt.model.atomic_model.dp_atomic_model.DPAtomicModel
deepmd.pt.model.atomic_model.dp_atomic_model.DPAtomicModel
deepmd.pt.model.atomic_model.base_atomic_model.BaseAtomicModel
result_dict
deepmd.pt.model.atomic_model.dp_atomic_model.DPAtomicModel
LinearEnergyAtomicModel
deepmd.pt.model.atomic_model.base_atomic_model.BaseAtomicModel
list
[DPAtomicModel
or PairTabAtomicModel
]list
[str
]result_dict
Union
[Callable
[[], List
[dict
]], List
[dict
]]Optional
[DPPath
]deepmd.pt.model.atomic_model.base_atomic_model.BaseAtomicModel
str
float
int
or list
[int
]List
[str
]float
, optional
Union
[Callable
[[], List
[dict
]], List
[dict
]]Optional
[DPPath
]torch.Tensor
torch.Tensor
torch.Tensor
torch.Tensor
torch.Tensor
Exception
torch.Tensor
torch.Tensor
torch.Tensor
torch.Tensor
torch.Tensor
torch.Tensor
int
torch.Tensor
torch.Tensor
torch.Tensor
torch.Tensor
deepmd.pt.model.atomic_model.dp_atomic_model.DPAtomicModel