deepmd_utils package

Untilization methods for DeePMD-kit.

The __init__ module should not import any modules for performance.

Subpackages

Submodules

deepmd_utils.common module

deepmd_utils.common.add_data_requirement(key: str, ndof: int, atomic: bool = False, must: bool = False, high_prec: bool = False, type_sel: Optional[bool] = None, repeat: int = 1, default: float = 0.0, dtype: Optional[dtype] = None)[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

deepmd_utils.common.expand_sys_str(root_dir: Union[str, 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_utils.common.get_np_precision(precision: _PRECISION) 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

deepmd_utils.common.j_loader(filename: Union[str, 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_utils.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_utils.common.make_default_mesh(pbc: bool, mixed_type: bool) 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_utils.common.select_idx_map(atom_types: ndarray, select_types: ndarray) 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_utils.env module

deepmd_utils.env.GLOBAL_ENER_FLOAT_PRECISION

alias of float64

deepmd_utils.env.GLOBAL_NP_FLOAT_PRECISION

alias of float64

deepmd_utils.main module

The entry points for DeePMD-kit.

If only printing the help message, this module does not call the main DeePMD-kit module to avoid the slow import of TensorFlow.

class deepmd_utils.main.RawTextArgumentDefaultsHelpFormatter(prog, indent_increment=2, max_help_position=24, width=None)[source]

Bases: RawTextHelpFormatter, ArgumentDefaultsHelpFormatter

This formatter is used to print multile-line help message with default value.

Methods

format_help()

start_section(heading)

add_argument

add_arguments

add_text

add_usage

end_section

deepmd_utils.main.get_ll(log_level: str) int[source]

Convert string to python logging level.

Parameters
log_levelstr

allowed input values are: DEBUG, INFO, WARNING, ERROR, 3, 2, 1, 0

Returns
int

one of python logging module log levels - 10, 20, 30 or 40

deepmd_utils.main.main()[source]

DeePMD-kit new entry point.

Raises
RuntimeError

if no command was input

deepmd_utils.main.main_parser() ArgumentParser[source]

DeePMD-Kit commandline options argument parser.

Returns
argparse.ArgumentParser

main parser of DeePMD-kit

deepmd_utils.main.parse_args(args: Optional[List[str]] = None) Namespace[source]

Parse arguments and convert argument strings to objects.

Parameters
argsList[str]

list of command line arguments, main purpose is testing default option None takes arguments from sys.argv

Returns
argparse.Namespace

the populated namespace