当前位置: 首页>>代码示例>>Python>>正文


Python Atom.set_vel方法代码示例

本文整理汇总了Python中atom.Atom.set_vel方法的典型用法代码示例。如果您正苦于以下问题:Python Atom.set_vel方法的具体用法?Python Atom.set_vel怎么用?Python Atom.set_vel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在atom.Atom的用法示例。


在下文中一共展示了Atom.set_vel方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: repeat

# 需要导入模块: from atom import Atom [as 别名]
# 或者: from atom.Atom import set_vel [as 别名]
 def repeat(self,n1,n2,n3):
     #...unit vectors to be repeated
     self.a1= self.a1*n1
     self.a2= self.a2*n2
     self.a3= self.a3*n3
     n123= n1*n2*n3
     nsid= 0
     for ai in self.atoms:
         nsid= max(nsid,ai.sid)
     natm0= self.num_atoms()
     atoms0= copy.copy(self.atoms)
     self.atoms= []
     aid= 0
     for i1 in range(n1):
         for i2 in range(n2):
             for i3 in range(n3):
                 for ai0 in atoms0:
                     aid += 1
                     ai= Atom()
                     ai.sid= ai0.sid
                     ai.symbol= ai0.symbol
                     ai.ifmv= ai0.ifmv
                     x= ai0.pos[0]/n1 +1.0/n1*i1
                     y= ai0.pos[1]/n2 +1.0/n2*i2
                     z= ai0.pos[2]/n3 +1.0/n3*i3
                     ai.set_pos(x,y,z)
                     ai.set_vel(ai0.vel[0],ai0.vel[1],ai0.vel[2])
                     ai.set_id(aid)
                     self.atoms.append(ai)
开发者ID:,项目名称:,代码行数:31,代码来源:

示例2: from_ase_atoms

# 需要导入模块: from atom import Atom [as 别名]
# 或者: from atom.Atom import set_vel [as 别名]
 def from_ase_atoms(self,atoms):
     """
     Convert ASE Atoms object to NAPSystem object.
     """
     self.a1 = np.array(atoms.cell[0])
     self.a2 = np.array(atoms.cell[1])
     self.a3 = np.array(atoms.cell[2])
     spos = atoms.get_scaled_positions()
     symbols = atoms.get_chemical_symbols()
     #...initialize and remake self.specorder
     self.specorder = []
     for s in symbols:
         if s not in self.specorder:
             self.specorder.append(s)
     #...first, initialize atoms array
     self.atoms = []
     #...append each atom from ASE-Atoms
     for ia,spi in enumerate(spos):
         si = symbols[ia]
         ai = Atom()
         sid = self.specorder.index(si)+1
         ai.set_id(ia+1)
         ai.set_sid(sid)
         ai.set_symbol(si)
         ai.set_pos(spi[0],spi[1],spi[2])
         ai.set_vel(0.,0.,0.)
         self.atoms.append(ai)
     return
开发者ID:,项目名称:,代码行数:30,代码来源:

示例3: read_akr

# 需要导入模块: from atom import Atom [as 别名]
# 或者: from atom.Atom import set_vel [as 别名]
 def read_akr(self,fname='akr0000'):
     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])
     # 5th: 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.set_sid(data[0])
         ai.set_pos(data[1],data[2],data[3])
         ai.set_vel(data[4],data[5],data[6])
         if self.specorder:
             symbol = self.specorder[ai.sid-1]
         if symbol and ai.symbol != symbol:
             ai.set_symbol(symbol)
         self.atoms.append(ai)
     f.close()
开发者ID:,项目名称:,代码行数:29,代码来源:

示例4: read_POSCAR

# 需要导入模块: from atom import Atom [as 别名]
# 或者: from atom.Atom import set_vel [as 别名]
 def read_POSCAR(self,fname='POSCAR'):
     with open(fname,'r') as f:
         # 1st line: comment
         f.readline()
         # 2nd: lattice constant
         self.alc= float(f.readline().split()[0])
         # 3rd-5th: cell vectors
         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()])
         # 6th: species names or number of each species
         buff= f.readline().split()
         if not buff[0].isdigit():
             spcs = copy.deepcopy(buff)
             buff= f.readline().split()
             if not self.specorder:
                 self.specorder = spcs
         num_species= np.array([ int(n) for n in buff])
         natm= 0
         for n in num_species:
             natm += n
         #print("Number of atoms = {0:5d}".format(natm))
         # 7th or 8th line: comment
         c7= f.readline()
         if c7[0] in ('s','S'):
             c8= f.readline()
         # Atom positions hereafter
         self.atoms= []
         for i in range(natm):
             buff= f.readline().split()
             ai= Atom()
             sid= 1
             m= 0
             sindex=0
             symbol = None
             for n in num_species:
                 m += n
                 if i < m:
                     if spcs and self.specorder:
                         sid = self.specorder.index(spcs[sindex]) + 1
                         symbol = spcs[sindex]
                     break
                 sid += 1
                 sindex += 1
             ai.set_id(i+1)
             ai.set_sid(sid)
             if symbol:
                 ai.symbol = symbol
             ai.set_pos(float(buff[0]),float(buff[1]),float(buff[2]))
             ai.set_vel(0.0,0.0,0.0)
             self.atoms.append(ai)
开发者ID:,项目名称:,代码行数:53,代码来源:

示例5: read_pmd

# 需要导入模块: from atom import Atom [as 别名]
# 或者: from atom.Atom import set_vel [as 别名]
 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()
开发者ID:,项目名称:,代码行数:40,代码来源:

示例6: read_xsf

# 需要导入模块: from atom import Atom [as 别名]
# 或者: from atom.Atom import set_vel [as 别名]
 def read_xsf(self,fname="xsf"):
     f=open(fname,'r')
     mode= 'None'
     ixyz= 0
     iatm= 0
     self.atoms= []
     natm= 0
     for line in f.readlines():
         if 'CRYSTAL' in line:
             mode= 'CRYSTAL'
             continue
         elif 'PRIMVEC' in line:
             mode= 'PRIMVEC'
             continue
         elif 'PRIMCOORD' in line:
             mode= 'PRIMCOORD'
             # Before going further, create inversed h-matrix
             hi = unitvec_to_hi(self.a1,self.a2,self.a3)
             # print 'Inversed h-matrix:'
             # print hi
             continue
         
         if mode == 'CRYSTAL':
             pass
         elif mode == 'PRIMVEC':
             if ixyz == 0:
                 arr = [ float(x) for x in line.split() ]
                 self.a1[0] = arr[0]
                 self.a1[1] = arr[1]
                 self.a1[2] = arr[2]
             elif ixyz == 1:
                 arr = [ float(x) for x in line.split() ]
                 self.a2[0] = arr[0]
                 self.a2[1] = arr[1]
                 self.a2[2] = arr[2]
             elif ixyz == 2:
                 arr = [ float(x) for x in line.split() ]
                 self.a3[0] = arr[0]
                 self.a3[1] = arr[1]
                 self.a3[2] = arr[2]
             ixyz += 1
         elif mode == 'PRIMCOORD':
             data = line.split()
             if len(data) == 1:
                 natm= int(data[0])
                 continue
             elif len(data) == 2:
                 natm= int(data[0])
                 nspcs= int(data[1])
                 continue
             elif len(data) == 4 or len(data) == 7:
                 if iatm >= natm:
                     continue
                 symbol = get_symbol_from_number(int(data[0]))
                 if symbol not in self.specorder:
                     self.specorder.append(symbol)
                 sid = self.specorder.index(symbol) +1
                 ai= Atom()
                 ai.symbol = symbol
                 ai.set_sid(sid)
                 xc= float(data[1])
                 yc= float(data[2])
                 zc= float(data[3])
                 xi,yi,zi = cartessian_to_scaled(hi,xc,yc,zc)
                 ai.set_pos(xi,yi,zi)
                 ai.set_vel(0.0,0.0,0.0)
                 self.atoms.append(ai)
                 # print 'iatm,symbol,sid,xc,yc,zc = ',iatm,symbol,sid,xc,yc,zc
             else:
                 continue
             iatm += 1
     self.alc= 1.0
     # print self.alc
     # print self.a1[:]
     # print self.a2[:]
     # print self.a3[:]
     f.close()
开发者ID:,项目名称:,代码行数:79,代码来源:

示例7: read_dump

# 需要导入模块: from atom import Atom [as 别名]
# 或者: from atom.Atom import set_vel [as 别名]
 def read_dump(self,fname="dump"):
     f=open(fname,'r')
     mode= 'None'
     ixyz= 0
     iatm= 0
     symbol = None
     self.atoms= []
     self.alc= 1.0
     for line in f.readlines():
         if 'ITEM: NUMBER OF ATOMS' in line:
             mode= 'NUMBER OF ATOMS'
             continue
         elif 'ITEM: BOX BOUNDS' in line:
             mode= 'BOX BOUNDS'
             continue
         elif 'ITEM: ATOMS' in line:
             mode= 'ATOMS'
             continue
         
         if mode == 'NUMBER OF ATOMS':
             natm= int(line.split()[0])
         elif mode == 'BOX BOUNDS':
             data = line.split()
             if ixyz == 0:
                 xlo_bound= float(data[0])
                 xhi_bound= float(data[1])
                 if len(data) > 2:
                     xy = float(data[2])
             elif ixyz == 1:
                 ylo_bound= float(line.split()[0])
                 yhi_bound= float(line.split()[1])
                 if len(data) > 2:
                     xz = float(data[2])
             elif ixyz == 2:
                 zlo_bound= float(line.split()[0])
                 zhi_bound= float(line.split()[1])
                 if len(data) > 2:
                     yz = float(data[2])
             ixyz += 1
             if ixyz > 2:
                 xlo = xlo_bound -min(0.0,xy,xz,xy+yz)
                 xhi = xhi_bound -max(0.0,xy,xz,xy+yz)
                 ylo = ylo_bound -min(0.0,yz)
                 yhi = yhi_bound -max(0.0,yz)
                 zlo = zlo_bound
                 zhi = zhi_bound
                 self.a1 = np.array([xhi-xlo,xy,xz],dtype=float)
                 self.a2 = np.array([0.0,yhi-ylo,yz],dtype=float)
                 self.a3 = np.array([0.0,0.0,zhi-zlo],dtype=float)
                 hmat = self.get_hmat()
                 hmati= np.linalg.inv(hmat)
         elif mode == 'ATOMS':
             if iatm < natm:
                 data= line.split()
                 ai= Atom()
                 ai.set_sid(int(data[1]))
                 if self.specorder:
                     symbol = self.specorder[ai.sid-1]
                 if symbol and ai.symbol != symbol:
                     ai.set_symbol(symbol)
                 x0= float(data[2])
                 y0= float(data[3])
                 z0= float(data[4])
                 x = hmati[0,0]*x0 +hmati[0,1]*y0 +hmati[0,2]*z0
                 y = hmati[1,0]*x0 +hmati[1,1]*y0 +hmati[1,2]*z0
                 z = hmati[2,0]*x0 +hmati[2,1]*y0 +hmati[2,2]*z0
                 x = self._pbc(x)
                 y = self._pbc(y)
                 z = self._pbc(z)
                 ai.set_pos(x,y,z)
                 ai.set_vel(0.0,0.0,0.0)
                 self.atoms.append(ai)
             iatm += 1
     # print self.alc
     # print self.a1[:]
     # print self.a2[:]
     # print self.a3[:]
     f.close()
开发者ID:,项目名称:,代码行数:80,代码来源:


注:本文中的atom.Atom.set_vel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。