deepmd.dpmodel.atomic_model.pairtab_atomic_model#
Classes#
Pairwise tabulation energy model. |
Module Contents#
- class deepmd.dpmodel.atomic_model.pairtab_atomic_model.PairTabAtomicModel(tab_file: str, rcut: float, sel: int | list[int], type_map: list[str], rcond: float | None = None, atom_ener: list[float] | None = None, **kwargs)[source]#
Bases:
deepmd.dpmodel.atomic_model.base_atomic_model.BaseAtomicModelPairwise 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.
- Parameters:
- fitting_output_def() deepmd.dpmodel.output_def.FittingOutputDef[source]#
Get the output def of developer implemented atomic models.
- abstractmethod set_case_embd(case_idx: int)[source]#
Set the case embedding of this atomic model by the given case_idx, typically concatenated with the output of the descriptor and fed into the fitting net.
- get_nsel() int[source]#
Returns the total number of selected neighboring atoms in the cut-off radius.
- mixed_types() bool[source]#
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.
- need_sorted_nlist_for_lower() bool[source]#
Returns whether the atomic model needs sorted nlist when using forward_lower.
- change_type_map(type_map: list[str], model_with_new_type_stat=None) None[source]#
Change the type related params to new ones, according to type_map and the original one in the model. If there are new types in type_map, statistics will be updated accordingly to model_with_new_type_stat for these new types.
- classmethod deserialize(data) PairTabAtomicModel[source]#
- forward_atomic(extended_coord, extended_atype, nlist, mapping: numpy.ndarray | None = None, fparam: numpy.ndarray | None = None, aparam: numpy.ndarray | None = None) dict[str, numpy.ndarray][source]#
- _pair_tabulated_inter(nlist: numpy.ndarray, i_type: numpy.ndarray, j_type: numpy.ndarray, rr: numpy.ndarray) numpy.ndarray[source]#
Pairwise tabulated energy.
- Parameters:
- nlist
np.ndarray The unmasked neighbour list. (nframes, nloc)
- i_type
np.ndarray The integer representation of atom type for all local atoms for all frames. (nframes, nloc)
- j_type
np.ndarray The integer representation of atom type for all neighbour atoms of all local atoms for all frames. (nframes, nloc, nnei)
- rr
np.ndarray The salar distance vector between two atoms. (nframes, nloc, nnei)
- nlist
- Returns:
np.ndarrayThe masked atomic energy for all local atoms for all frames. (nframes, nloc, nnei)
- Raises:
ExceptionIf 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.
- static _get_pairwise_dist(coords: numpy.ndarray, nlist: numpy.ndarray) numpy.ndarray[source]#
Get pairwise distance dr.
- Parameters:
- coords
np.ndarray The coordinate of the atoms, shape of (nframes, nall, 3).
- nlist
The masked nlist, shape of (nframes, nloc, nnei).
- coords
- Returns:
np.ndarrayThe pairwise distance between the atoms (nframes, nloc, nnei).
- static _extract_spline_coefficient(i_type: numpy.ndarray, j_type: numpy.ndarray, idx: numpy.ndarray, tab_data: numpy.ndarray, nspline: numpy.int64) numpy.ndarray[source]#
Extract the spline coefficient from the table.
- Parameters:
- i_type
np.ndarray The integer representation of atom type for all local atoms for all frames. (nframes, nloc)
- j_type
np.ndarray The integer representation of atom type for all neighbour atoms of all local atoms for all frames. (nframes, nloc, nnei)
- idx
np.ndarray The index of the spline coefficient. (nframes, nloc, nnei)
- tab_data
np.ndarray The table storing all the spline coefficient. (ntype, ntype, nspline, 4)
- nspline
int The number of splines in the table.
- i_type
- Returns:
np.ndarrayThe spline coefficient. (nframes, nloc, nnei, 4), shape may be squeezed.
- static _calculate_ener(coef: numpy.ndarray, uu: numpy.ndarray) numpy.ndarray[source]#
Calculate energy using spline coeeficients.
- Parameters:
- coef
np.ndarray The spline coefficients. (nframes, nloc, nnei, 4)
- uu
np.ndarray The atom displancemnt used in interpolation and extrapolation (nframes, nloc, nnei)
- coef
- Returns:
np.ndarrayThe atomic energy for all local atoms for all frames. (nframes, nloc, nnei)
- get_sel_type() list[int][source]#
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.