deepmd.dpmodel.atomic_model.linear_atomic_model

Module Contents

Classes

LinearEnergyAtomicModel

Linear model make linear combinations of several existing models.

DPZBLLinearEnergyAtomicModel

Model linearly combine a list of AtomicModels.

class deepmd.dpmodel.atomic_model.linear_atomic_model.LinearEnergyAtomicModel(models: List[deepmd.dpmodel.atomic_model.base_atomic_model.BaseAtomicModel], type_map: List[str], **kwargs)[source]

Bases: deepmd.dpmodel.atomic_model.base_atomic_model.BaseAtomicModel

Linear model make linear combinations of several existing models.

Parameters:
modelslist[DPAtomicModel or PairTabAtomicModel]

A list of models to be combined. PairTabAtomicModel must be used together with a DPAtomicModel.

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.

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.

get_rcut() float[source]

Get the cut-off radius.

get_type_map() List[str][source]

Get the type map.

get_model_rcuts() List[float][source]

Get the cut-off radius for each individual models.

get_sel() List[int][source]

Returns the number of selected atoms for each type.

get_model_nsels() List[int][source]

Get the processed sels for each individual models. Not distinguishing types.

get_model_sels() List[int | List[int]][source]

Get the sels for each individual models.

_sort_rcuts_sels() Tuple[List[float], List[int]][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]

Return atomic prediction.

Parameters:
extended_coord

coodinates in extended region, (nframes, nall * 3)

extended_atype

atomic type in extended region, (nframes, nall)

nlist

neighbor list, (nframes, nloc, nsel).

mapping

mapps the extended indices to local indices.

fparam

frame parameter. (nframes, ndf)

aparam

atomic parameter. (nframes, nloc, nda)

Returns:
result_dict

the result dict, defined by the fitting net output def.

static remap_atype(ori_map: List[str], new_map: List[str]) numpy.ndarray[source]

This method is used to map the atype from the common type_map to the original type_map of indivial AtomicModels.

Parameters:
ori_mapList[str]

The original type map of an AtomicModel.

new_mapList[str]

The common type map of the DPZBLLinearEnergyAtomicModel, created by the get_type_map method, must be a subset of the ori_map.

Returns:
np.ndarray
fitting_output_def() deepmd.dpmodel.output_def.FittingOutputDef[source]

Get the output def of developer implemented atomic models.

serialize() dict[source]
classmethod deserialize(data: dict) LinearEnergyAtomicModel[source]
_compute_weight(extended_coord: numpy.ndarray, extended_atype: numpy.ndarray, nlists_: List[numpy.ndarray]) List[numpy.ndarray][source]

This should be a list of user defined weights that matches the number of models to be combined.

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).

class deepmd.dpmodel.atomic_model.linear_atomic_model.DPZBLLinearEnergyAtomicModel(dp_model: deepmd.dpmodel.atomic_model.dp_atomic_model.DPAtomicModel, zbl_model: deepmd.dpmodel.atomic_model.pairtab_atomic_model.PairTabAtomicModel, sw_rmin: float, sw_rmax: float, type_map: List[str], smin_alpha: float | None = 0.1, **kwargs)[source]

Bases: LinearEnergyAtomicModel

Model linearly combine a list of AtomicModels.

Parameters:
dp_model

The DPAtomicModel being combined.

zbl_model

The PairTable model being combined.

sw_rmin

The lower boundary of the interpolation between short-range tabulated interaction and DP.

sw_rmax

The upper boundary of the interpolation between short-range tabulated interaction and DP.

type_map

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

smin_alpha

The short-range tabulated interaction will be swithed according to the distance of the nearest neighbor. This distance is calculated by softmin.

serialize() dict[source]
classmethod deserialize(data) DPZBLLinearEnergyAtomicModel[source]
_compute_weight(extended_coord: numpy.ndarray, extended_atype: numpy.ndarray, nlists_: List[numpy.ndarray]) List[numpy.ndarray][source]

ZBL weight.

Returns:
List[np.ndarray]

the atomic ZBL weight for interpolation. (nframes, nloc, 1)