示例#1
0
文件: epw.py 项目: vanceeasleaf/aces
 def getbol(self):
     maindir = tl.pwd()
     tl.mkcd('bol')
     self.runscf()
     self.runnscf()
     self.runw()
     tl.cd(maindir)
示例#2
0
 def checkMinimize(self):
     import yaml
     data = yaml.load(open('disp.yaml').read())
     disps = [map(float, a['direction']) for a in data['displacements']]
     maindir = pwd()
     dirs = ls('dirs/dir_*')
     ii = 0
     L = np.linalg.norm
     # d,p,d1,p1=self.m.rot
     out = open('ccos.txt', 'w')
     for dir in dirs:
         cd(dir)
         f = open('dump.force')
         for i in range(9):
             f.next()
         for b in range(ii):
             f.next()
         line = f.next()
         line = line.split()
         force = np.array(map(float, line[1:4]))
         # force=RotateVector(force,d1,-p1)
         # force=RotateVector(force,d,-p)
         d = disps[i]
         ccos = force.dot(d) / L(force) / L(d)
         ii += 1
         print >> out, "%d\t%f" % (ii, ccos)
         cd(maindir)
示例#3
0
文件: epw.py 项目: vanceeasleaf/aces
 def getPhonons(self):
     maindir = tl.pwd()
     tl.mkcd('phonons')
     self.runscf()
     self.runph()
     self.collect()
     tl.cd(maindir)
示例#4
0
 def getvasprun(self, files):
     m = self.m
     maindir = pwd()
     if m.engine == "vasp":
         calculator = self.getVaspRun_vasp
     elif m.engine == "lammps":
         calculator = self.getVaspRun_lammps
     self.jm = jobManager()
     for file in files:
         print(file)
         dir = "dirs/dir_" + file
         mkdir(dir)
         mv(file, dir + '/POSCAR')
         cd(dir)
         calculator()
         cd(maindir)
     self.jm.run()
     if m.th:
         mkdir(m.pbsname)
         self.thcode(files, m.pbsname)
         cp("dirs", m.pbsname)
         passthru("tar zcf %s.tar.gz %s" % (m.pbsname, m.pbsname))
     print('start check')
     self.jm.check()
     if m.engine == "lammps1":
         from multiprocessing.dummy import Pool
         pool = Pool()
         pool.map_async(lammpsvasprun, files)
         pool.close()
         pool.join()
示例#5
0
 def checkMinimize(self):
     import yaml
     data = yaml.load(open('disp.yaml').read())
     disps = [map(float, a['direction']) for a in data['displacements']]
     maindir = pwd()
     dirs = ls('dirs/dir_*')
     ii = 0
     L = np.linalg.norm
     # d,p,d1,p1=self.m.rot
     out = open('ccos.txt', 'w')
     for dir in dirs:
         cd(dir)
         f = open('dump.force')
         for i in range(9):
             f.next()
         for b in range(ii):
             f.next()
         line = f.next()
         line = line.split()
         force = np.array(map(float, line[1:4]))
         # force=RotateVector(force,d1,-p1)
         # force=RotateVector(force,d,-p)
         d = disps[i]
         ccos = force.dot(d) / L(force) / L(d)
         ii += 1
         print >> out, "%d\t%f" % (ii, ccos)
         cd(maindir)
示例#6
0
    def getVaspRun_vasp(self):
        m = self.m

        if m.isym:
            sym = "ISYM = 1"
        else:
            sym = "ISYM = 0"
        if m.ispin:
            spin = "ISPIN =2"
        else:
            spin = ""
        s = """SYSTEM=calculate energy
        PREC = High
        IBRION = 8
        ENCUT = %f
        EDIFF = 1.0e-8
        ISMEAR = %d; SIGMA = 0.01
        IALGO = 38
        LREAL = .FALSE.
        ADDGRID = .TRUE.
        LWAVE = .FALSE.
        LCHARG = .FALSE.
        %s
        %s
        """ % (self.m.ecut, m.ismear, sym, spin)
        s = s.replace(r'^\s+', '')
        tl.write(s, 'INCAR')
        m = self.m
        m.writePOTCAR()
        s = """A
        0
        Monkhorst-Pack
        %s
        0  0  0
        """ % ' '.join(map(str, m.ekpoints))
        s = s.replace(r'^\s+', '')
        tl.write(s, 'KPOINTS')
        if 'jm' in self.__dict__:
            from aces.jobManager import pbs
            path = tl.pwd()
            if m.queue == "q3.4":
                pb = pbs(queue=m.queue,
                         nodes=12,
                         procs=4,
                         disp=m.pbsname,
                         path=path,
                         content=config.mpirun + " 48 " + config.vasp +
                         ' >log.out')
            else:
                pb = pbs(queue=m.queue,
                         nodes=4,
                         procs=12,
                         disp=m.pbsname,
                         path=path,
                         content=config.mpirun + " 48 " + config.vasp +
                         ' >log.out')
            self.jm.reg(pb)
        else:
            tl.shell_exec(config.mpirun + " %s " % m.cores + config.vasp +
                          ' >log.out')
示例#7
0
 def getvasprun(self, files):
     m = self.m
     maindir = pwd()
     if m.engine == "vasp":
         calculator = self.getVaspRun_vasp
     elif m.engine == "lammps":
         calculator = self.getVaspRun_lammps
     self.jm = jobManager()
     for file in files:
         print(file)
         dir = "dirs/dir_" + file
         mkdir(dir)
         mv(file, dir + '/POSCAR')
         cd(dir)
         calculator()
         cd(maindir)
     self.jm.run()
     if m.th:
         mkdir(m.pbsname)
         self.thcode(files, m.pbsname)
         cp("dirs", m.pbsname)
         passthru("tar zcf %s.tar.gz %s" % (m.pbsname, m.pbsname))
     print('start check')
     self.jm.check()
     if m.engine == "lammps1":
         from multiprocessing.dummy import Pool
         pool = Pool()
         pool.map_async(lammpsvasprun, files)
         pool.close()
         pool.join()
示例#8
0
 def run(self):
     old = tl.pwd()
     for job in self.jobs:
         tl.cd(job.path)
         job.writepbs()
         job.submit()
     tl.cd(old)
示例#9
0
 def getbol(self):
     maindir = tl.pwd()
     tl.mkcd('bol')
     self.runscf()
     self.runnscf()
     self.runw()
     tl.cd(maindir)
示例#10
0
 def getPhonons(self):
     maindir = tl.pwd()
     tl.mkcd('phonons')
     self.runscf()
     self.runph()
     self.collect()
     tl.cd(maindir)
示例#11
0
文件: App.py 项目: vanceeasleaf/aces
    def __init__(self):
        """
        while not os.path.exists('app.json'):
                time.sleep(1)
                print pwd()+'/app.json'
        """
        if tl.exists('app.json'):
            opt = tl.loadjson('app.json')
        elif tl.exists('../app.json'):
            opt = tl.loadjson('../app.json')
        elif tl.exists('../../app.json'):
            opt = tl.loadjson('../../app.json')
        elif tl.exists('../../../app.json'):
            opt = tl.loadjson('../../../app.json')
        else:
            tl.exit('app.json lost!')
        species = opt['species']
        s = im('aces.materials.%s' % species)
        m = s.structure(opt)
        self.m = m
        m.home = tl.pwd()
        assert m.home != ''

        Runner = im('aces.runners.%s' % m.runner)
        self.runner = Runner.runner(m)
示例#12
0
 def run(self):
     old = tl.pwd()
     for job in self.jobs:
         tl.cd(job.path)
         job.writepbs()
         job.submit()
     tl.cd(old)
示例#13
0
 def dyinput(self):
     m = self.m
     f = open('in.dy', 'w')
     print >> f, "STRUCTURE FILE POSCAR"
     print >> f, tl.pwd() + "/POSCAR"
     print >> f, "FORCE SETS"
     print >> f, tl.pwd() + "/FORCE_SETS"
     # print >>f,"STRUCTURE FILE OUTCAR"
     # print >>f,pwd()+"/dynaphopy.lammpstrj"
     print >> f, "SUPERCELL MATRIX PHONOPY"
     print >> f, " %d 0 0 \n 0 %d 0\n 0 0 %d" % tuple(m.supercell)
     print >> f, "BANDS"
     bp = m.bandpath
     bpp = m.bandpoints
     for i in range(len(bp) - 1):
         u = "%s %s" % (tl.toString(bpp[bp[i]],
                                    ','), tl.toString(bpp[bp[i + 1]], ','))
         print >> f, u
     f.close()
示例#14
0
 def dyinput(self):
     m = self.m
     f = open('in.dy', 'w')
     print >> f, "STRUCTURE FILE POSCAR"
     print >> f, tl.pwd() + "/POSCAR"
     print >> f, "FORCE SETS"
     print >> f, tl.pwd() + "/FORCE_SETS"
     # print >>f,"STRUCTURE FILE OUTCAR"
     # print >>f,pwd()+"/dynaphopy.lammpstrj"
     print >> f, "SUPERCELL MATRIX PHONOPY"
     print >> f, " %d 0 0 \n 0 %d 0\n 0 0 %d" % tuple(m.supercell)
     print >> f, "BANDS"
     bp = m.bandpath
     bpp = m.bandpoints
     for i in range(len(bp) - 1):
         u = "%s %s" % (tl.toString(bpp[bp[i]], ','),
                        tl.toString(bpp[bp[i + 1]], ','))
         print >> f, u
     f.close()
示例#15
0
文件: epw.py 项目: vanceeasleaf/aces
 def getPotName(self):
     maindir = tl.pwd()
     tl.cd(config.qepot)
     files = tl.ls("*")
     tl.cd(maindir)
     import re
     q = [re.split("[_\.]", a)[0].capitalize() for a in files]
     u = {}
     for i, v in enumerate(q):
         u[v] = files[i]
     return u
示例#16
0
 def getPotName(self):
     maindir = tl.pwd()
     tl.cd(config.qepot)
     files = tl.ls("*")
     tl.cd(maindir)
     import re
     q = [re.split("[_\.]", a)[0].capitalize() for a in files]
     u = {}
     for i, v in enumerate(q):
         u[v] = files[i]
     return u
示例#17
0
    def getVaspRun_vasp(self):

        self.writeINCAR()
        m = self.m
        writePOTCAR(m, m.elements)

        if (m.kpointspath):
            cp(m.kpointspath, "KPOINTS")
        else:
            from aces.io.vasp import writeKPOINTS
            writeKPOINTS(m.ekpoints)
        if 'jm' in self.__dict__:
            if not m.th:
                path = pwd()
                if m.queue == "q3.4":
                    pb = pbs(
                        queue=m.queue,
                        nodes=12,
                        procs=1,
                        disp=m.pbsname,
                        path=path,
                        content=config.mpirun + " 12 " + config.vasp +
                        ' >log.out')
                else:
                    pb = pbs(
                        queue=m.queue,
                        nodes=1,
                        procs=12,
                        disp=m.pbsname,
                        path=path,
                        content=config.mpirun + " 12 " + config.vasp +
                        ' >log.out')
            else:
                path = pwd()
                pb = th(disp=m.pbsname, path=path)
            self.jm.reg(pb)

        else:
            shell_exec(config.mpirun + " %s " % m.cores + config.vasp +
                       ' >log.out')
示例#18
0
 def runSPOSCAR(self):
     m = self.m
     maindir = pwd()
     file = "SPOSCAR"
     dir = "dir_" + file
     mkdir(dir)
     cp(file, dir + '/POSCAR')
     cd(dir)
     if m.engine == "vasp":
         self.getVaspRun_vasp()
     if m.engine == "lammps":
         self.getVaspRun_lammps()
     cd(maindir)
示例#19
0
文件: epw.py 项目: vanceeasleaf/aces
 def getepw(self):
     m = self.m
     maindir = tl.pwd()
     tl.mkcd('epw')
     """为了保证q+k也在k的格点上,必须要求qs*cell*[nk1,nk2,nk3]为整数,即nk=N*nq
     否则可能出现Error in routine createkmap (1):
     """
     u = np.array(m.ekpoints) / np.array(m.kpoints)
     assert np.allclose(np.floor(u + .5), u, rtol=0.01)
     self.runscf()
     self.runnscf()
     self.runepw()
     tl.cd(maindir)
示例#20
0
 def runSPOSCAR(self):
     m = self.m
     maindir = pwd()
     file = "SPOSCAR"
     dir = "dir_" + file
     mkdir(dir)
     cp(file, dir + '/POSCAR')
     cd(dir)
     if m.engine == "vasp":
         self.getVaspRun_vasp()
     if m.engine == "lammps":
         self.getVaspRun_lammps()
     cd(maindir)
示例#21
0
 def getVaspRun_lammps(self):
     m = self.m
     if 'jm' in self.__dict__:
         path = pwd()
         pb = pbs(queue=m.queue,
                  nodes=1,
                  procs=4,
                  disp=m.pbsname,
                  path=path,
                  content=config.python + vasprun.__file__ + ' >log.out')
         self.jm.reg(pb)
     else:
         shell_exec(config.python + vasprun.__file__ + ' >log.out')
示例#22
0
def ineq(m):
    now = tl.pwd()
    species = m.species
    if not (species in ["CN-small"]):
        return 0.0
    tl.cd('minimize')
    tl.mkdir('nonequ')
    tl.cd('nonequ')

    ie = inequality()
    nonequ5 = ie.run()
    tl.cd(now)
    return nonequ5
示例#23
0
 def getepw(self):
     m = self.m
     maindir = tl.pwd()
     tl.mkcd('epw')
     """为了保证q+k也在k的格点上,必须要求qs*cell*[nk1,nk2,nk3]为整数,即nk=N*nq
     否则可能出现Error in routine createkmap (1):
     """
     u = np.array(m.ekpoints) / np.array(m.kpoints)
     assert np.allclose(np.floor(u + .5), u, rtol=0.01)
     self.runscf()
     self.runnscf()
     self.runepw()
     tl.cd(maindir)
示例#24
0
def ineq(m):
    now = tl.pwd()
    species = m.species
    if not (species in ["CN-small"]):
        return 0.0
    tl.cd('minimize')
    tl.mkdir('nonequ')
    tl.cd('nonequ')

    ie = inequality()
    nonequ5 = ie.run()
    tl.cd(now)
    return nonequ5
示例#25
0
    def getVaspRun_vasp(self):

        self.writeINCAR()
        m = self.m
        writePOTCAR(m, m.elements)

        if (m.kpointspath):
            cp(m.kpointspath, "KPOINTS")
        else:
            from aces.io.vasp import writeKPOINTS
            writeKPOINTS(m.ekpoints)
        if 'jm' in self.__dict__:
            if not m.th:
                path = pwd()
                if m.queue == "q3.4":
                    pb = pbs(queue=m.queue,
                             nodes=12,
                             procs=1,
                             disp=m.pbsname,
                             path=path,
                             content=config.mpirun + " 12 " + config.vasp +
                             ' >log.out')
                else:
                    pb = pbs(queue=m.queue,
                             nodes=1,
                             procs=12,
                             disp=m.pbsname,
                             path=path,
                             content=config.mpirun + " 12 " + config.vasp +
                             ' >log.out')
            else:
                path = pwd()
                pb = th(disp=m.pbsname, path=path)
            self.jm.reg(pb)

        else:
            shell_exec(config.mpirun + " %s " % m.cores + config.vasp +
                       ' >log.out')
示例#26
0
    def creatmini(self, m):
        print('creatmini')
        m.home = pwd()
        assert m.home != ''
        mkdir('minimize')
        cd('minimize')
        minimize_input(m)
        write(time.strftime('%Y-%m-%d %H:%M:%S'), 'done')
        cd('..')
        if m.engine == "lammps":
            return m.dump2POSCAR(m.home + '/minimize/range')
        else:

            return io.read(m.home + '/minimize/CONTCAR')
示例#27
0
 def getVaspRun_lammps(self):
     m = self.m
     if 'jm' in self.__dict__:
         path = pwd()
         pb = pbs(
             queue=m.queue,
             nodes=1,
             procs=4,
             disp=m.pbsname,
             path=path,
             content=config.python + vasprun.__file__ + ' >log.out')
         self.jm.reg(pb)
     else:
         shell_exec(config.python + vasprun.__file__ + ' >log.out')
示例#28
0
def tDisorder():

    # disorder degree*/
    now = tl.pwd()
    tl.cd('minimize')
    tl.mkcd('disorder')

    disorderLine = tl.shell_exec(
        "cp %s" % SRCHOME + "/in.disorder .;" + config.lammps +
        " <in.disorder 2>err 1>log;tail -1 disorder.txt  2>err;")
    k = disorderLine.split()[1:3]
    if len(k) == 1:
        k.append("")
    disorder, rd = k
    tl.cd(now)
    return (disorder, rd)
示例#29
0
def tDisorder():

    # disorder degree*/
    now = tl.pwd()
    tl.cd('minimize')
    tl.mkcd('disorder')

    disorderLine = tl.shell_exec(
        "cp %s" %
        SRCHOME +
        "/in.disorder .;" +
        config.lammps +
        " <in.disorder 2>err 1>log;tail -1 disorder.txt  2>err;")
    k = disorderLine.split()[1:3]
    if len(k) == 1:
        k.append("")
    disorder, rd = k
    tl.cd(now)
    return (disorder, rd)
示例#30
0
 def creatmini(self, dir):
     cur = tl.pwd()
     tl.mkdir(dir)
     tl.cd(dir)
     minimize_input(self.m)
     tl.cd(cur)
示例#31
0
 def creatmini(self, dir):
     cur = tl.pwd()
     tl.mkdir(dir)
     tl.cd(dir)
     minimize_input(self.m)
     tl.cd(cur)
示例#32
0
文件: env.py 项目: vanceeasleaf/aces
# -*- coding: utf-8 -*-
# @Author: YangZhou
# @Date:   2017-06-18 22:01:52
# @Last Modified by:   YangZhou
# @Last Modified time: 2017-06-18 22:02:30
from os.path import realpath, dirname, basename
from aces.tools import pwd, exists
SRCHOME = dirname(realpath(__file__))


def checkParent(dir, n=0):
    if n == 5:
        raise Exception('error when find sub.py')
    if not exists(dir + '/sub.py'):
        dir = realpath(dir + '/..')
        return checkParent(dir, n + 1)
    else:
        return dir
PROJHOME = checkParent(pwd())
PROJNAME = basename(PROJHOME)
示例#33
0
    def getVaspRun_vasp(self):
        m = self.m

        if m.isym:
            sym = "ISYM = 1"
        else:
            sym = "ISYM = 0"
        if m.ispin:
            spin = "ISPIN =2"
        else:
            spin = ""
        s = """SYSTEM=calculate energy
        PREC = High
        IBRION = 8
        ENCUT = %f
        EDIFF = 1.0e-8
        ISMEAR = %d; SIGMA = 0.01
        IALGO = 38
        LREAL = .FALSE.
        ADDGRID = .TRUE.
        LWAVE = .FALSE.
        LCHARG = .FALSE.
        %s
        %s
        """ % (self.m.ecut, m.ismear, sym, spin)
        s = s.replace(r'^\s+', '')
        tl.write(s, 'INCAR')
        m = self.m
        m.writePOTCAR()
        s = """A
        0
        Monkhorst-Pack
        %s
        0  0  0
        """ % ' '.join(map(str, m.ekpoints))
        s = s.replace(r'^\s+', '')
        tl.write(s, 'KPOINTS')
        if 'jm' in self.__dict__:
            from aces.jobManager import pbs
            path = tl.pwd()
            if m.queue == "q3.4":
                pb = pbs(
                    queue=m.queue,
                    nodes=12,
                    procs=4,
                    disp=m.pbsname,
                    path=path,
                    content=config.mpirun +
                    " 48 " +
                    config.vasp +
                    ' >log.out')
            else:
                pb = pbs(
                    queue=m.queue,
                    nodes=4,
                    procs=12,
                    disp=m.pbsname,
                    path=path,
                    content=config.mpirun +
                    " 48 " +
                    config.vasp +
                    ' >log.out')
            self.jm.reg(pb)
        else:
            tl.shell_exec(
                config.mpirun +
                " %s " %
                m.cores +
                config.vasp +
                ' >log.out')
示例#34
0
from os.path import *
from aces.tools import pwd, exists
import sys
SRCHOME = dirname(realpath(__file__))


def checkParent(dir, n=0):
    if n == 5: raise Exception('error when find sub.py')
    if not exists(dir + '/sub.py'):
        dir = realpath(dir + '/..')
        return checkParent(dir, n + 1)
    else:
        return dir


PROJHOME = checkParent(pwd())
PROJNAME = basename(PROJHOME)