def beta645_L32_analysis(run_pre_analysis=True,
                         run_post_analysis=True,
                         only_generate_data=False,
                         observables=None,
                         include_b645x48xx3x96=True,
                         post_analysis_data_type=["bootstrap"]):
    from pre_analysis.pre_analyser import pre_analysis
    from post_analysis.post_analyser import post_analysis
    from default_analysis_params import get_default_parameters
    from tools.folderreadingtools import get_num_observables
    import copy
    import os

    # Different batches
    data_batch_folder = "../data/data11"

    obs_exlusions = ["w_t_energy", "energy", "topcMC", "topsusMC", "qtq0effMC"]
    default_params = get_default_parameters(
        data_batch_folder=data_batch_folder, obs_exlusions=obs_exlusions)

    # Post analysis figures folder
    figures_folder = "figures_b645_32xx4"

    if include_b645x48xx3x96:
        figures_folder = "figures_b645_32xx4_full"

    if not isinstance(observables, type(None)):
        default_params["observables"] = observables

    # Post analysis parameters
    line_fit_interval_points = 20
    # topsus_fit_targets = [0.3,0.4,0.5,0.58]
    # topsus_fit_targets = [0.3, 0.4, 0.5, 0.6] # tf = sqrt(8*t0)
    topsus_fit_targets = [0.5, 0.6]
    energy_fit_target = 0.3

    # Method of continuum extrapolation.
    # Options: plateau, plateau_mean, nearest, interpolate, bootstrap
    extrapolation_methods = [
        "plateau", "plateau_mean", "nearest", "interpolate", "bootstrap"
    ]
    extrapolation_methods = ["plateau"]
    extrapolation_methods = ["bootstrap"]
    plot_continuum_fit = False

    # Topcr reference value. Options: [float], t0beta, article, t0
    topcr_t0 = "t0beta"

    # Number of different sectors we will analyse in euclidean time
    default_params["numsplits_eucl"] = 4
    intervals_eucl = [None, None, None, None]

    # Number of different sectors we will analyse in monte carlo time
    default_params["MC_time_splits"] = 4
    # MC_intervals = [[0, 1000], [500, 1000], [500, 1000], [175, 250]]
    MC_intervals = [None, None, None, None]

    # Extraction point in flow time a*t_f for q0 in qtq0
    q0_flow_times = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6]  # [fermi]

    # Flow time indexes in percent to plot qtq0 in euclidean time at
    euclidean_time_percents = [0, 0.25, 0.50, 0.75, 1.00]
    # euclidean_time_percents = [0]

    # Blocking
    default_params["blocking_analysis"] = True

    # Check to only generate data for post-analysis
    default_params["only_generate_data"] = only_generate_data

    ########## Main analysis ##########
    databeta60 = copy.deepcopy(default_params)
    databeta60["batch_name"] = "beta60"
    databeta60["ensemble_name"] = r"$A$"
    databeta60["beta"] = 6.0
    databeta60["block_size"] = 10  # None
    databeta60["topc_y_limits"] = [-9, 9]
    databeta60["topc2_y_limits"] = [-81, 81]
    databeta60["NCfgs"] = get_num_observables(databeta60["batch_folder"],
                                              databeta60["batch_name"])
    databeta60["obs_file"] = "24_6.00"
    databeta60["MCInt"] = MC_intervals[0]
    databeta60["N"] = 24
    databeta60["NT"] = 2 * databeta60["N"]
    databeta60["color"] = "#e41a1c"

    databeta61 = copy.deepcopy(default_params)
    databeta61["batch_name"] = "beta61"
    databeta61["ensemble_name"] = r"$B$"
    databeta61["beta"] = 6.1
    databeta61["block_size"] = 10  # None
    databeta61["topc_y_limits"] = [-12, 12]
    databeta61["topc2_y_limits"] = [-144, 144]
    databeta61["NCfgs"] = get_num_observables(databeta61["batch_folder"],
                                              databeta61["batch_name"])
    databeta61["obs_file"] = "28_6.10"
    databeta61["MCInt"] = MC_intervals[1]
    databeta61["N"] = 28
    databeta61["NT"] = 2 * databeta61["N"]
    databeta61["color"] = "#377eb8"

    databeta62 = copy.deepcopy(default_params)
    databeta62["batch_name"] = "beta62"
    databeta62["ensemble_name"] = r"$C$"
    databeta62["beta"] = 6.2
    databeta62["block_size"] = 10  # None
    databeta62["topc_y_limits"] = [-12, 12]
    databeta62["topc2_y_limits"] = [-196, 196]
    databeta62["NCfgs"] = get_num_observables(databeta62["batch_folder"],
                                              databeta62["batch_name"])
    databeta62["obs_file"] = "32_6.20"
    databeta62["MCInt"] = MC_intervals[2]
    databeta62["N"] = 32
    databeta62["NT"] = 2 * databeta62["N"]
    databeta62["color"] = "#4daf4a"

    databeta645 = copy.deepcopy(default_params)
    databeta645["flow_epsilon"] = 0.02
    databeta645["batch_name"] = "beta645"
    databeta645["ensemble_name"] = r"$D_2$"
    databeta645["beta"] = 6.45
    databeta645["block_size"] = 25  # None
    databeta645["topc_y_limits"] = [-15, 15]
    databeta645["topc2_y_limits"] = [-300, 300]
    databeta645["NCfgs"] = get_num_observables(databeta645["batch_folder"],
                                               databeta645["batch_name"])
    databeta645["obs_file"] = "48_6.45"
    databeta645["MCInt"] = MC_intervals[3]
    databeta645["N"] = 48
    databeta645["NT"] = 2 * databeta645["N"]
    databeta645["color"] = "#984ea3"

    databeta645_32xx4 = copy.deepcopy(default_params)
    databeta645_32xx4["flow_epsilon"] = 0.02
    databeta645_32xx4["batch_name"] = "beta645-32xx4"
    databeta645_32xx4["ensemble_name"] = r"$D_1$"
    databeta645_32xx4["beta"] = 6.45
    databeta645_32xx4["block_size"] = 40  # None
    databeta645_32xx4["topc_y_limits"] = [-15, 15]
    databeta645_32xx4["topc2_y_limits"] = [-300, 300]
    databeta645_32xx4["NCfgs"] = get_num_observables(
        databeta645_32xx4["batch_folder"], databeta645_32xx4["batch_name"])
    databeta645_32xx4["obs_file"] = "32_6.45"
    databeta645_32xx4["MCInt"] = MC_intervals[3]
    databeta645_32xx4["N"] = 32
    databeta645_32xx4["NT"] = 32
    databeta645_32xx4["color"] = "#98A519"

    # Adding relevant batches to args
    if include_b645x48xx3x96:
        analysis_parameter_list = [
            databeta60, databeta61, databeta62, databeta645, databeta645_32xx4
        ]
    else:
        analysis_parameter_list = [
            databeta60, databeta61, databeta62, databeta645_32xx4
        ]

    # analysis_parameter_list = [databeta645_32xx4, databeta645]

    section_seperator = "=" * 160
    print section_seperator
    print "Observables to be analysed: %s" % ", ".join(
        default_params["observables"])
    print section_seperator + "\n"

    # Submitting main analysis
    if run_pre_analysis:
        for analysis_parameters in analysis_parameter_list:
            pre_analysis(analysis_parameters)

    if not analysis_parameter_list[0]["MCInt"] is None:
        assert sum(
            [len(plist["MCInt"]) - len(analysis_parameter_list[0]["MCInt"])
             for plist in analysis_parameter_list]) == 0, \
            "unequal amount of MC intervals"

    # Submitting post-analysis data
    if run_post_analysis:
        if len(analysis_parameter_list) >= 3:
            post_analysis(analysis_parameter_list,
                          default_params["observables"],
                          topsus_fit_targets,
                          line_fit_interval_points,
                          energy_fit_target,
                          q0_flow_times,
                          euclidean_time_percents,
                          extrapolation_methods=extrapolation_methods,
                          plot_continuum_fit=plot_continuum_fit,
                          post_analysis_data_type=post_analysis_data_type,
                          figures_folder=figures_folder,
                          gif_params=default_params["gif"],
                          verbose=default_params["verbose"])
        else:
            msg = "Need at least 3 different beta values to run post analysis"
            msg += "(%d given)." % len(analysis_parameter_list)
            print msg
예제 #2
0
        if not init_file.exists():
            initialize_using_FBP(sim)
        else:

            with h5py.File(init_file, mode='r') as file:
                #take the latest sample from the folder
                samples_history = file['Layers 1/samples_history'][()]
                init_Sym = util.symmetrize(cp.asarray(samples_history[-1]))
                del samples_history
                u_samples_history = file['Layers 0/samples_history'][()]
                u_init_Sym = util.symmetrize(cp.asarray(u_samples_history[-1]))
                del u_samples_history

            sim.Layers[-1].current_sample_sym = init_Sym
            sim.Layers[-1].current_sample = sim.Layers[-1].current_sample_sym[
                sim.fourier.basis_number_2D_ravel - 1:]
            sim.Layers[-1].record_sample()

            sim.Layers[0].current_sample_sym = u_init_Sym
            sim.Layers[0].current_sample = sim.Layers[0].current_sample_sym[
                sim.fourier.basis_number_2D_ravel - 1:]
            sim.Layers[0].record_sample()
    print("Used bytes so far, before even running the simulation {}".format(
        sim.mempool.used_bytes()))
    sim.run()
    sim.save(str(simResultPath / 'result.hdf5'))
    print('simulation Result path is {}'.format(simResultPath))
    #
    #do analysis offline
    pa.post_analysis(folderName, simResultPath.parent)
예제 #3
0
def topc_modes_analysis():
    """Analysis for different lattice sizes and their topological charges."""
    default_params = get_default_parameters(data_batch_folder="temp")
    default_params["blocking_analysis"] = True

    default_params["observables"] = ["plaq", "topc", "topc2", "topc4", "topcr",
                                     "topsus", "topsusqtq0", "qtq0e",
                                     "qtq0eff", "topcMC"]
    default_params["observables"] = ["topc2", "topc4", "topcr"]

    # Check to only generate data for post-analysis
    default_params["only_generate_data"] = False

    run_pre_analysis = False
    run_post_analysis = False

    # run_pre_analysis = True
    # run_post_analysis = True
    default_params["verbose"] = True

    ########## Post analysis parameters ##########
    line_fit_interval_points = 20
    topsus_fit_targets = [0.5, 0.6]
    energy_fit_target = 0.3
    q0_flow_times = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6]  # [fermi]
    euclidean_time_percents = [0, 0.25, 0.50, 0.75, 1.00]
    extrapolation_methods = ["bootstrap"]
    plot_continuum_fit = False
    post_analysis_data_type = ["bootstrap"]
    figures_folder = "figures/topc_modes_analysis"

    data_path = "../data/"
    if not os.path.isdir(data_path):
        data_path = "../" + data_path

    ########## Smaug data 8x16 analysis ##########
    smaug8x16_data_beta60_analysis = copy.deepcopy(default_params)
    smaug8x16_data_beta60_analysis["batch_folder"] = data_path
    smaug8x16_data_beta60_analysis["batch_name"] = "beta60_8x16_run"
    smaug8x16_data_beta60_analysis["ensemble_name"] = r"$E$"
    smaug8x16_data_beta60_analysis["beta"] = 6.0
    smaug8x16_data_beta60_analysis["block_size"] = 10  # None
    smaug8x16_data_beta60_analysis["topc_y_limits"] = [-2, 2]
    smaug8x16_data_beta60_analysis["num_bins_per_int"] = 32
    smaug8x16_data_beta60_analysis["bin_range"] = [-2.5, 2.5]
    smaug8x16_data_beta60_analysis["hist_flow_times"] = [0, 250, 600]
    smaug8x16_data_beta60_analysis["NCfgs"] = get_num_observables(
        smaug8x16_data_beta60_analysis["batch_folder"],
        smaug8x16_data_beta60_analysis["batch_name"])
    smaug8x16_data_beta60_analysis["obs_file"] = "8_6.00"
    smaug8x16_data_beta60_analysis["N"] = 8
    smaug8x16_data_beta60_analysis["NT"] = 16
    smaug8x16_data_beta60_analysis["color"] = "#377eb8"

    ########## Smaug data 12x24 analysis ##########
    smaug12x24_data_beta60_analysis = copy.deepcopy(default_params)
    smaug12x24_data_beta60_analysis["batch_folder"] = data_path
    smaug12x24_data_beta60_analysis["batch_name"] = "beta60_12x24_run"
    smaug12x24_data_beta60_analysis["ensemble_name"] = r"$F$"
    smaug12x24_data_beta60_analysis["beta"] = 6.0
    smaug12x24_data_beta60_analysis["block_size"] = 10  # None
    smaug12x24_data_beta60_analysis["topc_y_limits"] = [-4, 4]
    smaug12x24_data_beta60_analysis["num_bins_per_int"] = 16
    smaug12x24_data_beta60_analysis["bin_range"] = [-4.5, 4.5]
    smaug12x24_data_beta60_analysis["hist_flow_times"] = [0, 100, 600]
    smaug12x24_data_beta60_analysis["NCfgs"] = get_num_observables(
        smaug12x24_data_beta60_analysis["batch_folder"],
        smaug12x24_data_beta60_analysis["batch_name"])
    smaug12x24_data_beta60_analysis["obs_file"] = "12_6.00"
    smaug12x24_data_beta60_analysis["N"] = 12
    smaug12x24_data_beta60_analysis["NT"] = 24
    smaug12x24_data_beta60_analysis["color"] = "#377eb8"

    ########## Smaug data 16x32 analysis ##########
    smaug16x32_data_beta61_analysis = copy.deepcopy(default_params)
    smaug16x32_data_beta61_analysis["batch_folder"] = data_path
    smaug16x32_data_beta61_analysis["batch_name"] = "beta61_16x32_run"
    smaug16x32_data_beta61_analysis["ensemble_name"] = r"$G$"
    smaug16x32_data_beta61_analysis["beta"] = 6.1
    smaug16x32_data_beta61_analysis["block_size"] = 10  # None
    smaug16x32_data_beta61_analysis["topc_y_limits"] = [-8, 8]
    smaug16x32_data_beta61_analysis["num_bins_per_int"] = 16
    smaug16x32_data_beta61_analysis["bin_range"] = [-7.5, 7.5]
    smaug16x32_data_beta61_analysis["hist_flow_times"] = [0, 100, 400]
    smaug16x32_data_beta61_analysis["NCfgs"] = get_num_observables(
        smaug16x32_data_beta61_analysis["batch_folder"],
        smaug16x32_data_beta61_analysis["batch_name"])
    smaug16x32_data_beta61_analysis["obs_file"] = "16_6.10"
    smaug16x32_data_beta61_analysis["N"] = 16
    smaug16x32_data_beta61_analysis["NT"] = 32
    smaug16x32_data_beta61_analysis["color"] = "#377eb8"

    param_list = [
        smaug8x16_data_beta60_analysis,
        smaug12x24_data_beta60_analysis,
        smaug16x32_data_beta61_analysis]

    if run_pre_analysis:
        # Submitting analysis
        for analysis_parameters in param_list:
            pre_analysis(analysis_parameters)

    # Submitting post-analysis data
    if run_post_analysis:
        if len(param_list) >= 3:
            post_analysis(param_list,
                          default_params["observables"],
                          topsus_fit_targets, line_fit_interval_points,
                          energy_fit_target,
                          q0_flow_times, euclidean_time_percents,
                          extrapolation_methods=extrapolation_methods,
                          plot_continuum_fit=plot_continuum_fit,
                          post_analysis_data_type=post_analysis_data_type,
                          figures_folder=figures_folder, # "figures/topc_modes_analysis"
                          verbose=default_params["verbose"])
        else:
            msg = "Need at least 3 different beta values to run post analysis"
            msg += "(%d given)." % len(analysis_parameter_list)
            print msg

    # Loads topc data
    data = []
    # N_val = [24, 24, 28]
    for i, param in enumerate(param_list):
        print "Loading data for: {}".format(param["batch_name"])
        data_, p = get_data_parameters(param)
        data.append({"data": data_("topc")["obs"].T,
                     "beta": param["beta"],
                     "N": param["N"],
                     "ensemble_name": param["ensemble_name"]})

    # Flow time to plots
    flow_times = [0, 25, 50, 100, 150, 250, 450, 600]

    # Histogram plotting
    xlim = 7.5
    NBins = np.arange(-xlim, xlim, 0.05)
    for t_f in flow_times:
        # Adds unanalyzed data
        fig, axes = plt.subplots(len(param_list), 1,
                                 sharey=False, sharex=True)
        axes = np.atleast_1d(axes)
        for i, ax in enumerate(axes):
            # lab = r"${0:d}^3\times{1:d}$, $\beta={2:.2f}$".format(
            #     data[i]["N"], data[i]["N"]*2, data[i]["beta"])
            lab = data[i]["ensemble_name"]

            weights = np.ones_like(data[i]["data"][t_f])
            weights /= len(data[i]["data"][t_f])
            ax.hist(data[i]["data"][t_f], bins=NBins,
                    label=lab, weights=weights)
            ax.legend(loc="upper right")
            ax.grid(True)
            ax.set_xlim(-xlim, xlim)

            if i == 1:
                ax.set_ylabel(r"Hits(normalized)")
            elif i == 2:
                ax.set_xlabel(r"$Q$")

        # Sets up figure
        figpath = figures_folder
        if not os.path.isdir(figpath):
            figpath = "../" + figpath
        check_folder(figpath, verbose=default_params["verbose"])
        figpath = os.path.join(figpath, "topc_modes_tf{}.pdf".format(t_f))
        fig.savefig(figpath)
        print "Figure saved at {0:s}".format(figpath)
        plt.close(fig)