deepmd.dpmodel package
- class deepmd.dpmodel.DPModel(*args, **kwargs)[source]
Bases:
CM
,BaseModel
Methods
__call__
(*args, **kwargs)Forward pass in NumPy implementation.
atomic_output_def
()Get the output def of the atomic model.
call
(coord, atype[, box, fparam, aparam, ...])Return model prediction.
call_lower
(extended_coord, extended_atype, nlist)Return model prediction.
deserialize
(data)Deserialize the 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.
format_nlist
(extended_coord, extended_atype, ...)Format the neighbor list.
forward_atomic
(extended_coord, ...[, ...])Models' atomic predictions.
get_class_by_type
(class_type)Get the class by the plugin type.
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_plugins
()Get all the registered plugins.
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.
input_type_cast
(coord[, box, fparam, aparam])Cast the input data to global float type.
is_aparam_nall
()Check whether the shape of atomic parameters is (nframes, nall, ndim).
mixed_types
()If true, the model 1.
model_output_def
()Get the output def for the model.
model_output_type
()Get the output type for the model.
output_type_cast
(model_ret, input_prec)Convert the model output to the input prec.
register
(key)Register a descriptor plugin.
update_sel
(global_jdata, local_jdata)Update the selection and perform neighbor statistics.
forward_common_atomic
get_model_def_script
reinit_atom_exclude
reinit_pair_exclude
serialize
- class deepmd.dpmodel.FittingOutputDef(var_defs: List[OutputVariableDef])[source]
Bases:
object
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.
Methods
get_data
keys
- get_data() Dict[str, OutputVariableDef] [source]
- class deepmd.dpmodel.ModelOutputDef(fit_defs: FittingOutputDef)[source]
Bases:
object
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
Methods
get_data
keys
keys_derv_c
keys_derv_c_redu
keys_derv_r
keys_hess_r
keys_outp
keys_redu
- class deepmd.dpmodel.NativeOP[source]
Bases:
ABC
The unit operation of a native model.
Methods
__call__
(*args, **kwargs)Forward pass in NumPy implementation.
call
(*args, **kwargs)Forward pass in NumPy implementation.
- class deepmd.dpmodel.OutputVariableDef(name: str, shape: List[int], reduciable: bool = False, r_differentiable: bool = False, c_differentiable: bool = False, atomic: bool = True, category: int = 0, r_hessian: bool = False)[source]
Bases:
object
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].
- reduciable
If the variable is reduced.
- r_differentiable
If the variable is differentiated with respect to coordinates of atoms. Only reduciable variable are differentiable. Negative derivative w.r.t. coordinates will be calcualted. (e.g. force)
- c_differentiable
If the variable is differentiated with respect to the cell tensor (pbc case). Only reduciable 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.
- category
int
The category of the output variable.
- hessianbool
If hessian is requred
- 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.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.
Subpackages
- deepmd.dpmodel.atomic_model package
BaseAtomicModel
DPAtomicModel
DPAtomicModel.deserialize()
DPAtomicModel.fitting_output_def()
DPAtomicModel.forward_atomic()
DPAtomicModel.get_dim_aparam()
DPAtomicModel.get_dim_fparam()
DPAtomicModel.get_rcut()
DPAtomicModel.get_sel()
DPAtomicModel.get_sel_type()
DPAtomicModel.get_type_map()
DPAtomicModel.is_aparam_nall()
DPAtomicModel.mixed_types()
DPAtomicModel.serialize()
DPZBLLinearAtomicModel
LinearAtomicModel
LinearAtomicModel.deserialize()
LinearAtomicModel.fitting_output_def()
LinearAtomicModel.forward_atomic()
LinearAtomicModel.get_dim_aparam()
LinearAtomicModel.get_dim_fparam()
LinearAtomicModel.get_model_nsels()
LinearAtomicModel.get_model_rcuts()
LinearAtomicModel.get_model_sels()
LinearAtomicModel.get_rcut()
LinearAtomicModel.get_sel()
LinearAtomicModel.get_sel_type()
LinearAtomicModel.get_type_map()
LinearAtomicModel.is_aparam_nall()
LinearAtomicModel.mixed_types()
LinearAtomicModel.serialize()
PairTabAtomicModel
PairTabAtomicModel.deserialize()
PairTabAtomicModel.fitting_output_def()
PairTabAtomicModel.forward_atomic()
PairTabAtomicModel.get_dim_aparam()
PairTabAtomicModel.get_dim_fparam()
PairTabAtomicModel.get_nsel()
PairTabAtomicModel.get_rcut()
PairTabAtomicModel.get_sel()
PairTabAtomicModel.get_sel_type()
PairTabAtomicModel.get_type_map()
PairTabAtomicModel.is_aparam_nall()
PairTabAtomicModel.mixed_types()
PairTabAtomicModel.serialize()
make_base_atomic_model()
- Submodules
- deepmd.dpmodel.atomic_model.base_atomic_model module
- deepmd.dpmodel.atomic_model.dp_atomic_model module
DPAtomicModel
DPAtomicModel.deserialize()
DPAtomicModel.fitting_output_def()
DPAtomicModel.forward_atomic()
DPAtomicModel.get_dim_aparam()
DPAtomicModel.get_dim_fparam()
DPAtomicModel.get_rcut()
DPAtomicModel.get_sel()
DPAtomicModel.get_sel_type()
DPAtomicModel.get_type_map()
DPAtomicModel.is_aparam_nall()
DPAtomicModel.mixed_types()
DPAtomicModel.serialize()
- deepmd.dpmodel.atomic_model.linear_atomic_model module
DPZBLLinearAtomicModel
LinearAtomicModel
LinearAtomicModel.deserialize()
LinearAtomicModel.fitting_output_def()
LinearAtomicModel.forward_atomic()
LinearAtomicModel.get_dim_aparam()
LinearAtomicModel.get_dim_fparam()
LinearAtomicModel.get_model_nsels()
LinearAtomicModel.get_model_rcuts()
LinearAtomicModel.get_model_sels()
LinearAtomicModel.get_rcut()
LinearAtomicModel.get_sel()
LinearAtomicModel.get_sel_type()
LinearAtomicModel.get_type_map()
LinearAtomicModel.is_aparam_nall()
LinearAtomicModel.mixed_types()
LinearAtomicModel.serialize()
- deepmd.dpmodel.atomic_model.make_base_atomic_model module
- deepmd.dpmodel.atomic_model.pairtab_atomic_model module
PairTabAtomicModel
PairTabAtomicModel.deserialize()
PairTabAtomicModel.fitting_output_def()
PairTabAtomicModel.forward_atomic()
PairTabAtomicModel.get_dim_aparam()
PairTabAtomicModel.get_dim_fparam()
PairTabAtomicModel.get_nsel()
PairTabAtomicModel.get_rcut()
PairTabAtomicModel.get_sel()
PairTabAtomicModel.get_sel_type()
PairTabAtomicModel.get_type_map()
PairTabAtomicModel.is_aparam_nall()
PairTabAtomicModel.mixed_types()
PairTabAtomicModel.serialize()
- deepmd.dpmodel.descriptor package
DescrptHybrid
DescrptHybrid.call()
DescrptHybrid.compute_input_stats()
DescrptHybrid.deserialize()
DescrptHybrid.get_dim_emb()
DescrptHybrid.get_dim_out()
DescrptHybrid.get_ntypes()
DescrptHybrid.get_rcut()
DescrptHybrid.get_sel()
DescrptHybrid.mixed_types()
DescrptHybrid.serialize()
DescrptHybrid.share_params()
DescrptHybrid.update_sel()
DescrptSeA
DescrptSeA.cal_g()
DescrptSeA.call()
DescrptSeA.compute_input_stats()
DescrptSeA.deserialize()
DescrptSeA.dim_out
DescrptSeA.get_dim_emb()
DescrptSeA.get_dim_out()
DescrptSeA.get_ntypes()
DescrptSeA.get_rcut()
DescrptSeA.get_sel()
DescrptSeA.mixed_types()
DescrptSeA.reinit_exclude()
DescrptSeA.serialize()
DescrptSeA.share_params()
DescrptSeA.update_sel()
DescrptSeR
DescrptSeR.cal_g()
DescrptSeR.call()
DescrptSeR.compute_input_stats()
DescrptSeR.deserialize()
DescrptSeR.dim_out
DescrptSeR.get_dim_emb()
DescrptSeR.get_dim_out()
DescrptSeR.get_ntypes()
DescrptSeR.get_rcut()
DescrptSeR.get_sel()
DescrptSeR.mixed_types()
DescrptSeR.serialize()
DescrptSeR.share_params()
DescrptSeR.update_sel()
make_base_descriptor()
- Submodules
- deepmd.dpmodel.descriptor.base_descriptor module
- deepmd.dpmodel.descriptor.hybrid module
DescrptHybrid
DescrptHybrid.call()
DescrptHybrid.compute_input_stats()
DescrptHybrid.deserialize()
DescrptHybrid.get_dim_emb()
DescrptHybrid.get_dim_out()
DescrptHybrid.get_ntypes()
DescrptHybrid.get_rcut()
DescrptHybrid.get_sel()
DescrptHybrid.mixed_types()
DescrptHybrid.serialize()
DescrptHybrid.share_params()
DescrptHybrid.update_sel()
- deepmd.dpmodel.descriptor.make_base_descriptor module
- deepmd.dpmodel.descriptor.se_e2_a module
DescrptSeA
DescrptSeA.cal_g()
DescrptSeA.call()
DescrptSeA.compute_input_stats()
DescrptSeA.deserialize()
DescrptSeA.dim_out
DescrptSeA.get_dim_emb()
DescrptSeA.get_dim_out()
DescrptSeA.get_ntypes()
DescrptSeA.get_rcut()
DescrptSeA.get_sel()
DescrptSeA.mixed_types()
DescrptSeA.reinit_exclude()
DescrptSeA.serialize()
DescrptSeA.share_params()
DescrptSeA.update_sel()
- deepmd.dpmodel.descriptor.se_r module
DescrptSeR
DescrptSeR.cal_g()
DescrptSeR.call()
DescrptSeR.compute_input_stats()
DescrptSeR.deserialize()
DescrptSeR.dim_out
DescrptSeR.get_dim_emb()
DescrptSeR.get_dim_out()
DescrptSeR.get_ntypes()
DescrptSeR.get_rcut()
DescrptSeR.get_sel()
DescrptSeR.mixed_types()
DescrptSeR.serialize()
DescrptSeR.share_params()
DescrptSeR.update_sel()
- deepmd.dpmodel.fitting package
DipoleFitting
EnergyFittingNet
InvarFitting
PolarFitting
make_base_fitting()
- Submodules
- deepmd.dpmodel.fitting.base_fitting module
- deepmd.dpmodel.fitting.dipole_fitting module
- deepmd.dpmodel.fitting.ener_fitting module
- deepmd.dpmodel.fitting.general_fitting module
- deepmd.dpmodel.fitting.invar_fitting module
- deepmd.dpmodel.fitting.make_base_fitting module
- deepmd.dpmodel.fitting.polarizability_fitting module
- deepmd.dpmodel.infer package
- deepmd.dpmodel.model package
- deepmd.dpmodel.utils package
AtomExcludeMask
EmbeddingNet
EnvMat
FittingNet
NativeLayer
NativeNet
NetworkCollection
PairExcludeMask
build_multiple_neighbor_list()
build_neighbor_list()
extend_coord_with_ghosts()
get_multiple_nlist_key()
inter2phys()
load_dp_model()
make_embedding_network()
make_fitting_network()
make_multilayer_network()
nlist_distinguish_types()
normalize_coord()
phys2inter()
save_dp_model()
to_face_distance()
traverse_model_dict()
- Submodules
- deepmd.dpmodel.utils.batch_size module
- deepmd.dpmodel.utils.env_mat module
- deepmd.dpmodel.utils.exclude_mask module
- deepmd.dpmodel.utils.neighbor_stat module
- deepmd.dpmodel.utils.network module
- deepmd.dpmodel.utils.nlist module
- deepmd.dpmodel.utils.region module
- deepmd.dpmodel.utils.update_sel module
Submodules
deepmd.dpmodel.common module
- deepmd.dpmodel.common.GLOBAL_ENER_FLOAT_PRECISION
alias of
float64
- deepmd.dpmodel.common.GLOBAL_NP_FLOAT_PRECISION
alias of
float64
deepmd.dpmodel.output_def module
- class deepmd.dpmodel.output_def.FittingOutputDef(var_defs: List[OutputVariableDef])[source]
Bases:
object
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.
Methods
get_data
keys
- get_data() Dict[str, OutputVariableDef] [source]
- class deepmd.dpmodel.output_def.ModelOutputDef(fit_defs: FittingOutputDef)[source]
Bases:
object
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
Methods
get_data
keys
keys_derv_c
keys_derv_c_redu
keys_derv_r
keys_hess_r
keys_outp
keys_redu
- class deepmd.dpmodel.output_def.OutputVariableCategory(value)[source]
Bases:
IntEnum
Defines the category of the output variable.
- DERV_C = 4
Atomic component of the virial, see PRB 104, 224202 (2021)
- DERV_C_REDU = 5
Virial, the transposed negative gradient with cell tensor times cell tensor, see eq 40 JCP 159, 054801 (2023).
- DERV_R = 2
Negative derivative w.r.t. coordinates. (e.g. force)
- DERV_R_DERV_R = 10
Hession matrix, the second derivative w.r.t. coordinates.
- OUT = 0
Output variable. (e.g. atom energy)
- REDU = 1
Reduced output variable. (e.g. system energy)
- class deepmd.dpmodel.output_def.OutputVariableDef(name: str, shape: List[int], reduciable: bool = False, r_differentiable: bool = False, c_differentiable: bool = False, atomic: bool = True, category: int = 0, r_hessian: bool = False)[source]
Bases:
object
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].
- reduciable
If the variable is reduced.
- r_differentiable
If the variable is differentiated with respect to coordinates of atoms. Only reduciable variable are differentiable. Negative derivative w.r.t. coordinates will be calcualted. (e.g. force)
- c_differentiable
If the variable is differentiated with respect to the cell tensor (pbc case). Only reduciable 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.
- category
int
The category of the output variable.
- hessianbool
If hessian is requred
- class deepmd.dpmodel.output_def.OutputVariableOperation(value)[source]
Bases:
IntEnum
Defines the operation of the output variable.
- DERV_C = 4
Derivative w.r.t. cell.
- DERV_R = 2
Derivative w.r.t. coordinates.
- REDU = 1
Reduce the output variable.
- deepmd.dpmodel.output_def.apply_operation(var_def: OutputVariableDef, op: OutputVariableOperation) int [source]
Apply a operation to the category of a variable definition.
- Parameters
- var_def
OutputVariableDef
The variable definition.
- op
OutputVariableOperation
The operation to be applied.
- var_def
- Returns
int
The new category of the variable definition.
- Raises
ValueError
If the operation has been applied to the variable definition, and exceed the maximum limitation.
- deepmd.dpmodel.output_def.check_operation_applied(var_def: OutputVariableDef, op: OutputVariableOperation) bool [source]
Check if a operation has been applied to a variable definition.
- Parameters
- var_def
OutputVariableDef
The variable definition.
- op
OutputVariableOperation
The operation to be checked.
- var_def
- Returns
- bool
True if the operation has been applied, False otherwise.
- deepmd.dpmodel.output_def.check_shape(shape: List[int], def_shape: List[int])[source]
Check if the shape satisfies the defined shape.
- deepmd.dpmodel.output_def.do_derivative(def_outp_data: Dict[str, OutputVariableDef]) Tuple[Dict[str, OutputVariableDef], Dict[str, OutputVariableDef]] [source]
- deepmd.dpmodel.output_def.do_reduce(def_outp_data: Dict[str, OutputVariableDef]) Dict[str, OutputVariableDef] [source]
- deepmd.dpmodel.output_def.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.