예제 #1
0
파일: .AIMDLoop.py 프로젝트: 91bsjun/CCpyNN
def write_data(crt):
    # -- Save diffusivity and conductivity of current step
    # -- Skip initial heating process and stablizing process : set as start_num
    start_num = 1
    if crt >= start_num:
        vaspruns = []
        for i in range(start_num, crt + 1):
            dirname = "run%03d" % i
            vasprun = dirname + "/vasprun.xml.gz"
            vaspruns.append(vasprun)

        # -- collect all smoothing modes of analyzer
        analyzers = {}
        for mode in [False, 'constant', 'max']:
            try:
                analyzers[mode] = DiffusionAnalyzer.from_files(vaspruns,
                                                               specie=specie,
                                                               smoothed=mode,
                                                               min_obs=60)
            except:
                analyzers[mode] = None

        # -- save DiffusionAnalzyer as pickle to plot msd quickly
        if crt % 10 == 0:
            with open("analyzer%03d.pkl" % crt, 'wb') as save_data:
                pickle.dump(analyzers, save_data)
        os.system("gzip analyzer%03d.pkl" % crt)

        # -- write data
        f = open("data_%sK.csv" % temp, "a")
        timestep = (crt - start_num + 1) * nsw * 2 / 1000
        step_info = "%d,%d," % (crt, timestep)
        f.write(step_info)
        for mode in [False, 'constant', 'max']:
            if analyzers[mode] == None:
                diffusivity, conductivity = 0.0, 0.0
            else:
                sd = analyzers[mode].get_summary_dict()
                diffusivity = sd['D']
                conductivity = sd['S']
            f = open("data_%sK.csv" % temp, "a")
            line = "%.10f,%.4f," % (diffusivity, conductivity)
            f.write(line)
        f.write("\n")
        f.close()
예제 #2
0
    def Diffusion(self, skip=10, spaces='S', temp=[300, 310, 350, 390]):
        from pymatgen.analysis.diffusion_analyzer import DiffusionAnalyzer, fit_arrhenius, get_arrhenius_plot
        import shutil
        import os

        os.chdir(self.dire)
        filePath = self.dire
        file = []
        for dirpath, dirnames, filenames in os.walk(filePath):
            # print(dirpath)
            for name in dirnames:
                path = os.path.join(filePath, name)
                path1 = os.path.join(path, 'vasprun.xml')
                print(path1)
                file.append(str(path1))

        diff = DiffusionAnalyzer.from_files(file,
                                            specie=spaces,
                                            step_skip=skip)
        diff.get_msd_plot()
        diff.get_summary_dict()
        fit = fit_arrhenius(temps=temp, diffusivities=diff.diffusivity)
        plot = get_arrhenius_plot(temps=temp, diffusivities=diff.diffusivity)
예제 #3
0
temperatures = [500, 600, 700, 800, 900, 1000]
tetrels = ["Ge", "Sn"]

for i in temperatures:
    for j in tetrels:
        x1 = Xdatcar(f'{i}K/{j}/1/XDATCAR')
        x2 = Xdatcar(f'{i}K/{j}/2/XDATCAR')
        x3 = Xdatcar(f'{i}K/{j}/3/XDATCAR')
        x4 = Xdatcar(f'{i}K/{j}/4/XDATCAR')
        x5 = Xdatcar(f'{i}K/{j}/5/XDATCAR')
        structures = x1.structures + x2.structures + x3.structures + x4.structures + x5.structures

s500K = [
    "500/Sn/1/vasprun.xml", "500/Sn/2/vasprun.xml", "500/Sn/3/vasprun.xml"
]
d500K = DiffusionAnalyzer.from_files(s500K, specie="Na", smoothed=max)
s600K = [
    "600/Sn/1/vasprun.xml", "600/Sn/2/vasprun.xml", "600/Sn/3/vasprun.xml"
]
d600K = DiffusionAnalyzer.from_files(s600K, specie="Na", smoothed=max)
s700K = [
    "700/Sn/1/vasprun.xml", "700/Sn/2/vasprun.xml", "700/Sn/3/vasprun.xml"
]
d700K = DiffusionAnalyzer.from_files(s700K, specie="Na", smoothed=max)
s800K = [
    "800/Sn/1/vasprun.xml", "800/Sn/2/vasprun.xml", "800/Sn/3/vasprun.xml"
]
d800K = DiffusionAnalyzer.from_files(s800K, specie="Na", smoothed=max)
s900K = [
    "900/Sn/1/vasprun.xml", "900/Sn/2/vasprun.xml", "900/Sn/3/vasprun.xml"
]