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


Python Model.write方法代码示例

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


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

示例1: update

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import write [as 别名]
def update():
    '''
    Prompt user to insert a new record or update an existing record
    to data file.
    '''
    # Read file
    m = Model(compute=False)
    print('\n', m.df.tail())

    # Enter date. Default is today.
    today = str(datetime.now().date())
    date = input('Enter {0} ({1}): '.format(DATE, today))
    if date == '':
        date = today
    d = pd.Timestamp(date)

    # Enter weight.
    weight = input('Enter {0}: '.format(WEIGHT))
    w = float(weight)

    # Update table
    m.update(d, w)
    print('\n', m.df.tail())

    # Write file
    confirm = input('Write file (y/[n])?: ')
    if confirm == 'y':
        m.write()
开发者ID:tomboo,项目名称:weight,代码行数:30,代码来源:update.py

示例2: main

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import write [as 别名]
def main():
    # sys.argv == [categorize_parameters.txt, modelfile]
    if len(sys.argv) <= 2:
        sys.exit(
            "\nERROR! Fix your inputs!\n\nArg 1:  input param file detailing each voronoi 'structure'.\nShould be of the form:\nCrystal:\n    0,2,8,*\n\nArg2: a model file.\n\nOutput is printed to screen."
        )

    paramfile = sys.argv[1]
    modelfiles = sys.argv[2:]

    from cutoff import cutoff

    vp_dict = load_param_file(paramfile)

    m0 = Model(modelfiles[0])
    m0.generate_neighbors(cutoff)
    # voronoi_3d(m0, cutoff)
    # set_atom_vp_types(m0, vp_dict)
    # stats0 = VPStatistics(m0)
    # stats0.print_indexes()
    # stats0.print_categories()

    from atom import Atom

    m = Model(
        "atoms with less than 12 neighbors in Zr50Cu45Al15 MD model (originally with 91200 atoms)",
        m0.lx,
        m0.ly,
        m0.lz,
        [],
    )
    count = 0
    for j, atom in enumerate(m0.atoms):
        if len(atom.neighs) >= 12:
            continue
        new = Atom(count, "Si", *atom.coord)
        count += 1
        print("Added new atom {0}".format(new))
        m.add(new)
    m.write("less_than_12_neighbors.xyz")

    if len(modelfiles) > 1:
        for modelfile in modelfiles[1:]:
            m = Model(modelfile)
            voronoi_3d(m, cutoff)
            set_atom_vp_types(m, vp_dict)

            stats0 = stats0 + m
            stats0.print_categories()
            stats0.print_indexes()
开发者ID:adehgha,项目名称:model_analysis,代码行数:52,代码来源:categorize_vor.py

示例3: main

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import write [as 别名]
def main():
    modelfile = sys.argv[1]
    paramfile = sys.argv[2]

    m = Model(modelfile)
    m.generate_neighbors(3.45)

    cutoff = {}
    cutoff[(40,40)] = 3.6
    cutoff[(13,29)] = 3.6
    cutoff[(29,13)] = 3.6
    cutoff[(40,13)] = 3.6
    cutoff[(13,40)] = 3.6
    cutoff[(29,40)] = 3.6
    cutoff[(40,29)] = 3.6
    cutoff[(13,13)] = 3.6
    cutoff[(29,29)] = 3.6

    cutoff[(41,41)] = 3.7
    cutoff[(28,28)] = 3.7
    cutoff[(41,28)] = 3.7
    cutoff[(28,41)] = 3.7

    cutoff[(46,46)] = 3.45
    cutoff[(14,14)] = 3.45
    cutoff[(46,14)] = 3.45
    cutoff[(14,46)] = 3.45

    m.generate_neighbors(cutoff)

    voronoi_3d(m,cutoff)

    vp_dict = load_param_file(paramfile)
    set_atom_vp_types(m,vp_dict)

    #vor_stats(m) # Prints what you probably want
    #index_stats(m)
    count = 0
    for atom in m.atoms:
        #print(atom.vp.index[:4])
        if(atom.vp.index[:4] == (0,1,10,2)):
            atoms = [a for a in atom.neighs]+[atom]
            for atom in atoms[1:]:
                #if( abs(atom.coord[0]-atoms[0].coord[0]) > 10 ):
                fix_atom(m, atoms[0], atom)
            vp = Model('0,1,10,2 vp',100,100,100,atoms)
            recenter_model(vp)
            vp.write('vp_data/vp{0}.xyz'.format(count))
            convert(vp,'polyhedron','vp_data/vp{0}.txt'.format(count))
            count += 1
开发者ID:jjmaldonis,项目名称:model_analysis,代码行数:52,代码来源:model_to_gams_input.py

示例4: main

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import write [as 别名]
def main():
    if(len(sys.argv) != 4):
        raise Exception("Usage: paramfile, jobid, npix for center positions of spots")
    paramfile = sys.argv[1]
    jobid = sys.argv[2]
    npix = int(sys.argv[3])
    #types = ['mgrid','ft_onespot1','ft_onespot2']
    types = ['mgrid']
    with open(paramfile) as f:
        params = f.readlines()
    params = [x.strip() for x in params]
    modelfile = params[0]
    stop = int(params[1])

    for i in range(0,stop):
        j = i*7 +2
        for t in types:
            prefix = params[j] + t + '_' + jobid
            file = prefix + '.gfx'
            lines_to_3d_wave(file, prefix + '.txt')
            if(t == 'mgrid'):
                p = subprocess.Popen(['/home/maldonis/3dft/stdev',file,jobid], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                for nextline in iter(p.stdout.readline, ""):
                    sys.stdout.write(nextline)
                    sys.stdout.flush()
                poutput = p.stdout.read()
                perr = p.stderr.read()
                preturncode = p.wait()
                if(preturncode != 0):
                    print("stdev exit status: "+str(preturncode))
                    raise Exception("stdev failed on file {0}!".format(file)+perr)
                new_model_file_base_name = params[j] + jobid
                worked = atom_selection(modelfile, 'stdev_'+jobid+'.gfx', 256, new_model_file_base_name)
                x0,y0,z0 = tuple([float(x) for x in params[j+1].split()])
                sx,sy,sz = tuple([float(x) for x in params[j+2].split()])
                cxy,cxz,cyz = tuple([float(x) for x in params[j+3].split()])
                xc = eval(params[j+4].split()[2])
                yc = eval(params[j+5].split()[2])
                zc = eval(params[j+6].split()[2])
                gvec = float(params[j+6].split()[3])
                print("g-vector length = {0}".format(gvec))
                print("The more correct g-vector length == {0}".format(sqrt((npix/4.0-x0+1)**2 + (npix/4.0-y0+1)**2 + (npix/4.0-z0)**2+1)*3.0/(npix/2)))
                if(worked == 0):
                    m = Model(new_model_file_base_name+'.xyz')
                    rot_arr = calc_rot_array_from_hkl(npix/2-xc,npix/2-yc,npix/2-zc)
                    rot(m, rot_arr)
                    m.write(new_model_file_base_name+'.rotated.xyz')
                    m.write(new_model_file_base_name+'.rotated.cif')
                print('')
开发者ID:jjmaldonis,项目名称:3dft,代码行数:51,代码来源:batch_convert.py

示例5: main

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import write [as 别名]
def main():
    modelfile = sys.argv[1]
    m = Model(modelfile)
    extension = modelfile.split('.')[-1]
    m.write('temp.dat')

    of = open("cgm_temp.in", 'w')
    of.write("""units		metal
boundary	p p p
atom_style	atomic

read_data temp.dat

pair_style	eam/alloy
pair_coeff	* * potentials/ZrCuAl2011.eam.alloy Zr Cu Al

thermo_style	custom step etotal fmax fnorm
thermo		1

minimize	1.0e-6 0 1000 10000
write_data  output.dat""")
    of.close()
开发者ID:jjmaldonis,项目名称:md,代码行数:24,代码来源:cgm.py

示例6: main

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import write [as 别名]
def main():
    model = Model(sys.argv[1])
    cluster_prefix = 'jason'
    #cluster_types = 'Crystal-like'
    #cluster_types = ['Icosahedra-like', 'Full-icosahedra']
    cluster_types = 'Icosahedra-like','Full-icosahedra'
    #cluster_types = 'Full-icosahedra'
    #cluster_types = 'Icosahedra-like'

    ag = AtomGraph(sys.argv[1],3.5)
    #clusters = ag.get_connected_clusters_with_neighs(3.5,cluster_types)
    #clusters = ag.get_connected_clusters_with_neighs(3.5,'Icosahedra-like','Full-icosahedra')
    #clusters = ag.get_interpenetrating_clusters_with_neighs(3.5,cluster_types)
    #clusters = ag.get_clusters(cluster_types)

    #clusters = ag.get_vertex_sharing_clusters(3.5,cluster_types)
    #clusters = ag.get_edge_sharing_clusters(3.5,cluster_types)
    #clusters = ag.get_face_sharing_clusters(3.5,cluster_types)
    #clusters = ag.get_interpenetrating_clusters_with_neighs(3.5,cluster_types)
    clusters = ag.get_interpenetrating_atoms(3.5,cluster_types)

    orig_clusters = clusters[:]
    # Print orig clusters
    j = 0
    for i,cluster in enumerate(clusters):
        print("Orig cluster {0} contains {1} atoms.".format(i,len(cluster)))
        # This changes all the atoms in the original cluster
        # (ie of type set above) to have no atomic number, 
        # which displays as Te (gold) in vesta for me
        #for atom in cluster:
        #    if(i==0): print(atom.vp.type)
        #    if(atom.vp.type in cluster_types):
        #        atom.z = 0
        # Save cluster files
        cluster_model = Model("Orig cluster {0} contains {1} atoms.".format(i,len(cluster)),model.lx, model.ly, model.lz, cluster)
        #for atom in cluster_model.atoms:
        #    if(atom.vp.type in cluster_types): print('  {0}\t{1}'.format(atom,atom.vp.type))
        cluster_model.write('{1}cluster{0}.cif'.format(i,cluster_prefix))
        cluster_model.write('{1}cluster{0}.xyz'.format(i,cluster_prefix))
开发者ID:adehgha,项目名称:model_analysis,代码行数:41,代码来源:atom_graph.py

示例7: main

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import write [as 别名]
def main():
    cutoff = {}
    cutoff[(40,40)] = 3.6
    cutoff[(13,29)] = 3.6
    cutoff[(29,13)] = 3.6
    cutoff[(40,13)] = 3.6
    cutoff[(13,40)] = 3.6
    cutoff[(29,40)] = 3.6
    cutoff[(40,29)] = 3.6
    cutoff[(13,13)] = 3.6
    cutoff[(29,29)] = 3.6

    cutoff[(41,41)] = 3.7
    cutoff[(28,28)] = 3.7
    cutoff[(41,28)] = 3.7
    cutoff[(28,41)] = 3.7

    cutoff[(46,46)] = 3.45
    cutoff[(14,14)] = 3.45
    cutoff[(46,14)] = 3.45
    cutoff[(14,46)] = 3.45

    paramfile = sys.argv[1]
    vp_dict = load_param_file(paramfile)

    modelfiles = sys.argv[2:]
    count = defaultdict(int) # Stores how many VPs have been found of each index type
    count = 0
    direc = 'ZrCuAl/md_80k/'
    for modelfile in modelfiles:
        print(modelfile)
        m = Model(modelfile)
        m.generate_neighbors(cutoff)
        #voronoi_3d(m,cutoff)
        #set_atom_vp_types(m,vp_dict)
        #vor_stats(m)
        #cats = index_stats(m)
        #for atom in m.atoms:
        #    #new = Model('0,0,12,0; number of atoms is {0};'.format(count), m.lx, m.ly, m.lz, atom.neighs + [atom])
        #    new = Model('{0}; number of atoms is {1};'.format(atom.vp.index, count[atom.vp.index]), m.lx, m.ly, m.lz, atom.neighs + [atom])
        #    fix_cluster_pbcs(new)
        #    val = normalize_bond_distances(new)
        #    new.comment = '{0}; number of atoms is {1}; bond length scaling factor is {2}'.format(atom.vp.index, count,val)
        #    center = find_center_atom(new)
        #    new.remove(center)
        #    new.add(center)
        #    vp_str = ''.join([str(x) for x in atom.vp.index])
        #    if not os.path.exists(direc+vp_str):
        #        os.makedirs(direc+vp_str)
        #    new.write(direc+'{0}/{0}.{1}.xyz'.format(vp_str, count[atom.vp.index]))
        #    count[atom.vp.index] += 1
        #print(count)
        cn = 0.0
        for atom in m.atoms:
            cn += atom.cn
        cn = float(cn)/m.natoms
        print(cn)

        for atom in m.atoms:
            new_cut = copy.copy(cutoff)
            old_cn = atom.cn
            inc = 0.0
            while atom.cn < 12:
                for key,val in new_cut.items(): new_cut[key] = val + 0.1
                inc += 0.1
                atom.neighs = m.get_atoms_in_cutoff(atom, new_cut)
                if(atom in atom.neighs): atom.neighs.remove(atom)
                atom.cn = len(atom.neighs)
            new = Model('CN changed from {0} to {1};'.format(old_cn, atom.cn), m.lx, m.ly, m.lz, atom.neighs + [atom])
            new.write('temp/{0}.xyz'.format(count))
            if inc > 0.0: print("Increased shell by {0} Ang. for atom {1}".format(inc, count))
            count += 1
        cn = 0.0
        for atom in m.atoms:
            cn += atom.cn
        cn = float(cn)/m.natoms
        print(cn)

    return 0

    modelfile = sys.argv[2]
    m = Model(modelfile)
    xtal_atoms = sys.argv[3]
    xtal_atoms = Model(xtal_atoms).atoms

    #x,y,z = (round(x,6) for x in self.coord)
    #a,b,c = (round(x,6) for x in other.coord)
    #print("HERE")
    #print([round(x,7) for x in xtal_atoms[13].coord])
    #print([round(x,7) for x in m.atoms[153].coord])
    #print(type(xtal_atoms[13]))
    #print(type(m.atoms[153]))
    #print(xtal_atoms[13] == m.atoms[153])
    #return 0

    glassy_atoms = []
    for atom in m.atoms:
        if atom not in xtal_atoms:
            glassy_atoms.append(atom)
    print(len(glassy_atoms))
#.........这里部分代码省略.........
开发者ID:adehgha,项目名称:model_analysis,代码行数:103,代码来源:generate_VP_clusters.py

示例8: Model

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import write [as 别名]
import sys, os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'resource-gcg', 'scripts'))
from model import Model

lexicon = Model('L')
sfile = open(sys.argv[1],'r')
opts = sys.argv[2:]

unkhold = [o for o in opts if '-u' in o]
if unkhold != []:
  unkhold = int(unkhold[0][2:])
else:
  unkhold = 0

for line in sfile.readlines():
  for word in line.split():
    lexicon[word] += 1
sfile.close()

for word in lexicon:
  if lexicon[word] < unkhold:
    lexicon[word] = 0.0

lexicon.write()
开发者ID:modelblocks,项目名称:modelblocks-release,代码行数:26,代码来源:buildlexicon.py

示例9: main

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import write [as 别名]
def main():
    # Load the MD model
    modelfile = sys.argv[1]
    md = Model(modelfile)

    # Make a model to hold all the atoms we pull out to make sure the original model was sampled uniformly.
    # Only the center atoms are added to this model.
    holding_model = Model(comment='holding box', xsize=md.xsize, ysize=md.ysize, zsize=md.zsize, atoms=[])

    # Load the cutoff dictionary so that we can generate neighbors for every atom
    from cutoff import cutoff

    # Directory name to save the files to
    dir = 'all_91200_clusters'
    if not os.path.exists(dir):
        os.makedirs(dir)

    # Set the number of clusters to randomly select
    num_clusters = 'all'
    if num_clusters == 'all' or num_clusters == md.natoms:
        random_selection = False
        num_clusters = md.natoms
    else:
        num_clusters = min(num_clusters, md.natoms)
        random_selection = True

    if random_selection:
        unpicked = range(md.natoms)

    start = 0
    for n in range(start, num_clusters+start):
        if random_selection:
            rand = random.choice(unpicked)
            unpicked.remove(rand)
            atom = md.atoms[rand]
        else:
            atom = md.atoms[n-start]
            rand = n-start

        # Generate neighbors for this atom
        atom.neighs = md.get_atoms_in_cutoff(atom, cutoff)
        if(atom in atom.neighs): atom.neighs.remove(atom)
        atom.cn = len(atom.neighs)

        holding_model.add(atom)

        # Create the cluster, normalize the bond distances, and write to disk
        atoms = atom.neighs + [atom]
        # c = create_cluster(md, atom, start, n, rand, center_included=True)
        c = Cluster(
            comment='cluster #{0} from atom {1}'.format(n-start, rand),
            xsize=md.xsize,
            ysize=md.ysize,
            zsize=md.zsize,
            atoms=atoms,
            center_included = True
        )
        ratio = c.normalize_bond_distances()
        c.comment='cluster #{0} from atom {1}; normalized bond distances by {2}'.format(n-start, rand, ratio)
        c.write(os.path.join(dir, '{0}.xyz'.format(n)))
        print(n-start, atom.id)
        #print(c)

    holding_model.write(os.path.join(dir, 'holding_model.xyz'))
开发者ID:jjmaldonis,项目名称:model_analysis,代码行数:66,代码来源:generate_clusters_for_alignment.py

示例10: Model

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import write [as 别名]
sunib = Model('UB'+opts)
sbi = CondModel(opts)

ver = -1

for line in srif:
  if line[0] == '\\':
    ver += 1
    if opts == 'U' and ver > 1:
      break
    continue
  elif ver == 0:
    continue

  sline = line.split()
  if (len(sline) < 3 and opts != 'U') or (opts == 'U' and len(sline) < 2):
    continue
  if ver == 1:
    suni[sline[1]] = 10**float(sline[0])
    if opts != 'U':
      sunib[sline[1]] = 10**float(sline[2])
  elif ver == 2:
    sbi[sline[1]][sline[2]] = 10**float(sline[0])

srif.close()

suni.write()
if opts != 'U':
  sunib.write()
  sbi.write()
开发者ID:modelblocks,项目名称:modelblocks-release,代码行数:32,代码来源:convert_srilm.py

示例11: main

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import write [as 别名]
def main():
    modelfile = sys.argv[1]
    m = Model(modelfile)
    for i,atom in enumerate(m.atoms):
        atom.id = i
    m.write(modelfile, ext='dat')
开发者ID:jjmaldonis,项目名称:md,代码行数:8,代码来源:sort_by_id.py


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