Skip to content

Commit

Permalink
refactor with new plugin system
Browse files Browse the repository at this point in the history
continue on deepmodeling#115
  • Loading branch information
njzjz committed Jul 9, 2021
1 parent 325bf87 commit b4669a5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
20 changes: 20 additions & 0 deletions dpdata/plugins/ase.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from dpdata.format import Format
import dpdata.ase.db


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

return structures


@Format.register("db")
@Format.register("ase/db")
class ASEStructureFormat(Format):
@Format.post("rot_lower_triangular")
def from_labeled_system(self, file_name, begin = 0, step = 1) :
data = {}
data['atom_names'], \
data['atom_numbs'], \
data['atom_types'], \
data['cells'], \
data['coords'], \
data['energies'], \
data['forces'], \
tmp_virial, \
= dpdata.ase.db.get_frames(file_name, begin = begin, step = step)
return data

16 changes: 0 additions & 16 deletions dpdata/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,22 +932,6 @@ def has_virial(self) :
# return ('virials' in self.data) and (len(self.data['virials']) > 0)
return ('virials' in self.data)

@register_from_funcs.register_funcs('db')
@register_from_funcs.register_funcs('ase/db')
def from_ase_db(self, file_name, begin = 0, step = 1) :
self.data['atom_names'], \
self.data['atom_numbs'], \
self.data['atom_types'], \
self.data['cells'], \
self.data['coords'], \
self.data['energies'], \
self.data['forces'], \
tmp_virial, \
= dpdata.ase.db.get_frames(file_name, begin = begin, step = step)

# rotate the system to lammps convention
self.rot_lower_triangular()

def affine_map_fv(self, trans, f_idx) :
assert(np.linalg.det(trans) != 0)
self.data['forces'][f_idx] = np.matmul(self.data['forces'][f_idx], trans)
Expand Down

0 comments on commit b4669a5

Please sign in to comment.