deepmd package
Root of the deepmd package, exposes all public classes and submodules.
- class deepmd.DeepEval(model_file: Path, load_prefix: str = 'load', default_tf_graph: bool = False, auto_batch_size: bool | int | AutoBatchSize = False)[source]
Bases:
objectCommon methods for DeepPot, DeepWFC, DeepPolar, …
- Parameters:
- model_file
Path The name of the frozen model file.
- load_prefix: str
The prefix in the load computational graph
- default_tf_graphbool
If uses the default tf graph, otherwise build a new tf graph for evaluation
- auto_batch_sizebool or
intorAutomaticBatchSize, default:False If True, automatic batch size will be used. If int, it will be used as the initial batch size.
- model_file
- Attributes:
model_typeGet type of model.
model_versionGet version of model.
sessGet TF session.
Methods
Evaluate output of type embedding network by using this model.
make_natoms_vec(atom_types[, mixed_type])Make the natom vector used by deepmd-kit.
reverse_map(vec, imap)Reverse mapping of a vector according to the index map.
sort_input(coord, atom_type[, sel_atoms, ...])Sort atoms in the system according their types.
- eval_typeebd() ndarray[source]
Evaluate output of type embedding network by using this model.
- Returns:
np.ndarrayThe output of type embedding network. The shape is [ntypes, o_size], where ntypes is the number of types, and o_size is the number of nodes in the output layer.
- Raises:
KeyErrorIf the model does not enable type embedding.
See also
deepmd.utils.type_embed.TypeEmbedNetThe type embedding network.
Examples
Get the output of type embedding network of graph.pb:
>>> from deepmd.infer import DeepPotential >>> dp = DeepPotential('graph.pb') >>> dp.eval_typeebd()
- make_natoms_vec(atom_types: ndarray, mixed_type: bool = False) ndarray[source]
Make the natom vector used by deepmd-kit.
- Parameters:
- atom_types
The type of atoms
- mixed_type
Whether to perform the mixed_type mode. If True, the input data has the mixed_type format (see doc/model/train_se_atten.md), in which frames in a system may have different natoms_vec(s), with the same nloc.
- Returns:
natomsThe number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms
- static reverse_map(vec: ndarray, imap: List[int]) ndarray[source]
Reverse mapping of a vector according to the index map.
- Parameters:
- vec
Input vector. Be of shape [nframes, natoms, -1]
- imap
Index map. Be of shape [natoms]
- Returns:
vec_outReverse mapped vector.
- property sess: Session
Get TF session.
- static sort_input(coord: ndarray, atom_type: ndarray, sel_atoms: List[int] | None = None, mixed_type: bool = False)[source]
Sort atoms in the system according their types.
- Parameters:
- coord
The coordinates of atoms. Should be of shape [nframes, natoms, 3]
- atom_type
The type of atoms Should be of shape [natoms]
- sel_atoms
The selected atoms by type
- mixed_type
Whether to perform the mixed_type mode. If True, the input data has the mixed_type format (see doc/model/train_se_atten.md), in which frames in a system may have different natoms_vec(s), with the same nloc.
- Returns:
coord_outThe coordinates after sorting
atom_type_outThe atom types after sorting
idx_mapThe index mapping from the input to the output. For example coord_out = coord[:,idx_map,:]
sel_atom_typeOnly output if sel_atoms is not None The sorted selected atom types
sel_idx_mapOnly output if sel_atoms is not None The index mapping from the selected atoms to sorted selected atoms.
- deepmd.DeepPotential(model_file: str | Path, load_prefix: str = 'load', default_tf_graph: bool = False) DeepDipole | DeepGlobalPolar | DeepPolar | DeepPot | DeepWFC[source]
Factory function that will inialize appropriate potential read from model_file.
- Parameters:
- Returns:
Union[DeepDipole,DeepGlobalPolar,DeepPolar,DeepPot,DeepWFC]one of the available potentials
- Raises:
RuntimeErrorif model file does not correspond to any implementd potential
- class deepmd.DipoleChargeModifier(model_name: str, model_charge_map: List[float], sys_charge_map: List[float], ewald_h: float = 1, ewald_beta: float = 1)[source]
Bases:
DeepDipole- 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}
- Attributes:
model_typeGet type of model.
model_versionGet version of model.
sessGet TF session.
Methods
Build the computational graph for the force and virial inference.
eval(coord, box, atype[, eval_fv])Evaluate the modification.
eval_full(coords, cells, atom_types[, ...])Evaluate the model with interface similar to the energy model.
eval_typeebd()Evaluate output of type embedding network by using this model.
get_dim_aparam()Unsupported in this model.
get_dim_fparam()Unsupported in this model.
get_ntypes()Get the number of atom types of this model.
get_rcut()Get the cut-off radius of this model.
get_sel_type()Get the selected atom types of this model.
get_type_map()Get the type map (element name of the atom types) of this model.
make_natoms_vec(atom_types[, mixed_type])Make the natom vector used by deepmd-kit.
modify_data(data)Modify data.
reverse_map(vec, imap)Reverse mapping of a vector according to the index map.
sort_input(coord, atom_type[, sel_atoms, ...])Sort atoms in the system according their types.
- eval(coord: ndarray, box: ndarray, atype: ndarray, eval_fv: bool = True) Tuple[ndarray, ndarray, 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
- modify_data(data: dict) 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
Subpackages
- deepmd.cluster package
- deepmd.descriptor package
DescriptorDescriptor.build()Descriptor.build_type_exclude_mask()Descriptor.compute_input_stats()Descriptor.enable_compression()Descriptor.enable_mixed_precision()Descriptor.get_dim_out()Descriptor.get_dim_rot_mat_1()Descriptor.get_feed_dict()Descriptor.get_nlist()Descriptor.get_ntypes()Descriptor.get_rcut()Descriptor.get_tensor_names()Descriptor.init_variables()Descriptor.pass_tensors_from_frz_model()Descriptor.prod_force_virial()Descriptor.register()
DescrptHybridDescrptHybrid.build()DescrptHybrid.compute_input_stats()DescrptHybrid.enable_compression()DescrptHybrid.enable_mixed_precision()DescrptHybrid.get_dim_out()DescrptHybrid.get_nlist()DescrptHybrid.get_nlist_i()DescrptHybrid.get_ntypes()DescrptHybrid.get_rcut()DescrptHybrid.get_tensor_names()DescrptHybrid.init_variables()DescrptHybrid.merge_input_stats()DescrptHybrid.pass_tensors_from_frz_model()DescrptHybrid.prod_force_virial()
DescrptLocFrameDescrptSeADescrptSeA.build()DescrptSeA.compute_input_stats()DescrptSeA.enable_compression()DescrptSeA.enable_mixed_precision()DescrptSeA.get_dim_out()DescrptSeA.get_dim_rot_mat_1()DescrptSeA.get_nlist()DescrptSeA.get_ntypes()DescrptSeA.get_rcut()DescrptSeA.get_rot_mat()DescrptSeA.init_variables()DescrptSeA.merge_input_stats()DescrptSeA.prod_force_virial()
DescrptSeAEbdDescrptSeAEfDescrptSeAEfLowerDescrptSeAMaskDescrptSeAttenDescrptSeRDescrptSeT- Submodules
- deepmd.descriptor.descriptor module
DescriptorDescriptor.build()Descriptor.build_type_exclude_mask()Descriptor.compute_input_stats()Descriptor.enable_compression()Descriptor.enable_mixed_precision()Descriptor.get_dim_out()Descriptor.get_dim_rot_mat_1()Descriptor.get_feed_dict()Descriptor.get_nlist()Descriptor.get_ntypes()Descriptor.get_rcut()Descriptor.get_tensor_names()Descriptor.init_variables()Descriptor.pass_tensors_from_frz_model()Descriptor.prod_force_virial()Descriptor.register()
- deepmd.descriptor.hybrid module
DescrptHybridDescrptHybrid.build()DescrptHybrid.compute_input_stats()DescrptHybrid.enable_compression()DescrptHybrid.enable_mixed_precision()DescrptHybrid.get_dim_out()DescrptHybrid.get_nlist()DescrptHybrid.get_nlist_i()DescrptHybrid.get_ntypes()DescrptHybrid.get_rcut()DescrptHybrid.get_tensor_names()DescrptHybrid.init_variables()DescrptHybrid.merge_input_stats()DescrptHybrid.pass_tensors_from_frz_model()DescrptHybrid.prod_force_virial()
- deepmd.descriptor.loc_frame module
- deepmd.descriptor.se module
- deepmd.descriptor.se_a module
DescrptSeADescrptSeA.build()DescrptSeA.compute_input_stats()DescrptSeA.enable_compression()DescrptSeA.enable_mixed_precision()DescrptSeA.get_dim_out()DescrptSeA.get_dim_rot_mat_1()DescrptSeA.get_nlist()DescrptSeA.get_ntypes()DescrptSeA.get_rcut()DescrptSeA.get_rot_mat()DescrptSeA.init_variables()DescrptSeA.merge_input_stats()DescrptSeA.prod_force_virial()
- deepmd.descriptor.se_a_ebd module
- deepmd.descriptor.se_a_ef module
- deepmd.descriptor.se_a_mask module
- deepmd.descriptor.se_atten module
- deepmd.descriptor.se_r module
- deepmd.descriptor.se_t module
- deepmd.entrypoints package
compress()config()convert()doc_train_input()freeze()make_model_devi()neighbor_stat()test()train_dp()transfer()- Submodules
- deepmd.entrypoints.compress module
- deepmd.entrypoints.config module
- deepmd.entrypoints.convert module
- deepmd.entrypoints.doc module
- deepmd.entrypoints.freeze module
- deepmd.entrypoints.ipi module
- deepmd.entrypoints.main module
- deepmd.entrypoints.neighbor_stat module
- deepmd.entrypoints.test module
- deepmd.entrypoints.train module
- deepmd.entrypoints.transfer module
- deepmd.fit package
- deepmd.infer package
DeepDipoleDeepEvalDeepGlobalPolarDeepPolarDeepPotDeepPotential()DeepWFCDipoleChargeModifierEwaldRecpcalc_model_devi()- Submodules
- deepmd.infer.data_modifier module
- deepmd.infer.deep_dipole module
- deepmd.infer.deep_eval module
- deepmd.infer.deep_polar module
- deepmd.infer.deep_pot module
- deepmd.infer.deep_tensor module
- deepmd.infer.deep_wfc module
- deepmd.infer.ewald_recp module
- deepmd.infer.model_devi module
- deepmd.loggers package
- deepmd.loss package
- deepmd.model package
- deepmd.nvnmd package
- Subpackages
- deepmd.nvnmd.data package
- deepmd.nvnmd.descriptor package
- deepmd.nvnmd.entrypoints package
- deepmd.nvnmd.fit package
- deepmd.nvnmd.utils package
EncodeFioBinFioDicFioTxtget_filter_weight()get_fitnet_weight()map_nvnmd()nvnmd_args()one_layer()- Submodules
- deepmd.nvnmd.utils.argcheck module
- deepmd.nvnmd.utils.config module
- deepmd.nvnmd.utils.encode module
- deepmd.nvnmd.utils.fio module
- deepmd.nvnmd.utils.network module
- deepmd.nvnmd.utils.op module
- deepmd.nvnmd.utils.weight module
- Subpackages
- deepmd.op package
- deepmd.train package
- deepmd.utils package
DeepmdDataDeepmdData.add()DeepmdData.avg()DeepmdData.check_batch_size()DeepmdData.check_test_size()DeepmdData.get_atom_type()DeepmdData.get_batch()DeepmdData.get_data_dict()DeepmdData.get_natoms()DeepmdData.get_natoms_vec()DeepmdData.get_ntypes()DeepmdData.get_numb_batch()DeepmdData.get_numb_set()DeepmdData.get_sys_numb_batch()DeepmdData.get_test()DeepmdData.get_type_map()DeepmdData.reduce()DeepmdData.reset_get_batch()
DeepmdDataSystemDeepmdDataSystem.add()DeepmdDataSystem.add_dict()DeepmdDataSystem.compute_energy_shift()DeepmdDataSystem.get_batch()DeepmdDataSystem.get_batch_mixed()DeepmdDataSystem.get_batch_size()DeepmdDataSystem.get_batch_standard()DeepmdDataSystem.get_data_dict()DeepmdDataSystem.get_nbatches()DeepmdDataSystem.get_nsystems()DeepmdDataSystem.get_ntypes()DeepmdDataSystem.get_sys()DeepmdDataSystem.get_sys_ntest()DeepmdDataSystem.get_test()DeepmdDataSystem.get_type_map()DeepmdDataSystem.print_summary()DeepmdDataSystem.reduce()DeepmdDataSystem.set_sys_probs()
LearningRateExpPairTabPluginPluginVariant- Submodules
- deepmd.utils.argcheck module
ArgsPlugindescrpt_hybrid_args()descrpt_local_frame_args()descrpt_se_a_args()descrpt_se_a_mask_args()descrpt_se_a_tpe_args()descrpt_se_atten_args()descrpt_se_r_args()descrpt_se_t_args()descrpt_variant_type_args()fitting_dipole()fitting_ener()fitting_polar()fitting_variant_type_args()gen_args()gen_doc()gen_json()learning_rate_args()learning_rate_dict_args()learning_rate_exp()learning_rate_variant_type_args()limit_pref()list_to_doc()loss_args()loss_dict_args()loss_ener()loss_tensor()loss_variant_type_args()make_index()make_link()mixed_precision_args()model_args()model_compression()model_compression_type_args()modifier_dipole_charge()modifier_variant_type_args()normalize()normalize_data_dict()normalize_fitting_net_dict()normalize_fitting_weight()normalize_hybrid_list()normalize_learning_rate_dict()normalize_learning_rate_dict_with_single_learning_rate()normalize_loss_dict()normalize_multi_task()start_pref()training_args()training_data_args()type_embedding_args()validation_data_args()
- deepmd.utils.batch_size module
- deepmd.utils.compat module
- deepmd.utils.convert module
- deepmd.utils.data module
DeepmdDataDeepmdData.add()DeepmdData.avg()DeepmdData.check_batch_size()DeepmdData.check_test_size()DeepmdData.get_atom_type()DeepmdData.get_batch()DeepmdData.get_data_dict()DeepmdData.get_natoms()DeepmdData.get_natoms_vec()DeepmdData.get_ntypes()DeepmdData.get_numb_batch()DeepmdData.get_numb_set()DeepmdData.get_sys_numb_batch()DeepmdData.get_test()DeepmdData.get_type_map()DeepmdData.reduce()DeepmdData.reset_get_batch()
- deepmd.utils.data_system module
DeepmdDataSystemDeepmdDataSystem.add()DeepmdDataSystem.add_dict()DeepmdDataSystem.compute_energy_shift()DeepmdDataSystem.get_batch()DeepmdDataSystem.get_batch_mixed()DeepmdDataSystem.get_batch_size()DeepmdDataSystem.get_batch_standard()DeepmdDataSystem.get_data_dict()DeepmdDataSystem.get_nbatches()DeepmdDataSystem.get_nsystems()DeepmdDataSystem.get_ntypes()DeepmdDataSystem.get_sys()DeepmdDataSystem.get_sys_ntest()DeepmdDataSystem.get_test()DeepmdDataSystem.get_type_map()DeepmdDataSystem.print_summary()DeepmdDataSystem.reduce()DeepmdDataSystem.set_sys_probs()
- deepmd.utils.errors module
- deepmd.utils.finetune module
- deepmd.utils.graph module
get_attention_layer_nodes_from_graph_def()get_attention_layer_variables_from_graph_def()get_embedding_net_nodes()get_embedding_net_nodes_from_graph_def()get_embedding_net_variables()get_embedding_net_variables_from_graph_def()get_fitting_net_nodes()get_fitting_net_nodes_from_graph_def()get_fitting_net_variables()get_fitting_net_variables_from_graph_def()get_pattern_nodes_from_graph_def()get_tensor_by_name()get_tensor_by_name_from_graph()get_tensor_by_type()get_type_embedding_net_nodes_from_graph_def()get_type_embedding_net_variables_from_graph_def()load_graph_def()
- deepmd.utils.learning_rate module
- deepmd.utils.multi_init module
- deepmd.utils.neighbor_stat module
- deepmd.utils.network module
- deepmd.utils.pair_tab module
- deepmd.utils.parallel_op module
- deepmd.utils.path module
- deepmd.utils.plugin module
- deepmd.utils.random module
- deepmd.utils.sess module
- deepmd.utils.tabulate module
- deepmd.utils.type_embed module
- deepmd.utils.weight_avg module
Submodules
deepmd.calculator module
ASE calculator interface module.
- class deepmd.calculator.DP(model: str | Path, label: str = 'DP', type_dict: Dict[str, int] | None = None, **kwargs)[source]
Bases:
CalculatorImplementation of ASE deepmd calculator.
Implemented propertie are energy, forces and stress
- Parameters:
Examples
Compute potential energy
>>> from ase import Atoms >>> from deepmd.calculator import DP >>> water = Atoms('H2O', >>> positions=[(0.7601, 1.9270, 1), >>> (1.9575, 1, 1), >>> (1., 1., 1.)], >>> cell=[100, 100, 100], >>> calculator=DP(model="frozen_model.pb")) >>> print(water.get_potential_energy()) >>> print(water.get_forces())
Run BFGS structure optimization
>>> from ase.optimize import BFGS >>> dyn = BFGS(water) >>> dyn.run(fmax=1e-6) >>> print(water.get_positions())
- Attributes:
- directory
- label
Methods
band_structure()Create band-structure object for plotting.
calculate([atoms, properties, system_changes])Run calculation with deepmd model.
calculate_numerical_forces(atoms[, d])Calculate numerical forces using finite difference.
calculate_numerical_stress(atoms[, d, voigt])Calculate numerical stress using finite difference.
calculate_properties(atoms, properties)This method is experimental; currently for internal use.
check_state(atoms[, tol])Check for any system changes since last calculation.
get_magnetic_moments([atoms])Calculate magnetic moments projected onto atoms.
get_property(name[, atoms, allow_calculation])Get the named property.
get_stresses([atoms])the calculator should return intensive stresses, i.e., such that stresses.sum(axis=0) == stress
read(label)Read atoms, parameters and calculated properties from output file.
reset()Clear all information from old calculation.
set(**kwargs)Set parameters like set(key1=value1, key2=value2, ...).
set_label(label)Set label and convert label to directory and prefix.
calculation_required
export_properties
get_atoms
get_charges
get_default_parameters
get_dipole_moment
get_forces
get_magnetic_moment
get_potential_energies
get_potential_energy
get_stress
read_atoms
todict
- calculate(atoms: Atoms | None = None, properties: List[str] = ['energy', 'forces', 'virial'], system_changes: List[str] = ['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])[source]
Run calculation with deepmd model.
- Parameters:
- atoms
Optional[Atoms],optional atoms object to run the calculation on, by default None
- properties
List[str],optional unused, only for function signature compatibility, by default [“energy”, “forces”, “stress”]
- system_changes
List[str],optional unused, only for function signature compatibility, by default all_changes
- atoms
- implemented_properties: List[str] = ['energy', 'free_energy', 'forces', 'virial', 'stress']
Properties calculator can handle (energy, forces, …)
- name = 'DP'
deepmd.common module
Collection of functions and classes used throughout the whole package.
- deepmd.common.add_data_requirement(key: str, ndof: int, atomic: bool = False, must: bool = False, high_prec: bool = False, type_sel: bool | None = None, repeat: int = 1, default: float = 0.0, dtype: dtype | None = None)[source]
Specify data requirements for training.
- Parameters:
- key
str type of data stored in corresponding *.npy file e.g. forces or energy
- ndof
int number of the degrees of freedom, this is tied to atomic parameter e.g. forces have atomic=True and ndof=3
- atomicbool,
optional specifies whwther the ndof keyworrd applies to per atom quantity or not, by default False
- mustbool,
optional specifi if the *.npy data file must exist, by default False
- high_precbool,
optional if true load data to np.float64 else np.float32, by default False
- type_selbool,
optional select only certain type of atoms, by default None
- repeat
int,optional if specify repaeat data repeat times, by default 1
- default
float,optional, default=0. default value of data
- dtype
np.dtype,optional the dtype of data, overwrites high_prec if provided
- key
- deepmd.common.cast_precision(func: Callable) Callable[source]
A decorator that casts and casts back the input and output tensor of a method.
The decorator should be used in a classmethod.
The decorator will do the following thing: (1) It casts input Tensors from GLOBAL_TF_FLOAT_PRECISION to precision defined by property precision. (2) It casts output Tensors from precision to GLOBAL_TF_FLOAT_PRECISION. (3) It checks inputs and outputs and only casts when input or output is a Tensor and its dtype matches GLOBAL_TF_FLOAT_PRECISION and precision, respectively. If it does not match (e.g. it is an integer), the decorator will do nothing on it.
- Returns:
Callablea decorator that casts and casts back the input and output tensor of a method
Examples
>>> class A: ... @property ... def precision(self): ... return tf.float32 ... ... @cast_precision ... def f(x: tf.Tensor, y: tf.Tensor) -> tf.Tensor: ... return x ** 2 + y
- deepmd.common.expand_sys_str(root_dir: str | Path) List[str][source]
Recursively iterate over directories taking those that contain type.raw file.
- deepmd.common.gelu(x: Tensor) Tensor[source]
Gaussian Error Linear Unit.
This is a smoother version of the RELU, implemented by custom operator.
- Parameters:
- x
tf.Tensor float Tensor to perform activation
- x
- Returns:
tf.Tensorx with the GELU activation applied
References
Original paper https://arxiv.org/abs/1606.08415
- deepmd.common.gelu_tf(x: Tensor) Tensor[source]
Gaussian Error Linear Unit.
This is a smoother version of the RELU, implemented by TF.
- Parameters:
- x
tf.Tensor float Tensor to perform activation
- x
- Returns:
tf.Tensorx with the GELU activation applied
References
Original paper https://arxiv.org/abs/1606.08415
- deepmd.common.get_activation_func(activation_fn: _ACTIVATION | None) Callable[[Tensor], Tensor] | None[source]
Get activation function callable based on string name.
- Parameters:
- activation_fn
_ACTIVATION one of the defined activation functions
- activation_fn
- Returns:
- Raises:
RuntimeErrorif unknown activation function is specified
- deepmd.common.get_np_precision(precision: _PRECISION) dtype[source]
Get numpy precision constant from string.
- Parameters:
- precision
_PRECISION string name of numpy constant or default
- precision
- Returns:
np.dtypenumpy presicion constant
- Raises:
RuntimeErrorif string is invalid
- deepmd.common.get_precision(precision: _PRECISION) Any[source]
Convert str to TF DType constant.
- Parameters:
- precision
_PRECISION one of the allowed precisions
- precision
- Returns:
tf.python.framework.dtypes.DTypeappropriate TF constant
- Raises:
RuntimeErrorif supplied precision string does not have acorresponding TF constant
- deepmd.common.j_loader(filename: str | Path) Dict[str, Any][source]
Load yaml or json settings file.
- deepmd.common.j_must_have(jdata: Dict[str, _DICT_VAL], key: str, deprecated_key: List[str] = []) _DICT_VAL[source]
Assert that supplied dictionary conaines specified key.
- Returns:
_DICT_VALvalue that was store unde supplied key
- Raises:
RuntimeErrorif the key is not present
- deepmd.common.make_default_mesh(test_box: ndarray, cell_size: float = 3.0) ndarray[source]
Get number of cells of size=`cell_size` fit into average box.
- Parameters:
- test_box
np.ndarray numpy array with cells of shape Nx9
- cell_size
float,optional length of one cell, by default 3.0
- test_box
- Returns:
np.ndarraymesh for supplied boxes, how many cells fit in each direction
- deepmd.common.safe_cast_tensor(input: Tensor, from_precision: DType, to_precision: DType) Tensor[source]
Convert a Tensor from a precision to another precision.
If input is not a Tensor or without the specific precision, the method will not cast it.
- deepmd.common.select_idx_map(atom_types: ndarray, select_types: ndarray) ndarray[source]
Build map of indices for element supplied element types from all atoms list.
- Parameters:
- atom_types
np.ndarray array specifing type for each atoms as integer
- select_types
np.ndarray types of atoms you want to find indices for
- atom_types
- Returns:
np.ndarrayindices of types of atoms defined by select_types in atom_types array
Warning
select_types array will be sorted before finding indices in atom_types
deepmd.env module
Module that sets tensorflow working environment and exports inportant constants.
- deepmd.env.GLOBAL_ENER_FLOAT_PRECISION
alias of
float64
- deepmd.env.GLOBAL_NP_FLOAT_PRECISION
alias of
float64
- deepmd.env.global_cvt_2_ener_float(xx: Tensor) Tensor[source]
Cast tensor to globally set energy precision.
deepmd.lmp module
Register entry points for lammps-wheel.
- deepmd.lmp.get_env(paths: List[str | None]) str[source]
Get the environment variable from given paths.