deepmd.tf.modifier#
Submodules#
Classes#
Potential energy model. | |
Package Contents#
- class deepmd.tf.modifier.BaseModifier(*args: Any, **kwargs: Any)[source]#
Bases:
deepmd.tf.infer.DeepPot,make_base_modifier()Potential energy model.
- Parameters:
- model_file
Path The name of the frozen model file.
- *args
list Positional arguments.
- auto_batch_sizebool or
intorAutoBatchSize, default:True If True, automatic batch size will be used. If int, it will be used as the initial batch size.
- neighbor_list
ase.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.
- **kwargs
dict Keyword arguments.
- model_file
Examples
>>> from deepmd.infer import DeepPot >>> import numpy as np >>> dp = DeepPot("graph.pb") >>> coord = np.array([[1, 0, 0], [0, 0, 1.5], [1, 0, 3]]).reshape([1, -1]) >>> cell = np.diag(10 * np.ones(3)).reshape([1, -1]) >>> atype = [1, 0, 1] >>> e, f, v = dp.eval(coord, cell, atype)
where e, f and v are predicted energy, force and virial of the system, respectively.
- static get_params_from_frozen_model(model: deepmd.tf.infer.DeepEval) dict[source]#
- Abstractmethod:
Extract the modifier parameters from a model.
This method should extract the necessary parameters from a model to create an instance of this modifier.
- Parameters:
- model
The model from which to extract parameters
- Returns:
dictThe modifier parameters
- class deepmd.tf.modifier.DipoleChargeModifier(model_name: str, model_charge_map: list[float], sys_charge_map: list[float], ewald_h: float = 1, ewald_beta: float = 1)[source]#
Bases:
deepmd.tf.infer.deep_dipole.DeepDipoleOld,deepmd.tf.modifier.base_modifier.BaseModifier- Parameters:
- model_name
The model file for the DeepDipole model
- model_charge_map
Gives the amount of charge for the wfcc
- sys_charge_map
Gives the amount of charge for the real atoms
- ewald_h
Grid spacing of the reciprocal part of Ewald sum. Unit: A
- ewald_beta
Splitting parameter of the Ewald sum. Unit: A^{-1}
- modifier_prefix = 'dipole_charge'#
- model_name#
- model_charge_map#
- sys_charge_map#
- sel_type#
- ewald_h = 1#
- ewald_beta = 1#
- er#
- ext_dim = 3#
- t_ndesc#
- t_sela#
- sel_r#
- nnei_a#
- nnei_r#
- nnei#
- ndescrpt_a#
- ndescrpt_r#
- force = None#
- ntypes#
- classmethod deserialize(data: dict) deepmd.tf.modifier.base_modifier.BaseModifier[source]#
Deserialize the modifier.
- Parameters:
- data
dict The serialized data
- data
- Returns:
BaseModelThe deserialized modifier
- build_fv_graph() deepmd.tf.env.tf.Tensor[source]#
Build the computational graph for the force and virial inference.
- _build_fv_graph_inner() tuple[deepmd.tf.env.tf.Tensor, deepmd.tf.env.tf.Tensor, deepmd.tf.env.tf.Tensor][source]#
- eval(coord: numpy.ndarray, box: numpy.ndarray, atype: numpy.ndarray, eval_fv: bool = True) tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray][source]#
Evaluate the modification.
- Parameters:
- coord
The coordinates of atoms
- box
The simulation region. PBC is assumed
- atype
The atom types
- eval_fv
Evaluate force and virial
- Returns:
tot_eThe energy modification
tot_fThe force modification
tot_vThe virial modification
- _eval_fv(coords: numpy.ndarray, cells: numpy.ndarray, atom_types: numpy.ndarray, ext_f: numpy.ndarray) tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray][source]#
- _extend_system(coord: numpy.ndarray, box: numpy.ndarray, atype: numpy.ndarray, charge: numpy.ndarray) tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray][source]#
- modify_data(data: dict, data_sys: deepmd.tf.utils.data.DeepmdData) None[source]#
Modify data.
- Parameters:
- data
Internal data of DeepmdData. Be a dict, has the following keys - coord coordinates - box simulation box - type atom types - find_energy tells if data has energy - find_force tells if data has force - find_virial tells if data has virial - energy energy - force force - virial virial
- data_sys
DeepmdData The data system.
- static get_params_from_frozen_model(model: deepmd.tf.infer.DeepEval) dict[source]#
Extract modifier parameters from a DeepEval model.
- Parameters:
- model
DeepEval The DeepEval model instance containing the modifier tensors.
- model
- Returns:
dictDictionary containing modifier parameters: - model_name : str - model_charge_map : list[int] - sys_charge_map : list[int] - ewald_h : float - ewald_beta : float