예제 #1
0
def submit(jobs):
    job_num = len(jobs)
    max_paralell = 3
    count = 0
    submitted_jobs = []
    finished_jobs = []

    def test_finished(jobs):
        nonlocal count
        for job in jobs[:]:
            if if_cal_finish(job):
                finished_jobs.append(job)
                rec = job.path
                rec += '\n'
                rec += 'calculation finished.\n'
                rec += '---' * 25
                print(rec)
                record(job.root_path, rec)
                count -= 1
                jobs.remove(job)

    # test if there is some job which is already finished
    for job in jobs[:]:
        # print(job)
        if if_cal_finish(job):
            finished_jobs.append(job)
            jobs.remove(job)

    # submit and detect statu of jobs
    j = 0
    while True:
        test_finished(submitted_jobs)
        if len(finished_jobs) == job_num and len(submitted_jobs) == 0:
            break
        else:
            if count < max_paralell and len(jobs) != 0:
                new_job = jobs.pop()
                os.chdir(new_job.path)
                rename_file(new_job.path, 'hf.out')
                rename_file(new_job.path, 'fort.9')
                out = submit_hf1_job()
                count += 1
                submitted_jobs.append(new_job)
                rec = new_job.path + '\n'
                rec += 'job submitted.'
                rec += '\n' + out + '\n'
                rec += '---' * 25
                record(new_job.root_path, rec)
                print(rec)
            else:
                time.sleep(500)
                j += 1
                if j > 35:
                    rec = 'noting changes...'
                    record(submitted_jobs[0].root_path, rec)
                    j = 0
                continue

    return finished_jobs
예제 #2
0
def test_read_all_results():
    path = 'C:\\Users\\ccccc\\Documents\\Theoritische Chemie\\Masterarbeit\\test\\hf_1'
    walks = os.walk(path)
    jobs = []
    for root, dirs, files in walks:
        if 'hf.out' in files:
            job = Job(root)
            if if_cal_finish(job):
                jobs.append(job)
    read_all_results_hf1(jobs, init_dist=3.1)
예제 #3
0
def get_jobs(path):
    path = os.path.join(path, 'hf1')
    walks = os.walk(path)
    jobs = []
    for root, dirs, files in walks:
        if ('hf.out' in files) and ('fort.9' in files):
            new_path = root
            new_job = Job(new_path)
            if if_cal_finish(new_job):
                jobs.append(new_job)
    return jobs
예제 #4
0
 def test_finished(jobs):
     nonlocal count
     for job in jobs[:]:
         if if_cal_finish(job):
             finished_jobs.append(job)
             rec = job.path
             rec += '\n'
             rec += 'calculation finished.\n'
             rec += '---' * 25
             print(rec)
             record(job.root_path, rec)
             count -= 1
             jobs.remove(job)
예제 #5
0
def test_if_finished():
    path = r'C:\Users\ccccc\Documents\Theoritische Chemie\Masterarbeit\test\hf_1\x_-0.150\z_-0.106'
    job = Job(path)
    res = if_cal_finish(job)
    print(res)