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


Python Atom.set_symbol方法代码示例

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


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

示例1: from_ase_atoms

# 需要导入模块: from atom import Atom [as 别名]
# 或者: from atom.Atom import set_symbol [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,代码来源:

示例2: read_akr

# 需要导入模块: from atom import Atom [as 别名]
# 或者: from atom.Atom import set_symbol [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,代码来源:

示例3: make_sc

# 需要导入模块: from atom import Atom [as 别名]
# 或者: from atom.Atom import set_symbol [as 别名]
def make_sc(latconst=1.0):
    """
    Make a cell of simple cubic structure.
    """
    s= NAPSystem(specorder=_default_specorder)
    #...lattice
    a1= np.array([ 1.0, 0.0, 0.0 ])
    a2= np.array([ 0.0, 1.0, 0.0 ])
    a3= np.array([ 0.0, 0.0, 1.0 ])
    s.set_lattice(latconst,a1,a2,a3)
    p=[0.00, 0.00, 0.00]
    atom= Atom()
    atom.set_pos(p[0],p[1],p[2])
    atom.set_symbol(_default_specorder[0])
    s.add_atom(atom)
    return s
开发者ID:,项目名称:,代码行数:18,代码来源:

示例4: make_bcc

# 需要导入模块: from atom import Atom [as 别名]
# 或者: from atom.Atom import set_symbol [as 别名]
def make_bcc(latconst=1.0):
    """
    Make a cell of bcc structure.
    """
    s= NAPSystem(specorder=_default_specorder)
    #...lattice
    a1= np.array([ 1.0, 0.0, 0.0 ])
    a2= np.array([ 0.0, 1.0, 0.0 ])
    a3= np.array([ 0.0, 0.0, 1.0 ])
    s.set_lattice(latconst,a1,a2,a3)
    positions=[(0.00, 0.00, 0.00),
               (0.50, 0.50, 0.50)]
    for p in positions:
        atom= Atom()
        atom.set_pos(p[0],p[1],p[2])
        atom.set_symbol(_default_specorder[0])
        s.add_atom(atom)
    return s
开发者ID:,项目名称:,代码行数:20,代码来源:

示例5: read_pmd

# 需要导入模块: from atom import Atom [as 别名]
# 或者: from atom.Atom import set_symbol [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: print

# 需要导入模块: from atom import Atom [as 别名]
# 或者: from atom.Atom import set_symbol [as 别名]
 print('Extracting the atoms inside the new unit vectors...')
 hmat= psnew.get_hmat()
 hi = np.linalg.inv(hmat)
 for ia,posi in enumerate(expos):
     sposi = np.dot(hi,posi)
     if 0.0 <= sposi[0] < 1.0 and \
        0.0 <= sposi[1] < 1.0 and \
        0.0 <= sposi[2] < 1.0:
         atom = Atom()
         symbol = exsymbols[ia]
         print('{0:5d} {1:s}'.format(ia,symbol)
               +' {0:12.5f} {1:12.5f} {2:12.5f}'.format(sposi[0],
                                                        sposi[1],
                                                        sposi[2]))
         
         atom.set_symbol(symbol)
         atom.set_pos(sposi[0],sposi[1],sposi[2])
         psnew.add_atom(atom)
         
 tmp = None
 #tmp = raw_input('Input periodic shift vector if you want: ')
 tmp = ' 0.5, 0.0, 0.5'
 if tmp:
     shift = [ float(x) for x in tmp.split(',')]
     for a in psnew.atoms:
         a.pos[0] += shift[0]
         a.pos[1] += shift[1]
         a.pos[2] += shift[2]
     psnew.assign_pbc()
 psnew.write_POSCAR(infile+'.new')
 print('Check '+infile+'.new')
开发者ID:ryokbys,项目名称:nap,代码行数:33,代码来源:cell_convert.py

示例7: read_dump

# 需要导入模块: from atom import Atom [as 别名]
# 或者: from atom.Atom import set_symbol [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_symbol方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。