deepmd.dpmodel.infer.deep_eval

Module Contents

Classes

DeepEval

NumPy backend implementaion of DeepEval.

class deepmd.dpmodel.infer.deep_eval.DeepEval(model_file: str, output_def: deepmd.dpmodel.output_def.ModelOutputDef, *args: List[Any], auto_batch_size: bool | int | deepmd.dpmodel.utils.batch_size.AutoBatchSize = True, neighbor_list: ase.neighborlist.NewPrimitiveNeighborList | None = None, **kwargs: Dict[str, Any])[source]

Bases: deepmd.infer.deep_eval.DeepEvalBackend

NumPy backend implementaion of DeepEval.

Parameters:
model_filePath

The name of the frozen model file.

output_defModelOutputDef

The output definition of the model.

*argslist

Positional arguments.

auto_batch_sizebool or int or AutomaticBatchSize, default: False

If True, automatic batch size will be used. If int, it will be used as the initial batch size.

neighbor_listase.neighborlist.NewPrimitiveNeighborList, optional

The ASE neighbor list class to produce the neighbor list. If None, the neighbor list will be built natively in the model.

**kwargsdict

Keyword arguments.

property model_type: Type[deepmd.infer.deep_eval.DeepEval][source]

The the evaluator of the model type.

get_rcut() float[source]

Get the cutoff radius of this model.

get_ntypes() int[source]

Get the number of atom types of this model.

get_type_map() List[str][source]

Get the type map (element name of the atom types) of this model.

get_dim_fparam() int[source]

Get the number (dimension) of frame parameters of this DP.

get_dim_aparam() int[source]

Get the number (dimension) of atomic parameters of this DP.

get_sel_type() List[int][source]

Get the selected atom types of this model.

Only atoms with selected atom types have atomic contribution to the result of the model. If returning an empty list, all atom types are selected.

get_numb_dos() int[source]

Get the number of DOS.

get_has_efield()[source]

Check if the model has efield.

get_ntypes_spin()[source]

Get the number of spin atom types of this model.

eval(coords: numpy.ndarray, cells: numpy.ndarray, atom_types: numpy.ndarray, atomic: bool = False, fparam: numpy.ndarray | None = None, aparam: numpy.ndarray | None = None, **kwargs: Dict[str, Any]) Dict[str, numpy.ndarray][source]

Evaluate the energy, force and virial by using this DP.

Parameters:
coords

The coordinates of atoms. The array should be of size nframes x natoms x 3

cells

The cell of the region. If None then non-PBC is assumed, otherwise using PBC. The array should be of size nframes x 9

atom_types

The atom types The list should contain natoms ints

atomic

Calculate the atomic energy and virial

fparam

The frame parameter. The array can be of size : - nframes x dim_fparam. - dim_fparam. Then all frames are assumed to be provided with the same fparam.

aparam

The atomic parameter The array can be of size : - nframes x natoms x dim_aparam. - natoms x dim_aparam. Then all frames are assumed to be provided with the same aparam. - dim_aparam. Then all frames and atoms are provided with the same aparam.

**kwargs

Other parameters

Returns:
output_dictdict

The output of the evaluation. The keys are the names of the output variables, and the values are the corresponding output arrays.

_get_request_defs(atomic: bool) List[deepmd.dpmodel.output_def.OutputVariableDef][source]

Get the requested output definitions.

When atomic is True, all output_def are requested. When atomic is False, only energy (tensor), force, and virial are requested.

Parameters:
atomicbool

Whether to request the atomic output.

Returns:
list[OutputVariableDef]

The requested output definitions.

_eval_func(inner_func: Callable, numb_test: int, natoms: int) Callable[source]

Wrapper method with auto batch size.

Parameters:
inner_funcCallable

the method to be wrapped

numb_testint

number of tests

natomsint

number of atoms

Returns:
Callable

the wrapper

_get_natoms_and_nframes(coords: numpy.ndarray, atom_types: numpy.ndarray, mixed_type: bool = False) Tuple[int, int][source]
_eval_model(coords: numpy.ndarray, cells: numpy.ndarray | None, atom_types: numpy.ndarray, request_defs: List[deepmd.dpmodel.output_def.OutputVariableDef])[source]
_get_output_shape(odef, nframes, natoms)[source]