def export(self, export_dir, file_format='xyz'):
"""
Export MOF atom coordinates and names in .xyz format.
Example usage:
>>> mof.export(export_dir, file_format='xyz')
"""
if file_format == 'xyz':
xyz_path = os.path.join(export_dir, self.name + '.xyz')
if os.path.exists(xyz_path):
os.remove(xyz_path)
with open(xyz_path, 'w') as xyz_file:
xyz_file.write(str(len(self.atom_coors)) + '\n')
xyz_file.write(self.name + '\n')
for atom, coor in zip(self.atom_names, self.atom_coors):
xyz_file.write(atom + ' ' + str(coor[0]) + ' ' + str(coor[1]) + ' ' + str(coor[2]) + '\n')
else:
file_path = os.path.join(export_dir, self.name + '.' + file_format)
ase.write(file_path, self.ase_atoms, file_format=file_format)
评论列表
文章目录