本文整理汇总了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)
示例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)
示例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
示例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()