deepmd.dpmodel.utils package

class deepmd.dpmodel.utils.AtomExcludeMask(ntypes: int, exclude_types: List[int] = [])[source]

Bases: object

Computes the type exclusion mask for atoms.

Methods

build_type_exclude_mask(atype)

Compute type exclusion mask for atoms.

build_type_exclude_mask(atype: ndarray)[source]

Compute type exclusion mask for atoms.

Parameters
atype

The extended aotm types. shape: nf x natom

Returns
mask

The type exclusion mask for atoms. shape: nf x natom Element [ff,ii] being 0 if type(ii) is excluded, otherwise being 1.

deepmd.dpmodel.utils.EmbeddingNet

alias of EN

class deepmd.dpmodel.utils.EnvMat(rcut, rcut_smth)[source]

Bases: NativeOP

Methods

__call__(*args, **kwargs)

Forward pass in NumPy implementation.

call(coord_ext, atype_ext, nlist[, davg, ...])

Compute the environment matrix.

deserialize

serialize

call(coord_ext: ndarray, atype_ext: ndarray, nlist: ndarray, davg: Optional[ndarray] = None, dstd: Optional[ndarray] = None, radial_only: bool = False) ndarray[source]

Compute the environment matrix.

Parameters
nlist

The neighbor list. shape: nf x nloc x nnei

coord_ext

The extended coordinates of atoms. shape: nf x (nallx3)

atype_ext

The extended aotm types. shape: nf x nall

davg

The data avg. shape: nt x nnei x (4 or 1)

dstd

The inverse of data std. shape: nt x nnei x (4 or 1)

radial_only

Whether to only compute radial part of the environment matrix. If True, the output will be of shape nf x nloc x nnei x 1. Otherwise, the output will be of shape nf x nloc x nnei x 4. Default: False.

Returns
env_mat

The environment matrix. shape: nf x nloc x nnei x (4 or 1)

switch

The value of switch function. shape: nf x nloc x nnei

classmethod deserialize(data: dict) EnvMat[source]
serialize() dict[source]
deepmd.dpmodel.utils.FittingNet

alias of FN

class deepmd.dpmodel.utils.NativeLayer(num_in, num_out, bias: bool = True, use_timestep: bool = False, activation_function: Optional[str] = None, resnet: bool = False, precision: str = 'float64')[source]

Bases: NativeOP

Native representation of a layer.

Parameters
wnp.ndarray, optional

The weights of the layer.

bnp.ndarray, optional

The biases of the layer.

idtnp.ndarray, optional

The identity matrix of the layer.

activation_functionstr, optional

The activation function of the layer.

resnetbool, optional

Whether the layer is a residual layer.

Methods

__call__(*args, **kwargs)

Forward pass in NumPy implementation.

call(x)

Forward pass.

deserialize(data)

Deserialize the layer from a dict.

serialize()

Serialize the layer to a dict.

check_shape_consistency

check_type_consistency

dim_in

dim_out

call(x: ndarray) ndarray[source]

Forward pass.

Parameters
xnp.ndarray

The input.

Returns
np.ndarray

The output.

check_shape_consistency()[source]
check_type_consistency()[source]
classmethod deserialize(data: dict) NativeLayer[source]

Deserialize the layer from a dict.

Parameters
datadict

The dict to deserialize from.

dim_in() int[source]
dim_out() int[source]
serialize() dict[source]

Serialize the layer to a dict.

Returns
dict

The serialized layer.

deepmd.dpmodel.utils.NativeNet

alias of NN

class deepmd.dpmodel.utils.NetworkCollection(ndim: int, ntypes: int, network_type: str = 'network', networks: ~typing.List[~typing.Union[~deepmd.dpmodel.utils.network.make_multilayer_network.<locals>.NN, dict]] = [])[source]

Bases: object

A collection of networks for multiple elements.

The number of dimesions for types might be 0, 1, or 2. - 0: embedding or fitting with type embedding, in () - 1: embedding with type_one_side, or fitting, in (type_i) - 2: embedding without type_one_side, in (type_i, type_j)

Parameters
ndimint

The number of dimensions.

network_typestr, optional

The type of the network.

networksdict, optional

The networks to initialize with.

Methods

check_completeness()

Check whether the collection is complete.

deserialize(data)

Deserialize the networks from a dict.

serialize()

Serialize the networks to a dict.

NETWORK_TYPE_MAP: ClassVar[Dict[str, type]] = {'embedding_network': <class 'deepmd.dpmodel.utils.network.make_embedding_network.<locals>.EN'>, 'fitting_network': <class 'deepmd.dpmodel.utils.network.make_fitting_network.<locals>.FN'>, 'network': <class 'deepmd.dpmodel.utils.network.make_multilayer_network.<locals>.NN'>}
check_completeness()[source]

Check whether the collection is complete.

Raises
RuntimeError

If the collection is incomplete.

classmethod deserialize(data: dict) NetworkCollection[source]

Deserialize the networks from a dict.

Parameters
datadict

The dict to deserialize from.

serialize() dict[source]

Serialize the networks to a dict.

Returns
dict

The serialized networks.

class deepmd.dpmodel.utils.PairExcludeMask(ntypes: int, exclude_types: List[Tuple[int, int]] = [])[source]

Bases: object

Computes the type exclusion mask for atom pairs.

Methods

build_type_exclude_mask(nlist, atype_ext)

Compute type exclusion mask for atom pairs.

build_type_exclude_mask(nlist: ndarray, atype_ext: ndarray)[source]

Compute type exclusion mask for atom pairs.

Parameters
nlist

The neighbor list. shape: nf x nloc x nnei

atype_ext

The extended aotm types. shape: nf x nall

Returns
mask

The type exclusion mask for pair atoms of shape: nf x nloc x nnei. Element [ff,ii,jj] being 0 if type(ii), type(nlist[ff,ii,jj]) is excluded, otherwise being 1.

deepmd.dpmodel.utils.build_multiple_neighbor_list(coord: ndarray, nlist: ndarray, rcuts: List[float], nsels: List[int]) Dict[str, ndarray][source]

Input one neighbor list, and produce multiple neighbor lists with different cutoff radius and numbers of selection out of it. The required rcuts and nsels should be smaller or equal to the input nlist.

Parameters
coordnp.ndarray

exptended coordinates of shape [batch_size, nall x 3]

nlistnp.ndarray

Neighbor list of shape [batch_size, nloc, nsel], the neighbors should be stored in an ascending order.

rcutsList[float]

list of cut-off radius in ascending order.

nselsList[int]

maximal number of neighbors in ascending order.

Returns
nlist_dictDict[str, np.ndarray]

A dict of nlists, key given by get_multiple_nlist_key(rc, nsel) value being the corresponding nlist.

deepmd.dpmodel.utils.build_neighbor_list(coord1: ndarray, atype: ndarray, nloc: int, rcut: float, sel: Union[int, List[int]], distinguish_types: bool = True) ndarray[source]

Build neightbor list for a single frame. keeps nsel neighbors.

Parameters
coord1np.ndarray

exptended coordinates of shape [batch_size, nall x 3]

atypenp.ndarray

extended atomic types of shape [batch_size, nall]

nlocint

number of local atoms.

rcutfloat

cut-off radius

selint or List[int]

maximal number of neighbors (of each type). if distinguish_types==True, nsel should be list and the length of nsel should be equal to number of types.

distinguish_typesbool

distinguish different types.

Returns
neighbor_listnp.ndarray

Neighbor list of shape [batch_size, nloc, nsel], the neighbors are stored in an ascending order. If the number of neighbors is less than nsel, the positions are masked with -1. The neighbor list of an atom looks like |------ nsel ------| xx xx xx xx -1 -1 -1 if distinguish_types==True and we have two types |---- nsel[0] -----| |---- nsel[1] -----| xx xx xx xx -1 -1 -1 xx xx xx -1 -1 -1 -1

deepmd.dpmodel.utils.extend_coord_with_ghosts(coord: ndarray, atype: ndarray, cell: Optional[ndarray], rcut: float)[source]

Extend the coordinates of the atoms by appending peridoc images. The number of images is large enough to ensure all the neighbors within rcut are appended.

Parameters
coordnp.ndarray

original coordinates of shape [-1, nloc*3].

atypenp.ndarray

atom type of shape [-1, nloc].

cellnp.ndarray

simulation cell tensor of shape [-1, 9].

rcutfloat

the cutoff radius

Returns
extended_coord: np.ndarray

extended coordinates of shape [-1, nall*3].

extended_atype: np.ndarray

extended atom type of shape [-1, nall].

index_mapping: np.ndarray

maping extended index to the local index

deepmd.dpmodel.utils.get_multiple_nlist_key(rcut: float, nsel: int) str[source]
deepmd.dpmodel.utils.inter2phys(coord: ndarray, cell: ndarray) ndarray[source]

Convert internal(direct) coordinates to physical coordinates.

Parameters
coordnp.ndarray

internal coordinates of shape [*, na, 3].

cellnp.ndarray

simulation cell tensor of shape [*, 3, 3].

Returns
phys_coord: np.ndarray

the physical coordinates

deepmd.dpmodel.utils.load_dp_model(filename: str) dict[source]

Load a DP model from a file in the native format.

Parameters
filenamestr

The filename to load from.

Returns
dict

The loaded model dict, including meta information.

deepmd.dpmodel.utils.make_embedding_network(T_Network, T_NetworkLayer)[source]
deepmd.dpmodel.utils.make_fitting_network(T_EmbeddingNet, T_Network, T_NetworkLayer)[source]
deepmd.dpmodel.utils.make_multilayer_network(T_NetworkLayer, ModuleBase)[source]
deepmd.dpmodel.utils.nlist_distinguish_types(nlist: ndarray, atype: ndarray, sel: List[int])[source]

Given a nlist that does not distinguish atom types, return a nlist that distinguish atom types.

deepmd.dpmodel.utils.normalize_coord(coord: ndarray, cell: ndarray) ndarray[source]

Apply PBC according to the atomic coordinates.

Parameters
coordnp.ndarray

orignal coordinates of shape [*, na, 3].

cellnp.ndarray

simulation cell shape [*, 3, 3].

Returns
wrapped_coord: np.ndarray

wrapped coordinates of shape [*, na, 3].

deepmd.dpmodel.utils.phys2inter(coord: ndarray, cell: ndarray) ndarray[source]

Convert physical coordinates to internal(direct) coordinates.

Parameters
coordnp.ndarray

physical coordinates of shape [*, na, 3].

cellnp.ndarray

simulation cell tensor of shape [*, 3, 3].

Returns
inter_coord: np.ndarray

the internal coordinates

deepmd.dpmodel.utils.save_dp_model(filename: str, model_dict: dict) None[source]

Save a DP model to a file in the native format.

Parameters
filenamestr

The filename to save to.

model_dictdict

The model dict to save.

deepmd.dpmodel.utils.to_face_distance(cell: ndarray) ndarray[source]

Compute the to-face-distance of the simulation cell.

Parameters
cellnp.ndarray

simulation cell tensor of shape [*, 3, 3].

Returns
dist: np.ndarray

the to face distances of shape [*, 3]

deepmd.dpmodel.utils.traverse_model_dict(model_obj, callback: callable, is_variable: bool = False)[source]

Traverse a model dict and call callback on each variable.

Parameters
model_objobject

The model object to traverse.

callbackcallable()

The callback function to call on each variable.

is_variablebool, optional

Whether the current node is a variable.

Returns
object

The model object after traversing.

Submodules

deepmd.dpmodel.utils.batch_size module

class deepmd.dpmodel.utils.batch_size.AutoBatchSize(initial_batch_size: int = 1024, factor: float = 2.0)[source]

Bases: AutoBatchSize

Automatic batch size for NumPy.

Methods

execute(callable, start_index, natoms)

Excuate a method with given batch size.

execute_all(callable, total_size, natoms, ...)

Excuate a method with all given data.

is_gpu_available()

Check if GPU is available.

is_oom_error(e)

Check if the exception is an OOM error.

is_gpu_available() bool[source]

Check if GPU is available.

Returns
bool

True if GPU is available

is_oom_error(e: Exception) bool[source]

Check if the exception is an OOM error.

Parameters
eException

Exception

deepmd.dpmodel.utils.env_mat module

class deepmd.dpmodel.utils.env_mat.EnvMat(rcut, rcut_smth)[source]

Bases: NativeOP

Methods

__call__(*args, **kwargs)

Forward pass in NumPy implementation.

call(coord_ext, atype_ext, nlist[, davg, ...])

Compute the environment matrix.

deserialize

serialize

call(coord_ext: ndarray, atype_ext: ndarray, nlist: ndarray, davg: Optional[ndarray] = None, dstd: Optional[ndarray] = None, radial_only: bool = False) ndarray[source]

Compute the environment matrix.

Parameters
nlist

The neighbor list. shape: nf x nloc x nnei

coord_ext

The extended coordinates of atoms. shape: nf x (nallx3)

atype_ext

The extended aotm types. shape: nf x nall

davg

The data avg. shape: nt x nnei x (4 or 1)

dstd

The inverse of data std. shape: nt x nnei x (4 or 1)

radial_only

Whether to only compute radial part of the environment matrix. If True, the output will be of shape nf x nloc x nnei x 1. Otherwise, the output will be of shape nf x nloc x nnei x 4. Default: False.

Returns
env_mat

The environment matrix. shape: nf x nloc x nnei x (4 or 1)

switch

The value of switch function. shape: nf x nloc x nnei

classmethod deserialize(data: dict) EnvMat[source]
serialize() dict[source]
deepmd.dpmodel.utils.env_mat.compute_smooth_weight(distance: ndarray, rmin: float, rmax: float)[source]

Compute smooth weight for descriptor elements.

deepmd.dpmodel.utils.exclude_mask module

class deepmd.dpmodel.utils.exclude_mask.AtomExcludeMask(ntypes: int, exclude_types: List[int] = [])[source]

Bases: object

Computes the type exclusion mask for atoms.

Methods

build_type_exclude_mask(atype)

Compute type exclusion mask for atoms.

build_type_exclude_mask(atype: ndarray)[source]

Compute type exclusion mask for atoms.

Parameters
atype

The extended aotm types. shape: nf x natom

Returns
mask

The type exclusion mask for atoms. shape: nf x natom Element [ff,ii] being 0 if type(ii) is excluded, otherwise being 1.

class deepmd.dpmodel.utils.exclude_mask.PairExcludeMask(ntypes: int, exclude_types: List[Tuple[int, int]] = [])[source]

Bases: object

Computes the type exclusion mask for atom pairs.

Methods

build_type_exclude_mask(nlist, atype_ext)

Compute type exclusion mask for atom pairs.

build_type_exclude_mask(nlist: ndarray, atype_ext: ndarray)[source]

Compute type exclusion mask for atom pairs.

Parameters
nlist

The neighbor list. shape: nf x nloc x nnei

atype_ext

The extended aotm types. shape: nf x nall

Returns
mask

The type exclusion mask for pair atoms of shape: nf x nloc x nnei. Element [ff,ii,jj] being 0 if type(ii), type(nlist[ff,ii,jj]) is excluded, otherwise being 1.

deepmd.dpmodel.utils.neighbor_stat module

class deepmd.dpmodel.utils.neighbor_stat.NeighborStat(ntypes: int, rcut: float, mixed_type: bool = False)[source]

Bases: NeighborStat

Neighbor statistics using pure NumPy.

Parameters
ntypesint

The num of atom types

rcutfloat

The cut-off radius

mixed_typebool, optional, default=False

Treat all types as a single type.

Methods

get_stat(data)

Get the data statistics of the training data, including nearest nbor distance between atoms, max nbor size of atoms.

iterator(data)

Abstract method for producing data.

iterator(data: DeepmdDataSystem) Iterator[Tuple[ndarray, float, str]][source]

Abstract method for producing data.

Yields
np.ndarray

The maximal number of neighbors

float

The squared minimal distance between two atoms

str

The directory of the data system

class deepmd.dpmodel.utils.neighbor_stat.NeighborStatOP(ntypes: int, rcut: float, mixed_types: bool)[source]

Bases: NativeOP

Class for getting neighbor statics data information.

Parameters
ntypes

The num of atom types

rcut

The cut-off radius

mixed_typesbool, optional

If True, treat all types as a single type.

Methods

__call__(*args, **kwargs)

Forward pass in NumPy implementation.

call(coord, atype, cell)

Calculate the neareest neighbor distance between atoms, maximum nbor size of atoms and the output data range of the environment matrix.

call(coord: ndarray, atype: ndarray, cell: Optional[ndarray]) Tuple[float, ndarray][source]

Calculate the neareest neighbor distance between atoms, maximum nbor size of atoms and the output data range of the environment matrix.

Parameters
coord

The coordinates of atoms.

atype

The atom types.

cell

The cell.

Returns
float

The minimal squared distance between two atoms

np.ndarray

The maximal number of neighbors

deepmd.dpmodel.utils.network module

Native DP model format for multiple backends.

See issue #2982 for more information.

class deepmd.dpmodel.utils.network.Counter[source]

Bases: object

A callable counter.

Examples

>>> counter = Counter()
>>> counter()
0
>>> counter()
1

Methods

__call__()

Call self as a function.

deepmd.dpmodel.utils.network.EmbeddingNet

alias of EN

deepmd.dpmodel.utils.network.FittingNet

alias of FN

class deepmd.dpmodel.utils.network.NativeLayer(num_in, num_out, bias: bool = True, use_timestep: bool = False, activation_function: Optional[str] = None, resnet: bool = False, precision: str = 'float64')[source]

Bases: NativeOP

Native representation of a layer.

Parameters
wnp.ndarray, optional

The weights of the layer.

bnp.ndarray, optional

The biases of the layer.

idtnp.ndarray, optional

The identity matrix of the layer.

activation_functionstr, optional

The activation function of the layer.

resnetbool, optional

Whether the layer is a residual layer.

Methods

__call__(*args, **kwargs)

Forward pass in NumPy implementation.

call(x)

Forward pass.

deserialize(data)

Deserialize the layer from a dict.

serialize()

Serialize the layer to a dict.

check_shape_consistency

check_type_consistency

dim_in

dim_out

call(x: ndarray) ndarray[source]

Forward pass.

Parameters
xnp.ndarray

The input.

Returns
np.ndarray

The output.

check_shape_consistency()[source]
check_type_consistency()[source]
classmethod deserialize(data: dict) NativeLayer[source]

Deserialize the layer from a dict.

Parameters
datadict

The dict to deserialize from.

dim_in() int[source]
dim_out() int[source]
serialize() dict[source]

Serialize the layer to a dict.

Returns
dict

The serialized layer.

deepmd.dpmodel.utils.network.NativeNet

alias of NN

class deepmd.dpmodel.utils.network.NetworkCollection(ndim: int, ntypes: int, network_type: str = 'network', networks: ~typing.List[~typing.Union[~deepmd.dpmodel.utils.network.make_multilayer_network.<locals>.NN, dict]] = [])[source]

Bases: object

A collection of networks for multiple elements.

The number of dimesions for types might be 0, 1, or 2. - 0: embedding or fitting with type embedding, in () - 1: embedding with type_one_side, or fitting, in (type_i) - 2: embedding without type_one_side, in (type_i, type_j)

Parameters
ndimint

The number of dimensions.

network_typestr, optional

The type of the network.

networksdict, optional

The networks to initialize with.

Methods

check_completeness()

Check whether the collection is complete.

deserialize(data)

Deserialize the networks from a dict.

serialize()

Serialize the networks to a dict.

NETWORK_TYPE_MAP: ClassVar[Dict[str, type]] = {'embedding_network': <class 'deepmd.dpmodel.utils.network.make_embedding_network.<locals>.EN'>, 'fitting_network': <class 'deepmd.dpmodel.utils.network.make_fitting_network.<locals>.FN'>, 'network': <class 'deepmd.dpmodel.utils.network.make_multilayer_network.<locals>.NN'>}
check_completeness()[source]

Check whether the collection is complete.

Raises
RuntimeError

If the collection is incomplete.

classmethod deserialize(data: dict) NetworkCollection[source]

Deserialize the networks from a dict.

Parameters
datadict

The dict to deserialize from.

serialize() dict[source]

Serialize the networks to a dict.

Returns
dict

The serialized networks.

deepmd.dpmodel.utils.network.load_dp_model(filename: str) dict[source]

Load a DP model from a file in the native format.

Parameters
filenamestr

The filename to load from.

Returns
dict

The loaded model dict, including meta information.

deepmd.dpmodel.utils.network.make_embedding_network(T_Network, T_NetworkLayer)[source]
deepmd.dpmodel.utils.network.make_fitting_network(T_EmbeddingNet, T_Network, T_NetworkLayer)[source]
deepmd.dpmodel.utils.network.make_multilayer_network(T_NetworkLayer, ModuleBase)[source]
deepmd.dpmodel.utils.network.save_dp_model(filename: str, model_dict: dict) None[source]

Save a DP model to a file in the native format.

Parameters
filenamestr

The filename to save to.

model_dictdict

The model dict to save.

deepmd.dpmodel.utils.network.traverse_model_dict(model_obj, callback: callable, is_variable: bool = False)[source]

Traverse a model dict and call callback on each variable.

Parameters
model_objobject

The model object to traverse.

callbackcallable()

The callback function to call on each variable.

is_variablebool, optional

Whether the current node is a variable.

Returns
object

The model object after traversing.

deepmd.dpmodel.utils.nlist module

deepmd.dpmodel.utils.nlist.build_multiple_neighbor_list(coord: ndarray, nlist: ndarray, rcuts: List[float], nsels: List[int]) Dict[str, ndarray][source]

Input one neighbor list, and produce multiple neighbor lists with different cutoff radius and numbers of selection out of it. The required rcuts and nsels should be smaller or equal to the input nlist.

Parameters
coordnp.ndarray

exptended coordinates of shape [batch_size, nall x 3]

nlistnp.ndarray

Neighbor list of shape [batch_size, nloc, nsel], the neighbors should be stored in an ascending order.

rcutsList[float]

list of cut-off radius in ascending order.

nselsList[int]

maximal number of neighbors in ascending order.

Returns
nlist_dictDict[str, np.ndarray]

A dict of nlists, key given by get_multiple_nlist_key(rc, nsel) value being the corresponding nlist.

deepmd.dpmodel.utils.nlist.build_neighbor_list(coord1: ndarray, atype: ndarray, nloc: int, rcut: float, sel: Union[int, List[int]], distinguish_types: bool = True) ndarray[source]

Build neightbor list for a single frame. keeps nsel neighbors.

Parameters
coord1np.ndarray

exptended coordinates of shape [batch_size, nall x 3]

atypenp.ndarray

extended atomic types of shape [batch_size, nall]

nlocint

number of local atoms.

rcutfloat

cut-off radius

selint or List[int]

maximal number of neighbors (of each type). if distinguish_types==True, nsel should be list and the length of nsel should be equal to number of types.

distinguish_typesbool

distinguish different types.

Returns
neighbor_listnp.ndarray

Neighbor list of shape [batch_size, nloc, nsel], the neighbors are stored in an ascending order. If the number of neighbors is less than nsel, the positions are masked with -1. The neighbor list of an atom looks like |------ nsel ------| xx xx xx xx -1 -1 -1 if distinguish_types==True and we have two types |---- nsel[0] -----| |---- nsel[1] -----| xx xx xx xx -1 -1 -1 xx xx xx -1 -1 -1 -1

deepmd.dpmodel.utils.nlist.extend_coord_with_ghosts(coord: ndarray, atype: ndarray, cell: Optional[ndarray], rcut: float)[source]

Extend the coordinates of the atoms by appending peridoc images. The number of images is large enough to ensure all the neighbors within rcut are appended.

Parameters
coordnp.ndarray

original coordinates of shape [-1, nloc*3].

atypenp.ndarray

atom type of shape [-1, nloc].

cellnp.ndarray

simulation cell tensor of shape [-1, 9].

rcutfloat

the cutoff radius

Returns
extended_coord: np.ndarray

extended coordinates of shape [-1, nall*3].

extended_atype: np.ndarray

extended atom type of shape [-1, nall].

index_mapping: np.ndarray

maping extended index to the local index

deepmd.dpmodel.utils.nlist.get_multiple_nlist_key(rcut: float, nsel: int) str[source]
deepmd.dpmodel.utils.nlist.nlist_distinguish_types(nlist: ndarray, atype: ndarray, sel: List[int])[source]

Given a nlist that does not distinguish atom types, return a nlist that distinguish atom types.

deepmd.dpmodel.utils.region module

deepmd.dpmodel.utils.region.b_to_face_distance(cell)[source]
deepmd.dpmodel.utils.region.inter2phys(coord: ndarray, cell: ndarray) ndarray[source]

Convert internal(direct) coordinates to physical coordinates.

Parameters
coordnp.ndarray

internal coordinates of shape [*, na, 3].

cellnp.ndarray

simulation cell tensor of shape [*, 3, 3].

Returns
phys_coord: np.ndarray

the physical coordinates

deepmd.dpmodel.utils.region.normalize_coord(coord: ndarray, cell: ndarray) ndarray[source]

Apply PBC according to the atomic coordinates.

Parameters
coordnp.ndarray

orignal coordinates of shape [*, na, 3].

cellnp.ndarray

simulation cell shape [*, 3, 3].

Returns
wrapped_coord: np.ndarray

wrapped coordinates of shape [*, na, 3].

deepmd.dpmodel.utils.region.phys2inter(coord: ndarray, cell: ndarray) ndarray[source]

Convert physical coordinates to internal(direct) coordinates.

Parameters
coordnp.ndarray

physical coordinates of shape [*, na, 3].

cellnp.ndarray

simulation cell tensor of shape [*, 3, 3].

Returns
inter_coord: np.ndarray

the internal coordinates

deepmd.dpmodel.utils.region.to_face_distance(cell: ndarray) ndarray[source]

Compute the to-face-distance of the simulation cell.

Parameters
cellnp.ndarray

simulation cell tensor of shape [*, 3, 3].

Returns
dist: np.ndarray

the to face distances of shape [*, 3]

deepmd.dpmodel.utils.update_sel module

class deepmd.dpmodel.utils.update_sel.UpdateSel[source]

Bases: BaseUpdateSel

Attributes
neighbor_stat

Methods

get_min_nbor_dist

get_nbor_stat

get_rcut

get_sel

get_type_map

hook

parse_auto_sel

parse_auto_sel_ratio

update_one_sel

wrap_up_4

hook(min_nbor_dist, max_nbor_size)[source]
property neighbor_stat: Type[NeighborStat]