def orthsuper(B):
    '''For lattice with orthogonal nonprimitive lattice vectors (cubic, tetragonal, orthorhombic),
    finds the simple orthorhombic superlattice with minimum s/v.'''
    # Find a set of three shortest lattice vectors that are perpendicular
    A = lattice()
    A.vecs = trimSmall(inv(transpose(B.vecs)))
    #    print 'A'; print A.vecs
    #    print 'det a', det(A.vecs)
    [A.symops, A.nops] = getGroup(A.vecs)
    A.lattype = latticeType(A.nops)

    #    printops_eigs(A)
    #    print 'transp A'; print transpose(A)
    S = zeros((3, 3), dtype=float)
    M = zeros((3, 3), dtype=int)
    K = zeros((3, 3), dtype=float)
    #    S_orth = three_perp(A.vecs,B.lattype)
    print
    S_orth = three_perp_eigs(A)
    #    sys.exit('stop')
    M = rint(transpose(dot(inv(A.vecs), S_orth))).astype(int)
    print 'M by finding 3 shortest perpendicular vectors'
    print M
    print 'det M', det(M)

    #starting mesh Q with 3 free directions.
    Q = dot(B.vecs, inv(M))
    print 'mesh numbers'
    [n0, n1, n2] = svmesh(B.Nmesh / abs(det(M)), Q)[0]
    print[n0, n1, n2]
    K[:, 0] = Q[:, 0] / n0
    K[:, 1] = Q[:, 1] / n1
    K[:, 2] = Q[:, 2] / n2
    #    print K
    Nmesh = B.det / abs(det(K))
    if checksymmetry(K, B):
        pf = packingFraction(K)
        print 'Packing fraction (orthmesh)', pf, 'vs original B', packingFraction(
            B.vecs)
        print 'Nmesh', Nmesh, 'vs target', B.Nmesh
    else:
        sys.exit('Symmetry failed in orthsuper')
    return [K, pf, True]
Esempio n. 2
0
def orthsuper(B):
    '''For lattice with orthogonal nonprimitive lattice vectors (cubic, tetragonal, orthorhombic),
    finds the simple orthorhombic superlattice with minimum s/v.'''
    # Find a set of three shortest lattice vectors that are perpendicular
    A = lattice()
    A.vecs = trimSmall(inv(transpose(B.vecs)))
#    print 'A'; print A.vecs
#    print 'det a', det(A.vecs)
    [A.symops,A.nops] = getGroup(A.vecs)
    A.lattype = latticeType(A.nops)
    
#    printops_eigs(A)
#    print 'transp A'; print transpose(A)    
    S = zeros((3,3),dtype = float)
    M = zeros((3,3),dtype = int)
    K = zeros((3,3),dtype = float)
#    S_orth = three_perp(A.vecs,B.lattype)
    print; S_orth =  three_perp_eigs(A)  
#    sys.exit('stop')  
    M = rint(transpose(dot(inv(A.vecs),S_orth))).astype(int)
    print 'M by finding 3 shortest perpendicular vectors';print M
    print 'det M', det(M)

    #starting mesh Q with 3 free directions. 
    Q = dot(B.vecs,inv(M))
    print 'mesh numbers'; 
    [n0,n1,n2] = svmesh(B.Nmesh/abs(det(M)),Q)[0]
    print [n0,n1,n2]
    K[:,0] = Q[:,0]/n0; K[:,1] = Q[:,1]/n1; K[:,2] = Q[:,2]/n2
#    print K
    Nmesh = B.det/abs(det(K))
    if checksymmetry(K,B):
        pf = packingFraction(K)
        print 'Packing fraction (orthmesh)', pf, 'vs original B', packingFraction(B.vecs)  
        print 'Nmesh', Nmesh, 'vs target', B.Nmesh 
    else:
        sys.exit('Symmetry failed in orthsuper')
    return [K,pf,True]
Esempio n. 3
0
            print "New real lattice"
            reallatt = 2 * np.pi**np.linalg.inv(np.transpose(reciplatt))
            print reallatt
        pos.write_poscar('POSCAR')
        #        [descriptor, scale, latticevecs, reciplatt, natoms, postype, positions] = km.readposcar('POSCAR0',path) #
        #        print 'lattice from aconvasp --sprim < POSCAR0 > POSCAR'
        ##        print 'lattice from aconvasp --sprim < POSCAR0 > POSCAR'
        #        print latticevecs
        #        print
        #        print 'reciprocal lattice vectors'
        #        print reciplatt
        #        print
        #        reciplatt = np.array((pos.bvecs[0],pos.bvecs[1],pos.bvecs[2]))
        #        print reciplatt
        ##        print 'bvecs'
        ##        print pos.bvecs
        ##        print pos.bvecs[1,:]
        #        [mesh_ns, irrat] = km.svmesh(N,pos.bvecs)
        [mesh_ns, irrat] = km.svmesh(N, reciplatt)
        km.writekpts_vasp(maindir, dir, 'KPOINTS', mesh_ns)  #correct kmesh

        print mesh_ns, 's/v method'
        #        if len(irrat)>0:
        #            print dir, irrat
        print irrat
        os.system('rm slurm*')
        subprocess.call(['rm', 'vasp.out'])
        subprocess.call(['rm', 'OUTCAR'])
        #        subprocess.call(['sbatch', 'vaspjob'])
        os.chdir(maindir)
print 'Done'
Esempio n. 4
0
            print "New real lattice"
            reallatt  = 2*np.pi**np.linalg.inv(np.transpose(reciplatt)) 
            print  reallatt
        pos.write_poscar('POSCAR')
#        [descriptor, scale, latticevecs, reciplatt, natoms, postype, positions] = km.readposcar('POSCAR0',path) #
#        print 'lattice from aconvasp --sprim < POSCAR0 > POSCAR'
##        print 'lattice from aconvasp --sprim < POSCAR0 > POSCAR'
#        print latticevecs
#        print
#        print 'reciprocal lattice vectors'
#        print reciplatt
#        print
#        reciplatt = np.array((pos.bvecs[0],pos.bvecs[1],pos.bvecs[2]))
#        print reciplatt
##        print 'bvecs'
##        print pos.bvecs
##        print pos.bvecs[1,:]   
#        [mesh_ns, irrat] = km.svmesh(N,pos.bvecs)        
        [mesh_ns, irrat] = km.svmesh(N,reciplatt)
        km.writekpts_vasp(maindir,dir,'KPOINTS',mesh_ns) #correct kmesh
        
        print mesh_ns, 's/v method'
#        if len(irrat)>0:
#            print dir, irrat
        print irrat
        os.system('rm slurm*')
        subprocess.call(['rm', 'vasp.out'])
        subprocess.call(['rm', 'OUTCAR'])            
#        subprocess.call(['sbatch', 'vaspjob'])                        
        os.chdir(maindir)   
print 'Done'
Esempio n. 5
0
        os.chdir(currdir)
        print currdir
        file1 = open(testfile,'r')
        vaspout = file1.readlines()
        file1.close()
        for i in [4,5,6,7]:
            print vaspout[i].replace('\n','')
        kmesh = km.getkpts_vasp(currdir)
        print kmesh, kmesh[0]*kmesh[1]*kmesh[2] 
        [descriptor, scale, reallatt, natoms, type_pos, positions] [natoms,reallatt,reciplatt] = km.readposcar('POSCAR',currdir) 
        Nkppra = 10000
        N = np.rint(Nkppra/natoms).astype(int)
        print 'natoms', natoms
        print 'reciplatt'
        print reciplatt
        print 'mesh', km.svmesh(N,reciplatt)
#        os.system('grep -i "bad news" slurm*')
#        os.system('grep -i kpts slurm*')
#        os.system('grep -i exceed slurm*')
#        os.system('grep -i sgrcon slurm*') 
#        os.system('grep -i bad vasp.out')
#        print subprocess.call(['grep','-i','bad','vasp.out']) 
#        slurm = os.system('find slurm*')
        slurms = [f for f in os.listdir(os.getcwd()) if 'slurm' in f]
        for slurm in slurms:
            km.regpy_nocase('bad',currdir+slurm)
#        print subprocess.check_output(['grep','-i','bad','vasp.out'])
#        print slurm
#        km.regpy_nocase('bad',currdir+ slurm)
        km.regpy_nocase('bad',currdir+'vasp.out')
#        subprocess.call(['grep','-i','bad','vasp.out']) 
Esempio n. 6
0
for dir in dirs:
    if testfile in os.listdir(dir):
        print
        print dir
        file1 = open(maindir + dir + '/' + testfile, 'r')
        poscar = file1.readlines()
        file1.close()
        if len(poscar) > 0:
            scale = np.sum(np.array(float(poscar[1])))
            #            print 'natoms', np.array(poscar[5].split(),dtype=np.int16)
            N = np.rint(
                Nkppra /
                np.sum(np.array(poscar[5].split(), dtype=np.int16))).astype(
                    int)  # number of kpts desired
            reallatt[0, :] = np.array(poscar[2].split())
            reallatt[1, :] = np.array(poscar[3].split())
            reallatt[2, :] = np.array(poscar[4].split())
            reallatt = scale * reallatt.astype(np.float)
            #            print reallatt
            reciplatt = 2 * np.pi * np.transpose(np.linalg.inv(reallatt))
            #            print reciplatt
            mesh_ns = km.svmesh(N, reciplatt)
            print mesh_ns, 's/v method'
            if 'KPOINTS.relax1' in os.listdir(dir):
                os.chdir(dir)
                os.system('cp KPOINTS.relax1 KPOINTS')
                os.chdir(maindir)
            print km.getkpts_vasp(dir), 'Aflow'
#            writekpts_vasp(dir, mesh_ns)
#
print 'Done'
Esempio n. 7
0
        file1 = open(testfile, 'r')
        vaspout = file1.readlines()
        file1.close()
        for i in [4, 5, 6, 7]:
            print vaspout[i].replace('\n', '')
        kmesh = km.getkpts_vasp(currdir)
        print kmesh, kmesh[0] * kmesh[1] * kmesh[2]
        [descriptor, scale, reallatt, natoms, type_pos,
         positions][natoms, reallatt,
                    reciplatt] = km.readposcar('POSCAR', currdir)
        Nkppra = 10000
        N = np.rint(Nkppra / natoms).astype(int)
        print 'natoms', natoms
        print 'reciplatt'
        print reciplatt
        print 'mesh', km.svmesh(N, reciplatt)
        #        os.system('grep -i "bad news" slurm*')
        #        os.system('grep -i kpts slurm*')
        #        os.system('grep -i exceed slurm*')
        #        os.system('grep -i sgrcon slurm*')
        #        os.system('grep -i bad vasp.out')
        #        print subprocess.call(['grep','-i','bad','vasp.out'])
        #        slurm = os.system('find slurm*')
        slurms = [f for f in os.listdir(os.getcwd()) if 'slurm' in f]
        for slurm in slurms:
            km.regpy_nocase('bad', currdir + slurm)
#        print subprocess.check_output(['grep','-i','bad','vasp.out'])
#        print slurm
#        km.regpy_nocase('bad',currdir+ slurm)
        km.regpy_nocase('bad', currdir + 'vasp.out')
        #        subprocess.call(['grep','-i','bad','vasp.out'])
Esempio n. 8
0
reallatt = np.zeros((3,3))
os.chdir(maindir)
dirs= sorted([d for d in os.listdir(os.getcwd()) if os.path.isdir(d)])
for dir in dirs:
    if testfile in os.listdir(dir):
        print
        print dir
        file1 = open(maindir+dir+'/'+testfile,'r')
        poscar = file1.readlines()
        file1.close()
        if len(poscar) >0:
            scale = np.sum(np.array(float(poscar[1])))
#            print 'natoms', np.array(poscar[5].split(),dtype=np.int16)
            N = np.rint(Nkppra/np.sum(np.array(poscar[5].split(),dtype=np.int16))).astype(int) # number of kpts desired
            reallatt[0,:] = np.array(poscar[2].split())
            reallatt[1,:] = np.array(poscar[3].split())
            reallatt[2,:] = np.array(poscar[4].split())
            reallatt = scale*reallatt.astype(np.float)        
#            print reallatt
            reciplatt = 2*np.pi*np.transpose(np.linalg.inv(reallatt))
#            print reciplatt
            mesh_ns = km.svmesh(N,reciplatt)
            print mesh_ns, 's/v method'
            if 'KPOINTS.relax1' in os.listdir(dir):
                os.chdir(dir)
                os.system('cp KPOINTS.relax1 KPOINTS')
                os.chdir(maindir)               
            print km.getkpts_vasp(dir), 'Aflow'
#            writekpts_vasp(dir, mesh_ns)
#                        
print 'Done'