Ejemplo n.º 1
0
        os.system('cp %sPOTCAR .' % mirdir)
        os.system('cp %svaspjob .' % mirdir)
        os.system('cp %sPOSCAR POSCARaflow' % mirdir)
        #        totatoms = km.aflow2poscar(path)
        #        os.system('aconvasp --sprim < POSCAR0 > POSCAR')
        #        back = subprocess.check_output(["echo", "Hello World!"])
        #        back = check_out(["echo", "Hello World!"])
        #        back = os.system('mink_reduction.py < POSCAR0 ')
        #        back = subprocess.check_output(['mink_reduction.py',' <',' POSCAR0 '], shell=True,)
        #        back = nstrip(subprocess.check_output(['mink_reduction.py < POSCAR0'], shell=True,).split())
        #        print 'back'
        #        print back

        pfile = open('POSCARaflow', 'r')
        rlines = [i.strip() for i in pfile.readlines()]
        pos = POSCAR(lines=rlines)
        totatoms = np.sum(pos.types)
        N = np.rint(Nkppra / totatoms).astype(int)
        oldROD = pos.rod
        oldbvecs = np.array(pos.bvecs)
        reallatt = np.array((pos.avecs[0], pos.avecs[1], pos.avecs[2]))
        print "Real lattice"
        print reallatt
        print "Recip lattice"
        reciplatt = np.array((pos.bvecs[0], pos.bvecs[1], pos.bvecs[2]))
        print reciplatt
        print "Recip lattice/2pi"
        reciplatt = np.array((pos.bvecs[0], pos.bvecs[1], pos.bvecs[2]))
        print reciplatt / 2 / np.pi
        print "Real lattice orth defect:", pos.orthogonality_defect
        print "Recp lattice orth defect:", pos.rod
Ejemplo n.º 2
0
if __name__ == "__main__":

    args= docopt(__doc__)

    zmin= float(args['--zmin'])
    zmax= float(args['--zmax'])
    sfplane= args['--plane']
    ndiv= int(args['--ndiv'])
    _fname= args['POSCAR']
    dr= []
    for i in range(len(args['DX'])):
        dr.append((float(args['DX'][i]),float(args['DY'][i])))

    if not sfplane in ('x','y','z'):
        print(' --plane must be x, y, or z !!!')
        print(' Now --plane=',sfplane)
        exit

    if zmin < 0.0 or zmin > 1.0 or zmax < 0.0 or zmax > 1.0 or zmax < zmin:
        print(' Should be 0.0 <= zmin < zmax < 1.0 !!!')
        print(' zmin, zmax = ',zmin, zmax)
        exit

    poscar= POSCAR()
    poscar.read(fname=_fname)

    _shift_and_write(poscar,sfplane,ndiv,zmin,zmax,dr)
    
    
Ejemplo n.º 3
0
############################################################ main

if __name__ == "__main__":

    args = docopt(__doc__)
    # print args

    zmin = float(args['--zmin'])
    zmax = float(args['--zmax'])
    sfplane = args['--plane']
    ndiv = int(args['--ndiv'])
    _fname = args['POSCAR']
    dr = []
    for i in range(len(args['DX'])):
        dr.append((float(args['DX'][i]), float(args['DY'][i])))

    if not sfplane in ('x', 'y', 'z'):
        print ' --plane must be x, y, or z !!!'
        print ' Now --plane=', sfplane
        exit

    if zmin < 0.0 or zmin > 1.0 or zmax < 0.0 or zmax > 1.0 or zmax < zmin:
        print ' Should be 0.0 <= zmin < zmax < 1.0 !!!'
        print ' zmin, zmax = ', zmin, zmax
        exit

    poscar = POSCAR()
    poscar.read(fname=_fname)

    _shift_and_write(poscar, sfplane, ndiv, zmin, zmax, dr)
Ejemplo n.º 4
0
                  +" Default value is 0.05.")
parser.add_option("-n","--num-output",dest="nout",
                  type="int",default=10,
                  help="number of output files in total."
                  +" Default value is 10.")
parser.add_option("-o","--offset",dest="offset",
                  type="int",default=0,
                  help="offset of sequential number in output file.")
(options,args)= parser.parse_args()

maxdis= options.maxdis
nout= options.nout
offset= options.offset

fname= args[0]
poscar= POSCAR()
poscar.read(fname=fname)

#...original a vectors
ho= poscar.h *poscar.afac

hi= np.linalg.inv(ho)

inc= offset

for i in range(nout):
    for ia in range(1,len(poscar.pos)):
        r= maxdis*random()
        theta= pi*random()
        phi= 2.0*pi*random()
        dr= get_displacement(r,theta,phi)
Ejemplo n.º 5
0
        os.system('cp %sPOTCAR .' % mirdir)
        os.system('cp %svaspjob .' % mirdir)
        os.system('cp %sPOSCAR POSCARaflow' % mirdir)        
#        totatoms = km.aflow2poscar(path)
#        os.system('aconvasp --sprim < POSCAR0 > POSCAR')
#        back = subprocess.check_output(["echo", "Hello World!"])  
#        back = check_out(["echo", "Hello World!"])
#        back = os.system('mink_reduction.py < POSCAR0 ')
#        back = subprocess.check_output(['mink_reduction.py',' <',' POSCAR0 '], shell=True,)
#        back = nstrip(subprocess.check_output(['mink_reduction.py < POSCAR0'], shell=True,).split())
#        print 'back'
#        print back

        pfile = open('POSCARaflow','r')
        rlines  = [i.strip() for i in pfile.readlines()]       
        pos = POSCAR(lines=rlines)
        totatoms = np.sum(pos.types)
        N = np.rint(Nkppra/totatoms).astype(int)   
        oldROD = pos.rod
        oldbvecs = np.array(pos.bvecs)
        reallatt = np.array((pos.avecs[0],pos.avecs[1],pos.avecs[2]))
        print "Real lattice"
        print  reallatt  
        print "Recip lattice"
        reciplatt = np.array((pos.bvecs[0],pos.bvecs[1],pos.bvecs[2]))
        print  reciplatt
        print "Recip lattice/2pi"         
        reciplatt = np.array((pos.bvecs[0],pos.bvecs[1],pos.bvecs[2]))
        print reciplatt/2/np.pi     
        print "Real lattice orth defect:",pos.orthogonality_defect
        print "Recp lattice orth defect:",pos.rod
Ejemplo n.º 6
0
 os.system('cp ../../KPOINTS .')
 os.system('cp ../../INCAR .')
 os.system('cp ../../POTCAR .')
 totatoms = km.aflow2poscar(path)
 #        os.system('aconvasp --sprim < POSCAR0 > POSCAR')
 #        back = subprocess.check_output(["echo", "Hello World!"])
 #        back = check_out(["echo", "Hello World!"])
 #        back = os.system('mink_reduction.py < POSCAR0 ')
 #        back = subprocess.check_output(['mink_reduction.py',' <',' POSCAR0 '], shell=True,)
 #        back = nstrip(subprocess.check_output(['mink_reduction.py < POSCAR0'], shell=True,).split())
 #        print 'back'
 #        print back
 N = np.rint(Nkppra / totatoms).astype(int)
 pfile = open('POSCAR0', 'r')
 rlines = [i.strip() for i in pfile.readlines()]
 pos = POSCAR(lines=rlines)
 oldROD = pos.rod
 oldbvecs = np.array(pos.bvecs)
 print "Real lattice orth defect:", pos.orthogonality_defect
 print "Recp lattice orth defect:", pos.rod
 pos.kmink_reduce(1e-1)
 sys.stdout.flush()
 newROD = pos.rod
 newbvecs = np.array(pos.bvecs)
 reciplatt = np.array((pos.bvecs[0], pos.bvecs[1], pos.bvecs[2]))
 #        print reciplatt
 test = []
 if abs(newROD - oldROD) < 1e-3 and np.equal(newbvecs, oldbvecs).all:
     #        if abs(newROD - oldROD) < 1e-3 :
     print "Recip lattice already reduced"
 else:
parser= optparse.OptionParser(usage=usage)
parser.add_option("-d","--dev",dest="dev",type="float",default=0.01,
                  help="maximum value of each strain element.")
parser.add_option("-n","--num-dev",dest="ndev",type="int",default=2,
                  help="number of devision in each strain element.")
parser.add_option("--offset",dest="offset",type="int",default=0,
                  help="offset of sequential number in output file.")

(options,args)= parser.parse_args()

dev= options.dev
ndev= options.ndev
offset= options.offset

fname= args[0]
poscar= POSCAR()
poscar.read(fname=fname)

#.....original lattice constant
afac0= copy.deepcopy(poscar.afac)

inc= offset

da= 2*dev/ndev *afac0
al0= afac0 *(1.0 -dev)
print "afac0=",afac0
print "dev  =",dev
print "ndev =",ndev
print "da   =",da
print "al0  =",al0
for na in range(ndev+1):
Ejemplo n.º 8
0
        os.system('cp ../../KPOINTS .')
        os.system('cp ../../INCAR .')
        os.system('cp ../../POTCAR .')        
        totatoms = km.aflow2poscar(path)
#        os.system('aconvasp --sprim < POSCAR0 > POSCAR')
#        back = subprocess.check_output(["echo", "Hello World!"])  
#        back = check_out(["echo", "Hello World!"])
#        back = os.system('mink_reduction.py < POSCAR0 ')
#        back = subprocess.check_output(['mink_reduction.py',' <',' POSCAR0 '], shell=True,)
#        back = nstrip(subprocess.check_output(['mink_reduction.py < POSCAR0'], shell=True,).split())
#        print 'back'
#        print back
        N = np.rint(Nkppra/totatoms).astype(int)
        pfile = open('POSCAR0','r')
        rlines  = [i.strip() for i in pfile.readlines()]       
        pos = POSCAR(lines=rlines)   
        oldROD = pos.rod
        oldbvecs = np.array(pos.bvecs)
        print "Real lattice orth defect:",pos.orthogonality_defect
        print "Recp lattice orth defect:",pos.rod
        pos.kmink_reduce(1e-1)
        sys.stdout.flush()
        newROD = pos.rod
        newbvecs = np.array(pos.bvecs)
        reciplatt = np.array((pos.bvecs[0],pos.bvecs[1],pos.bvecs[2]))
#        print reciplatt
        test = []
        if abs(newROD - oldROD) < 1e-3 and np.equal(newbvecs,oldbvecs).all:
#        if abs(newROD - oldROD) < 1e-3 :
            print "Recip lattice already reduced"         
        else: