Ejemplo n.º 1
0
def main():
    Bash.mkdir('cova')
    cova_list = Array.frange_stp(1.0, 1.05, 0.05)
    series = series_vasp.Produce('POSCAR', 'cova')
    series.set_cova(cova_list)
    series.make_files()
    series.append_list_run('run_cova.sh')
Ejemplo n.º 2
0
    def from_new(cls):
        """
        seq ディレクトリを作成し originals ディレクトリ中に初期ファイルを保存
        実行ディレクトリを記憶
        """
        seq_list = glob.glob("seq*/")
        i = 0
        for seq in seq_list:
            try:
                j = int(seq.split("seq")[-1].split("/")[0])
                if i < j:
                    i = j
            except ValueError:
                pass
        i += 1
        dirc = 'seq{0}/originals/'.format(i)
        str_files = glob.glob('*.str')
        Bash.mkdir(dirc)
        for fname in ['IN.CVM', 'def.txt', 'energies.txt'] + str_files:
            copyfile(fname, os.path.join(dirc, fname))

        seq_dirc = "seq{0}".format(str(i))
        print("New directory of '{}' is created".format(seq_dirc))

        clus_name = cls.get_clus_name(".")

        results = CEMResults([])
        return cls(seq_dirc, None, None, clus_name, results)
Ejemplo n.º 3
0
    def view_osz(self):
        path = '.'
        if self.value.value == 'EV curve':
            path = glob.glob('voldep/volume_*')[0]
        print(path)

        Bash.execute("emacs {0}/OSZICAR".format(path))
Ejemplo n.º 4
0
    def set_condition(self, r, n):
        """
        path 中に originals ファイルをコピーして rmax, nmax を def.txt にセットする
        """
        if not self.distances:
            self.current_label = "RmaxN2"
            rmax = r
        else:
            self.current_label = "R{0}N{1}".format(r, n)
            rmax = self.distances[r-1]+0.005
        dst = os.path.join(self.seq_dirc, self.current_label)
        Bash.copy_dir(os.path.join(self.seq_dirc, "originals"), dst)

        deftxt = os.path.join(dst, "def.txt")
        with open(deftxt, 'r') as rfile:
            lines = rfile.readlines()
        meta = re.compile(r"^{0}\s*.*".format(self.clus_name))
        i = 0
        # print(self.clus_name)
        while not meta.match(lines[i]):
            # print(i)
            # print(lines[i])
            i += 1
        lines[i] = "{0}      RMAX={1} NSMAX={2}  PRNTMAXCL=T NMAX=0\n".format(
            self.clus_name, rmax, n)
        with open(os.path.join(dst, "def.txt"), 'w') as wfile:
            wfile.write("".join(lines))
Ejemplo n.º 5
0
 def alt_incvm(src, dst):
     """
     CONW, ECLI を書き換えて出力する
     """
     call("cat {0}/IN.CVM | sed 's/CONW=T/CONW=F/g' | "
          "sed 's/ECLI=T/ECLI=F/g' > tmp".format(src), shell=True)
     Bash.move('tmp', os.path.join(dst, "IN.CVM"))
Ejemplo n.º 6
0
def main():
    Bash.mkdir('kp')
    kp_list = Array.frange_stp(0.08, 0.24, 0.02)
    #kp_list = Array.frange_stp(0.04, 0.07, 0.02)
    series = series_vasp.Produce('POSCAR', 'kp')
    series.set_kp_relax(kp_list)
    series.make_files()
    series.make_list_run('run.sh')
Ejemplo n.º 7
0
 def test_plt(self):
     clean_prev_dir(self.path, 'output')
     Bash.mkdir(os.path.join(self.path, 'output', 'text'))
     combi_para = [['Co'], ['Al']]
     pathA = os.path.join(self.path, 'typeA')
     pathB = os.path.join(self.path, 'typeB')
     path_out = os.path.join(self.path, 'output')
     self.plt_double(combi_para, pathA, pathB, path_out)
Ejemplo n.º 8
0
 def mkdirs(self):
     """
     pathに記された階層ディレクトリを作成
     階層の順番はsetした順番となる
     """
     for param in self.series:
         dst_path = param['path']
         Bash.mkdir(dst_path)
Ejemplo n.º 9
0
 def conv2poscar(cif_file, out_path):
     """
     A cif file convert to POSCAR
     """
     cif_file = os.path.normpath(cif_file)
     cmd = 'cif2cell -p vasp -f {0} -o {1}/POSCAR --no-reduce \
     --vasp-print-species --vasp-cartesian-lattice-vectors \
     --vasp-format=5'.format(cif_file, out_path)
     Bash.execute(cmd)
Ejemplo n.º 10
0
 def test_volume(self):
     print("SeriesVasp test_volume")
     os.chdir(self.path)
     clean_prev_dir('.', 'volume')
     Bash.mkdir('volume')
     volume_list = [5, 6, 7]
     series = series_vasp.Produce('POSCAR', 'volume')
     series.set_volume(volume_list)
     series.make_files()
Ejemplo n.º 11
0
def stack(args):
    """
    hcp-fcc Mg stacking 構造を作成する
    """
    path = args
    strs = CVMStrs.from_str_file(path)
    for structure in strs:
        dirc = str(structure.label).split('*')[0]
        Bash.mkdir(dirc)
        structure.make_stack_poscar(os.path.join(dirc, "POSCAR"))
Ejemplo n.º 12
0
def for_ferrite():
    """
    ferrite系のcombinatorial
    """
    Bash.mkdir('combi')
    elem_list = ['Ni', 'Mn', 'Cu', 'Zn', 'Cr']
    comp_list = [['O', 'Fe', x] for x in elem_list]
    series = series_vasp.Produce('POSCAR', 'combi')
    series.set_elements(comp_list)
    series.make_files()
    series.append_list_run('run_combi.sh')
Ejemplo n.º 13
0
 def expand_poscars(self, elements):
     """
     self.poscarsのPOSCARをディレクトリ(ID名)に展開
     elements名も追記する
     self.path中に作成
     pathを変えたい場合はself.pathを変更
     """
     for poscar in self.poscars:
         Bash.mkdir(os.path.join(self.path, poscar['ID']))
         poscar['object'].elements = elements
         poscar['object'].write_poscar(os.path.join(self.path,
                                                    poscar['ID'], 'POSCAR'))
Ejemplo n.º 14
0
 def execute(self):
     if self.value == 'EV curve':
         Bash.execute("batch_run.sh 100")
     else:
         Bash.execute("qsub run.sh")
     top = tk.Toplevel()
     f = tk.Frame(top)
     f.pack()
     label = tk.Label(f, text="{0} calculation started !".format(self.value))
     label.pack()
     btn = tk.Button(f, text="OK", command=top.destroy)
     btn.pack()
Ejemplo n.º 15
0
    def make_system(self, dirname=None):
        os.chdir(CWD)
        font = ('Helevetica', 12, 'bold')
        self.initial.status.configure(text='None', font=font, fg='red')

        if not dirname:
            dirname = self.e_dir.get()
        dirname = "enshu_" + self.e_dir.get()
        path = os.path.join(CWD, dirname)
        Bash.mkdir(path)
        self.initial.listbox.delete(0, tk.END)
        SYSTEMS = [x[6:] for x in glob.glob('enshu_*')]
        print(SYSTEMS)
        self.initial.listbox.insert(tk.END, *SYSTEMS)
        self.top.destroy()
Ejemplo n.º 16
0
def relax(path, num, vaspcmd):
    """
    judgeの結果がTrueの場合終了
    それ以外はOSZICAR, OUTCARを保管してVASPを再実行
    """
    for i in range(0, num):
        judge = judge_oszicar(path)
        if judge:
            break
        else:
            shutil.copyfile('OUTCAR', "out.relax.{0}".format(i))
            shutil.copyfile('OSZICAR', "osz.relax.{0}".format(i))
            shutil.copyfile('CONTCAR', 'POSCAR')
            print("Start re-calculation.")
            Bash.execute(vaspcmd)
Ejemplo n.º 17
0
def for_Fe16N2():
    """
    perovskite系のcombinatorial
    """
    Bash.mkdir('combi')
    elem_list = [['Sc', 'As', 'Se', 'Y', 'Mo',
                  'Tc', 'Ag', 'Cd', 'In', 'Te',
                  'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir',
                  'Au', 'Hg', 'Tl', 'Pb', 'Bi'], ['C', 'B', 'N']]
    combi = Combinatorial(*elem_list)
    comp_list = [['Fe', x['elements'][0], 'Fe', x['elements'][1]]
                 for x in combi.compositions]
    series = series_vasp.Produce('POSCAR', 'combi')
    series.set_elements(comp_list)
    series.make_files()
    series.append_list_run('run_combi.sh')
Ejemplo n.º 18
0
def for_perovskite():
    """
    perovskite系のcombinatorial
    """
    Bash.mkdir('combi')
    elem_list = [['Al', 'Co', 'Cr', 'Cu', 'Fe', 'Ga',
                  'Ge', 'Mn', 'Nb', 'Ni', 'Pd', 'Pt',
                  'Rh', 'Ru', 'Sb', 'Si', 'Sn', 'Ti',
                  'V', 'Zn', 'Zr'], ['C', 'B', 'N']]
    combi = Combinatorial(*elem_list)
    comp_list = [['Fe', x['elements'][0], x['elements'][1]]
                 for x in combi.compositions]
    series = series_vasp.Produce('POSCAR', 'combi')
    series.set_elements(comp_list)
    series.make_files()
    series.append_list_run('run_combi.sh')
Ejemplo n.º 19
0
 def extract_strs(self, exch_fix,
                  src_path="../*/str.out", dst_dirc="extracts"):
     """
     src_path 中の等価な全ての構造を genstr から抽出する
     """
     for path in glob.glob(src_path):
         dst_path = os.path.join(
             dst_dirc, os.path.basename(os.path.dirname(path)))
         Bash.mkdir(dst_path)
         idx = self.get_idx_same_str(os.path.dirname(path), exch_fix=exch_fix)
         if idx:
             lines = self.lines[idx[0]:idx[1]]
             with open(os.path.join(dst_path, "str.out"), 'w') as wfile:
                 wfile.write("".join(lines))
         else:
             with open(os.path.join(dst_path, "too_large"), 'w') as wfile:
                 wfile.write("")
Ejemplo n.º 20
0
def save_results(temp, plot_data):
    Bash.mkdir('results_cv1')
    lines = "x\ty\n"
    for i in range(len(plot_data[0])):
        lines += str(plot_data[0][i]) + "\t"
        lines += str(plot_data[1][i]) + "\n"
    fname = "raw_" + str(temp)
    with open(os.path.join('results_cv1', fname), 'w') as wfile:
        wfile.write(lines)

    lines = "x_fit\ty_fit\n"
    for i in range(len(plot_data[2])):
        lines += str(plot_data[2][i]) + "\t"
        lines += str(plot_data[3][i]) + "\n"
    fname = "fit_" + str(temp)
    with open(os.path.join('results_cv1', fname), 'w') as wfile:
        wfile.write(lines)
Ejemplo n.º 21
0
def clean_prev_dir(path, dirc):
    """
    既存dirctoryを消去
    """
    trush_list = Bash.find_files(path, dirc)
    for trush in trush_list:
        fname = os.path.join(path, trush)
        shutil.rmtree(fname)
        print("{0} is removed.".format(fname))
Ejemplo n.º 22
0
def clean_prev(path, files):
    """
    既存filesを消去
    """
    trush_list = Bash.find_files(path, files)
    for trush in trush_list:
        fname = os.path.join(path, trush)
        os.remove(fname)
        print("{0} is removed.".format(fname))
Ejemplo n.º 23
0
 def convert_all(self, dst_path):
     """
     det_path中の5種のINCARファイルを修正し上書きする
     追加したパラメータを出力
     """
     incar_list = Bash.find_files('INCAR_*soc*')
     for incar in incar_list:
         self.convert_incar(dst_path, incar)
     self.note_update()
Ejemplo n.º 24
0
 def prep_one(cls, cif_file, dst_dir):
     """
     The dst_dir is current directory,
     this method search POSCAR and reserve it.
     If not, it will search whethre dst_dir already exist or not.
     If it already exist, this module will do nothing.
     If not, new directory make and prepare POSCAR file.
     """
     if dst_dir == '.':
         Cabinet.reserve_file('POSCAR')
     elif glob.glob(dst_dir):
         line = ("\'{0}\' directory is already exist.\n"
                 "Do Nothing...\n".format(dst_dir.split('/')[-1]))
         print(line)
         return
     else:
         Bash.mkdir(dst_dir)
     cls.conv2poscar(cif_file, dst_dir)
     shutil.copy(cif_file, dst_dir)
Ejemplo n.º 25
0
 def all(cls, path, incar_obj=None, kp_rx=0.15, kp_soc=0.11):
     """
     All pattern of INCAR files are prepared.
     それぞれのパラメータの変更は
     class method "cls_add_fixedtag"や"cls_add_extratag"を使うか
     incar_objに書き替えたincarを入力
     省略した場合、path中のPOSCARをbaseに作成
     """
     if not incar_obj:
         incar_obj = IncarReadPoscar(os.path.join(path, 'POSCAR'))
     cls.make_potcar_kpoints(path, kp_rx, kp_soc)
     methods = ['relax', 'cell', 'volume', 'volumeE', 'presoc', 'presoc_nc',
                'ibzkp', 'soc',
                'dos', 'band', 'static']
     for method in methods:
         getattr(cls, method)(path, incar_obj)
     src_dir = os.path.join(MODULE_DIR, '../sorce/originalsVASP', 'Calc')
     dst_dir = os.path.join(path, 'Calc')
     Bash.copy_dir(src_dir, dst_dir)
Ejemplo n.º 26
0
 def test_normalize(self):
     """normalize lattice parameter """
     print("VaspyPoscar test_normalize")
     os.chdir(self.path)
     clean_prev_dir(".", "normalize")
     Bash.mkdir("normalize")
     poscar = vaspy.Poscar("POSCAR")
     poscar.normalize_lattice()
     poscar.write_poscar("normalize/POSCAR")
     poscar1 = vaspy.Poscar("POSCAR")
     poscar2 = vaspy.Poscar("normalize/POSCAR")
     len1 = poscar1.get_lattice_length()
     len2 = poscar2.get_lattice_length()
     vol1 = poscar1.get_cell_volume()
     vol2 = poscar1.get_cell_volume()
     self.assertEqual(len1, len2)
     self.assertEqual(vol1, vol2)
     self.assertEqual(poscar2.cell_lattices[0, 0], 1)
     self.assertEqual(poscar2.cell_lattices[0, 1], 0)
     self.assertEqual(poscar2.cell_lattices[0, 2], 0)
Ejemplo n.º 27
0
def initialize():
    """
    seq ディレクトリを作成し originals ディレクトリ中に初期ファイルを保存
    """
    seq_list = glob.glob("seq*/")
    i = 0
    for seq in seq_list:
        try:
            j = int(seq.split("seq")[-1].split("/")[0])
            if i < j:
                i = j
        except ValueError:
            pass
    i += 1
    dirc = 'seq{0}/originals/'.format(i)
    str_files = glob.glob('*.str')
    Bash.mkdir(dirc)
    for fname in ['IN.CVM', 'def.txt', 'energies.txt'] + str_files:
        copyfile(fname, os.path.join(dirc, fname))
    return 'seq{0}'.format(i)
Ejemplo n.º 28
0
 def find_cif_files(path):
     """
     This method find **.cif or **.cif.txt in path and path/cifs directory.
     All cif files are moved in path/cifs/ dirctory
     """
     cifs_dir = os.path.join(path, 'cifs')
     Bash.mkdir(cifs_dir)
     search_cif = glob.glob(os.path.join(path, "*.cif"))
     search_ciftxt = glob.glob(os.path.join(path, "*.cif.txt"))
     search_cwd = search_cif + search_ciftxt
     for cif_file in search_cwd:
         Bash.move(cif_file, cifs_dir)
     search_cif = glob.glob(os.path.join(cifs_dir, "*.cif"))
     search_ciftxt = glob.glob(os.path.join(cifs_dir, "*.cif.txt"))
     search_cifs = search_cif + search_ciftxt
     if len(search_cifs) == 0:
         print('I cannot find any .cif file in {0} and {1}'
               .format(path, cifs_dir))
         exit()
     return search_cifs
Ejemplo n.º 29
0
    def test_latt(self):
        print("SeriesVasp test_latt")
        os.chdir(self.path)
        clean_prev_dir('.', 'scale')
        Bash.mkdir('scale')
        scale_list = [round(random.uniform(1, 3), 3) for x in range(0, 3)]
        series = series_vasp.Produce('POSCAR', 'scale')
        series.set_scale(scale_list)
        series.make_files()

        test_param = random.choice(series.series)
        test_path = test_param['path']
        test = vaspy.Poscar(os.path.join(test_path, 'POSCAR'))

        orig_pos = vaspy.Poscar('POSCAR')
        orig_a, _, orig_c = orig_pos.get_lattice_length()

        len_a, _, len_c = test.get_lattice_length()
        scale = test.cell_scale
        self.assertAlmostEqual(len_c/len_a, orig_c/orig_a)
        self.assertAlmostEqual(scale, test_param['scale'])
Ejemplo n.º 30
0
 def send(self):
     # cwd = os.path.basename(os.getcwd())
     for system in SYSTEMS:
         drctry = 'enshu_' + system
         dst = os.path.join('/cooper', 'KSZM_2016', BASE_DIR, drctry)
         Bash.mkdir(dst)
         files = ['POSCAR', 'CHGCAR', 'OSZICAR', 'OUTCAR',
                  'murnaghan_plot.eps', 'band.eps']
         for file in files:
             try:
                 shutil.copyfile(os.path.join(CWD, drctry, file),
                                 os.path.join(dst, file))
             except IOError:
                 pass
     top = tk.Toplevel()
     f = tk.Frame(top)
     f.pack()
     label = tk.Label(f, text="Data were send !")
     label.pack()
     btn = tk.Button(f, text="OK", command=top.destroy)
     btn.pack()