Example #1
0
def collect_data(default_path, elects_d, widths, lmbdas):
    """Visit directory for each slab width and lmbda and
    parse the outfile for 1d, 2d, and 3d diffusivities"""
    cols = ["elect", "d", "lmbda", \
            "Dx", "Dy", "Dz", "Dxy", "Dyz", "Dxz", "D3d"]
    index = np.arange(len(lmbdas) * len(widths) * len(elects_d))
    df = DataFrame(index=index, columns=cols)

    cnt = 0
    for el in sorted(elects_d.keys()):
        for d in widths:
            for l in lmbdas:
                data = [elects_d[el], d, l]
                fname = "diffusivity_%s_d%i_l%i.log" % (el, d, l)
                fpath = default_path + fname
                try:
                    f = open(fpath, "r").readlines()
                    for line in f:
                        if "1d diff" in line:
                            data.extend(np.array(line.split()[5:]).astype(float))
                        if "2d diff" in line:
                            data.extend(np.array(line.split()[5:]).astype(float))
                        if "3d diff" in line:
                            data.extend(np.array(line.split()[2:]).astype(float))
                except FileNotFoundError:
                    print("File not found: %s." % fpath)

                if len(data) == len(cols):
                    df.loc[cnt] = data
                    cnt += 1
    return df
Example #2
0
def collect_data(default_path, elects_d, widths, lmbdas):
    """Visit directory for each slab width and lmbda and
    parse the outfile for 2d and 3d percolations"""
    cols = ["elect", "d", "lmbda", "occ_2d", "P2d", "occ_3d", "P3d"]
    index = np.arange(len(lmbdas) * len(widths) * len(elects_d))
    df = DataFrame(index=index, columns=cols)

    cnt = 0
    for el in sorted(elects_d.keys()):
        for d in widths:
            for l in lmbdas:
                data = [elects_d[el], d, l]
                for dim in [2, 3]:
                    fname = "clustering_%id_%s_d%i_l%i.log" % (dim, el, d, l)
                    fpath = str(default_path) + fname
                    try:
                        f = open(fpath, "r").readlines()
                        data.append(float(f[-1].split()[-1]))  # P inf
                        fields = [line for line in f if "Full fields" in line]
                        if len(fields) == 0:
                            print("Empty Full fields, check %s" % fname)
                            continue
                        data.append(float(fields[-1].split()[-1]))
                    except FileNotFoundError:
                        print("File not found: %s." % fpath)

                if len(data) == len(cols):
                    df.loc[cnt] = data
                    cnt += 1
    return df
Example #3
0
def collect_data(default_path, lmbdas):
    """Visit directory for each lmbda and
    parse the outfile for 2d and 3d percolations"""
    cols = ["lmbda", "P2d", "P3d"]
    df = DataFrame(index=range(len(lmbdas)), columns=cols)

    cnt = 0
    for l in lmbdas:
        data = [l]
        for dim in [2, 3]:
            fname = "clustering_%id_l%i.log" % (dim, l)
            fpath = str(default_path) + fname
            try:
                f = open(fpath, "r").readlines()
                data.append(float(f[-1].split()[-1]))
            except FileNotFoundError:
                print("File not found: %s." % fpath)

        if len(data) == 3:
            df.loc[cnt] = data
            cnt += 1
    return df