コード例 #1
0
ファイル: batch_run.py プロジェクト: hackberie/00_workSpace
    def prep_run_file(self, next_run='next_run.sh'):
        """
        run_fileを修正してnext_run.shを作成
        run_listの実行したjobをコメントアウト
        """
        work_path, fname_exe = self.run_list[0]
        key = "cd $PBS_O_WORKDIR\n"
        # work_pathが相対pathの場合、絶対pathに修正する
        if work_path[0] == '/':
            alt = "cd {0}\n".format(os.path.join(work_path))
        else:
            alt = "cd {0}\n".format(os.path.join(os.getcwd(), work_path))

        lines = Cabinet.read_file(fname_exe)

        # $PBS_O_WORKDIRの記述が無い場合errorメッセージを出力
        try:
            pos = lines.index(key)
        except ValueError:
            print("{0}に'cd $PBS_O_WORKDIR'の記述がありません".format(fname_exe))
            exit()
        lines[pos] = alt
        Cabinet.write_file(next_run, lines)

        finished = self.run_list.pop(0)
        finished[0] = '#' + finished[0]
        self.finished_list.append(finished)
        tmp_list = self.finished_list + self.run_list
        all_list = [" ".join(x) + "\n" for x in tmp_list]
        Cabinet.write_file(self.list_run_file, all_list)
コード例 #2
0
ファイル: vaspy.py プロジェクト: hackberry-tree/00_workSpace
 def write_potcar(self, path, fname='POTCAR'):
     """
     Make a combined single POTCAR file
     """
     fname = os.path.join(path, fname)
     out_lines = [x for y in self.potentials_lines for x in y]
     Cabinet.write_file(fname, out_lines)
コード例 #3
0
ファイル: vaspy.py プロジェクト: hackberry-tree/00_workSpace
 def write_poscar(self, poscar='POSCAR'):
     """
     write_poscar(path)
     Make a 'POSCAR' file at 'path'
     """
     Cabinet.reserve_file(poscar)
     Cabinet.write_file(poscar, str(self))
コード例 #4
0
 def make_list_run(self, run_file):
     """
     next.py用のlist_run.txtを作成
     """
     lines = ""
     for param in self.series:
         path = param['path']
         run_file = os.path.abspath(run_file)
         lines += "{0}    {1}\n".format(path, run_file)
     Cabinet.write_file('list_run', lines)
コード例 #5
0
ファイル: batch_run.py プロジェクト: hackberie/00_workSpace
 def run_job_and_get_id(self, fname_exe='next_run.sh'):
     """
     jobを走らせる
     走らせるファイルはnext_run.sh
     """
     cmd = ['qsub', fname_exe]
     job_id = Popen(cmd, stdout=PIPE).communicate()[0]
     add_line = job_id.split('.')[0] + b'\n'
     self.running_jobs.append(add_line)
     Cabinet.write_file(self.running_jobs_file, self.running_jobs)
コード例 #6
0
ファイル: vaspy.py プロジェクト: hackberry-tree/00_workSpace
 def write_kpoints(self, fname='KPOINTS', mode='M'):
     """Write KPOINTS file using self.kpoints"""
     if mode == 'M':
         mline = "Monkhorst Pack"
     elif mode == 'G':
         mline = "Gamma"
     kp_lines = ("Automatic mesh\n0\n{0}\n"
                 "  {1[0]}  {1[1]}  {1[2]}\n  0.  0.  0.\n"
                 .format(mline, self.kpoints))
     Cabinet.write_file(fname, kp_lines)
コード例 #7
0
ファイル: test_grapy.py プロジェクト: hackberie/00_workSpace
    def plt_double(self, combipara, in_dir1, in_dir2, out_dir):
        """2種の結果のlattice依存性をプロット"""
        combi = Combinatorial(*combipara)
        combi.set_formula(2, 1)
        for composition in combi.compositions:
            formula = composition['formula']
            formula = ''.join(formula.split('2'))
            total_elem = ['Fe'] + composition['elements']
            total_num_atoms = [1] + composition['num_atoms']
            print(formula)

            all_dir_list = glob.glob(os.path.join(in_dir1, formula, 'fixed_*'))
            regular = collect_vasp.Energy(all_dir_list, 'POSCAR', 'OSZICAR')
            regular['c/a'] /= 2 ** 0.5

            fixed_elem = [total_elem[1], total_elem[0], total_elem[2]]
            fixed_elem = np.array([fixed_elem] * len(regular['elements']))

            regular['elements'] = fixed_elem
            regular.set_enthalpy()
            regular.set_mae('OSZICAR_SOC001', 'OSZICAR_SOC100')

            all_dir_list = glob.glob(os.path.join(in_dir2, formula, 'fixed_*'))
            inverse = collect_vasp.Energy(all_dir_list, 'POSCAR', 'OSZICAR')
            inverse['c/a'] /= 2 ** 0.5
            inverse['elements'] = fixed_elem
            inverse.set_enthalpy()
            inverse.set_mae('OSZICAR_SOC001', 'OSZICAR_SOC100')

            rlines = [str(regular)]
            ilines = [str(inverse)]
            fname_reg = "Fe2{0[0]}{0[1]}_reg.txt".format(composition['elements'])
            fname_inv = "Fe2{0[0]}{0[1]}_inv.txt".format(composition['elements'])
            Cabinet.write_file(os.path.join(out_dir, 'text', fname_reg), rlines)
            Cabinet.write_file(os.path.join(out_dir, 'text', fname_inv), ilines)


            def plot():
                plt = grapy.Vertical(3)
                plt.set_title("Heusler Fe$_2${0[0]}{0[1]}"
                                .format(composition['elements']))
                plt.set_style('blue')
                plt.set123(regular, 'c/a', 'enthalpy', 'mag', 'mae')
                plt.set_style('magenta')
                plt.set123(inverse, 'c/a', 'enthalpy', 'mag', 'mae')

                plt.adjust_auto()
                plt.ax2.set_ylim(-0.5, 3)
                plt.plot('show')
                #fname = "Fe2{0[0]}{0[1]}.eps".format(composition['elements'])
                #plt.plot(os.path.join(out_dir, fname))
            plot()
コード例 #8
0
ファイル: spr_conc.py プロジェクト: buriedwood/00_workSpace
def change_conc():
    """
    concを変更する
    """
    list1 = [str(i*0.1) for i in range(0, 11)]
    list2 = ['001', '100']
    list3 = ['0.950', '1.000', '1.050', '1.100', '1.150',
             '1.200', '1.250', '1.300', '1.350', '1.400',
             '1.450', '1.500']
    combi = Combinatorial(list1, list2, list3)
#    print(combi.compositions)
    comp_list = [x['elements']
                 for x in combi.compositions]
    lines = ""
    for comp in comp_list:
        lines += "/".join(comp) + " run.sh\n"
    print(lines)
    Cabinet.write_file('list_run.txt', lines)
コード例 #9
0
ファイル: batch_run.py プロジェクト: hackberie/00_workSpace
 def is_running(self):
     """
     jobが動作中かどうかcheckする
     終了していた場合、running_jobsから削除
     """
     cmd = ['qstat']
     jobs = Popen(cmd, stdout=PIPE).communicate()[0].split(b'\n')
     uname = getpass.getuser()
     still_run = []
     for job_id in self.running_jobs:
         key = r"{0}.*{1}.*".format(job_id[:-1], uname)
         meta = re.compile(key)
         judge = True
         for job in jobs:
             if meta.match(job):
                 judge = None
         if not judge:
             still_run.append(job_id)
     self.running_jobs = still_run
     Cabinet.write_file(self.running_jobs_file, self.running_jobs)
コード例 #10
0
ファイル: vaspy.py プロジェクト: hackberry-tree/00_workSpace
 def write_incar(self, fname):
     """Write INCAR file"""
     Cabinet.write_file(fname, str(self))
コード例 #11
0
ファイル: vaspy.py プロジェクト: buriedwood/00_workSpace
 def write_kpoints(self, fname='KPOINTS'):
     """Write KPOINTS file using self.kpoints"""
     kp_lines = ('Automatic mesh\n0\nMonkhorst Pack\n'
                 '  {0[0]}  {0[1]}  {0[2]}\n  0.  0.  0.\n'
                 .format(self.kpoints))
     Cabinet.write_file(fname, kp_lines)