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


Python Atom.set_id方法代码示例

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


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

示例1: structure2aSys

# 需要导入模块: from atom import Atom [as 别名]
# 或者: from atom.Atom import set_id [as 别名]
def structure2aSys(structure,idoffset=1):
    """
    Converts Structure object of pymatgen to NAPSystem object in nap.

    Args:
        structure (Structure): pymatgen Structure object to be converted
        to NAPSystem object..

    Returns:
        aSys (NAPSystem): 
    """
    lattice= structure.lattice
    alc= 1.0
    a1= np.array(lattice.matrix[0])
    a2= np.array(lattice.matrix[1])
    a3= np.array(lattice.matrix[2])
    #... rescale a? vectors
    a1= a1/alc
    a2= a2/alc
    a3= a3/alc
    aSys= NAPSystem()
    aSys.set_lattice(alc,a1,a2,a3)
    for ia in range(structure.num_sites):
        ai= Atom()
        si= structure[ia]
        crd= si.frac_coords
        ai.set_pos(crd[0],crd[1],crd[2])
        sid= structure.symbol_set.index(si.species_string)+idoffset
        ai.set_sid(sid)
        ai.set_id(ia+1)
        aSys.add_atom(ai)
    return aSys
开发者ID:ryokbys,项目名称:nap,代码行数:34,代码来源:vasp2fitpot.py

示例2: from_ase_atoms

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

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

示例4: read_POSCAR

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

# 需要导入模块: from atom import Atom [as 别名]
# 或者: from atom.Atom import set_id [as 别名]
amax= options.amax
print(' amax          = ',amax)
distance= options.distance
print(' distance      = ',distance,' Ang.')
pmdexec= options.pmdexec

asys= NAPSystem()
a1= np.array([2.0, 0.0, 0.0])
a2= np.array([0.0, 2.0, 0.0])
a3= np.array([0.0, 0.0, 1.0])
alc= rcut
asys.set_lattice(alc,a1,a2,a3)

atom1= Atom()
atom1.set_pos(0.0,0.0,0.0)
atom1.set_id(1)
asys.add_atom(atom1)

hd= distance/(alc*2)
atom2= Atom()
atom2.set_pos(hd,0.0,0.0)
atom2.set_id(2)
asys.add_atom(atom2)

atom3= Atom()
atom3.set_pos(0.0,0.0,0.0)
atom3.set_id(3)
asys.add_atom(atom3)

da  = (amax-amin)/nsmpl
开发者ID:ryokbys,项目名称:nap,代码行数:32,代码来源:get_3body_pot.py

示例6: print

# 需要导入模块: from atom import Atom [as 别名]
# 或者: from atom.Atom import set_id [as 别名]
sid2= options.sid2
print(' sid2          = ',sid2)
pmdexec= options.pmdexec

asys= NAPSystem()
# system size is bigger than 2*rcut
a1= np.array([2.0, 0.0, 0.0])
a2= np.array([0.0, 1.0, 0.0])
a3= np.array([0.0, 0.0, 1.0])
alc= rcut
asys.set_lattice(alc,a1,a2,a3)

atom1= Atom()
atom2= Atom()
atom1.set_pos(0.0,0.0,0.0)
atom1.set_id(1)
atom1.set_sid(sid1)
asys.add_atom(atom1)
atom2.set_pos(0.5,0.0,0.0)
atom2.set_id(2)
atom2.set_sid(sid2)
asys.add_atom(atom2)

hmin= rmin/(2*rcut)
hd  = (0.5-hmin)/nsmpl

os.system('cp pmdini pmdorig')

fout= open('out.2body','w')
for ip in range(nsmpl+1):
    print('.',end='')
开发者ID:ryokbys,项目名称:nap,代码行数:33,代码来源:get_2body_pot.py


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