當前位置: 首頁>>代碼示例>>Python>>正文


Python Atom.symbol方法代碼示例

本文整理匯總了Python中atom.Atom.symbol方法的典型用法代碼示例。如果您正苦於以下問題:Python Atom.symbol方法的具體用法?Python Atom.symbol怎麽用?Python Atom.symbol使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在atom.Atom的用法示例。


在下文中一共展示了Atom.symbol方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: repeat

# 需要導入模塊: from atom import Atom [as 別名]
# 或者: from atom.Atom import symbol [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: read_POSCAR

# 需要導入模塊: from atom import Atom [as 別名]
# 或者: from atom.Atom import symbol [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,代碼來源:

示例3: make_residue

# 需要導入模塊: from atom import Atom [as 別名]
# 或者: from atom.Atom import symbol [as 別名]
def make_residue(key,hydrogens = True):
    """ returns a molecule object with
    default geometry"""

    if not library._aacids.has_key(key):
        raise KeyError, "Residue %s not known" % key
    m = Molecule()
    m.unity = 'A'
    m.resname = key
    for i, entry in enumerate(library._aacids[key]):
        if hydrogens == False and entry[0][0] == 'H':
            continue
        else:
            a = Atom()
            a.id = i+1
            a.name = entry[0]
            a.symbol = a.name[0]
            a.x = entry[1]
            a.occ = 1.
            a.resname = key
            a.m = library._atommass[a.symbol]
            a.unity = 'A'
            m.atoms.append(a)
    return m
開發者ID:esguerra,項目名稱:pmx,代碼行數:26,代碼來源:builder.py

示例4: read_xsf

# 需要導入模塊: from atom import Atom [as 別名]
# 或者: from atom.Atom import symbol [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,代碼來源:


注:本文中的atom.Atom.symbol方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。