deepmd package
DeePMD-kit is a package written in Python/C++, designed to minimize the effort required to build deep learning-based model of interatomic potential energy and force field and to perform molecular dynamics (MD).
The top module (deepmd.__init__) should not import any third-party modules for performance.
- deepmd.DeepPotential(*args, **kwargs)[source]
Factory function that forwards to DeepEval (for compatbility and performance).
- Parameters
- *args
positional arguments
- **kwargs
keyword arguments
- Returns
DeepEval
potentials
Subpackages
- deepmd.backend package
- Submodules
- deepmd.backend.backend module
Backend
Backend.Feature
Backend.deep_eval
Backend.deserialize_hook
Backend.detect_backend_by_model()
Backend.entry_point_hook
Backend.features
Backend.get_backend()
Backend.get_backends()
Backend.get_backends_by_feature()
Backend.is_available()
Backend.name
Backend.neighbor_stat
Backend.serialize_hook
Backend.suffixes
- deepmd.backend.dpmodel module
- deepmd.backend.pytorch module
- deepmd.backend.suffix module
- deepmd.backend.tensorflow module
- deepmd.dpmodel package
DPModel
FittingOutputDef
ModelOutputDef
NativeOP
OutputVariableDef
fitting_check_output()
get_deriv_name()
get_hessian_name()
get_reduce_name()
model_check_output()
- Subpackages
- deepmd.dpmodel.atomic_model package
BaseAtomicModel
DPAtomicModel
DPZBLLinearAtomicModel
LinearAtomicModel
PairTabAtomicModel
make_base_atomic_model()
- Submodules
- deepmd.dpmodel.atomic_model.base_atomic_model module
- deepmd.dpmodel.atomic_model.dp_atomic_model module
- deepmd.dpmodel.atomic_model.linear_atomic_model module
- deepmd.dpmodel.atomic_model.make_base_atomic_model module
- deepmd.dpmodel.atomic_model.pairtab_atomic_model module
- deepmd.dpmodel.descriptor package
- 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
- deepmd.dpmodel.atomic_model package
- Submodules
- deepmd.dpmodel.common module
- deepmd.dpmodel.output_def module
- deepmd.entrypoints package
- deepmd.infer package
DeepPot
calc_model_devi()
- Submodules
- deepmd.infer.deep_dipole module
- deepmd.infer.deep_dos module
- deepmd.infer.deep_eval module
DeepEval
DeepEvalBackend
DeepEvalBackend.eval()
DeepEvalBackend.eval_descriptor()
DeepEvalBackend.eval_typeebd()
DeepEvalBackend.get_dim_aparam()
DeepEvalBackend.get_dim_fparam()
DeepEvalBackend.get_has_efield()
DeepEvalBackend.get_ntypes()
DeepEvalBackend.get_ntypes_spin()
DeepEvalBackend.get_numb_dos()
DeepEvalBackend.get_rcut()
DeepEvalBackend.get_sel_type()
DeepEvalBackend.get_type_map()
DeepEvalBackend.model_type
- deepmd.infer.deep_polar module
- deepmd.infer.deep_pot module
- deepmd.infer.deep_tensor module
- deepmd.infer.deep_wfc module
- deepmd.infer.model_devi module
- deepmd.loggers package
- deepmd.pt package
- Subpackages
- deepmd.pt.entrypoints package
- deepmd.pt.infer package
- deepmd.pt.loss package
- deepmd.pt.model package
- deepmd.pt.optimizer package
- deepmd.pt.train package
- deepmd.pt.utils package
AtomExcludeMask
PairExcludeMask
- Submodules
- deepmd.pt.utils.ase_calc module
- deepmd.pt.utils.auto_batch_size module
- deepmd.pt.utils.cache module
- deepmd.pt.utils.dataloader module
- deepmd.pt.utils.dataset module
- deepmd.pt.utils.dp_random module
- deepmd.pt.utils.env module
- deepmd.pt.utils.env_mat_stat module
- deepmd.pt.utils.exclude_mask module
- deepmd.pt.utils.finetune module
- deepmd.pt.utils.learning_rate module
- deepmd.pt.utils.multi_task module
- deepmd.pt.utils.neighbor_stat module
- deepmd.pt.utils.nlist module
- deepmd.pt.utils.plugin module
- deepmd.pt.utils.preprocess module
- deepmd.pt.utils.region module
- deepmd.pt.utils.serialization module
- deepmd.pt.utils.stat module
- deepmd.pt.utils.update_sel module
- deepmd.pt.utils.utils module
- Subpackages
- deepmd.tf package
DeepEval
DeepEval.build_neighbor_list()
DeepEval.eval()
DeepEval.eval_descriptor()
DeepEval.eval_typeebd()
DeepEval.get_dim_aparam()
DeepEval.get_dim_fparam()
DeepEval.get_has_efield()
DeepEval.get_ntypes()
DeepEval.get_ntypes_spin()
DeepEval.get_numb_dos()
DeepEval.get_rcut()
DeepEval.get_sel_type()
DeepEval.get_type_map()
DeepEval.make_natoms_vec()
DeepEval.model_type
DeepEval.model_version
DeepEval.reverse_map()
DeepEval.sess
DeepEval.sort_input()
DeepPotential()
DipoleChargeModifier
- Subpackages
- deepmd.tf.cluster package
- deepmd.tf.descriptor package
Descriptor
DescrptHybrid
DescrptLocFrame
DescrptSeA
DescrptSeAEbd
DescrptSeAEbdV2
DescrptSeAEf
DescrptSeAEfLower
DescrptSeAMask
DescrptSeAtten
DescrptSeAttenV2
DescrptSeR
DescrptSeT
- Submodules
- deepmd.tf.descriptor.descriptor module
- deepmd.tf.descriptor.hybrid module
- deepmd.tf.descriptor.loc_frame module
- deepmd.tf.descriptor.se module
- deepmd.tf.descriptor.se_a module
- deepmd.tf.descriptor.se_a_ebd module
- deepmd.tf.descriptor.se_a_ebd_v2 module
- deepmd.tf.descriptor.se_a_ef module
- deepmd.tf.descriptor.se_a_mask module
- deepmd.tf.descriptor.se_atten module
- deepmd.tf.descriptor.se_atten_v2 module
- deepmd.tf.descriptor.se_r module
- deepmd.tf.descriptor.se_t module
- deepmd.tf.entrypoints package
compress()
convert()
doc_train_input()
freeze()
make_model_devi()
neighbor_stat()
start_dpgui()
test()
train_dp()
transfer()
- Submodules
- deepmd.tf.entrypoints.compress module
- deepmd.tf.entrypoints.convert module
- deepmd.tf.entrypoints.doc module
- deepmd.tf.entrypoints.freeze module
- deepmd.tf.entrypoints.gui module
- deepmd.tf.entrypoints.ipi module
- deepmd.tf.entrypoints.main module
- deepmd.tf.entrypoints.neighbor_stat module
- deepmd.tf.entrypoints.test module
- deepmd.tf.entrypoints.train module
- deepmd.tf.entrypoints.transfer module
- deepmd.tf.fit package
- deepmd.tf.infer package
DeepDOS
DeepDipole
DeepEval
DeepGlobalPolar
DeepPolar
DeepPot
DeepPotential()
DeepWFC
DipoleChargeModifier
EwaldRecp
calc_model_devi()
- Submodules
- deepmd.tf.infer.data_modifier module
- deepmd.tf.infer.deep_dipole module
- deepmd.tf.infer.deep_dos module
- deepmd.tf.infer.deep_eval module
- deepmd.tf.infer.deep_polar module
- deepmd.tf.infer.deep_pot module
- deepmd.tf.infer.deep_tensor module
- deepmd.tf.infer.deep_wfc module
- deepmd.tf.infer.ewald_recp module
- deepmd.tf.infer.model_devi module
- deepmd.tf.loggers package
- deepmd.tf.loss package
- deepmd.tf.model package
DOSModel
DipoleModel
EnerModel
FrozenModel
GlobalPolarModel
LinearEnergyModel
MultiModel
PairTabModel
PairwiseDPRc
PolarModel
WFCModel
- Submodules
- deepmd.tf.model.dos module
- deepmd.tf.model.ener module
- deepmd.tf.model.frozen module
- deepmd.tf.model.linear module
- deepmd.tf.model.model module
- deepmd.tf.model.model_stat module
- deepmd.tf.model.multi module
- deepmd.tf.model.pairtab module
- deepmd.tf.model.pairwise_dprc module
- deepmd.tf.model.tensor module
- deepmd.tf.nvnmd package
- deepmd.tf.op package
- deepmd.tf.train package
- deepmd.tf.utils package
DeepmdData
DeepmdDataSystem
LearningRateExp
PairTab
Plugin
PluginVariant
- Submodules
- deepmd.tf.utils.argcheck module
- deepmd.tf.utils.batch_size module
- deepmd.tf.utils.compat module
- deepmd.tf.utils.compress module
- deepmd.tf.utils.convert module
- deepmd.tf.utils.data module
- deepmd.tf.utils.data_system module
- deepmd.tf.utils.errors module
- deepmd.tf.utils.finetune module
- deepmd.tf.utils.graph module
- deepmd.tf.utils.learning_rate module
- deepmd.tf.utils.multi_init module
- deepmd.tf.utils.neighbor_stat module
- deepmd.tf.utils.network module
- deepmd.tf.utils.nlist module
- deepmd.tf.utils.pair_tab module
- deepmd.tf.utils.parallel_op module
- deepmd.tf.utils.path module
- deepmd.tf.utils.plugin module
- deepmd.tf.utils.random module
- deepmd.tf.utils.region module
- deepmd.tf.utils.serialization module
- deepmd.tf.utils.sess module
- deepmd.tf.utils.spin module
- deepmd.tf.utils.tabulate module
- deepmd.tf.utils.type_embed module
- deepmd.tf.utils.update_sel module
- deepmd.tf.utils.weight_avg module
- Submodules
- deepmd.tf.calculator module
- deepmd.tf.common module
- deepmd.tf.env module
- deepmd.tf.lmp module
- deepmd.utils package
- Submodules
- deepmd.utils.argcheck module
ArgsPlugin
descrpt_dpa2_args()
descrpt_hybrid_args()
descrpt_local_frame_args()
descrpt_se_a_args()
descrpt_se_a_ebd_v2_args()
descrpt_se_a_mask_args()
descrpt_se_a_tpe_args()
descrpt_se_atten_args()
descrpt_se_atten_common_args()
descrpt_se_atten_v2_args()
descrpt_se_r_args()
descrpt_se_t_args()
descrpt_variant_type_args()
fitting_dipole()
fitting_dos()
fitting_ener()
fitting_polar()
fitting_variant_type_args()
frozen_model_args()
gen_args()
gen_doc()
gen_json()
learning_rate_args()
learning_rate_dict_args()
learning_rate_exp()
learning_rate_variant_type_args()
limit_pref()
linear_ener_model_args()
list_to_doc()
loss_args()
loss_dict_args()
loss_dos()
loss_ener()
loss_ener_spin()
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()
multi_model_args()
normalize()
normalize_data_dict()
normalize_fitting_net_dict()
normalize_fitting_weight()
normalize_learning_rate_dict()
normalize_learning_rate_dict_with_single_learning_rate()
normalize_loss_dict()
normalize_multi_task()
pairtab_model_args()
pairwise_dprc()
spin_args()
standard_model_args()
start_pref()
training_args()
training_data_args()
type_embedding_args()
validation_data_args()
- deepmd.utils.argcheck_nvnmd module
- deepmd.utils.batch_size module
- deepmd.utils.compat module
- deepmd.utils.data module
DataRequirementItem
DeepmdData
DeepmdData.add()
DeepmdData.avg()
DeepmdData.check_batch_size()
DeepmdData.check_test_size()
DeepmdData.get_atom_type()
DeepmdData.get_batch()
DeepmdData.get_data_dict()
DeepmdData.get_item_torch()
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.reformat_data_torch()
DeepmdData.reset_get_batch()
- deepmd.utils.data_system module
DeepmdDataSystem
DeepmdDataSystem.add()
DeepmdDataSystem.add_dict()
DeepmdDataSystem.compute_energy_shift()
DeepmdDataSystem.default_mesh
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()
get_data()
print_summary()
prob_sys_size_ext()
process_sys_probs()
process_systems()
- deepmd.utils.env_mat_stat module
- deepmd.utils.errors module
- deepmd.utils.finetune module
- deepmd.utils.hostlist module
- deepmd.utils.model_stat module
- deepmd.utils.neighbor_stat module
- deepmd.utils.out_stat module
- deepmd.utils.pair_tab module
- deepmd.utils.path module
- deepmd.utils.plugin module
- deepmd.utils.random module
- deepmd.utils.summary module
- deepmd.utils.update_sel module
BaseUpdateSel
BaseUpdateSel.get_min_nbor_dist()
BaseUpdateSel.get_nbor_stat()
BaseUpdateSel.get_rcut()
BaseUpdateSel.get_sel()
BaseUpdateSel.get_type_map()
BaseUpdateSel.hook()
BaseUpdateSel.neighbor_stat
BaseUpdateSel.parse_auto_sel()
BaseUpdateSel.parse_auto_sel_ratio()
BaseUpdateSel.update_one_sel()
BaseUpdateSel.wrap_up_4()
- deepmd.utils.version module
- deepmd.utils.weight_avg module
Submodules
deepmd.calculator module
ASE calculator interface module.
- class deepmd.calculator.DP(model: Union[str, Path], label: str = 'DP', type_dict: Optional[Dict[str, int]] = None, neighbor_list=None, **kwargs)[source]
Bases:
Calculator
Implementation of ASE deepmd calculator.
Implemented propertie are energy, forces and stress
- Parameters
- model
Union
[str
,Path
] path to the model
- label
str
,optional
calculator label, by default “DP”
- type_dict
Dict
[str
,int
],optional
mapping of element types and their numbers, best left None and the calculator will infer this information from model, by default None
- neighbor_list
ase.neighborlist.NeighborList
,optional
The neighbor list object. If None, then build the native neighbor list.
- model
Examples
Compute potential energy
>>> from ase import Atoms >>> from deepmd.tf.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: Optional[Atoms] = 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: ClassVar[List[str]] = ['energy', 'free_energy', 'forces', 'virial', 'stress']
Properties calculator can handle (energy, forces, …)
- name = 'DP'
deepmd.common module
- deepmd.common.add_data_requirement(key: str, ndof: int, atomic: bool = False, must: bool = False, high_prec: bool = False, type_sel: Optional[bool] = None, repeat: int = 1, default: float = 0.0, dtype: Optional[dtype] = None, output_natoms_for_type_sel: bool = False)[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
- output_natoms_for_type_selbool,
optional
if True and type_sel is True, the atomic dimension will be natoms instead of nsel
- key
- deepmd.common.expand_sys_str(root_dir: Union[str, Path]) List[str] [source]
Recursively iterate over directories taking those that contain type.raw file.
- 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.dtype
numpy presicion constant
- Raises
RuntimeError
if string is invalid
- deepmd.common.j_loader(filename: Union[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_VAL
value that was store unde supplied key
- Raises
RuntimeError
if the key is not present
- deepmd.common.make_default_mesh(pbc: bool, mixed_type: bool) ndarray [source]
Make mesh.
Only the size of mesh matters, not the values: * 6 for PBC, no mixed types * 0 for no PBC, no mixed types * 7 for PBC, mixed types * 1 for no PBC, mixed types
- Parameters
- Returns
np.ndarray
mesh
- 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.ndarray
indices 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.driver module
deepmd.env module
- deepmd.env.GLOBAL_ENER_FLOAT_PRECISION
alias of
float64
- deepmd.env.GLOBAL_NP_FLOAT_PRECISION
alias of
float64
deepmd.main module
The entry points for DeePMD-kit.
If only printing the help message, this module does not call the main DeePMD-kit module to avoid the slow import of TensorFlow.
- class deepmd.main.BackendOption(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]
Bases:
Action
Map backend alias to unique name.
Methods
__call__
(parser, namespace, values[, ...])Call self as a function.
format_usage
- class deepmd.main.RawTextArgumentDefaultsHelpFormatter(prog, indent_increment=2, max_help_position=24, width=None)[source]
Bases:
RawTextHelpFormatter
,ArgumentDefaultsHelpFormatter
This formatter is used to print multile-line help message with default value.
Methods
format_help
()start_section
(heading)add_argument
add_arguments
add_text
add_usage
end_section
- deepmd.main.main()[source]
DeePMD-kit new entry point.
- Raises
RuntimeError
if no command was input
- deepmd.main.main_parser() ArgumentParser [source]
DeePMD-Kit commandline options argument parser.
- Returns
argparse.ArgumentParser
main parser of DeePMD-kit