












# File: cell_into_POSCAR.py
#
# Author: Pei Yang
#
# Organization:School of Physics, Beijing Institute of Technology
# China Academy ofEngineering Physics
#
# Create Date: 2017-09-15 23:59:55
#
# Comment:
# Put the *.cell file (for exampleperfect_4_3_1.cell from Materials Studio into
# the document and execute this file, aPOSCAR file will be given.
#
#——————————————————————————-
cell = open(cellname,’r’)
poscar = open(‘POSCAR’,’w’)
poscar.write(“POSCAR of “)
poscar.write(cellname)
poscar.write(” is written by cell_into_POSCAR.py(Pei Yang).”)
poscar.write(“n”)
poscar.write(“1.000000 n”)
for i in range(3):
lattice_vector=cell.readline()
poscar.write(lattice_vector.strip())
poscar.write(“n”)
cell.readline()
cell.readline()
atom.append(cell.readline().split())
break
else:
n=n+1
for i in range(1,n-1):
if atom[i][0]!=atom[i-1][0]:
poscar.write(‘%s ‘%(atom[i][0]))
for i in range(1,n):
if atom[i][0]==atom[i-1][0]:
atom_number=atom_number+1
else:
poscar.write(‘%s ‘%atom_number)
atom_number=1
poscar.write(“n “)
poscar.write(“Direct”)
poscar.write(“n “)
for i in range(n-1):
poscar.write(‘%s ‘%(atom[i][1]))
poscar.write(‘%s ‘%(atom[i][2]))
poscar.write(‘%s ‘%(atom[i][3]))
poscar.write(‘%s ‘%(atom[i][0]))
poscar.write(‘n ‘)
poscar.close()

声明:如需转载请注明出处(华算科技旗下资讯学习网站-学术资讯),并附有原文链接,谢谢!