Beispiel #1
0
    def correlation(self):
        m = self.m
        if not tl.exists("jin.npy"):
            print("loading jin.txt")
            j = np.loadtxt('jin.txt', skiprows=2)[:, 1]
            np.save('jin.npy', j)
        j = np.load('jin.npy')
        print("loaded")
        n = len(j)
        if not tl.exists("jj0.npy"):

            jj0 = acf(j)[:n / 2 + 1]
            np.save('jj0.npy', jj0)
        jj0 = np.load('jj0.npy')[:m.aveRate]

        xlo, xhi, ylo, yhi, zlo, zhi, lx, ly, lz = m.box
        v = lx * ly * lz
        factor = m.corRate * m.timestep / \
            (v * m.kb * m.T * m.T) * m.zfactor * m.tcfactor
        x = range(len(jj0))
        plot([x, 'Correlation Time (ps)'],
             [jj0, 'Heat Flut Correlation Function'], 'acf.png')
        plot([x, 'Correlation Time (ps)'],
             [jj0.cumsum() * factor, 'Thermal Conductivity (W/mK)'],
             'kappa.png')
Beispiel #2
0
def writePOTCAR(options, elements):
    dir = 'pot'  # LDA
    # paw:PAW-LDA
    # paw_gga:PAW-GGA-PW91
    # paw_pbe:PAW-GGA-PBE
    # pot:USPP-LDA
    # pot_GGA:USPP-GGA
    if not options.paw:
        if options.gga:
            dir = 'pot_GGA'
        else:
            dir = 'pot'
    else:
        if not options.gga:
            dir = 'paw'
        else:
            if options.pbe:
                dir = 'paw_pbe'
            else:
                dir = 'paw_gga'
    tl.passthru('cat "" >POTCAR')
    for ele in elements:
        file = config.vasppot + "/%s/%s/POTCAR" % (dir, ele)
        z = False
        if not tl.exists(file):
            file += '.Z'
            z = True
        assert tl.exists(file)
        if z:
            tl.passthru('zcat %s >> POTCAR' % file)
        else:
            tl.passthru('cat %s >> POTCAR' % file)
Beispiel #3
0
    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)
Beispiel #4
0
def writePOTCAR(options, elements):
    dir = 'pot'  # LDA
    # paw:PAW-LDA
    # paw_gga:PAW-GGA-PW91
    # paw_pbe:PAW-GGA-PBE
    # pot:USPP-LDA
    # pot_GGA:USPP-GGA
    if not options.paw:
        if options.gga:
            dir = 'pot_GGA'
        else:
            dir = 'pot'
    else:
        if not options.gga:
            dir = 'paw'
        else:
            if options.pbe:
                dir = 'paw_pbe'
            else:
                dir = 'paw_gga'
    tl.passthru('cat "" >POTCAR')
    for ele in elements:
        file = config.vasppot + "/%s/%s/POTCAR" % (dir, ele)
        z = False
        if not tl.exists(file):
            file += '.Z'
            z = True
        assert tl.exists(file)
        if z:
            tl.passthru('zcat %s >> POTCAR' % file)
        else:
            tl.passthru('cat %s >> POTCAR' % file)
Beispiel #5
0
 def check(self):
     jobdone = np.array(
         [tl.exists(job.path + "/done") for job in self.jobs])
     tl.debug('entering loop waiting for vasp...')
     while not jobdone.all():
         time.sleep(3)
         jobdone = np.array(
             [tl.exists(job.path + "/done") for job in self.jobs])
         # debug(paths[jobdone])
     tl.debug('done')
Beispiel #6
0
 def check(self):
     jobdone = np.array(
         [tl.exists(job.path + "/done") for job in self.jobs])
     tl.debug('entering loop waiting for vasp...')
     while not jobdone.all():
         time.sleep(3)
         jobdone = np.array(
             [tl.exists(job.path + "/done") for job in self.jobs])
         # debug(paths[jobdone])
     tl.debug('done')
Beispiel #7
0
 def getsatoms(self):
     filename = 'disp_fc3.yaml'
     if (tl.exists(filename)):
         return disp2atoms(filename)
     filename = 'disp.yaml'
     if (tl.exists(filename)):
         return disp2atoms(filename)
     filename = '3RD.SPOSCAR'
     if (tl.exists(filename)):
         from ase import io
         return io.read(filename, format='vasp')
     filename = 'SPOSCAR'
     if (tl.exists(filename)):
         from ase import io
         return io.read(filename, format='vasp')
Beispiel #8
0
    def reduce(self, nd, *pn):
        from aces.qpointsyaml import phononyaml
        pya = phononyaml("qpoints/qpoints.yaml")
        nq = pya.nqpoint
        nbr = pya.nbranch
        import h5py
        nma = h5py.File('lifenma.h5')
        q = np.array(nma['/q/0/0'])
        n = len(q)
        v = np.zeros([nq * nbr, n])

        def onedir(dir, num):
            for idir in num:
                print(idir)
                nma = h5py.File(dir + '/%d/lifenma.h5' % idir)
                for i in range(nq):
                    for j in range(nbr):
                        node = '/q/%d/%d' % (i, j)
                        v[i * nbr + j, :] += np.array(nma[node])
            return len(num)

        N = 0
        for i in range(nd):
            dir, num = pn[i * 2:i * 2 + 2]
            N += onedir(dir, num)
        # N+=onedir('../q3.1',30)
        # N+=onedir('../q3.2',90)
        v /= N
        if tl.exists('phis.h5'):
            tl.passthru('rm phis.h5')
        phis = h5py.File('phis.h5')
        for i in range(nq):
            for j in range(nbr):
                node = '/%d/%d' % (i, j)
                phis[node] = v[i * nbr + j, :]
Beispiel #9
0
    def check(self, filename='FORCE_CONSTANTS'):
        ref = io.read('SPOSCAR')
        files = shell_exec("ls dirs").split('\n')
        fc2 = readfc2(filename)
        np.set_printoptions(precision=2, suppress=True)
        vasprunxml = "dir_SPOSCAR/vasprun.xml"
        if exists(vasprunxml):
            vasprun = etree.iterparse(vasprunxml, tag='varray')
            forces0 = parseVasprun(vasprun, 'forces')
            print(forces0.max())
        else:
            forces0 = 0.0
        for file in files:
            print(file)
            POSCAR = 'dirs/%s/POSCAR' % file
            vasprunxml = "dirs/%s/vasprun.xml" % file
            atoms = io.read(POSCAR)
            u = atoms.positions - ref.positions
            f = -np.einsum('ijkl,jl', fc2, u)

            vasprun = etree.iterparse(vasprunxml, tag='varray')
            forces = parseVasprun(vasprun, 'forces') - forces0
            print(np.abs(f).max(), "\n")
            print(np.abs(forces - f).max())
            print(np.allclose(f, forces, atol=1e-2))
Beispiel #10
0
    def reduce(self, nd, *pn):
        from aces.qpointsyaml import phononyaml
        pya = phononyaml("qpoints/qpoints.yaml")
        nq = pya.nqpoint
        nbr = pya.nbranch
        import h5py
        nma = h5py.File('lifenma.h5')
        q = np.array(nma['/q/0/0'])
        n = len(q)
        v = np.zeros([nq * nbr, n])

        def onedir(dir, num):
            for idir in num:
                print(idir)
                nma = h5py.File(dir + '/%d/lifenma.h5' % idir)
                for i in range(nq):
                    for j in range(nbr):
                        node = '/q/%d/%d' % (i, j)
                        v[i * nbr + j, :] += np.array(nma[node])
            return len(num)

        N = 0
        for i in range(nd):
            dir, num = pn[i * 2:i * 2 + 2]
            N += onedir(dir, num)
        # N+=onedir('../q3.1',30)
        # N+=onedir('../q3.2',90)
        v /= N
        if tl.exists('phis.h5'):
            tl.passthru('rm phis.h5')
        phis = h5py.File('phis.h5')
        for i in range(nq):
            for j in range(nbr):
                node = '/%d/%d' % (i, j)
                phis[node] = v[i * nbr + j, :]
Beispiel #11
0
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
Beispiel #12
0
    def check(self, filename='FORCE_CONSTANTS'):
        ref = io.read('SPOSCAR')
        files = shell_exec("ls dirs").split('\n')
        fc2 = readfc2(filename)
        np.set_printoptions(precision=2, suppress=True)
        vasprunxml = "dir_SPOSCAR/vasprun.xml"
        if exists(vasprunxml):
            vasprun = etree.iterparse(vasprunxml, tag='varray')
            forces0 = parseVasprun(vasprun, 'forces')
            print(forces0.max())
        else:
            forces0 = 0.0
        for file in files:
            print(file)
            POSCAR = 'dirs/%s/POSCAR' % file
            vasprunxml = "dirs/%s/vasprun.xml" % file
            atoms = io.read(POSCAR)
            u = atoms.positions - ref.positions
            f = -np.einsum('ijkl,jl', fc2, u)

            vasprun = etree.iterparse(vasprunxml, tag='varray')
            forces = parseVasprun(vasprun, 'forces') - forces0
            print(np.abs(f).max(), "\n")
            print(np.abs(forces - f).max())
            print(np.allclose(f, forces, atol=1e-2))
Beispiel #13
0
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
Beispiel #14
0
 def runbol(self):
     self.getwin()
     p = config.espresso + "bin/postw90.x"
     if not tl.exists(p):
         print("p not exists")
         return
     postw90 = self.getx("postw90", pool=False)
     tl.passthru(postw90 + " diam")
Beispiel #15
0
 def runbol(self):
     self.getwin()
     p = config.espresso + "bin/postw90.x"
     if not tl.exists(p):
         print("p not exists")
         return
     postw90 = self.getx("postw90", pool=False)
     tl.passthru(postw90 + " diam")
Beispiel #16
0
 def rerunepw(self):
     m = self.m
     subcores = m.cores
     if not tl.exists('epw.in'):
         self.getepwin()
     epw = config.mpirun + str(subcores) + \
         config.epw + " -npool " + str(subcores)
     cmd3 = epw + " <epw.in > epw.out"
     tl.passthru(cmd3)
Beispiel #17
0
 def rerunepw(self):
     m = self.m
     subcores = m.cores
     if not tl.exists('epw.in'):
         self.getepwin()
     epw = config.mpirun + str(subcores) + \
         config.epw + " -npool " + str(subcores)
     cmd3 = epw + " <epw.in > epw.out"
     tl.passthru(cmd3)
Beispiel #18
0
 def lifenmaq(self, filename="qpoints/qpoints.yaml",
              k=[0, 0, 0], correlation_supercell=[10, 10, 1], test=False):
     self.test = test
     self.pfactor = self.getpfactor(correlation_supercell)
     pya = phononyaml(filename)
     self.pya = pya
     self.testk = k
     if not tl.exists('NMA'):
         tl.mkdir('NMA')
     self.specialk(pya, map(float, k))
Beispiel #19
0
 def parse(self, f, filename):
     npy = filename + '.npy'
     if self.cache and exists(npy): return np.load(npy)
     print "scanning the file %s" % filename
     _line = [0]
     while f.readline():
         _line.append(f.tell())
     del _line[-1]
     if self.cache:
         np.save(npy, _line)
     return _line
Beispiel #20
0
	def info(self):
		if not exists('velocity.info'):
			self.prepare()
		s=read('velocity.info').split()
		self.natom=int(s[0])
		self.totalStep=int(s[1])
		self.timestep=float(s[2])
		self.times=np.arange(self.totalStep)*self.timestep
		maxFreq=1/2.0/self.timestep
		self.freq=np.linspace(0,1,self.totalStep/2)*maxFreq
		return self.natom,self.totalStep,self.timestep,self.freq,self.times
Beispiel #21
0
 def getV(self):
     if not exists('groupv'):
         mkdir('groupv')
     cd('groupv')
     cp('../FORCE_CONSTANTS', '.')
     cp('../POSCAR', '.')
     cp('../disp.yaml', '.')
     self.generate_vconf()
     passthru(config.phonopy + "--tolerance=1e-4    v.conf")
     self.drawV()
     cd('..')
Beispiel #22
0
def get_eigs(file="mesh.npz"):
    if not tl.exists(file):
        name = file.replace('npz', 'yaml')
        print("generate " + file)
        data = meshyaml(name)
        np.savez(file, **data)
    data = np.load(file)
    freqs = data['frequency']
    eigs = data['eigs']
    qpoints = data['qpoints']
    return qpoints, freqs, eigs
Beispiel #23
0
 def getV(self):
     if not exists('groupv'):
         mkdir('groupv')
     cd('groupv')
     cp('../FORCE_CONSTANTS', '.')
     cp('../POSCAR', '.')
     cp('../disp.yaml', '.')
     self.generate_vconf()
     passthru(config.phonopy + "--tolerance=1e-4    v.conf")
     self.drawV()
     cd('..')
Beispiel #24
0
 def parse(self, f, filename):
     npy = filename + '.npy'
     if self.cache and exists(npy):
         return np.load(npy)
     print("scanning the file %s" % filename)
     _line = [0]
     while f.readline():
         _line.append(f.tell())
     del _line[-1]
     if self.cache:
         np.save(npy, _line)
     return _line
Beispiel #25
0
 def minimize(self):
     if (self.m.copyN == -1):
         copymini = False
     else:
         copymini = True
     if copymini:
         while not tl.exists('../%d/minimize/done' % self.m.copyN):
             tl.sleep(30)
         print('copymini')
         tl.cp('../%d/minimize' % self.m.copyN, '.')
     else:
         self.creatmini()
Beispiel #26
0
 def force_constant(self, files):
     cmd = config.phonopy + "-f "
     if exists("dir_SPOSCAR/vasprun.xml"):
         cmd = config.phonopy + "--fz dir_SPOSCAR/vasprun.xml "
     for file in files:
         dir = "dirs/dir_" + file
         cmd += dir + '/vasprun.xml '
     # generate FORCE_SETS
     passthru(cmd)
     m = self.m
     # Create FORCE_CONSTANTS
     passthru(config.phonopy + "--tolerance=1e-4  --writefc --dim='%s'" %
              (m.dim))
Beispiel #27
0
 def force_constant(self, files):
     cmd = config.phonopy + "-f "
     if exists("dir_SPOSCAR/vasprun.xml"):
         cmd = config.phonopy + "--fz dir_SPOSCAR/vasprun.xml "
     for file in files:
         dir = "dirs/dir_" + file
         cmd += dir + '/vasprun.xml '
     # generate FORCE_SETS
     passthru(cmd)
     m = self.m
     # Create FORCE_CONSTANTS
     passthru(config.phonopy + "--tolerance=1e-4  --writefc --dim='%s'" %
              (m.dim))
Beispiel #28
0
 def lifenmaq(self,
              filename="qpoints/qpoints.yaml",
              k=[0, 0, 0],
              correlation_supercell=[10, 10, 1],
              test=False):
     self.test = test
     self.pfactor = self.getpfactor(correlation_supercell)
     pya = phononyaml(filename)
     self.pya = pya
     self.testk = k
     if not tl.exists('NMA'):
         tl.mkdir('NMA')
     self.specialk(pya, map(float, k))
Beispiel #29
0
 def allnma(self, filename="qpoints/qpoints.yaml"):
     pya = phononyaml(filename)
     f = open('allnma.txt', 'w')
     f.write('kx\tky\tkz\tfreq\tw0\tscatter\ttao\n')
     self.all = True
     c = h5py.File('allnma.h5')
     assert tl.exists('phis.h5')
     self.phis = h5py.File('phis.h5')
     for iqp in range(pya.nqpoint):
         for ibr in range(pya.nbranch):
             node = '/%s/%s' % (iqp, ibr)
             print(node)
             if node not in c:
                 k = pya.qposition(iqp)
                 freq = pya.frequency(iqp, ibr)
                 vec = pya.atoms(iqp, ibr)
                 v, q = self.calculateLife((k, freq, vec), iqp, ibr)
                 c[node] = v
             f.write('%s\n' % c[node][()])
Beispiel #30
0
 def allnma(self, filename="qpoints/qpoints.yaml"):
     pya = phononyaml(filename)
     f = open('allnma.txt', 'w')
     f.write('kx\tky\tkz\tfreq\tw0\tscatter\ttao\n')
     self.all = True
     c = h5py.File('allnma.h5')
     assert tl.exists('phis.h5')
     self.phis = h5py.File('phis.h5')
     for iqp in range(pya.nqpoint):
         for ibr in range(pya.nbranch):
             node = '/%s/%s' % (iqp, ibr)
             print(node)
             if node not in c:
                 k = pya.qposition(iqp)
                 freq = pya.frequency(iqp, ibr)
                 vec = pya.atoms(iqp, ibr)
                 v, q = self.calculateLife((k, freq, vec), iqp, ibr)
                 c[node] = v
             f.write('%s\n' % c[node][()])
Beispiel #31
0
 def lmp_structure(self):
     import os
     file = os.path.join(os.path.dirname(__file__), 'data',
                         self.poscar + ".POSCAR")
     # because file is unicode in default and ase check if file is not str
     # then look it as a file
     file = str(file)
     assert tl.exists(file)
     print(file)
     atoms = io.read(file)
     if not self.type == "zigzag":
         newatoms = atoms.copy()
         cell = [atoms.cell[1, 1], atoms.cell[0, 0], atoms.cell[2, 2]]
         positions = atoms.positions[:, [1, 0, 2]]
         newatoms.set_cell(cell)
         newatoms.set_positions(positions)
         atoms = newatoms
     atoms = atoms.repeat([self.latx, self.laty, self.latz])
     return atoms
Beispiel #32
0
    def sed_band(self, correlation_supercell=[10, 10, 1]):
        self.pfactor = self.getpfactor(correlation_supercell)
        data = tl.parseyaml('band.yaml')
        natom_unitcell = int(data['natom'])
        if not tl.exists('SEDBAND'):
            tl.mkdir('SEDBAND')
        sed = []
        db = h5py.File('sed.h5')

        def u(phonon):
            qp = phonon['q-position']
            qps = str(qp)
            print(qps)
            if qps not in db:
                db[qps] = self.calculateSED(map(float, qp), natom_unitcell)
            s = db[qps][:]
            sed.append(s)
        map(u, data['phonon'])
        totalStep = self.totalStep
        x = np.linspace(0, 1, totalStep / 2 + 1) * 1 / 2.0 / self.timestep
        np.save('wtick.npy', x)
        np.save('sed.npy', sed)
Beispiel #33
0
    def sed_band(self, correlation_supercell=[10, 10, 1]):
        self.pfactor = self.getpfactor(correlation_supercell)
        data = tl.parseyaml('band.yaml')
        natom_unitcell = int(data['natom'])
        if not tl.exists('SEDBAND'):
            tl.mkdir('SEDBAND')
        sed = []
        db = h5py.File('sed.h5')

        def u(phonon):
            qp = phonon['q-position']
            qps = str(qp)
            print(qps)
            if qps not in db:
                db[qps] = self.calculateSED(map(float, qp), natom_unitcell)
            s = db[qps][:]
            sed.append(s)

        map(u, data['phonon'])
        totalStep = self.totalStep
        x = np.linspace(0, 1, totalStep / 2 + 1) * 1 / 2.0 / self.timestep
        np.save('wtick.npy', x)
        np.save('sed.npy', sed)
Beispiel #34
0
 def pix(self, cmd):
     if tl.exists('dy.h5'):
         v = "-lv dy.h5"
     else:
         v = "dynaphopy.lammpstrj"
     tl.passthru("dynaphopy in.dy %s -ts %f %s" % (v, self.m.timestep, cmd))
Beispiel #35
0
	def __init__(self,timestep=0.0005):
		if exists('velocity.h5md'):
			self.db=h5py.File('velocity.h5md')
Beispiel #36
0
    n = 5
    sk = np.zeros_like(s[:, 1])
    for j, u in enumerate(s[n:-n]):
        sk[j + n] = s[j:j + n, 1].mean()
    v = []
    n = 30
    for j, u in enumerate(sk[n:-n]):
        var = abs(sk[j + n] - sk[j + n - 1])
        if var > 1.0 and var > sk[j:j + n].std():
            if len(v) > 0 and j - v[-1] < n:
                continue
            v.append(j + n)
    return np.array(v)


if not tl.exists('strain/seed1/cache.npz'):
    c = []
    d = []
    i = 0
    for seed in range(200, 400):
        dir = "strain/seed1/" + str(i)
        s = np.loadtxt(dir + "/cal_stress.txt", skiprows=1)
        v = getBreakStrains(s)
        i += 1
        print(dir, s[v, 0])
        c.append(s[v, 0])
        d.append([s, v])
    i = 0
    for seed in range(400, 600):
        dir = "strain/seed2/" + str(i)
        s = np.loadtxt(dir + "/cal_stress.txt", skiprows=1)
Beispiel #37
0
 def calculateLife(self, eigen, iqp, ibr):
     q = self.modeSed(eigen, iqp, ibr)
     if tl.exists('velocity.h5md'):
         tl.passthru('rm velocity.h5md')
     k, freq, vec = eigen
     return self.modefit(iqp, ibr, k, freq, q)
Beispiel #38
0
 def runph(self):
     if not tl.exists('ph.in'):
         self.getphin()
     ph = self.getx("ph")
     tl.passthru(ph + " < ph.in   > ph.out ")
Beispiel #39
0
 def runph(self):
     if not tl.exists('ph.in'):
         self.getphin()
     ph = self.getx("ph")
     tl.passthru(ph + " < ph.in   > ph.out ")
Beispiel #40
0
 def getfcs(self):
     tl.passthru(config.alm + "< fit.in > fit.out")
     assert tl.exists("alm.fcs")
     assert tl.exists("alm.xml")
Beispiel #41
0
 def getfcs(self):
     tl.passthru(config.alm + "< fit.in > fit.out")
     assert tl.exists("alm.fcs")
     assert tl.exists("alm.xml")
Beispiel #42
0
    def cal_lc(self, r, dr, m):
        from aces.lammpsdata import lammpsdata
        atoms = lammpsdata().set_src('correlation_structure')
        atoms.set_pbc([m.xp, m.yp, m.zp])
        nw = self.totalStep / 2 + 1
        nr = int(r / dr) + 1
        n = len(atoms)
        pos = atoms.positions
        cell = atoms.cell
        symbols = atoms.get_chemical_symbols()
        masses = self.getMassFromLabel(symbols)
        if not tl.exists('g.npz'):
            g = np.zeros([nw, nr], dtype=np.complex)
            ng = np.zeros(nr, dtype=np.int)
            c = self.get_nei(r, dr, pos, cell)
            for i, j, q in c:
                if j == 0:
                    print("center atom:%d/%d" % (i, n))
                aij = np.einsum(
                    'ij,ij->i',
                    self.fourier_atom(i).conjugate(),
                    self.fourier_atom(j))
                aii = np.einsum(
                    'ij,ij->i',
                    self.fourier_atom(i).conjugate(),
                    self.fourier_atom(i))
                ajj = np.einsum(
                    'ij,ij->i',
                    self.fourier_atom(j).conjugate(),
                    self.fourier_atom(j))
                x = aij / np.sqrt(aii * ajj) * np.sqrt(masses[i] * masses[j])
                for ir in q:
                    g[:, ir] += x
                    ng[ir] += 1
            np.savez('g.npz', g=g, ng=ng)
        npz = np.load('g.npz')
        g = npz['g']
        ng = npz['ng']
        rs = (np.arange(nr)) * dr
        rs = rs[:-1]

        def aa(x):
            if x > 0:
                return 1.0 / x
            else:
                return 0.0
        ivr = [aa(x) for x in ng]  # 1.0/4.0/np.pi/rs**2
        g = np.einsum('ij,j->ij', g, ivr)[:, :-1]
        g = (g.conjugate() * g).real
        imshow(g, 'g.png', extent=[0, 1, 0, 1])
        data = []
        for i in range(0, self.totalStep / 2 + 1, self.totalStep / 20):
            data.append([rs, g[i, :], str(i)])
        series(xlabel='length (A)',
               ylabel='Cross Phonon Energy Spectrum',
               datas=data, linewidth=2, filename='cpes.png')
        cg = g.cumsum(axis=1)
        imshow(cg, 'cg.png', extent=[0, 1, 0, 1])
        cg = np.einsum('ij,i->ij', cg, 1.0 / cg[:, -1])
        data = []
        for i in range(0, self.totalStep / 2 + 1, self.totalStep / 10):
            data.append([rs, cg[i, :], str(i)])
        series(xlabel='length (A)',
               ylabel='Cross Phonon Energy Spectrum',
               datas=data, linewidth=2, filename='cges.png')
        lc = ((cg < 0.80).sum(axis=1)) * dr
        x = np.linspace(0, 1, self.totalStep / 2 + 1) * 1 / 2.0 / self.timestep
        plot([x, 'Frequency (THz)'], [lc, 'Coherence length(A)'], 'coherence.png')
        return lc
Beispiel #43
0
 def v2h5(self):
     if not tl.exists('dy.h5'):
         self.pix('-sv dy.h5')
Beispiel #44
0
 def runnscf(self):
     if not tl.exists('nscf.in'):
         self.getnscfin()
     pw = self.getx("pw")
     tl.passthru(pw + " <nscf.in > nscf.out")
Beispiel #45
0
 def calculateLife(self, eigen, iqp, ibr):
     q = self.modeSed(eigen, iqp, ibr)
     if tl.exists('velocity.h5md'):
         tl.passthru('rm velocity.h5md')
     k, freq, vec = eigen
     return self.modefit(iqp, ibr, k, freq, q)
Beispiel #46
0
 def runnscf(self):
     if not tl.exists('nscf.in'):
         self.getnscfin()
     pw = self.getx("pw")
     tl.passthru(pw + " <nscf.in > nscf.out")
Beispiel #47
0
 def pix(self, cmd):
     if tl.exists('dy.h5'):
         v = "-lv dy.h5"
     else:
         v = "dynaphopy.lammpstrj"
     tl.passthru("dynaphopy in.dy %s -ts %f %s" % (v, self.m.timestep, cmd))
Beispiel #48
0
 def v2h5(self):
     if not tl.exists('dy.h5'):
         self.pix('-sv dy.h5')
Beispiel #49
0
 def allnmaq(self, filename="qpoints/qpoints.yaml", k=[0, 0, 0]):
     self.all = True
     assert tl.exists('phis.h5')
     self.phis = h5py.File('phis.h5')
     self.lifenmaq(filename, k)
Beispiel #50
0
    def cal_lc(self, r, dr, m):
        from aces.lammpsdata import lammpsdata
        atoms = lammpsdata().set_src('correlation_structure')
        atoms.set_pbc([m.xp, m.yp, m.zp])
        nw = self.totalStep / 2 + 1
        nr = int(r / dr) + 1
        n = len(atoms)
        pos = atoms.positions
        cell = atoms.cell
        symbols = atoms.get_chemical_symbols()
        masses = self.getMassFromLabel(symbols)
        if not tl.exists('g.npz'):
            g = np.zeros([nw, nr], dtype=np.complex)
            ng = np.zeros(nr, dtype=np.int)
            c = self.get_nei(r, dr, pos, cell)
            for i, j, q in c:
                if j == 0:
                    print("center atom:%d/%d" % (i, n))
                aij = np.einsum('ij,ij->i',
                                self.fourier_atom(i).conjugate(),
                                self.fourier_atom(j))
                aii = np.einsum('ij,ij->i',
                                self.fourier_atom(i).conjugate(),
                                self.fourier_atom(i))
                ajj = np.einsum('ij,ij->i',
                                self.fourier_atom(j).conjugate(),
                                self.fourier_atom(j))
                x = aij / np.sqrt(aii * ajj) * np.sqrt(masses[i] * masses[j])
                for ir in q:
                    g[:, ir] += x
                    ng[ir] += 1
            np.savez('g.npz', g=g, ng=ng)
        npz = np.load('g.npz')
        g = npz['g']
        ng = npz['ng']
        rs = (np.arange(nr)) * dr
        rs = rs[:-1]

        def aa(x):
            if x > 0:
                return 1.0 / x
            else:
                return 0.0

        ivr = [aa(x) for x in ng]  # 1.0/4.0/np.pi/rs**2
        g = np.einsum('ij,j->ij', g, ivr)[:, :-1]
        g = (g.conjugate() * g).real
        imshow(g, 'g.png', extent=[0, 1, 0, 1])
        data = []
        for i in range(0, self.totalStep / 2 + 1, self.totalStep / 20):
            data.append([rs, g[i, :], str(i)])
        series(xlabel='length (A)',
               ylabel='Cross Phonon Energy Spectrum',
               datas=data,
               linewidth=2,
               filename='cpes.png')
        cg = g.cumsum(axis=1)
        imshow(cg, 'cg.png', extent=[0, 1, 0, 1])
        cg = np.einsum('ij,i->ij', cg, 1.0 / cg[:, -1])
        data = []
        for i in range(0, self.totalStep / 2 + 1, self.totalStep / 10):
            data.append([rs, cg[i, :], str(i)])
        series(xlabel='length (A)',
               ylabel='Cross Phonon Energy Spectrum',
               datas=data,
               linewidth=2,
               filename='cges.png')
        lc = ((cg < 0.80).sum(axis=1)) * dr
        x = np.linspace(0, 1, self.totalStep / 2 + 1) * 1 / 2.0 / self.timestep
        plot([x, 'Frequency (THz)'], [lc, 'Coherence length(A)'],
             'coherence.png')
        return lc
Beispiel #51
0
 def allnmaq(self, filename="qpoints/qpoints.yaml", k=[0, 0, 0]):
     self.all = True
     assert tl.exists('phis.h5')
     self.phis = h5py.File('phis.h5')
     self.lifenmaq(filename, k)