@@ -368,7 +368,8 @@ def sort_atom_names(self, type_map=None):
368
368
# atom_names must be a subset of type_map
369
369
assert (set (self .data ['atom_names' ]).issubset (set (type_map )))
370
370
# for the condition that type_map is a proper superset of atom_names
371
- new_atoms = set (type_map ) - set (self .data ["atom_names" ])
371
+ # new_atoms = set(type_map) - set(self.data["atom_names"])
372
+ new_atoms = [e for e in type_map if e not in self .data ["atom_names" ]]
372
373
if new_atoms :
373
374
self .add_atom_names (new_atoms )
374
375
# index that will sort an array by type_map
@@ -414,8 +415,8 @@ def formula(self):
414
415
"""
415
416
Return the formula of this system, like C3H5O2
416
417
"""
417
- return '' .join (["{}{}" .format (symbol ,numb ) for symbol ,numb in sorted (
418
- zip (self .data ['atom_names' ], self .data ['atom_numbs' ])) ])
418
+ return '' .join (["{}{}" .format (symbol ,numb ) for symbol ,numb in
419
+ zip (self .data ['atom_names' ], self .data ['atom_numbs' ])])
419
420
420
421
421
422
def extend (self , systems ):
@@ -1455,29 +1456,31 @@ def check_atom_names(self, system):
1455
1456
"""
1456
1457
Make atom_names in all systems equal, prevent inconsistent atom_types.
1457
1458
"""
1458
- new_in_system = set (system ["atom_names" ]) - set (self .atom_names )
1459
- new_in_self = set (self .atom_names ) - set (system ["atom_names" ])
1459
+ # new_in_system = set(system["atom_names"]) - set(self.atom_names)
1460
+ # new_in_self = set(self.atom_names) - set(system["atom_names"])
1461
+ new_in_system = [e for e in system ["atom_names" ] if e not in self .atom_names ]
1462
+ new_in_self = [e for e in self .atom_names if e not in system ["atom_names" ]]
1460
1463
if len (new_in_system ):
1461
1464
# A new atom_name appear, add to self.atom_names
1462
1465
self .atom_names .extend (new_in_system )
1463
- self .atom_names .sort ()
1464
1466
# Add this atom_name to each system, and change their names
1465
1467
new_systems = {}
1466
1468
for each_system in self .systems .values ():
1467
1469
each_system .add_atom_names (new_in_system )
1468
- each_system .sort_atom_names ()
1470
+ each_system .sort_atom_names (type_map = self . atom_names )
1469
1471
new_systems [each_system .formula ] = each_system
1470
1472
self .systems = new_systems
1471
1473
if len (new_in_self ):
1472
1474
# Previous atom_name not in this system
1473
1475
system .add_atom_names (new_in_self )
1474
- system .sort_atom_names ()
1476
+ system .sort_atom_names (type_map = self . atom_names )
1475
1477
1476
1478
def from_quip_gap_xyz_file (self ,file_name ):
1477
1479
# quip_gap_xyz_systems = QuipGapxyzSystems(file_name)
1478
1480
# print(next(quip_gap_xyz_systems))
1479
1481
for info_dict in QuipGapxyzSystems (file_name ):
1480
1482
system = LabeledSystem (data = info_dict )
1483
+ system .sort_atom_names ()
1481
1484
self .append (system )
1482
1485
1483
1486
0 commit comments