Пример #1
0
def rdfCriteria(atoms,basis,cr,criteria=None,perTS=False):
    atoms = array(atoms)
    basis = array(basis)
    nTime = atoms.shape[0]
    nAtom = atoms.shape[1]

    nDel=0                      
    ltFlag = False
    if "lt" in criteria:                                                           
        ltFlag=True
    cutoff = float(criteria[2:])
                
    if perTS:
        pass
    else:
        for i,r in enumerate(cr):
            if ltFlag:
                if r>cutoff:
                    atoms = delete(atoms,i-nDel,1)
                    nAtom -= 1
                    nDel += 1
            else:
                if r<cutoff:
                    atoms = delete(atoms,i-nDel,1)
                    nAtom -= 1
                    nDel += 1
        print "nAtom=%d atoms meet criteria %s"%(nAtom,criteria)

    nbins = 1000
    rcut = 10.0
    rdf = zeros(nbins)
    for i in range(nTime):
        if perTS:
            if ltFlag:
                atomCR = atoms[i][ where( cr[i] < cutoff)[0] ]
            else:
                atomCR = atoms[i][ where( cr[i] > cutoff)[0] ]
            print "nAtom=%d atoms meet criteria %s"%(len(atomCR),criteria)
            rbins,rdist = rdf_periodic(atomCR,basis,rcut,nbins)
        else:
            rbins,rdist = rdf_periodic(atoms[i],basis,rcut,nbins)
        rdf += rdist
    rdf /= nTime

    return rbins,rdf
Пример #2
0
    rdistavg=zeros(nbins)

cnt=0
while True:
    try:
        dump,bounds,types,atoms,head = dumpReadNext(dump)
        cnt+=1
    except Exception as inst:
        #last of the configurations
        if avg==0:
            print "No more configs in dump file."
        else:
            print "Found %d configurations."%cnt
        break
    
    [rbins,rdist]=rdf_periodic(array(atoms),array(bounds),cutoff=cutoff,nbins=nbins)
    
    if avg==0:
        if smooth==1:
            smdist=rdist[:]
            smdist = wsmooth(smdist,nbins/10)
            plotting(rbins,smdist)
        else:
            plotting(rbins,rdist)
    else:
        rdistavg+=rdist

    if avg>=1 and cnt%avg==0 and cnt>0: 
        plotting(rbins,rdistavg/avg)
        rdistavg=zeros(nbins)
Пример #3
0
lengths = array(map(lambda x: float(x) * 1E10, xdatcar[1].split()[1:4]))
xdatcar = xdatcar[5:]

delr = float(cutoff) / numbins
pcors = list()

i = 0
cnt = 0
atomconfigs = list()
while i < len(xdatcar):
    i += 1
    cnt += 1
    atoms = map(lambda x: map(float, x.split()), xdatcar[i:i + Natoms])
    i += Natoms
    pcors.append(
        rdf_periodic(array(atoms), basis, cutoff=cutoff, nbins=numbins)[1])

print "=" * 50
print "=" * 50
print "%d Configurations found." % len(pcors)
print "=" * 50
print "=" * 50
print "Writing rdf of these configurations to %s" % pcfile
head = "\nCreated by %s, from %s\n" % (sys.argv[0].split(
    "/")[-1], xdatfile) + "\n" * 4 + str(numbins) + "\n" * 2 + str(
        delr / 1E10) + "\n" * 4
pcdat = open(pcfile, "w")
pcdat.write(head)
for pcor in pcors:
    dat = "\n".join(map(str, pcor))
    pcdat.write(dat + "\n\n")
Пример #4
0
    nbins=int(sys.argv[3])    
if len(sys.argv)==5:
    pcfile=sys.argv[4]

dumpfile=sys.argv[1]
dump=open(dumpfile,"r").readlines()

delr=float(cutoff)/nbins
pcors=list()

i=0
cnt=0
while True:
    try:
        dump,bounds,types,atoms,head = dumpReadNext(dump)
        cnt+=1
    except Exception as inst:
        #last of the configurations
        break
    pcors.append(rdf_periodic(array(atoms),array(bounds),cutoff=cutoff,nbins=nbins)[1])
    print cnt
print "Found %d configurations."%cnt
print "Writing RDF of these configurations to %s"%pcfile
head="\nCreated by %s, from %s\n"%(sys.argv[0].split("/")[-1],dumpfile)+"\n"*4+str(nbins)+"\n"*2+str(delr/1E10)+"\n"*4
pcdat=open(pcfile,"w")
pcdat.write(head)
for pcor in pcors:
    dat="\n".join(map(str,pcor))
    pcdat.write(dat+"\n\n")
    
Пример #5
0
Natoms = int(xdatcar[0].split()[0])
lengths = array(map(lambda x: float(x) * 1e10, xdatcar[1].split()[1:4]))
xdatcar = xdatcar[5:]

delr = float(cutoff) / numbins
pcors = list()

i = 0
cnt = 0
atomconfigs = list()
while i < len(xdatcar):
    i += 1
    cnt += 1
    atoms = map(lambda x: map(float, x.split()), xdatcar[i : i + Natoms])
    i += Natoms
    pcors.append(rdf_periodic(array(atoms), basis, cutoff=cutoff, nbins=numbins)[1])

print "=" * 50
print "=" * 50
print "%d Configurations found." % len(pcors)
print "=" * 50
print "=" * 50
print "Writing radial distribution function of these configurations to %s" % pcfile
head = (
    "\nCreated by %s, from %s\n" % (sys.argv[0].split("/")[-1], xdatfile)
    + "\n" * 4
    + str(numbins)
    + "\n" * 2
    + str(delr / 1e10)
    + "\n" * 4
)
Пример #6
0
cnt = 0
while True:
    try:
        dump, bounds, types, atoms, head = dumpReadNext(dump)
        cnt += 1
    except Exception as inst:
        #last of the configurations
        if avg == 0:
            print "No more configs in dump file."
        else:
            print "Found %d configurations." % cnt
        break

    [rbins, rdist] = rdf_periodic(array(atoms),
                                  array(bounds),
                                  cutoff=cutoff,
                                  nbins=nbins)

    if avg == 0:
        if smooth == 1:
            smdist = rdist[:]
            smdist = wsmooth(smdist, nbins / 10)
            plotting(rbins, smdist)
        else:
            plotting(rbins, rdist)
    else:
        rdistavg += rdist

    if avg >= 1 and cnt % avg == 0 and cnt > 0:
        plotting(rbins, rdistavg / avg)
        rdistavg = zeros(nbins)
Пример #7
0
dumpfile = sys.argv[1]
dump = open(dumpfile, "r").readlines()

delr = float(cutoff) / nbins
pcors = list()

i = 0
cnt = 0
while True:
    try:
        dump, bounds, types, atoms, head = dumpReadNext(dump)
        cnt += 1
    except Exception as inst:
        #last of the configurations
        break
    pcors.append(
        rdf_periodic(array(atoms), array(bounds), cutoff=cutoff,
                     nbins=nbins)[1])
    print cnt
print "Found %d configurations." % cnt
print "Writing RDF of these configurations to %s" % pcfile
head = "\nCreated by %s, from %s\n" % (sys.argv[0].split(
    "/")[-1], dumpfile) + "\n" * 4 + str(nbins) + "\n" * 2 + str(
        delr / 1E10) + "\n" * 4
pcdat = open(pcfile, "w")
pcdat.write(head)
for pcor in pcors:
    dat = "\n".join(map(str, pcor))
    pcdat.write(dat + "\n\n")