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


Python Model.write_real_xyz方法代码示例

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


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

示例1: main

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import write_real_xyz [as 别名]
def main():
    #print(rotate([[2,0,0],[0,1,0],[0,0,1]], 90, 'y'))
    #print(calc_rot_array_from_hkl(19,-24,28))
    modelfile = sys.argv[1]
    m = Model(modelfile)
    rot_arr = calc_rot_array_from_hkl(41,60,-6)
    rot(m,rot_arr)
    m.write_real_xyz('temp.real.xyz')
    return

    # Below is a (the?) rotation matrix of Pei's t1 that gives some planes. Oriented for a specific plane ~.
    #rot_arr = [ -0.977103, -0.123352, -0.173361, -0.130450, 0.990997, 0.030118, 0.168085, 0.052043, -0.984398 ]
    #rot(m,rot_arr)

    # Angles in radians
    # Note that these are semi difficult to figure out from the vesta rotation matrix,
    # partly because there are negative angles, so you may need to do 2pi - angle you found.
    #t1 = np.pi*2 - 0.0371505
    #t2 = 0.162790
    #t3 = 0
    #rot_arr = calc_rot_array(m,t1,t2,t3)
    #rot(m,rot_arr)

    kx = -0.76094085
    ky = 0.028182994
    kz = -0.648208872
    t2 = np.arctan(-ky/kx)
    t3 = 0.0
    t1 = np.arctan( (kx*np.cos(t2)-ky*cos(t2))/kz )
    t1 = 0.0
    print(t1,t2,t3)
    rot_arr = calc_rot_array(t1,t2,t3)
    rot(m,rot_arr)
开发者ID:adehgha,项目名称:model_analysis,代码行数:35,代码来源:rotate_3d.py

示例2: main

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import write_real_xyz [as 别名]
def main():
    # NOTE: Cutoff can either be a single integer or it
    # can be a dictionary where the keys are two-tuples
    # of atomic numbers (e.g. (40,13)=3.5 for Zr,Al).
    modelfile = sys.argv[1]
    submodelfile = sys.argv[2]
    rotatedsubmodelfile = sys.argv[3]
    m = Model(modelfile)
    try:
        cut = 3.5  # float(sys.argv[2])
        cutoff = {}
        for z1 in m.atomtypes:
            for z2 in m.atomtypes:
                cutoff[(z1, z2)] = cut
                cutoff[(z2, z1)] = cut
    except:
        print("You didn't input a cutoff so you much define it in the code.")
    voronoi_3d(m, cutoff)

    subm = Model(submodelfile)
    rotsubm = Model(rotatedsubmodelfile)
    for atom in subm.atoms:
        if atom in m.atoms:
            rotsubm.atoms[atom.id].vp = m.atoms[m.atoms.index(atom)].vp
        else:
            print("Couldn't find atom {0} in full model!".format(atom))
    icofrac(rotsubm)
    # rotsubm.write_real_xyz()
    rotsubm.write_real_xyz(rotatedsubmodelfile[:-4] + ".icofrac.real.xyz")
开发者ID:adehgha,项目名称:model_analysis,代码行数:31,代码来源:submodel_vp.py

示例3: dodecahedron

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import write_real_xyz [as 别名]
def dodecahedron(b,save=False,filename=None):
    # http://en.wikipedia.org/wiki/Dodecahedron#Regular_dodecahedron
    # b is the nearest-neighbor interatomic bond distance
    p = 1.61803398875 # golden ratio
    b = b * 0.5 * p
    coords = [[0,0,0]]

    coords.append([p,0,1./p])
    coords.append([-p,0,1./p])
    coords.append([-p,0,-1./p])
    coords.append([p,0,-1./p])

    coords.append([1./p, p, 0])
    coords.append([1./p, -p, 0])
    coords.append([-1./p, -p, 0])
    coords.append([-1./p, p, 0])

    coords.append([0, 1./p, p])
    coords.append([0, 1./p, -p])
    coords.append([0, -1./p, -p])
    coords.append([0, -1./p, p])

    coords.append([1,1,1])
    coords.append([1,-1,1])
    coords.append([-1,-1,1])
    coords.append([-1,1,1])

    coords.append([-1,1,-1])
    coords.append([1,1,-1])
    coords.append([1,-1,-1])
    coords.append([-1,-1,-1])

    coords = [ [b*x for x in c] for c in coords]
    m = 0
    for coord in coords:
        for x in coord:
            if(abs(x) > m): m = abs(x)

    atoms = [Atom(i,14,c[0],c[1],c[2]) for i,c in enumerate(coords)]
    model = Model(comment='dodecahedron', xsize=m, ysize=m, zsize=m, atoms=atoms)

    if(save):
        model.write_real_xyz(model.filename)
        if(filename == None):
            filename = 'dodecahedron.xyz'
        else:
            model.filename = filename
        #f = open(filename,'w')
        #f.write(str(len(coords))+'\n')
        #f.write('{0} {0} {0} comment\n'.format(m))
        #for c in coords:
        #    f.write('Si ' + ' '.join([str(x) for x in c]) + '\n')
        #f.close()
    return model
开发者ID:jjmaldonis,项目名称:model_analysis,代码行数:56,代码来源:icosahedron.py

示例4: dump_to_modelfiles

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import write_real_xyz [as 别名]
def dump_to_modelfiles(dump,masses,base_modelname):
    flag = None
    for line in open(dump):
        if('ITEM: TIMESTEP' in line):
            if(flag):
                # Save the model
                comment = 'timestep {0}'.format(timestep)
                lx = bounds[0]
                ly = bounds[1]
                lz = bounds[2]
                m = Model(comment,lx,ly,lz, atoms)
                m.atoms = sorted(m.atoms, key=operator.itemgetter('id'))
                filename = base_modelname + '_' + str(timestep) + '.xyz'
                m.write_real_xyz(filename)
            flag = 'TIMESTEP'
            continue
        elif('ITEM: NUMBER OF ATOMS' in line):
            flag = 'NUMBER OF ATOMS'
            continue
        elif('ITEM: BOX BOUNDS pp pp pp' in line):
            flag = 'BOX BOUNDS'
            bounds = []
            continue
        elif('ITEM: ATOMS id type xs ys zs' in line):
            flag = 'ATOMS'
            atoms = []
            continue

        if(flag == 'TIMESTEP'):
            timestep = int(line.strip())
        elif(flag == 'NUMBER OF ATOMS'):
            natoms = int(line.strip())
        elif(flag == 'BOX BOUNDS'):
            bounds.append( [float(x) for x in line.strip().split()] )
            bounds[-1] = sum([abs(x) for x in bounds[-1]])
        elif(flag == 'ATOMS'):
            line = line.strip().split()
            id = int(line[0])
            znum = masses[ int(line[1]) ]
            x,y,z = frac_to_cart(float(line[2]), float(line[3]), float(line[4]), bounds[0],bounds[1],bounds[2])
            atoms.append( Atom(id,znum,x,y,z) )
    # Save the last model
    comment = 'timestep {0}'.format(timestep)
    lx = bounds[0]
    ly = bounds[1]
    lz = bounds[2]
    m = Model(comment,lx,ly,lz, atoms)
    m.atoms = sorted(m.atoms, key=operator.itemgetter('id'))
    filename = base_modelname + '_' + str(timestep) + '.xyz'
    m.write_real_xyz(filename)
开发者ID:adehgha,项目名称:model_analysis,代码行数:52,代码来源:dump_to_modelfiles.py

示例5: icosahedron

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import write_real_xyz [as 别名]
def icosahedron(b,save=False,filename=None):
    # http://en.wikipedia.org/wiki/Regular_icosahedron
    # b is the nearest-neighbor interatomic bond distance
    b = b * sqrt(2)* 1.113516364 / 1.84375
    coords = [atom.coord for atom in dodecahedron(b).atoms]
    vertices = range(1,21)
    faces = [
        [15, 2, 12, 16, 9],
        [11, 19, 10, 4, 18],
        [6, 7, 14, 15, 12],
        [10, 18, 17, 5, 8],
        [9, 16, 13, 8, 5],
        [7, 6, 20, 19, 11],
        [5, 1, 13, 4, 18],
        [4, 19, 6, 14, 1],
        [1, 9, 13, 12, 14],
        [2, 3, 20, 7, 15],
        [2, 16, 8, 17, 3],
        [3, 20, 11, 10, 17]]
    face_coords = [(0,0,0)]
    for f in faces:
        center = (sum(coords[i][0] for i in f)/5., sum(coords[i][1] for i in f)/5., sum(coords[i][2] for i in f)/5.)
        face_coords.append(center)
    m = 0
    for coord in face_coords:
        for x in coord:
            if(abs(x) > m): m = abs(x)

    atoms = [Atom(i,14,c[0],c[1],c[2]) for i,c in enumerate(face_coords)]
    model = Model(comment='icosahedron', xsize=m, ysize=m, zsize=m, atoms=atoms)
    if(save):
        model.write_real_xyz(model.filename)
        if(filename == None):
            filename = 'icosahedron.xyz'
        else:
            model.filename = filename
        #f = open(filename,'w')
        #f.write(str(len(face_coords))+'\n')
        #f.write('{0} {0} {0} comment\n'.format(m))
        #for c in face_coords:
        #    f.write('Si ' + ' '.join([str(x) for x in c]) + '\n')
        #f.close()
    return model
开发者ID:jjmaldonis,项目名称:model_analysis,代码行数:45,代码来源:icosahedron.py


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