Skip to content

Commit e69d279

Browse files
committed
store type_dict when initializing the calculator
1 parent 4f3ee8e commit e69d279

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

source/train/calculator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ class DP(Calculator):
3535
def __init__(self, model, label="DP", **kwargs):
3636
Calculator.__init__(self, label=label, **kwargs)
3737
self.dp = DeepPot(model)
38+
self.type_dict = dict(zip(self.dp.get_type_map(), range(self.dp.get_ntypes())))
3839

3940
def calculate(self, atoms=None, properties=["energy", "forces", "stress"], system_changes=all_changes):
4041
coord = atoms.get_positions().reshape([1, -1])
4142
cell = atoms.get_cell().reshape([1, -1])
4243
symbols = atoms.get_chemical_symbols()
43-
type_dict = dict(zip(self.dp.get_type_map(), range(self.dp.get_ntypes())))
44-
atype = [type_dict[k] for k in symbols]
44+
atype = [self.type_dict[k] for k in symbols]
4545
e, f, v = self.dp.eval(coord, cell, atype)
4646
self.results['energy'] = e[0]
4747
self.results['forces'] = f[0]

0 commit comments

Comments
 (0)