Example #1
0
 def read_pmd(self,fname='pmd0000'):
     f=open(fname,'r')
     # 1st: lattice constant
     self.alc= float(f.readline().split()[0])
     # 2nd-4th: cell vectors
     # for i in range(3):
     #     data= f.readline().split()
     #     self.a1[i]= float(data[0])
     #     self.a2[i]= float(data[1])
     #     self.a3[i]= float(data[2])
     self.a1= np.array([float(x) for x in f.readline().split()])
     self.a2= np.array([float(x) for x in f.readline().split()])
     self.a3= np.array([float(x) for x in f.readline().split()])
     # 5th-7th: velocity of cell vectors
     tmp= f.readline().split()
     tmp= f.readline().split()
     tmp= f.readline().split()
     # 8st: num of atoms
     natm= int(f.readline().split()[0])
     # 9th-: atom positions
     self.atoms= []
     symbol = None
     for i in range(natm):
         data= [float(x) for x in f.readline().split()]
         ai= Atom()
         ai.decode_tag(data[0])
         if self.specorder:
             symbol = self.specorder[ai.sid-1]
         if symbol and ai.symbol != symbol:
             ai.set_symbol(symbol)
         ai.set_pos(data[1],data[2],data[3]) # position
         ai.set_vel(data[4],data[5],data[6]) # velocity
         ai.set_ekin(data[7])
         ai.set_epot(data[8])
         ai.set_strs(data[9],data[10],data[11],
                     data[12],data[13],data[14])
         self.atoms.append(ai)
     f.close()