def _submit_job(job_name, cpu_num): js = read_json() prep = js['job']['prepend'] exe = js['job']['exec'] subprocess.check_output(prep + ' && ' + 'mpirun -n ' + str(cpu_num) + ' ' + exe.split()[-1], shell=True, cwd=job_name)
def write_job_file(node_name,cpu_num,node_num,job_name): json_f = read_json() with open('job.sh','w') as f: f.writelines('#!/bin/bash \n') f.writelines('#SBATCH -J '+job_name+'\n') f.writelines('#SBATCH -p '+node_name+' -N '+ str(int(node_num)) +' -n '+str(int(cpu_num))+'\n\n') f.writelines(json_f['job']['prepend']+'\n') f.writelines(json_f['job']['exec']+'\n')
def write_file(self,filename='POTCAR'): json_f = read_json() potcar_main_dir_path = json_f['potcar_path'][self.functional] all_pot_file = [] for map in self.sym_potcar_map: pot_path = path.join(potcar_main_dir_path,map) if path.isfile(path.join(pot_path,'POTCAR')): all_pot_file.append(path.join(pot_path,'POTCAR')) elif path.isfile(path.join(pot_path,'POTCAR.Z')): all_pot_file.append(path.join(pot_path,'POTCAR.Z')) else: from os import listdir from os.path import isfile, join possible = [dir for dir in listdir(json_f['potcar_path'][self.functional]) if map.split('_')[0] in dir] raise FileNotFoundError('Not found supported POTCAR file' +' you can set sym_potcar_map='+ ','.join(possible)) with open(filename, 'w') as outfile: for fname in all_pot_file: outfile.write(zread(fname))