deepmd.common

Module Contents

Functions

add_data_requirement(key, ndof[, atomic, must, ...])

Specify data requirements for training.

select_idx_map(→ numpy.ndarray)

Build map of indices for element supplied element types from all atoms list.

make_default_mesh(→ numpy.ndarray)

Make mesh.

j_must_have(→ _DICT_VAL)

Assert that supplied dictionary conaines specified key.

j_loader(→ Dict[str, Any])

Load yaml or json settings file.

expand_sys_str(→ List[str])

Recursively iterate over directories taking those that contain type.raw file.

get_np_precision(→ numpy.dtype)

Get numpy precision constant from string.

Attributes

VALID_PRECISION

VALID_ACTIVATION

data_requirement

deepmd.common.VALID_PRECISION: Set[_PRECISION][source]
deepmd.common.VALID_ACTIVATION: Set[_ACTIVATION][source]
deepmd.common.data_requirement[source]
deepmd.common.add_data_requirement(key: str, ndof: int, atomic: bool = False, must: bool = False, high_prec: bool = False, type_sel: bool | None = None, repeat: int = 1, default: float = 0.0, dtype: numpy.dtype | None = None, output_natoms_for_type_sel: bool = False)[source]

Specify data requirements for training.

Parameters:
keystr

type of data stored in corresponding *.npy file e.g. forces or energy

ndofint

number of the degrees of freedom, this is tied to atomic parameter e.g. forces have atomic=True and ndof=3

atomicbool, optional

specifies whwther the ndof keyworrd applies to per atom quantity or not, by default False

mustbool, optional

specifi if the *.npy data file must exist, by default False

high_precbool, optional

if true load data to np.float64 else np.float32, by default False

type_selbool, optional

select only certain type of atoms, by default None

repeatint, optional

if specify repaeat data repeat times, by default 1

defaultfloat, optional, default=0.

default value of data

dtypenp.dtype, optional

the dtype of data, overwrites high_prec if provided

output_natoms_for_type_selbool, optional

if True and type_sel is True, the atomic dimension will be natoms instead of nsel

deepmd.common.select_idx_map(atom_types: numpy.ndarray, select_types: numpy.ndarray) numpy.ndarray[source]

Build map of indices for element supplied element types from all atoms list.

Parameters:
atom_typesnp.ndarray

array specifing type for each atoms as integer

select_typesnp.ndarray

types of atoms you want to find indices for

Returns:
np.ndarray

indices of types of atoms defined by select_types in atom_types array

Warning

select_types array will be sorted before finding indices in atom_types

deepmd.common.make_default_mesh(pbc: bool, mixed_type: bool) numpy.ndarray[source]

Make mesh.

Only the size of mesh matters, not the values: * 6 for PBC, no mixed types * 0 for no PBC, no mixed types * 7 for PBC, mixed types * 1 for no PBC, mixed types

Parameters:
pbcbool

if True, the mesh will be made for periodic boundary conditions

mixed_typebool

if True, the mesh will be made for mixed types

Returns:
np.ndarray

mesh

deepmd.common.j_must_have(jdata: Dict[str, _DICT_VAL], key: str, deprecated_key: List[str] = []) _DICT_VAL[source]

Assert that supplied dictionary conaines specified key.

Returns:
_DICT_VAL

value that was store unde supplied key

Raises:
RuntimeError

if the key is not present

deepmd.common.j_loader(filename: str | pathlib.Path) Dict[str, Any][source]

Load yaml or json settings file.

Parameters:
filenameUnion[str, Path]

path to file

Returns:
Dict[str, Any]

loaded dictionary

Raises:
TypeError

if the supplied file is of unsupported type

deepmd.common.expand_sys_str(root_dir: str | pathlib.Path) List[str][source]

Recursively iterate over directories taking those that contain type.raw file.

Parameters:
root_dirUnion[str, Path]

starting directory

Returns:
List[str]

list of string pointing to system directories

deepmd.common.get_np_precision(precision: _PRECISION) numpy.dtype[source]

Get numpy precision constant from string.

Parameters:
precision_PRECISION

string name of numpy constant or default

Returns:
np.dtype

numpy presicion constant

Raises:
RuntimeError

if string is invalid