deepmd.dpmodel.atomic_model package

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 ` DPModel = make_model(DPAtomicModel) `

class deepmd.dpmodel.atomic_model.BaseAtomicModel(atom_exclude_types: List[int] = [], pair_exclude_types: List[Tuple[int, int]] = [])[source]

Bases: BAM

Methods

atomic_output_def()

Get the output def of the atomic model.

do_grad_(var_name, base)

Tell if the output variable var_name is differentiable.

do_grad_c([var_name])

Tell if the output variable var_name is c_differentiable.

do_grad_r([var_name])

Tell if the output variable var_name is r_differentiable.

fitting_output_def()

Get the output def of developer implemented atomic models.

get_dim_aparam()

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

get_dim_fparam()

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

get_nnei()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_nsel()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_ntypes()

Get the number of atom types.

get_rcut()

Get the cut-off radius.

get_sel()

Returns the number of selected atoms for each type.

get_sel_type()

Get the selected atom types of this model.

get_type_map()

Get the type map.

is_aparam_nall()

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

mixed_types()

If true, the model 1.

deserialize

forward_atomic

forward_common_atomic

get_model_def_script

reinit_atom_exclude

reinit_pair_exclude

serialize

atomic_output_def() FittingOutputDef[source]

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.

forward_common_atomic(extended_coord: ndarray, extended_atype: ndarray, nlist: ndarray, mapping: Optional[ndarray] = None, fparam: Optional[ndarray] = None, aparam: Optional[ndarray] = None) Dict[str, ndarray][source]
reinit_atom_exclude(exclude_types: List[int] = [])[source]
reinit_pair_exclude(exclude_types: List[Tuple[int, int]] = [])[source]
serialize() dict[source]
class deepmd.dpmodel.atomic_model.DPAtomicModel(descriptor, fitting, type_map: Optional[List[str]] = None, **kwargs)[source]

Bases: BaseAtomicModel

Model give atomic prediction of some physical property.

Parameters
descriptor

Descriptor

fitting_net

Fitting net

type_map

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

Methods

atomic_output_def()

Get the output def of the atomic model.

do_grad_(var_name, base)

Tell if the output variable var_name is differentiable.

do_grad_c([var_name])

Tell if the output variable var_name is c_differentiable.

do_grad_r([var_name])

Tell if the output variable var_name is r_differentiable.

fitting_output_def()

Get the output def of the fitting net.

forward_atomic(extended_coord, ...[, ...])

Models' atomic predictions.

get_dim_aparam()

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

get_dim_fparam()

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

get_nnei()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_nsel()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_ntypes()

Get the number of atom types.

get_rcut()

Get the cut-off radius.

get_sel()

Get the neighbor selection.

get_sel_type()

Get the selected atom types of this model.

get_type_map()

Get the type map.

is_aparam_nall()

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

mixed_types()

If true, the model 1.

deserialize

forward_common_atomic

get_model_def_script

reinit_atom_exclude

reinit_pair_exclude

serialize

classmethod deserialize(data) DPAtomicModel[source]
fitting_output_def() FittingOutputDef[source]

Get the output def of the fitting net.

forward_atomic(extended_coord: ndarray, extended_atype: ndarray, nlist: ndarray, mapping: Optional[ndarray] = None, fparam: Optional[ndarray] = None, aparam: Optional[ndarray] = None) Dict[str, ndarray][source]

Models’ atomic predictions.

Parameters
extended_coord

coodinates in extended region

extended_atype

atomic type in extended region

nlist

neighbor list. nf x nloc x nsel

mapping

mapps the extended indices to local indices. nf x nall

fparam

frame parameter. nf x ndf

aparam

atomic parameter. nf x nloc x nda

Returns
result_dict

the result dict, defined by the FittingOutputDef.

get_dim_aparam() int[source]

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

get_dim_fparam() int[source]

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

get_rcut() float[source]

Get the cut-off radius.

get_sel() List[int][source]

Get the neighbor selection.

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.

get_type_map() Optional[List[str]][source]

Get the type map.

is_aparam_nall() bool[source]

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

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

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]
class deepmd.dpmodel.atomic_model.DPZBLLinearAtomicModel(dp_model: DPAtomicModel, zbl_model: PairTabAtomicModel, sw_rmin: float, sw_rmax: float, smin_alpha: Optional[float] = 0.1, **kwargs)[source]

Bases: LinearAtomicModel

Model linearly combine a list of AtomicModels.

Parameters
models

This linear model should take a DPAtomicModel and a PairTable model.

Methods

atomic_output_def()

Get the output def of the atomic model.

do_grad_(var_name, base)

Tell if the output variable var_name is differentiable.

do_grad_c([var_name])

Tell if the output variable var_name is c_differentiable.

do_grad_r([var_name])

Tell if the output variable var_name is r_differentiable.

fitting_output_def()

Get the output def of developer implemented atomic models.

forward_atomic(extended_coord, ...[, ...])

Return atomic prediction.

get_dim_aparam()

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

get_dim_fparam()

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

get_model_nsels()

Get the processed sels for each individual models.

get_model_rcuts()

Get the cut-off radius for each individual models.

get_model_sels()

Get the sels for each individual models.

get_nnei()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_nsel()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_ntypes()

Get the number of atom types.

get_rcut()

Get the cut-off radius.

get_sel()

Returns the number of selected atoms for each type.

get_sel_type()

Get the selected atom types of this model.

get_type_map()

Get the type map.

is_aparam_nall()

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

mixed_types()

If true, the model 1.

deserialize

forward_common_atomic

get_model_def_script

reinit_atom_exclude

reinit_pair_exclude

serialize

classmethod deserialize(data) DPZBLLinearAtomicModel[source]
serialize() dict[source]
class deepmd.dpmodel.atomic_model.LinearAtomicModel(models: List[BaseAtomicModel], **kwargs)[source]

Bases: 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.

Methods

atomic_output_def()

Get the output def of the atomic model.

do_grad_(var_name, base)

Tell if the output variable var_name is differentiable.

do_grad_c([var_name])

Tell if the output variable var_name is c_differentiable.

do_grad_r([var_name])

Tell if the output variable var_name is r_differentiable.

fitting_output_def()

Get the output def of developer implemented atomic models.

forward_atomic(extended_coord, ...[, ...])

Return atomic prediction.

get_dim_aparam()

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

get_dim_fparam()

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

get_model_nsels()

Get the processed sels for each individual models.

get_model_rcuts()

Get the cut-off radius for each individual models.

get_model_sels()

Get the sels for each individual models.

get_nnei()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_nsel()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_ntypes()

Get the number of atom types.

get_rcut()

Get the cut-off radius.

get_sel()

Returns the number of selected atoms for each type.

get_sel_type()

Get the selected atom types of this model.

get_type_map()

Get the type map.

is_aparam_nall()

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

mixed_types()

If true, the model 1.

deserialize

forward_common_atomic

get_model_def_script

reinit_atom_exclude

reinit_pair_exclude

serialize

static deserialize(data) List[BaseAtomicModel][source]
fitting_output_def() FittingOutputDef[source]

Get the output def of developer implemented atomic models.

forward_atomic(extended_coord, extended_atype, nlist, mapping: Optional[ndarray] = None, fparam: Optional[ndarray] = None, aparam: Optional[ndarray] = None) Dict[str, 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.

get_dim_aparam() int[source]

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

get_dim_fparam() int[source]

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

get_model_nsels() List[int][source]

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

get_model_rcuts() List[float][source]

Get the cut-off radius for each individual models.

get_model_sels() List[Union[int, List[int]]][source]

Get the sels for each individual models.

get_rcut() float[source]

Get the cut-off radius.

get_sel() List[int][source]

Returns the number of selected atoms for each type.

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.

get_type_map() Optional[List[str]][source]

Get the type map.

is_aparam_nall() bool[source]

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

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

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.

static serialize(models) dict[source]
class deepmd.dpmodel.atomic_model.PairTabAtomicModel(tab_file: str, rcut: float, sel: Union[int, List[int]], **kwargs)[source]

Bases: 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.

Methods

atomic_output_def()

Get the output def of the atomic model.

do_grad_(var_name, base)

Tell if the output variable var_name is differentiable.

do_grad_c([var_name])

Tell if the output variable var_name is c_differentiable.

do_grad_r([var_name])

Tell if the output variable var_name is r_differentiable.

fitting_output_def()

Get the output def of developer implemented atomic models.

get_dim_aparam()

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

get_dim_fparam()

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

get_nnei()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_nsel()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_ntypes()

Get the number of atom types.

get_rcut()

Get the cut-off radius.

get_sel()

Returns the number of selected atoms for each type.

get_sel_type()

Get the selected atom types of this model.

get_type_map()

Get the type map.

is_aparam_nall()

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

mixed_types()

If true, the model 1.

deserialize

forward_atomic

forward_common_atomic

get_model_def_script

reinit_atom_exclude

reinit_pair_exclude

serialize

classmethod deserialize(data) PairTabAtomicModel[source]
fitting_output_def() FittingOutputDef[source]

Get the output def of developer implemented atomic models.

forward_atomic(extended_coord, extended_atype, nlist, mapping: Optional[ndarray] = None, fparam: Optional[ndarray] = None, aparam: Optional[ndarray] = None) Dict[str, ndarray][source]
get_dim_aparam() int[source]

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

get_dim_fparam() int[source]

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

get_nsel() int[source]

Returns the total number of selected neighboring atoms in the cut-off radius.

get_rcut() float[source]

Get the cut-off radius.

get_sel() List[int][source]

Returns the number of selected atoms for each type.

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.

get_type_map() Optional[List[str]][source]

Get the type map.

is_aparam_nall() bool[source]

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

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

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]
deepmd.dpmodel.atomic_model.make_base_atomic_model(t_tensor, fwd_method_name: str = 'forward_atomic')[source]

Make the base class for the atomic model.

Parameters
t_tensor

The type of the tensor. used in the type hint.

fwd_method_name

Name of the forward method. For dpmodels, it should be “call”. For torch models, it should be “forward”.

Submodules

deepmd.dpmodel.atomic_model.base_atomic_model module

class deepmd.dpmodel.atomic_model.base_atomic_model.BaseAtomicModel(atom_exclude_types: List[int] = [], pair_exclude_types: List[Tuple[int, int]] = [])[source]

Bases: BAM

Methods

atomic_output_def()

Get the output def of the atomic model.

do_grad_(var_name, base)

Tell if the output variable var_name is differentiable.

do_grad_c([var_name])

Tell if the output variable var_name is c_differentiable.

do_grad_r([var_name])

Tell if the output variable var_name is r_differentiable.

fitting_output_def()

Get the output def of developer implemented atomic models.

get_dim_aparam()

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

get_dim_fparam()

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

get_nnei()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_nsel()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_ntypes()

Get the number of atom types.

get_rcut()

Get the cut-off radius.

get_sel()

Returns the number of selected atoms for each type.

get_sel_type()

Get the selected atom types of this model.

get_type_map()

Get the type map.

is_aparam_nall()

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

mixed_types()

If true, the model 1.

deserialize

forward_atomic

forward_common_atomic

get_model_def_script

reinit_atom_exclude

reinit_pair_exclude

serialize

atomic_output_def() FittingOutputDef[source]

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.

forward_common_atomic(extended_coord: ndarray, extended_atype: ndarray, nlist: ndarray, mapping: Optional[ndarray] = None, fparam: Optional[ndarray] = None, aparam: Optional[ndarray] = None) Dict[str, ndarray][source]
reinit_atom_exclude(exclude_types: List[int] = [])[source]
reinit_pair_exclude(exclude_types: List[Tuple[int, int]] = [])[source]
serialize() dict[source]

deepmd.dpmodel.atomic_model.dp_atomic_model module

class deepmd.dpmodel.atomic_model.dp_atomic_model.DPAtomicModel(descriptor, fitting, type_map: Optional[List[str]] = None, **kwargs)[source]

Bases: BaseAtomicModel

Model give atomic prediction of some physical property.

Parameters
descriptor

Descriptor

fitting_net

Fitting net

type_map

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

Methods

atomic_output_def()

Get the output def of the atomic model.

do_grad_(var_name, base)

Tell if the output variable var_name is differentiable.

do_grad_c([var_name])

Tell if the output variable var_name is c_differentiable.

do_grad_r([var_name])

Tell if the output variable var_name is r_differentiable.

fitting_output_def()

Get the output def of the fitting net.

forward_atomic(extended_coord, ...[, ...])

Models' atomic predictions.

get_dim_aparam()

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

get_dim_fparam()

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

get_nnei()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_nsel()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_ntypes()

Get the number of atom types.

get_rcut()

Get the cut-off radius.

get_sel()

Get the neighbor selection.

get_sel_type()

Get the selected atom types of this model.

get_type_map()

Get the type map.

is_aparam_nall()

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

mixed_types()

If true, the model 1.

deserialize

forward_common_atomic

get_model_def_script

reinit_atom_exclude

reinit_pair_exclude

serialize

classmethod deserialize(data) DPAtomicModel[source]
fitting_output_def() FittingOutputDef[source]

Get the output def of the fitting net.

forward_atomic(extended_coord: ndarray, extended_atype: ndarray, nlist: ndarray, mapping: Optional[ndarray] = None, fparam: Optional[ndarray] = None, aparam: Optional[ndarray] = None) Dict[str, ndarray][source]

Models’ atomic predictions.

Parameters
extended_coord

coodinates in extended region

extended_atype

atomic type in extended region

nlist

neighbor list. nf x nloc x nsel

mapping

mapps the extended indices to local indices. nf x nall

fparam

frame parameter. nf x ndf

aparam

atomic parameter. nf x nloc x nda

Returns
result_dict

the result dict, defined by the FittingOutputDef.

get_dim_aparam() int[source]

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

get_dim_fparam() int[source]

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

get_rcut() float[source]

Get the cut-off radius.

get_sel() List[int][source]

Get the neighbor selection.

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.

get_type_map() Optional[List[str]][source]

Get the type map.

is_aparam_nall() bool[source]

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

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

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]

deepmd.dpmodel.atomic_model.linear_atomic_model module

class deepmd.dpmodel.atomic_model.linear_atomic_model.DPZBLLinearAtomicModel(dp_model: DPAtomicModel, zbl_model: PairTabAtomicModel, sw_rmin: float, sw_rmax: float, smin_alpha: Optional[float] = 0.1, **kwargs)[source]

Bases: LinearAtomicModel

Model linearly combine a list of AtomicModels.

Parameters
models

This linear model should take a DPAtomicModel and a PairTable model.

Methods

atomic_output_def()

Get the output def of the atomic model.

do_grad_(var_name, base)

Tell if the output variable var_name is differentiable.

do_grad_c([var_name])

Tell if the output variable var_name is c_differentiable.

do_grad_r([var_name])

Tell if the output variable var_name is r_differentiable.

fitting_output_def()

Get the output def of developer implemented atomic models.

forward_atomic(extended_coord, ...[, ...])

Return atomic prediction.

get_dim_aparam()

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

get_dim_fparam()

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

get_model_nsels()

Get the processed sels for each individual models.

get_model_rcuts()

Get the cut-off radius for each individual models.

get_model_sels()

Get the sels for each individual models.

get_nnei()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_nsel()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_ntypes()

Get the number of atom types.

get_rcut()

Get the cut-off radius.

get_sel()

Returns the number of selected atoms for each type.

get_sel_type()

Get the selected atom types of this model.

get_type_map()

Get the type map.

is_aparam_nall()

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

mixed_types()

If true, the model 1.

deserialize

forward_common_atomic

get_model_def_script

reinit_atom_exclude

reinit_pair_exclude

serialize

classmethod deserialize(data) DPZBLLinearAtomicModel[source]
serialize() dict[source]
class deepmd.dpmodel.atomic_model.linear_atomic_model.LinearAtomicModel(models: List[BaseAtomicModel], **kwargs)[source]

Bases: 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.

Methods

atomic_output_def()

Get the output def of the atomic model.

do_grad_(var_name, base)

Tell if the output variable var_name is differentiable.

do_grad_c([var_name])

Tell if the output variable var_name is c_differentiable.

do_grad_r([var_name])

Tell if the output variable var_name is r_differentiable.

fitting_output_def()

Get the output def of developer implemented atomic models.

forward_atomic(extended_coord, ...[, ...])

Return atomic prediction.

get_dim_aparam()

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

get_dim_fparam()

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

get_model_nsels()

Get the processed sels for each individual models.

get_model_rcuts()

Get the cut-off radius for each individual models.

get_model_sels()

Get the sels for each individual models.

get_nnei()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_nsel()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_ntypes()

Get the number of atom types.

get_rcut()

Get the cut-off radius.

get_sel()

Returns the number of selected atoms for each type.

get_sel_type()

Get the selected atom types of this model.

get_type_map()

Get the type map.

is_aparam_nall()

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

mixed_types()

If true, the model 1.

deserialize

forward_common_atomic

get_model_def_script

reinit_atom_exclude

reinit_pair_exclude

serialize

static deserialize(data) List[BaseAtomicModel][source]
fitting_output_def() FittingOutputDef[source]

Get the output def of developer implemented atomic models.

forward_atomic(extended_coord, extended_atype, nlist, mapping: Optional[ndarray] = None, fparam: Optional[ndarray] = None, aparam: Optional[ndarray] = None) Dict[str, 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.

get_dim_aparam() int[source]

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

get_dim_fparam() int[source]

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

get_model_nsels() List[int][source]

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

get_model_rcuts() List[float][source]

Get the cut-off radius for each individual models.

get_model_sels() List[Union[int, List[int]]][source]

Get the sels for each individual models.

get_rcut() float[source]

Get the cut-off radius.

get_sel() List[int][source]

Returns the number of selected atoms for each type.

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.

get_type_map() Optional[List[str]][source]

Get the type map.

is_aparam_nall() bool[source]

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

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

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.

static serialize(models) dict[source]

deepmd.dpmodel.atomic_model.make_base_atomic_model module

deepmd.dpmodel.atomic_model.make_base_atomic_model.make_base_atomic_model(t_tensor, fwd_method_name: str = 'forward_atomic')[source]

Make the base class for the atomic model.

Parameters
t_tensor

The type of the tensor. used in the type hint.

fwd_method_name

Name of the forward method. For dpmodels, it should be “call”. For torch models, it should be “forward”.

deepmd.dpmodel.atomic_model.pairtab_atomic_model module

class deepmd.dpmodel.atomic_model.pairtab_atomic_model.PairTabAtomicModel(tab_file: str, rcut: float, sel: Union[int, List[int]], **kwargs)[source]

Bases: 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.

Methods

atomic_output_def()

Get the output def of the atomic model.

do_grad_(var_name, base)

Tell if the output variable var_name is differentiable.

do_grad_c([var_name])

Tell if the output variable var_name is c_differentiable.

do_grad_r([var_name])

Tell if the output variable var_name is r_differentiable.

fitting_output_def()

Get the output def of developer implemented atomic models.

get_dim_aparam()

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

get_dim_fparam()

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

get_nnei()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_nsel()

Returns the total number of selected neighboring atoms in the cut-off radius.

get_ntypes()

Get the number of atom types.

get_rcut()

Get the cut-off radius.

get_sel()

Returns the number of selected atoms for each type.

get_sel_type()

Get the selected atom types of this model.

get_type_map()

Get the type map.

is_aparam_nall()

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

mixed_types()

If true, the model 1.

deserialize

forward_atomic

forward_common_atomic

get_model_def_script

reinit_atom_exclude

reinit_pair_exclude

serialize

classmethod deserialize(data) PairTabAtomicModel[source]
fitting_output_def() FittingOutputDef[source]

Get the output def of developer implemented atomic models.

forward_atomic(extended_coord, extended_atype, nlist, mapping: Optional[ndarray] = None, fparam: Optional[ndarray] = None, aparam: Optional[ndarray] = None) Dict[str, ndarray][source]
get_dim_aparam() int[source]

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

get_dim_fparam() int[source]

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

get_nsel() int[source]

Returns the total number of selected neighboring atoms in the cut-off radius.

get_rcut() float[source]

Get the cut-off radius.

get_sel() List[int][source]

Returns the number of selected atoms for each type.

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.

get_type_map() Optional[List[str]][source]

Get the type map.

is_aparam_nall() bool[source]

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

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

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]