deepmd.pt.utils.ase_calc#
Classes#
Implementation of ASE deepmd calculator. |
Module Contents#
- class deepmd.pt.utils.ase_calc.DPCalculator(model: str | pathlib.Path, label: str = 'DP', type_dict: dict[str, int] | None = None, neighbor_list=None, head=None, **kwargs)#
Bases:
ase.calculators.calculator.Calculator
Implementation of ASE deepmd calculator.
Implemented properties 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.
- head
Union
[str
,None
],optional
a specific model branch choosing from pretrained model, by default None
- 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())
- name = 'DP'#
- implemented_properties: ClassVar[list[str]] = ['energy', 'free_energy', 'forces', 'virial', 'stress']#
Properties calculator can handle (energy, forces, …)
- dp#
- calculate(atoms: ase.Atoms | None = None, properties: list[str] = ['energy', 'forces', 'virial'], system_changes: list[str] = all_changes) None #
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