deepmd.dpmodel.atomic_model.pairtab_atomic_model
Module Contents
Classes
Pairwise tabulation energy model. |
- 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.BaseAtomicModel
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.
- Parameters:
- fitting_output_def() deepmd.dpmodel.output_def.FittingOutputDef [source]
Get the output def of developer implemented atomic models.
- 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.
- 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.ndarray
The masked atomic energy for all local atoms for all frames. (nframes, nloc, nnei)
- Raises:
Exception
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.
- 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.ndarray
The 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: int) 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.ndarray
The 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.ndarray
The atomic energy for all local atoms for all frames. (nframes, nloc, nnei)
- get_dim_aparam() int [source]
Get the number (dimension) of atomic parameters of this atomic model.