deepmd.dpmodel#

Submodules#

Attributes#

Classes#

NativeOP

The unit operation of a native model.

DPModelCommon

FittingOutputDef

Defines the shapes and other properties of the fitting network outputs.

ModelOutputDef

Defines the shapes and other properties of the model outputs.

OutputVariableDef

Defines the shape and other properties of the one output variable.

Functions#

fitting_check_output(cls)

Check if the output of the Fitting is consistent with the definition.

get_deriv_name(→ tuple[str, str])

get_hessian_name(→ str)

get_reduce_name(→ str)

model_check_output(cls)

Check if the output of the Model is consistent with the definition.

Package Contents#

deepmd.dpmodel.DEFAULT_PRECISION = 'float64'[source]#
deepmd.dpmodel.PRECISION_DICT[source]#
class deepmd.dpmodel.NativeOP[source]#

Bases: abc.ABC

The unit operation of a native model.

abstract call(*args, **kwargs)[source]#

Forward pass in NumPy implementation.

__call__(*args, **kwargs)[source]#

Forward pass in NumPy implementation.

class deepmd.dpmodel.DPModelCommon[source]#
classmethod update_sel(train_data: deepmd.utils.data_system.DeepmdDataSystem, type_map: list[str] | None, local_jdata: dict) tuple[dict, float | None][source]#

Update the selection and perform neighbor statistics.

Parameters:
train_dataDeepmdDataSystem

data used to do neighbor statistics

type_maplist[str], optional

The name of each type of atoms

local_jdatadict

The local data refer to the current class

Returns:
dict

The updated local data

float

The minimum distance between two atoms

class deepmd.dpmodel.FittingOutputDef(var_defs: list[OutputVariableDef])[source]#

Defines the shapes and other properties of the fitting network outputs.

It is assume that the fitting network output variables for each local atom. This class defines all the outputs.

Parameters:
var_defs

List of output variable definitions.

var_defs#
__getitem__(key: str) OutputVariableDef[source]#
get_data() dict[str, OutputVariableDef][source]#
keys()[source]#
class deepmd.dpmodel.ModelOutputDef(fit_defs: FittingOutputDef)[source]#

Defines the shapes and other properties of the model outputs.

The model reduce and differentiate fitting outputs if applicable. If a variable is named by foo, then the reduced variable is called foo_redu, the derivative w.r.t. coordinates is called foo_derv_r and the derivative w.r.t. cell is called foo_derv_c.

Parameters:
fit_defs

Definition for the fitting net output

def_outp#
def_redu#
def_derv_c_redu#
def_mask#
var_defs: dict[str, OutputVariableDef]#
__getitem__(key: str) OutputVariableDef[source]#
get_data() dict[str, OutputVariableDef][source]#
keys()[source]#
keys_outp()[source]#
keys_redu()[source]#
keys_derv_r()[source]#
keys_hess_r()[source]#
keys_derv_c()[source]#
keys_derv_c_redu()[source]#
class deepmd.dpmodel.OutputVariableDef(name: str, shape: list[int], reducible: bool = False, r_differentiable: bool = False, c_differentiable: bool = False, atomic: bool = True, category: int = OutputVariableCategory.OUT.value, r_hessian: bool = False, magnetic: bool = False, intensive: bool = False)[source]#

Defines the shape and other properties of the one output variable.

It is assume that the fitting network output variables for each local atom. This class defines one output variable, including its name, shape, reducibility and differentiability.

Parameters:
name

Name of the output variable. Notice that the xxxx_redu, xxxx_derv_c, xxxx_derv_r are reserved names that should not be used to define variables.

shape

The shape of the variable. e.g. energy should be [1], dipole should be [3], polarizabilty should be [3,3].

reducible

If the variable is reduced.

r_differentiable

If the variable is differentiated with respect to coordinates of atoms. Only reducible variable are differentiable. Negative derivative w.r.t. coordinates will be calculated. (e.g. force)

c_differentiable

If the variable is differentiated with respect to the cell tensor (pbc case). Only reducible variable are differentiable. Virial, the transposed negative gradient with cell tensor times cell tensor, will be calculated, see eq 40 JCP 159, 054801 (2023).

atomicbool

If the variable is defined for each atom.

categoryint

The category of the output variable.

r_hessianbool

If hessian is required

magneticbool

If the derivatives of variable have magnetic parts.

intensivebool

It indicates whether the fitting property is intensive or extensive.

name#
shape#
output_size = 1#
atomic#
reducible#
r_differentiable#
c_differentiable#
intensive#
category#
r_hessian#
magnetic#
property size#
squeeze(dim) None[source]#
deepmd.dpmodel.fitting_check_output(cls)[source]#

Check if the output of the Fitting is consistent with the definition.

Two methods are assumed to be provided by the Fitting: 1. Fitting.output_def that gives the output definition. 2. Fitting.__call__ defines the forward path of the fitting.

deepmd.dpmodel.get_deriv_name(name: str) tuple[str, str][source]#
deepmd.dpmodel.get_hessian_name(name: str) str[source]#
deepmd.dpmodel.get_reduce_name(name: str) str[source]#
deepmd.dpmodel.model_check_output(cls)[source]#

Check if the output of the Model is consistent with the definition.

Two methods are assumed to be provided by the Model: 1. Model.output_def that gives the output definition. 2. Model.__call__ that defines the forward path of the model.