Exemplo n.º 1
0
            indices = [i for i, rb in enumerate(rel_box_sizes) if rb == relbox]

            avg_dh = calc.add_mean([avg_dhs[i] for i in indices])
            std_dh = calc.add_std([std_dhs[i] for i in indices])
            n = [num_measurements[i] for i in indices]

            errorbars_dict[relbox] = [avg_dh, std_dh, sum(n)]

            # Assume that the best approximation is for the smallest box size
            if relbox == min(unique_relboxes):
                print(f"D_H = {avg_dh:.6f} +- {std_dh / sum(n):.0e}")
                best_dh = avg_dh
                best_error_dh = std_dh / sum(n)

        calc.plot_errorbars(errorbars_dict,
                            r"$\bar{D}_H \pm \sigma_{\bar{D}_H}$",
                            color=color,
                            axis=ax)

    ranges = [0.7 * min(unique_relboxes), 1.05 * max(unique_relboxes)]

    # correct_dh = 1.375
    # plt.plot(ranges,
    #          [correct_dh, correct_dh],
    #          c=const.COLOR_MAP["green"],
    #          label=rf"$D_H^G = {correct_dh}$")

    # Ugly way of getting the [(1, 64), (1, 32), ...]
    fractions = list(
        reversed(sorted([ur.as_integer_ratio() for ur in unique_relboxes])))
    labels = []
    for f in fractions:
Exemplo n.º 2
0
        avg_dh = calc.add_mean([avg_dhs[i] for i in indices])
        std_dh = calc.add_std([std_dhs[i] for i in indices])
        n = [num_measurements[i] for i in indices]
        errorbars_dict[u_relbox] = [avg_dh, std_dh, sum(n)]
        if u_relbox == min_relbox:
            print(f"D_H = {avg_dh:.5f} += {std_dh/np.sqrt(sum(n)):.0e}")
            # quit()
        x_relbox.append(u_relbox)
        y_lnnumboxes.append(avg_dh * np.log(1 / u_relbox))

    print(y_lnnumboxes)
    print(x_relbox)
    print(calc.bootstrap(fit_function, x_relbox, y_lnnumboxes))
    quit()
    # :data_dict: dict - Assumed to be {x0: [avg(y0), std(y0), num_measurements(y0)], x1: ...}
    calc.plot_errorbars(errorbars_dict, r"$\bar D_H \pm \sigma_{\bar D_H}$", color=c, axis=plt)

    # Ugly way of getting the [(1, 64), (1, 32), ...]
    fractions = list(reversed(sorted([(ub).as_integer_ratio() for ub in unique_rel_boxes])))
    labels = []
    for f in fractions:
        ln = f"{f[0]}"
        ld = f"{f[1]}"
        l = r"$\frac{" + ln + r"}{" + ld + r"}$"
        labels.append(l)

    plt.xscale("log")
    positions = sorted([ub for ub in unique_rel_boxes])
    plt.xticks(positions,
               labels,
               fontsize=14)
Exemplo n.º 3
0
rc('text', usetex=True)

if __name__ == '__main__':

    # Sudbo
    d_s = 2.287
    d_s_std = 2 * 10**(-3)
    # Prokof'ev
    d_p = 1.7655
    d_p_std = 2 * 10**(-3)
    # box counting result
    d_bc = 1.77468
    d_bc_std = 4 * 10**(-6)

    calc.plot_errorbars({0: [d_s, d_s_std, 1]},
                        label="Hove, Mo and Sudbo",
                        color=const.COLOR_MAP["red"])
    calc.plot_errorbars({1: [d_p, d_p_std, 1]},
                        label="Prokof'ev and Svistunov",
                        color=const.COLOR_MAP["blue"])
    calc.plot_errorbars({2: [d_bc, d_bc_std, 1]},
                        label="Box dimension",
                        color=const.COLOR_MAP["black"])

    plt.xticks([0, 1, 2], [], rotation=45)
    plt.legend(loc=1)
    plt.ylabel(r"$D_H$")
    plt.title(rf"Comparison of fractal dimensions on a $3D$ XY lattice")
    # illu.save_figure("dimenson_comparison_XY")
    plt.show()
Exemplo n.º 4
0
    # box counting result
    d_bc = 1.35193
    d_bc_std = 5 * 10**(-4)
    labels = [
        "Box dimension", "Scaling dimension", "Geometric $D_H$ $2D$ Ising",
        "Self avoiding walk", "Random walk"
    ]

    plt.scatter(0, d_rw, c=const.COLOR_MAP["black"], label="Random walk")
    plt.scatter(1,
                d_saw,
                c=const.COLOR_MAP["yellow"],
                label="Self avoiding walk")
    plt.scatter(2,
                d_dg,
                c=const.COLOR_MAP["green"],
                label="Geometric $D_H$ Ising")
    calc.plot_errorbars({3: [d_bc, d_bc_std, 1]},
                        label="Box dimension, Ising",
                        color=const.COLOR_MAP["red"])
    calc.plot_errorbars({4: [d_sc, d_sc_std, 1]},
                        label="Scaling dimension, Ising",
                        color=const.COLOR_MAP["blue"])

    plt.xticks([0, 1, 2, 3, 4], [], rotation=45)
    plt.legend(loc=1)
    plt.ylabel(r"$D$")
    plt.title(rf"Comparison of fractal dimensions on a $2D$ lattice")
    # illu.save_figure("dimenson_comparison")
    plt.show()
Exemplo n.º 5
0
    simulation_data = process_file("./data/loop_lengths128x128.txt")

    clean_processed_data(simulation_data, exclude_system_size=[])

    # plot_syssize_vs_looplength(simulation_data)

    errorbar_data = {}
    for size in simulation_data:
        errorbar_data[size] = [
            np.average(simulation_data[size]),
            np.std(simulation_data[size]),
            len(simulation_data[size])
        ]

    calc.plot_errorbars(
        errorbar_data,
        # label=r"$\bar{D}_H \pm \sigma_{\bar{D}_H}$",
        color=const.COLOR_MAP["black"])

    plot_syssize_vs_fit(simulation_data)

    plt.title("Maximum loop length on a 2D Ising lattice")
    plt.xlabel("Linear system size")
    plt.ylabel("Loop length")
    plt.legend()

    savefig = False
    if savefig:
        illu.save_figure(f"maximum_loop_length_for_2D_Ising")
    plt.show()
Exemplo n.º 6
0
    fig, ax = plt.subplots()

    color = const.COLOR_MAP["black"]
    avg_es = []
    for size in simulation_data:
        if 2 * size in simulation_data:
            avg_es.append(calc.add_mean(simulation_data[size][0]))

            simulation_data[size][0] = calc.add_mean(simulation_data[2 * size][0]) - calc.add_mean(simulation_data[size][0])
            simulation_data[size][1] = calc.add_std(simulation_data[2 * size][1]) - calc.add_std(simulation_data[size][1])
            simulation_data[size][2] = sum(simulation_data[size][2])


    simulation_data.pop(max(list(simulation_data.keys())))

    calc.plot_errorbars(simulation_data, r"$\Delta \bar{E} \pm \sigma_{\Delta \bar{E}}$", color=color, axis=ax)

    # xdata
    system_sizes = np.array(list(simulation_data.keys()))
    # ydata
    average_energy = np.array(avg_es)

    stderr_pars = calc.bootstrap(fit_function, system_sizes, average_energy, 10000)
    print(stderr_pars)
    opt_pars = list(stderr_pars.keys())
    # # Used for plotting against the fitted function
    xdata = np.linspace(min(system_sizes), max(system_sizes), 50)
    # colors = ["#966842", "#f44747", "#eedc31", "#7fdb6a", "#0e68ce"]
    plt.loglog(xdata, fit_function(xdata, *opt_pars),\
            c="#0e68ce",\
            label=fr"$\propto L^{{ 1 / ({1 / opt_pars[1]:.2f})  }}$")
Exemplo n.º 7
0
            # All indices for t = temp
            # NOTE: Done since the order of the data is random
            indices = [i for i, t in enumerate(temperatures) if t == temp]

            avg_w = calc.add_mean([avg_winding_number[i] for i in indices])
            std_w = calc.add_std([std_winding_number[i] for i in indices])
            n = [number_measurements[i] for i in indices]
            errorbars_dict[temp] = [avg_w, std_w, sum(n)]

            # For plotting lines between averages
            avg_ws.append(avg_w)

            if temp in closest_temps_to_tc:
                closest_ws_to_tc.append(avg_w)

        calc.plot_errorbars(errorbars_dict, f"${int(size)}^3$", color=c, axis=ax)
        ax.plot(unique_temperatures, avg_ws, color=c, linewidth=1.2)

        zoomed_data[size] = [unique_temperatures, avg_ws]
        plot_dict[size] = errorbars_dict

    # Get all permutations of Tc
    # Use the same thinking as distribution law for multiplication
    tcs = []
    perm_indices = [2 * l for l in range(len(closest_ws_to_tc) // 2)]
    sizes = list(simulation_data.keys())
    # will be size0 * size1 corresponding to each intersection
    weights = []
    for i in perm_indices:

        # print(i)
Exemplo n.º 8
0
if __name__ == '__main__':
    simulation_data = process_file("./data/susceptibility.txt")
    clean_processed_data(simulation_data, exclude_system_size=[])

    # plot_hist_of_error(simulation_data)

    plot_setup()
    # plot_syssize_vs_susc(simulation_data)

    errorbar_data = {}
    for size in simulation_data:
        errorbar_data[size] = [np.average(simulation_data[size]),
                               np.std(simulation_data[size]),
                               len(simulation_data[size])]

    calc.plot_errorbars(errorbar_data,
                        label=r"$\bar{\chi} \pm \sigma_{\bar{\chi}}$",
                        color=const.COLOR_MAP["black"])

    plot_syssize_vs_fit(simulation_data)

    # plt.xticks(list(simulation_data.keys()),
    #            list(simulation_data.keys()))

    plt.legend()

    savefig = True
    if savefig:
        illu.save_figure("susceptibility128x128Ising")
    # plt.show()