コード例 #1
0
ファイル: plot-dos.py プロジェクト: droundy/deft
# input: ["data/s%03d/periodic-ww%04.2f-ff%04.2f-N%i-%s-%s.dat" % (seed, ww, ff, N, method, data) for method in methods for data in ["E","lnw"]]

minlog = 0
for method in methods:
    e_hist = numpy.loadtxt("data/s%03d/periodic-ww%04.2f-ff%04.2f-N%i-%s-E.dat"
                           % (seed, ww, ff, N, method))
    lnw = numpy.loadtxt("data/s%03d/periodic-ww%04.2f-ff%04.2f-N%i-%s-lnw.dat"
                        % (seed, ww, ff, N, method))
    energy = -e_hist[:,0]/N
    log10w = lnw[e_hist[:,0].astype(int),1]*numpy.log10(numpy.exp(1))
    log10_dos = numpy.log10(e_hist[:,1]) - log10w
    log10_dos -= log10_dos.max()
    if log10_dos.min() < minlog:
        minlog = log10_dos.min()
    plt.figure('dos')
    plt.plot(energy, log10_dos, styles.dots(method),label=styles.title(method))

    log10w += log10w.min()
    if log10w.min() < minlog:
        minlog = log10w.min()
    plt.figure('w')
    plt.plot(energy, -log10w, styles.dots(method),label=styles.title(method))


def tentothe(n):
    if n == 0:
        return '1'
    if n == 10:
        return '10'
    if int(n) == n:
        return r'$10^{%d}$' % n
コード例 #2
0
        golden_u = t_u_cv_s[1]
        reference_error = mean_u_err(ww, ff, N, reference, golden_u)
        if reference_error == None:
            continue
        print '    ', reference, reference_error
        for method in methods:
            plt.figure(2)
            method_err = mean_u_err(ww, ff, N, method, golden_u)
            if method_err != None:
                print '    ', method, method_err
                plt.figure(1)
                if method not in labels_added:
                    plt.loglog(reference_error,
                               method_err,
                               styles.dots(method),
                               markerfacecolor='none',
                               markeredgecolor=styles.color(method),
                               label=styles.title(method))
                    labels_added |= set([method])
                else:
                    plt.loglog(reference_error,
                               method_err,
                               styles.dots(method),
                               markerfacecolor='none',
                               markeredgecolor=styles.color(method))
                plt.figure(2)
        plt.figure(2)
        plt.legend(loc='best')
        plt.savefig('figs/energy-for-debugging-ww%04.2f-ff%04.2f-N%i.pdf' %
                    (ww, ff, N))
コード例 #3
0
ff = float(sys.argv[2])
#arg ff = [0.1, 0.2, 0.3, 0.4]

N = int(sys.argv[3])
#arg N = range(5,21)+[100, 200, 1000]

methods = eval(sys.argv[4])
#arg methods = [["nw","kT0.4","kT0.5","wang_landau","simple_flat","tmmc","oetmmc"]]

seed = int(sys.argv[5])
#arg seed = [0]

# input: ["data/s%03d/periodic-ww%04.2f-ff%04.2f-N%i-%s-E.dat" % (seed, ww, ff, N, version) for version in methods]

plt.title('Energy histogram for $\lambda=%g$, $\eta=%g$, and $N=%i$' %
          (ww, ff, N))

for version in methods:
    data = numpy.loadtxt("data/s%03d/periodic-ww%04.2f-ff%04.2f-N%i-%s-E.dat" %
                         (seed, ww, ff, N, version))
    energy = -data[:, 0] / N
    DS = data[:, 1]
    plt.semilogy(energy, DS, styles.dots(version), label=styles.title(version))

plt.xlabel('$U/N\epsilon$')
plt.ylabel('$H$')
plt.legend(loc='best').get_frame().set_alpha(0.25)
plt.tight_layout(pad=0.2)
plt.savefig("figs/periodic-ww%02.0f-ff%02.0f-N%i-E.pdf" %
            (ww * 100, ff * 100, N))
コード例 #4
0
ファイル: plot-errors.py プロジェクト: droundy/deft
        plt.xlabel(r'$T$')
        plt.ylabel(r'$\Delta U$')

        golden_u = t_u_cv_s[1]
        reference_error = mean_u_err(ww, ff, N, reference, golden_u)
        if reference_error == None:
            continue
        print '    ', reference, reference_error
        for method in methods:
            plt.figure(2)
            method_err = mean_u_err(ww, ff, N, method, golden_u)
            if method_err != None:
                print '    ', method, method_err
                plt.figure(1)
                if method not in labels_added:
                    plt.loglog(reference_error, method_err, styles.dots(method),
                               markerfacecolor='none', markeredgecolor=styles.color(method),
                               label=styles.title(method))
                    labels_added |= set([method])
                else:
                    plt.loglog(reference_error, method_err, styles.dots(method),
                               markerfacecolor='none', markeredgecolor=styles.color(method))
                plt.figure(2)
        plt.figure(2)
        plt.legend(loc='best')
        plt.savefig(
            'figs/energy-for-debugging-ww%04.2f-ff%04.2f-N%i.pdf' % (ww, ff, N))

min_T = 0.2 # FIXME maybe shouldn't hardcode this?

plt.figure(1)
コード例 #5
0
ファイル: plot-errors.py プロジェクト: iCodeIN/deft
        plt.xlabel(r'$T$')
        plt.ylabel(r'$\Delta U$')

        golden_u = t_u_cv_s[1]
        reference_error = mean_u_err(ww, ff, N, reference, golden_u)
        if reference_error == None:
            continue
        print('    ', reference, reference_error)
        for method in methods:
            plt.figure(2)
            method_err = mean_u_err(ww, ff, N, method, golden_u)
            if method_err != None:
                print('    ', method, method_err)
                plt.figure(1)
                if method not in labels_added:
                    plt.loglog(reference_error, method_err, styles.dots(method),
                               markerfacecolor='none', markeredgecolor=styles.color(method),
                               label=styles.title(method))
                    labels_added |= {method}
                else:
                    plt.loglog(reference_error, method_err, styles.dots(method),
                               markerfacecolor='none', markeredgecolor=styles.color(method))
                plt.figure(2)
        plt.figure(2)
        plt.legend(loc='best')
        plt.savefig(
            'figs/energy-for-debugging-ww%04.2f-ff%04.2f-N%i.pdf' % (ww, ff, N))

min_T = 0.2 # FIXME maybe shouldn't hardcode this?

plt.figure(1)
コード例 #6
0
    log10_dos = numpy.log10(e_hist[:,1]) - log10w
    log10_dos -= log10_dos.max()

    return energy, e_hist, log10w, log10_dos


for method in methods:

    wildfilename = "../data/s%03d/periodic-ww%04.2f-ff%04.2f-N%i-%s-%%s.dat" \
                   % (seed, ww, ff, N, method)

    energy, e_hist, log10w, log10_dos = get_arrays(wildfilename)

    if method != 'wang_landau':
        plt.figure('dos-poster')
        plt.plot(energy, log10_dos, styles.dots(method),
                 markerfacecolor='none', markeredgecolor=styles.color(method),
                 label=styles.title(method))

    for ax in [ ax_dos, ax_dos_all ]:
        ax.plot(energy[log10_dos > -cap], log10_dos[log10_dos > -cap],
                styles.dots(method), markerfacecolor='none',
                markeredgecolor=styles.color(method), label=styles.title(method))

    for ax in [ ax_hist, ax_hist_all ]:
        ax.semilogy(energy, e_hist[:,1], styles.dots(method),
                    markerfacecolor='none', markeredgecolor=styles.color(method),
                    label=styles.title(method))

    for ax in [ ax_lnw, ax_lnw_all ]:
        ax.plot(energy[log10w < cap], log10w[log10w < cap], styles.dots(method),
コード例 #7
0
plt.legend(loc='best')
plt.tight_layout(pad=0.2)
plt.savefig("figs/s-scaling.pdf")

### error vs error figures

methods.remove(reference)

plt.figure('u',figsize=fig_size)
plt.figure('cv',figsize=fig_size)
plt.figure('s',figsize=fig_size)

for n in range(len(Ns)):
    for method in methods:
        plt.figure('u')
        plt.loglog(u_errors[reference][n], u_errors[method][n], styles.dots(method),
                   markerfacecolor='none', markeredgecolor=styles.color(method),
                   label=styles.title(method))
        plt.figure('cv')
        plt.loglog(cv_errors[reference][n], cv_errors[method][n], styles.dots(method),
                   markerfacecolor='none', markeredgecolor=styles.color(method),
                   label=styles.title(method))
        plt.figure('s')
        plt.loglog(s_errors[reference][n], s_errors[method][n], styles.dots(method),
                   markerfacecolor='none', markeredgecolor=styles.color(method),
                   label=styles.title(method))

for fig in ['u','cv','s']:
    plt.figure(fig)
    xmin,xmax = plt.xlim()
    ymin,ymax = plt.ylim()
コード例 #8
0
ファイル: plot-histograms.py プロジェクト: yidapa/deft
ww = float(sys.argv[1])
# arg ww = [1.3, 1.5, 2.0, 3.0]

ff = float(sys.argv[2])
# arg ff = [0.1, 0.2, 0.3, 0.4]

N = int(sys.argv[3])
# arg N = range(5,21)+[100, 200, 1000]

methods = eval(sys.argv[4])
# arg methods = [["nw","kT0.4","kT0.5","wang_landau","simple_flat","tmmc","oetmmc"]]

seed = int(sys.argv[5])
# arg seed = [0]

# input: ["data/s%03d/periodic-ww%04.2f-ff%04.2f-N%i-%s-E.dat" % (seed, ww, ff, N, version) for version in methods]

plt.title("Energy histogram for $\lambda=%g$, $\eta=%g$, and $N=%i$" % (ww, ff, N))

for version in methods:
    data = numpy.loadtxt("data/s%03d/periodic-ww%04.2f-ff%04.2f-N%i-%s-E.dat" % (seed, ww, ff, N, version))
    energy = -data[:, 0] / N
    DS = data[:, 1]
    plt.semilogy(energy, DS, styles.dots(version), label=styles.title(version))

plt.xlabel("$U/N\epsilon$")
plt.ylabel("$H$")
plt.legend(loc="best").get_frame().set_alpha(0.25)
plt.tight_layout(pad=0.2)
plt.savefig("figs/periodic-ww%02.0f-ff%02.0f-N%i-E.pdf" % (ww * 100, ff * 100, N))
コード例 #9
0
# input: ["data/s%03d/periodic-ww%04.2f-ff%04.2f-N%i-%s-%s.dat" % (seed, ww, ff, N, method, data) for method in methods for data in ["E","lnw"]]

minlog = 0
for method in methods:
    e_hist = numpy.loadtxt("data/s%03d/periodic-ww%04.2f-ff%04.2f-N%i-%s-E.dat"
                           % (seed, ww, ff, N, method))
    lnw = numpy.loadtxt("data/s%03d/periodic-ww%04.2f-ff%04.2f-N%i-%s-lnw.dat"
                        % (seed, ww, ff, N, method))
    energy = -e_hist[:, 0]/N
    log10w = lnw[e_hist[:, 0].astype(int), 1]*numpy.log10(numpy.exp(1))
    log10_dos = numpy.log10(e_hist[:, 1]) - log10w
    log10_dos -= log10_dos.max()
    if log10_dos.min() < minlog:
        minlog = log10_dos.min()
    plt.figure('dos')
    plt.plot(energy, log10_dos, styles.dots(method), label=styles.title(method))

    log10w += log10w.min()
    if log10w.min() < minlog:
        minlog = log10w.min()
    plt.figure('w')
    plt.plot(energy, -log10w, styles.dots(method), label=styles.title(method))


def tentothe(n):
    if n == 0:
        return '1'
    if n == 10:
        return '10'
    if int(n) == n:
        return r'$10^{%d}$' % n
コード例 #10
0
seed = int(sys.argv[5])
#arg seed = [0]

# input: ["data/s%03d/periodic-ww%04.2f-ff%04.2f-N%i-%s-ps.dat" % (seed, ww, ff, N, method) for method in methods]

plt.title('Iterations per sample for $\lambda=%g$, $\eta=%g$, and $N=%i$' % (ww, ff, N))
for method in methods:
    data_file = "data/s%03d/periodic-ww%04.2f-ff%04.2f-N%i-%s-ps.dat" \
                % (seed, ww, ff, N, method)
    with open(data_file,'r') as file_handle:
        for line in file_handle:
            entries = line.split()
            if 'iterations:' in entries:
                iterations = int(entries[entries.index('iterations:')+1].replace(',',''))
                continue
    data = numpy.loadtxt(data_file)
    energy = -data[:,0]/N
    round_trips = data[:,1]
    energy = energy[round_trips != 0]
    round_trips = round_trips[round_trips != 0]
    if sum(round_trips) > 0:
        plt.semilogy(energy, iterations/round_trips, styles.dots(method),
                     label=styles.title(method))

plt.xlabel('$U/N\epsilon$')
plt.ylabel('Iterations per sample')
plt.legend(loc='best').get_frame().set_alpha(0.25)
plt.tight_layout(pad=0.2)
plt.savefig("figs/periodic-ww%02.0f-ff%02.0f-N%i-sample-rate.pdf" % (ww*100, ff*100, N))

コード例 #11
0
ファイル: plot-errors.py プロジェクト: yidapa/deft
### error vs error figures

methods.remove(reference)

plt.figure("u", figsize=fig_size)
plt.figure("cv", figsize=fig_size)
plt.figure("s", figsize=fig_size)

for n in range(len(Ns)):
    for method in methods:
        plt.figure("u")
        plt.loglog(
            u_errors[reference][n],
            u_errors[method][n],
            styles.dots(method),
            markerfacecolor="none",
            markeredgecolor=styles.color(method),
            label=styles.title(method),
        )
        plt.figure("cv")
        plt.loglog(
            cv_errors[reference][n],
            cv_errors[method][n],
            styles.dots(method),
            markerfacecolor="none",
            markeredgecolor=styles.color(method),
            label=styles.title(method),
        )
        plt.figure("s")
        plt.loglog(
コード例 #12
0
ファイル: plot-sample-rates.py プロジェクト: beebo021/deft

    min_energy = 0
    for i in range(len(energies)):
        min_e = min(energies[i])
        if min_e < min_energy:
            min_energy = int(min_e)
    energy_num = -min_energy + 1

    energy[method] = -numpy.array(range(energy_num))
    net_rate[method] = numpy.zeros(energy_num)

    for i in range(len(seeds)):
        for j in range(len(rates[i])):
            net_rate[method][-energies[i][j]] += rates[i][j]
    net_rate[method] /= len(seeds)

    energy[method] = energy[method][net_rate[method] != 0]
    net_rate[method] = net_rate[method][net_rate[method] != 0]

for method in methods:
    plt.semilogy(energy[method], net_rate[method], styles.dots(method),
                 markerfacecolor='none', markeredgecolor=styles.color(method),
                 label=styles.title(method))

plt.axvline(min_e,linewidth=1,color='k',linestyle=':')
plt.xlabel('$E/\epsilon$')
plt.ylabel('$r_p(E)$')
ax.legend(loc='upper right',bbox_to_anchor=(1.65,0.95))
plt.savefig("figs/sample-rates.pdf")