Exemplo n.º 1
0
def build_dsq_file(path):

    done = 0
    fail = 0
    out = []

    subfolders = [f.path for f in os.scandir(path) if f.is_dir()]

    for folder in subfolders:
        outcar = os.path.join(folder, 'OUTCAR')
        flag = False
        if os.path.exists(outcar):
            try:
                outcar_done = check_outcar_done(outcar)
            except:
                outcar_done = check_outcar_done_slow(outcar)
            if outcar_done:
                flag = True
        if flag:
            done += 1
        else:
            fail += 1
            target_folder = cwd
            failpath = os.path.join(target_folder, folder)
            if fail < 1000:
                out.append('cd ' + failpath + '; ' + 'mpirun vasp_std' + '\n')
            else:
                raise ValueError("job cannot exceed 1000!")

    fw = open(os.path.join(path, 'out'), 'w')
    fw.writelines(out)
    fw.close()
    return done, fail
Exemplo n.º 2
0
def build_dsq_file(path):

    done = 0
    fail = 0
    out = []

    subfolders = [f.path for f in os.scandir(path) if f.is_dir()]

    for folder in subfolders:
        outcar = os.path.join(folder, 'OUTCAR')
        flag = False
        if os.path.exists(outcar):
            try:
                outcar_done = check_outcar_done(outcar)
            except:
                outcar_done = check_outcar_done_slow(outcar)
            if outcar_done:
                flag = True
        if flag:
            done += 1
        else:
            fail += 1
            target_folder = cwd
            failpath = os.path.join(target_folder, folder)
            out.append('cd ' + failpath + '; ' +
                       'qsub {0}'.format(args.submissionscript) + '\n')

    fw = open(os.path.join(path, 'out'), 'w')
    fw.writelines(out)
    fw.close()
    return done, fail
Exemplo n.º 3
0
def build_dsq_file(path):

    done = 0
    fail = 0
    out = []

    subfolders = [
        f.path for f in os.scandir(path)
        if f.is_dir() and not ('deepmd' in f.path)
    ]  # remove deepmd folder

    for folder in subfolders:
        outcar = os.path.join(folder, 'OUTCAR')
        flag = False
        if os.path.exists(outcar):
            try:
                outcar_done = check_outcar_done(outcar)
            except:
                outcar_done = check_outcar_done_slow(outcar)
                print("!!!!!ABNORMAL OUTCAR!!!!!", outcar)
            if outcar_done:
                flag = True
        if flag:
            done += 1
        else:
            fail += 1
            #            print("cwd : ",cwd)
            #            target_folder = cwd  ## it works here cwd is cwd, but confused by the logic why it works??!
            failpath = os.path.join(path, folder)
            #            if failpath != os.path.join(path,folder):
            #                print("They are different:", failpath, os.path.join(path,folder))
            #                raise ValueError()
            #            print("failpath is : ",failpath)
            if fail < 1000:
                out.append('cd ' + failpath + '; ' + 'mpirun vasp_std' + '\n')
            else:
                raise ValueError("job cannot exceed 1000!")

    fw = open(os.path.join(path, 'out'), 'w')
    fw.writelines(out)
    fw.close()
    return done, fail
Exemplo n.º 4
0
def xdt2pos(path, sel_nsw, tot_ele, copybs=False):
    """
    build POSCAR based on XDATCAR given in the path
    copy INCAR, POTCAR, KPOINTS into the same folder
    
    """

    XDATCAR = open(os.path.join(path, "XDATCAR"), 'r')
    incar = os.path.join(path, 'INCAR')
    path = os.path.join(path, 'recal')

    for _ in range(7):
        XDATCAR.readline()
    assert len(sel_nsw) > 1  ## at least two iteration are selected

    skp_nsw = []
    for i in range(len(sel_nsw)):
        if i == 0:
            skp_nsw.append(sel_nsw[i] * (tot_ele + 1))
        else:
            skp_nsw.append((sel_nsw[i] - sel_nsw[i - 1] - 1) * (tot_ele + 1))
    for i, diff_i in zip(sel_nsw, skp_nsw):
        try:
            os.mkdir(os.path.join(path, str(i + 1)))  # return None
        except:
            print("Folder {0} already exists,skip making".format(i))
        target_path = os.path.join(path, str(i + 1))
        #        print(target_path)
        ls_target_path = os.listdir(target_path)
        # skip some portion
        for _ in range(diff_i):
            XDATCAR.readline()

        if 'OUTCAR' in ls_target_path and check_outcar_done(
                os.path.join(target_path, 'OUTCAR')):
            print('calculation done')
            for _ in range(tot_ele + 1):
                XDATCAR.readline()

        elif 'INCAR'   in ls_target_path and \
             'POTCAR'  in ls_target_path and \
             'POSCAR'  in ls_target_path and \
             'KPOINTS' in ls_target_path:
            for _ in range(tot_ele + 1):
                XDATCAR.readline()

        else:
            coord = XDATCAR.readline()  # Direct
            #            print(coord)
            atomic_position = []
            for j in range(tot_ele):
                line_tmp = XDATCAR.readline()
                atomic_position.append(line_tmp)

            tobewriten = []
            tobewriten.append(title + '\n')
            tobewriten.append('{0}\n'.format(scaling_factor))
            for j in range(3):
                tobewriten.append('    {0:14.9f}{1:14.9f}{2:14.9f}\n'.format(
                    lattice[0][j], lattice[1][j], lattice[2][j]))
            for j in range(len(list_ele)):
                tobewriten.append('    %4s%s' % (list_ele[j], ' '))
            tobewriten.append('\n')
            for j in range(len(num_ele)):
                tobewriten.append('    %4d%s' % (num_ele[j], ' '))
            tobewriten.append('\n')
            tobewriten.append('Direct\n')
            for j in range(tot_ele):
                tobewriten.append(atomic_position[j])
            #begin to write POSCAR content to tmp file
            fw = open(os.path.join(target_path, 'POSCAR'), 'w')
            fw.writelines(tobewriten)
            fw.close()
            #            os.rename('tmp',os.path.join(target_path,'POSCAR'))
            target_incar = check_incar(incar)
            copy(os.path.join(inputfile, target_incar), target_path)
            os.rename(os.path.join(target_path, target_incar),
                      os.path.join(target_path, 'INCAR'))
            copy(os.path.join(inputfile, 'KPOINTS'), target_path)
            copy(os.path.join(inputfile, 'POTCAR'), target_path)

#            if copybs:
#                copy('bs.sh',target_path)
#                copy('bs_job.sh',target_path)
    XDATCAR.close()