deepmd.dpmodel.atomic_model.pairtab_atomic_model

Module Contents

Classes

PairTabAtomicModel

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:
tab_filestr

The path to the tabulation file.

rcutfloat

The cutoff radius.

selint or list[int]

The maxmum number of atoms in the cut-off radius.

type_maplist[str]

Mapping atom type to the name (str) of the type. For example type_map[1] gives the name of the type 1.

fitting_output_def() deepmd.dpmodel.output_def.FittingOutputDef[source]

Get the output def of developer implemented atomic models.

get_rcut() float[source]

Get the cut-off radius.

get_type_map() List[str][source]

Get the type map.

get_sel() List[int][source]

Returns the number of selected atoms for each type.

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.

serialize() dict[source]
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:
nlistnp.ndarray

The unmasked neighbour list. (nframes, nloc)

i_typenp.ndarray

The integer representation of atom type for all local atoms for all frames. (nframes, nloc)

j_typenp.ndarray

The integer representation of atom type for all neighbour atoms of all local atoms for all frames. (nframes, nloc, nnei)

rrnp.ndarray

The salar distance vector between two atoms. (nframes, nloc, nnei)

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:
coordsnp.ndarray

The coordinate of the atoms, shape of (nframes, nall, 3).

nlist

The masked nlist, shape of (nframes, nloc, nnei).

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_typenp.ndarray

The integer representation of atom type for all local atoms for all frames. (nframes, nloc)

j_typenp.ndarray

The integer representation of atom type for all neighbour atoms of all local atoms for all frames. (nframes, nloc, nnei)

idxnp.ndarray

The index of the spline coefficient. (nframes, nloc, nnei)

tab_datanp.ndarray

The table storing all the spline coefficient. (ntype, ntype, nspline, 4)

nsplineint

The number of splines in the table.

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:
coefnp.ndarray

The spline coefficients. (nframes, nloc, nnei, 4)

uunp.ndarray

The atom displancemnt used in interpolation and extrapolation (nframes, nloc, nnei)

Returns:
np.ndarray

The atomic energy for all local atoms for all frames. (nframes, nloc, nnei)

get_dim_fparam() int[source]

Get the number (dimension) of frame parameters of this atomic model.

get_dim_aparam() int[source]

Get the number (dimension) of atomic parameters of this atomic model.

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.

is_aparam_nall() bool[source]

Check whether the shape of atomic parameters is (nframes, nall, ndim).

If False, the shape is (nframes, nloc, ndim).