Skip to content

Commit b4669a5

Browse files
committed
refactor with new plugin system
continue on deepmodeling#115
1 parent 325bf87 commit b4669a5

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

dpdata/plugins/ase.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from dpdata.format import Format
2+
import dpdata.ase.db
23

34

45
@Format.register("ase/structure")
@@ -50,3 +51,22 @@ def to_labeled_system(self, data, *args, **kwargs):
5051
structures.append(structure)
5152

5253
return structures
54+
55+
56+
@Format.register("db")
57+
@Format.register("ase/db")
58+
class ASEStructureFormat(Format):
59+
@Format.post("rot_lower_triangular")
60+
def from_labeled_system(self, file_name, begin = 0, step = 1) :
61+
data = {}
62+
data['atom_names'], \
63+
data['atom_numbs'], \
64+
data['atom_types'], \
65+
data['cells'], \
66+
data['coords'], \
67+
data['energies'], \
68+
data['forces'], \
69+
tmp_virial, \
70+
= dpdata.ase.db.get_frames(file_name, begin = begin, step = step)
71+
return data
72+

dpdata/system.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -932,22 +932,6 @@ def has_virial(self) :
932932
# return ('virials' in self.data) and (len(self.data['virials']) > 0)
933933
return ('virials' in self.data)
934934

935-
@register_from_funcs.register_funcs('db')
936-
@register_from_funcs.register_funcs('ase/db')
937-
def from_ase_db(self, file_name, begin = 0, step = 1) :
938-
self.data['atom_names'], \
939-
self.data['atom_numbs'], \
940-
self.data['atom_types'], \
941-
self.data['cells'], \
942-
self.data['coords'], \
943-
self.data['energies'], \
944-
self.data['forces'], \
945-
tmp_virial, \
946-
= dpdata.ase.db.get_frames(file_name, begin = begin, step = step)
947-
948-
# rotate the system to lammps convention
949-
self.rot_lower_triangular()
950-
951935
def affine_map_fv(self, trans, f_idx) :
952936
assert(np.linalg.det(trans) != 0)
953937
self.data['forces'][f_idx] = np.matmul(self.data['forces'][f_idx], trans)

0 commit comments

Comments
 (0)