예제 #1
0
        exit(0)

    chgcarfiles = sys.argv[1].split(",")
    bondLengths = map(float, sys.argv[2].split(","))
    normalize = False
    if len(sys.argv) > 3:
        if sys.argv[3][0] in ["n", "N"]:
            normalize = True
    verbose = True

    Ninterps = [15, 15, 15]
    if len(sys.argv) > 4:
        Ninterps = map(int, sys.argv[4].split(","))

    for chgcarfile in chgcarfiles:

        avgGrids, bondCounts = chgcarBondAnalysis(chgcarfile,
                                                  bondLengths,
                                                  normalize,
                                                  verbose,
                                                  Ninterps=Ninterps)

        chgcar = open(chgcarfile, "r").readlines()
        poscardata, gridSize, chg = chgcarIO.read(chgcar)

        for avgGrid, bondCount, cutoff in zip(avgGrids, bondCounts,
                                              bondLengths):
            vtkfname = chgcarfile + "_cut%2.2f_NBond%d.vtk" % (cutoff,
                                                               bondCount)
            chgcarIO.writeVTK(vtkfname, poscardata, avgGrid.shape, avgGrid)
예제 #2
0
#mine
import chgcarIO

def usage():
    print "Usage:"
    print "%s <chg-vtk-file>"%sys.argv[0]
    sys.exit()

if not(len(sys.argv) in [2]):
    usage()

fname=sys.argv[1]
vtkfile=fname+".vtk"

poscarData,chgcarData=chgcarIO.read(open(fname,"r").readlines(),swapxz=False)
chgcarIO.writeVTK(vtkfile,poscarData,chgcarData)

#---------------------------------
#Below is taken from website
#x---------------------------------
# Interaction with an Isosurface visualization

# A reader
reader = vtkStructuredPointsReader()
reader.SetFileName(vtkfile)

renWin = vtkRenderWindow()
renWin.SetWindowName("%s"%vtkfile)
renWin.SetPolygonSmoothing(1)
#renWin.SetAAFrames(2)
예제 #3
0
        def clearoutlier(i,a): return 1.0 if i>a else i/a
        avgval=scipy.sum(chgdata)/Tot_pnts
        vclearout=vectorize(clearoutlier)
        chgdata=vclearout(chgdata,avgval)
        #chgdata=array([i/avgval for i in chgdata])
        chgdata.shape=gridsz
    #chgdata=chgdata.ravel()
    for i in range(gridsz[0]):
         for j in range(gridsz[1]):
            vtkfile.write(" ".join(map(lambda x:str(x),chgdata[i][j]))+"\n")
"""


def usage():
    print "Usage: %s <input chgcar> <optional:output vtk filename>" % sys.argv[
        0].split("/")[-1]


if len(sys.argv) < 2:
    usage()
    exit(0)

chgfname = sys.argv[1]
if len(sys.argv) == 3:
    vtkfname = sys.argv[2]
else:
    vtkfname = chgfname + ".vtk"

poscardata, chgdata = chgcarIO.read(open(chgfname, "r").readlines())
chgcarIO.writeVTK(vtkfname, poscardata, chgdata, clean=True)
예제 #4
0
    if clean==True:
        chgdata=chgdata.ravel()
        def clearoutlier(i,a): return 1.0 if i>a else i/a
        avgval=scipy.sum(chgdata)/Tot_pnts
        vclearout=vectorize(clearoutlier)
        chgdata=vclearout(chgdata,avgval)
        #chgdata=array([i/avgval for i in chgdata])
        chgdata.shape=gridsz
    #chgdata=chgdata.ravel()
    for i in range(gridsz[0]):
         for j in range(gridsz[1]):
            vtkfile.write(" ".join(map(lambda x:str(x),chgdata[i][j]))+"\n")
"""

def usage():
    print "Usage: %s <input chgcar> <optional:output vtk filename>"%sys.argv[0].split("/")[-1]

if len(sys.argv)<2:
    usage()
    exit(0)
    
chgfname=sys.argv[1]
if len(sys.argv)==3:
    vtkfname=sys.argv[2]
else:
    vtkfname=chgfname+".vtk"

poscardata,chgdata=chgcarIO.read(open(chgfname,"r").readlines())
chgcarIO.writeVTK(vtkfname,poscardata,chgdata,clean=True)
예제 #5
0
        print "Usage:"
        print "%s <CHGCAR0,CHGCAR1...> <maxL0,maxL1,maxL2...> <[N,n]ormalize by total avg charge> <Ninterps: x,y,z>"%(sys.argv[0])
        print "Note, CHGCAR must be part of a cubic/rectangular simulation"

    if len(sys.argv)<3:
        usage()
        exit(0)

    chgcarfiles=sys.argv[1].split(",")
    bondLengths=map(float,sys.argv[2].split(","))
    normalize=False
    if len(sys.argv)>3:
        if sys.argv[3][0] in ["n","N"]:
            normalize=True
    verbose=True

    Ninterps=[15,15,15]
    if len(sys.argv)>4:
        Ninterps=map(int,sys.argv[4].split(","))

    for chgcarfile in chgcarfiles:

        avgGrids,bondCounts=chgcarBondAnalysis(chgcarfile,bondLengths,normalize,verbose,Ninterps=Ninterps)

        chgcar=open(chgcarfile,"r").readlines()
        poscardata,gridSize,chg = chgcarIO.read(chgcar)
        
        for avgGrid,bondCount,cutoff in zip(avgGrids,bondCounts,bondLengths):
            vtkfname=chgcarfile+"_cut%2.2f_NBond%d.vtk"%(cutoff,bondCount)
            chgcarIO.writeVTK(vtkfname,poscardata,avgGrid.shape,avgGrid)