Example #1
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)


if avg==1:
    cntavg=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

    bounds=[[0,bounds[0][0]],[0,bounds[1][1]],[0,bounds[2][2]]]
    Qis=orderParam.bondOrientation(array(atoms),array(bounds),l,neighbCut=cutoff,ortho=True)
    (cnts,bins) = histogram(Qis,bins=nbins,range=(0,cutoff))
    
    if avg==0:
        if smooth==1:
            smCnts = wsmooth(cnts,nbins/10)
            plotting(bins,smCnts)
        else:
            plotting(bins,cnts)
    else:
        cntavg+=cnts
if avg==1:
    plotting(bins,cntavg/cnt)
Example #3
0

def residual_qhr(coefs, y, x):
    Q = interp(dx, coefs, x)
    hr = y
    return x * hr - hrq_calc(dr, Q, hr, x)


basis, atypes, atoms, head, poscar = poscarIO.read(
    open(sys.argv[1]).readlines())
atoms = array(atoms)
basis = array(basis)
rads, gr = radialDistribution(atoms, basis)
rads = array(rads)

hr = wsmooth(gr)[:-1] - 1  #superSmooth(rads,gr)[:-20] - 1
#hr = gr - 1
dr = rads[1] - rads[0]
density = atoms.shape[0] / dot(cross(basis[0], basis[1]), basis[2])

rcut = rads[-1]
radsCut = [i for i in rads if i <= rcut]
hrCut = [hr[i] for i in range(len(rads)) if rads[i] <= rcut]

Nknots = 70
xknots = array([i * max(radsCut) / Nknots for i in range(Nknots)])
dx = xknots[1] - xknots[0]
yknots = list()
for i in range(Nknots):
    if i == 0:
        yknots.append(0)
Example #4
0
    cq = array([ 4*pi*simps(rads*cr*np.sin(q*rads)/q,dx=dx) for q in qs])
    return 1./(1. - density*cq)

def residual_qhr(coefs,y,x):
    Q = interp(dx,coefs,x)
    hr = y
    return x*hr - hrq_calc(dr,Q,hr,x)


basis,atypes,atoms,head,poscar = poscarIO.read(open(sys.argv[1]).readlines())
atoms=array(atoms)
basis=array(basis)
rads,gr = radialDistribution(atoms,basis)
rads = array(rads)

hr = wsmooth(gr)[:-1] - 1#superSmooth(rads,gr)[:-20] - 1
#hr = gr - 1
dr=rads[1]-rads[0]
density = atoms.shape[0]/dot(cross(basis[0],basis[1]),basis[2])

rcut = rads[-1]
radsCut = [i for i in rads if i <= rcut]
hrCut = [hr[i] for i in range(len(rads)) if rads[i] <= rcut]

Nknots=70
xknots=array([i*max(radsCut)/Nknots for i in range(Nknots)])
dx=xknots[1]-xknots[0]
yknots=list()
for i in range(Nknots):
    if i==0:
        yknots.append(0)
Example #5
0
count = 0
for line in outcar:
    if "(temperature" in line:
        tmpt.append(float(line.split("(temperature")[1].split()[0]))
    if "in kB" in line:
        # print line.split("in kB")[1].strip()
        [sx, sy, sz] = [float(i) for i in line.split("in kB")[1].split()[:3]]
        strsx.append(sx)
        strsy.append(sy)
        strsz.append(sz)

# The average Stress
strsavg = [(strsx[i] + strsy[i] + strsz[i]) / 3 for i in range(len(strsx))]

# A windowed average
winavg = wsmooth(strsavg, 10)

print len(winavg), len(strsavg), len(strsz), len(tmpt)

# Plotting
pl.figure()
pl.plot(tmpt, strsx, ls="--")
pl.plot(tmpt, strsy, ls="--")
pl.plot(tmpt, strsz, ls="--")
pl.plot(tmpt, strsavg, ls="--")
pl.plot(tmpt, winavg, c="black", lw=2)
pl.legend(["StressX", "StressY", "StressZ", "Avg", "Running Avg"], loc=0)
pl.xlabel("Temperature (K)")
pl.ylabel("Stress (kB)")
pl.title(sys.argv[1])
pr.prshow("outcarStressT.png")
Example #6
0
    pl.show()
    exit(0)

#Special Case for FRDF histogrammic RDF
if op == "FRDF":
    from numpy import bincount,array,zeros
    import numpy as np
    from datatools import wsmooth

    t = zip(*[[j*100 for j in orderVals[i][1]] for i in range(len(orderVals))])
    avgx = orderVals[0][0]
    a=zeros([len(t),2000])
    mx=0
    for i,v in enumerate(t):
        a[i]=bincount(v,minlength=2000)
        a[i]=wsmooth(a[i],window_len=75)[0:2000]
        m=max(a[i])
        a[i]=np.log([j/m for j in a[i]])

    pl.imshow(a.T,origin='lower',cmap=pl.get_cmap("Blues"))
    pl.yticks(range(0,1000,100),range(10))
    pl.xticks(range(0,1001,100),range(11))

    pl.show()
    exit(0)

def savetxtWrapper(defaultFileName,data,delimiter=" ",header=" ",comments=""):
    try:
        if saveFileName is "None":
            savetxt(defaultFileName,data,delimiter=delimiter,header=header,comments=comments)
        else:
Example #7
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)
Example #8
0
    exit(0)

#Special Case for FRDF histogrammic RDF
if op == "FRDF":
    from numpy import bincount, array, zeros
    import numpy as np
    from datatools import wsmooth

    t = zip(*[[j * 100 for j in orderVals[i][1]]
              for i in range(len(orderVals))])
    avgx = orderVals[0][0]
    a = zeros([len(t), 2000])
    mx = 0
    for i, v in enumerate(t):
        a[i] = bincount(v, minlength=2000)
        a[i] = wsmooth(a[i], window_len=75)[0:2000]
        m = max(a[i])
        a[i] = np.log([j / m for j in a[i]])

    pl.imshow(a.T, origin='lower', cmap=pl.get_cmap("Blues"))
    pl.yticks(range(0, 1000, 100), range(10))
    pl.xticks(range(0, 1001, 100), range(11))

    pl.show()
    exit(0)


def savetxtWrapper(defaultFileName,
                   data,
                   delimiter=" ",
                   header=" ",
Example #9
0
utils.usage(["<.ensembleFile>","<window size (int or all)>"],2,2)

inputFile = sys.argv[1]
possibleSuffixes = [".tetra",".rmsd",".cn"]
if not any([suffix for suffix in possibleSuffixes if suffix in inputFile]):
    print "wrong input file dummy."
    exit(0)

windowSize = sys.argv[2]
outputFile = inputFile+".avg"+windowSize

#assume first line is a header
head = open(inputFile,"r").readline()

configIterator = parserGens.parseEnsemble(inputFile,keepAvg=True)
ops = zip(*[a for a in configIterator])

if windowSize == "all":
    opAvg = [sum(op)/len(op) for op in ops]
    opLines = [" ".join(map(str,opAvg))+"\n"]
else:
    windowSize = int(windowSize)

    opAvg = zip(*[datatools.wsmooth(atet,windowSize) for atet in ops])
    opLines = [" ".join(map(str,line))+"\n" for line in opAvg]

out = open(outputFile,"w")
out.write(head)
out.writelines(opLines)
Example #10
0
    print "wrong input file dummy."
    exit(0)

windowSize = sys.argv[2]
outputFile = inputFile + ".avg" + windowSize

configIterator = parserGens.parseEnsemble(inputFile, keepAvg=True)
tetras = zip(*[a for a in configIterator])

if windowSize == "all":
    tetraAvg = [sum(atet) / len(atet) for atet in tetras]
    tetraLines = [" ".join(map(str, tetraAvg)) + "\n"]
else:
    windowSize = int(windowSize)

    tetraAvg = zip(*[datatools.wsmooth(atet, windowSize) for atet in tetras])
    tetraLines = [" ".join(map(str, line)) + "\n" for line in tetraAvg]

    """
    tetraAvg = zip(*[datatools.windowAvg(atet,n=windowSize,option='valid') for atet in tetras])
    tetraPre = list()
    tetraPost = list()
    def avg(x):
        return sum(x)/len(x)
    for i in range(windowSize/2):
        print i
        tetraPre.append(map(avg,tetras[:i]))
        tetraPost.append(map(avg,tetras[-windowSize+i:]))
    tetraLines = [" ".join(map(str,line))+"\n" for line in tetraPre] +\
                 [" ".join(map(str,line))+"\n" for line in tetraAvg] +\
                 [" ".join(map(str,line))+"\n" for line in tetraPost]
Example #11
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

    bounds = [[0, bounds[0][0]], [0, bounds[1][1]], [0, bounds[2][2]]]
    Qis = orderParam.bondOrientation(array(atoms),
                                     array(bounds),
                                     l,
                                     neighbCut=cutoff,
                                     ortho=True)
    (cnts, bins) = histogram(Qis, bins=nbins, range=(0, cutoff))

    if avg == 0:
        if smooth == 1:
            smCnts = wsmooth(cnts, nbins / 10)
            plotting(bins, smCnts)
        else:
            plotting(bins, cnts)
    else:
        cntavg += cnts
if avg == 1:
    plotting(bins, cntavg / cnt)