deepmd.pd.model.atomic_model.dp_atomic_model#
Attributes#
Classes#
Model give atomic prediction of some physical property. |
Module Contents#
- class deepmd.pd.model.atomic_model.dp_atomic_model.DPAtomicModel(descriptor: deepmd.pd.model.descriptor.base_descriptor.BaseDescriptor, fitting: deepmd.pd.model.task.base_fitting.BaseFitting, type_map: list[str], **kwargs: Any)[source]#
Bases:
deepmd.pd.model.atomic_model.base_atomic_model.BaseAtomicModelModel give atomic prediction of some physical property.
- Parameters:
- descriptor
Descriptor
- fitting_net
Fitting net
- type_map
Mapping atom type to the name (str) of the type. For example type_map[1] gives the name of the type 1.
- set_eval_descriptor_hook(enable: bool) None[source]#
Set the hook for evaluating descriptor and clear the cache for descriptor list.
- set_eval_fitting_last_layer_hook(enable: bool) None[source]#
Set the hook for evaluating fitting last layer output and clear the cache for fitting last layer output list.
- fitting_output_def() deepmd.dpmodel.FittingOutputDef[source]#
Get the output def of the fitting net.
- get_buffer_type_map() paddle.Tensor[source]#
Return the type map as a buffer-style Tensor for JIT saving.
The original type map (e.g., [‘Ni’, ‘O’]) is first joined into a single space-separated string (e.g., “Ni O”). Each character in this string is then converted to its ASCII code using ord(), and the resulting integer sequence is stored as a 1D paddle.Tensor of dtype int.
This format allows the type map to be serialized as a raw byte buffer during JIT model saving.
- set_case_embd(case_idx: int) None[source]#
Set the case embedding of this atomic model by the given case_idx, typically concatenated with the output of the descriptor and fed into the fitting net.
- mixed_types() bool[source]#
If true, the model 1. assumes total number of atoms aligned across frames; 2. uses a neighbor list that does not distinguish different atomic types.
If false, the model 1. assumes total number of atoms of each atom type aligned across frames; 2. uses a neighbor list that distinguishes different atomic types.
- change_type_map(type_map: list[str], model_with_new_type_stat: DPAtomicModel | None = None) None[source]#
Change the type related params to new ones, according to type_map and the original one in the model. If there are new types in type_map, statistics will be updated accordingly to model_with_new_type_stat for these new types.
- need_sorted_nlist_for_lower() bool[source]#
Returns whether the atomic model needs sorted nlist when using forward_lower.
- classmethod deserialize(data: dict) DPAtomicModel[source]#
- enable_compression(min_nbor_dist: float, table_extrapolate: float = 5, table_stride_1: float = 0.01, table_stride_2: float = 0.1, check_frequency: int = -1) None[source]#
Call descriptor enable_compression().
- Parameters:
- min_nbor_dist
The nearest distance between atoms
- table_extrapolate
The scale of model extrapolation
- table_stride_1
The uniform stride of the first table
- table_stride_2
The uniform stride of the second table
- check_frequency
The overflow check frequency
- forward_atomic(extended_coord: paddle.Tensor, extended_atype: paddle.Tensor, nlist: paddle.Tensor, mapping: paddle.Tensor | None = None, fparam: paddle.Tensor | None = None, aparam: paddle.Tensor | None = None, comm_dict: dict[str, paddle.Tensor] | None = None) dict[str, paddle.Tensor][source]#
Return atomic prediction.
- Parameters:
- extended_coord
coordinates in extended region
- extended_atype
atomic type in extended region
- nlist
neighbor list. nf x nloc x nsel
- mapping
mapps the extended indices to local indices
- fparam
frame parameter. nf x ndf
- aparam
atomic parameter. nf x nloc x nda
- Returns:
result_dictthe result dict, defined by the FittingOutputDef.
- compute_or_load_stat(sampled_func: collections.abc.Callable[[], list[dict]], stat_file_path: deepmd.utils.path.DPPath | None = None, compute_or_load_out_stat: bool = True) None[source]#
Compute or load the statistics parameters of the model, such as mean and standard deviation of descriptors or the energy bias of the fitting net. When sampled is provided, all the statistics parameters will be calculated (or re-calculated for update), and saved in the stat_file_path`(s). When `sampled is not provided, it will check the existence of `stat_file_path`(s) and load the calculated statistics parameters.
- Parameters:
- sampled_func
The lazy sampled function to get data frames from different data systems.
- stat_file_path
The dictionary of paths to the statistics files.
- compute_or_load_out_statbool
Whether to compute the output statistics. If False, it will only compute the input statistics (e.g. mean and standard deviation of descriptors).
- compute_fitting_input_stat(sample_merged: collections.abc.Callable[[], list[dict]] | list[dict], stat_file_path: deepmd.utils.path.DPPath | None = None) None[source]#
Compute the input statistics (e.g. mean and stddev) for the fittings from packed data.
- Parameters:
- sample_merged
Union[Callable[[],list[dict]],list[dict]] - list[dict]: A list of data samples from various data systems.
Each element, merged[i], is a data dictionary containing keys: paddle.Tensor originating from the i-th data system.
- Callable[[], list[dict]]: A lazy function that returns data samples in the above format
only when needed. Since the sampling process can be slow and memory-intensive, the lazy function helps by only sampling once.
- stat_file_path
Optional[DPPath] The dictionary of paths to the statistics files.
- sample_merged
- get_buffer_dim_fparam() paddle.Tensor[source]#
Get the number (dimension) of frame parameters of this atomic model as a buffer-style Tensor.
- get_buffer_dim_aparam() paddle.Tensor[source]#
Get the number (dimension) of atomic parameters of this atomic model as a buffer-style Tensor.