def cal_excite_relax(self, knum, ocp_set, mpi=28, openmp=1, num_machines=1, num_mpiprocs_per_machine=28, max_wallclock_seconds=86400, queue_name='gold5120'): strufile = extract_largest_number_file() stru = read_stru(self.input_dict["ntype"], glob(strufile)) for elem in stru.orbitals.keys(): stru.orbitals[elem] = os.path.basename(stru.orbitals[elem]) kpt = Kpt('Gamma', knum) os.mkdir('excite') os.chdir('excite') command = Code( code_name=self.code_name, cmdline_params=[f"-n {mpi}", f"-env OMP_NUM_THREADS={openmp}"], stdout_name="job.log", stderr_name="job.err", withmpi="mpirun") submit_command = set_scheduler( 'torque', [command], num_machines=num_machines, num_mpiprocs_per_machine=num_mpiprocs_per_machine, run_mode='p', max_wallclock_seconds=max_wallclock_seconds, queue_name=queue_name) self.excite_relax(ocp_set, stru, kpt) os.system(submit_command) os.chdir('../')
def cal_ground_cell_relax(self, knum, mpi=28, openmp=1, num_machines=1, num_mpiprocs_per_machine=28, max_wallclock_seconds=86400, queue_name='gold5120'): stru = read_stru(self.input_dict["ntype"], "STRU") kpt = Kpt('Gamma', knum) os.mkdir('ground') os.chdir('ground') command = Code( code_name=self.code_name, cmdline_params=[f"-n {mpi}", f"-env OMP_NUM_THREADS={openmp}"], stdout_name="job.log", stderr_name="job.err", withmpi="mpirun") submit_command = set_scheduler( 'torque', [command], num_machines=num_machines, num_mpiprocs_per_machine=num_mpiprocs_per_machine, run_mode='p', max_wallclock_seconds=max_wallclock_seconds, queue_name=queue_name) self.ground_cell_relax(stru, kpt) os.system(submit_command) os.chdir('../')
def cal_phono(self, dim=[1, 1, 1], mpi=28, openmp=1, num_machines=1, num_mpiprocs_per_machine=28, max_wallclock_seconds=86400, queue_name='gold5120'): strufile = extract_largest_number_file() stru = read_stru(self.input_dict["ntype"], strufile) for elem in stru.orbitals.keys(): stru.orbitals[elem] = os.path.basename(stru.orbitals[elem]) self.input_dict['gamma_only'] = 1 kpt = Kpt('Gamma', [1, 1, 1]) command = Code( code_name=self.code_name, cmdline_params=[f"-n {mpi}", f"-env OMP_NUM_THREADS={openmp}"], stdout_name="job.log", stderr_name="job.err", withmpi="mpirun") os.mkdir('phonon_ground') os.chdir('phonon_ground') stru.write_stru() with open("setting.conf", 'w') as f: f.write( dedent(f"""\ DIM = {' '.join(list_elem2str(dim))} ATOM_NAME = {' '.join(stru.elements)} """)) os.system('phonopy setting.conf --abacus -d') disp_list = glob('STRU-*') for i in disp_list: dst = 'disp-' + i.split('-')[-1] os.mkdir(dst) shutil.move(i, dst) os.chdir(dst) disp_stru = read_stru(self.input_dict["ntype"], i) submit_command = set_scheduler( 'torque', [command], num_machines=num_machines, num_mpiprocs_per_machine=num_mpiprocs_per_machine, run_mode='p', max_wallclock_seconds=max_wallclock_seconds, queue_name=queue_name) self.ground_scf(disp_stru, kpt) os.system(submit_command) os.chdir('../') os.chdir('../')
def double_run(self, command: Command, scheduler: str, **kwargs): """Check if job is finished and execute again :params command: abacuskit.schedulers.data.Code` object to execute calculation :params scheduler: string of scheduler name :params kwargs: other parameters of scheduler """ current_path = Path.cwd() codes_info = [command] for folder in read_json("folders"): if not glob.glob(f"{folder}/matrix_*"): import warnings warnings.warn( f"'matrix_*' file not found in {folder}, it will execute again." ) os.chdir(folder) submit_command = set_scheduler(scheduler, codes_info, **kwargs) os.system(submit_command) os.chdir(current_path)
def batch_run(self, command: Code, scheduler: str, **kwargs): """Batch execute dimer calculation :params command: abacuskit.schedulers.data.Code` object to execute calculation :params scheduler: string of scheduler name :params kwargs: other parameters of scheduler """ self._prepare() filename = "folders" # TODO: for new dpsi scripts, it should be a dict with key "origin" subfolder_weight = { os.path.basename(key): value for key, value in self.folder_weight.items() } with open(filename, 'w') as file: json.dump(subfolder_weight, file, indent=4) current_path = Path.cwd() codes_info = [command] for folder in self.folder_weight: os.chdir(folder) submit_command = set_scheduler(scheduler, codes_info, **kwargs) os.system(submit_command) os.chdir(current_path)