19
19
from monty .json import MSONable
20
20
from monty .serialization import loadfn ,dumpfn
21
21
from dpdata .periodic_table import Element
22
- from dpdata .xyz .gap_xyz import GapxyzSystems
22
+ from dpdata .xyz .quip_gap_xyz import QuipGapxyzSystems
23
23
24
24
class System (MSONable ) :
25
25
'''
@@ -905,7 +905,7 @@ def sort_atom_types(self):
905
905
class MultiSystems :
906
906
'''A set containing several systems.'''
907
907
908
- def __init__ (self , * systems ,file_name = None , fmt = None , type_map = None ):
908
+ def __init__ (self , * systems ,type_map = None ):
909
909
"""
910
910
Parameters
911
911
----------
@@ -920,15 +920,6 @@ def __init__(self, *systems,file_name=None, fmt=None,type_map=None):
920
920
else :
921
921
self .atom_names = []
922
922
self .append (* systems )
923
- if file_name is not None :
924
- if fmt is None :
925
- raise RuntimeError ("must specify file format for file {}" .format (file_name ))
926
- elif fmt == 'gap/xyz' or 'xyz' :
927
- self .from_gap_xyz_file (file_name )
928
- else :
929
- raise RuntimeError ("unknown file format for file {} format {},now supported 'gap/xyz'" .format (file_name , fmt ))
930
-
931
-
932
923
933
924
def __getitem__ (self , key ):
934
925
"""Returns proerty stored in System by key or by idx"""
@@ -955,8 +946,20 @@ def __add__(self, others) :
955
946
raise RuntimeError ("Unspported data structure" )
956
947
957
948
@classmethod
958
- def from_file (cls ,file_name ,fmt ,type_map = None ):
959
- return cls (file_name = file_name , fmt = fmt ,type_map = type_map )
949
+ def from_file (cls ,file_name ,fmt ):
950
+ multi_systems = cls ()
951
+ multi_systems .load_systems_from_file (file_name = file_name ,fmt = fmt )
952
+ return multi_systems
953
+
954
+ def load_systems_from_file (self , file_name = None , fmt = None ):
955
+ if file_name is not None :
956
+ if fmt is None :
957
+ raise RuntimeError ("must specify file format for file {}" .format (file_name ))
958
+ elif fmt == 'quip/gap/xyz' or 'xyz' :
959
+ self .from_quip_gap_xyz_file (file_name )
960
+ else :
961
+ raise RuntimeError ("unknown file format for file {} format {},now supported 'quip/gap/xyz'" .format (file_name , fmt ))
962
+
960
963
961
964
def get_nframes (self ) :
962
965
"""Returns number of frames in all systems"""
@@ -1012,10 +1015,10 @@ def check_atom_names(self, system):
1012
1015
system .add_atom_names (new_in_self )
1013
1016
system .sort_atom_names ()
1014
1017
1015
- def from_gap_xyz_file (self ,filename ):
1016
- # gap_xyz_systems = GapxyzSystems (filename)
1017
- # print(next(gap_xyz_systems ))
1018
- for info_dict in GapxyzSystems (filename ):
1018
+ def from_quip_gap_xyz_file (self ,filename ):
1019
+ # quip_gap_xyz_systems = QuipGapxyzSystems (filename)
1020
+ # print(next(quip_gap_xyz_systems ))
1021
+ for info_dict in QuipGapxyzSystems (filename ):
1019
1022
system = LabeledSystem (data = info_dict )
1020
1023
self .append (system )
1021
1024
0 commit comments