Beispiel #1
0
def mean_u_err(ww, ff, N, method, golden_u):
    toterr = 0.0
    numseeds = 0
    for seed in seeds:
        t_u_cv_s_method = readandcompute.T_u_cv_s_minT(ww, ff, N, method, seed)
        if t_u_cv_s_method != None:
            du = abs((t_u_cv_s_method[1] -
                      golden_u)[t_u_cv_s_method[0] > Tmax]).max()
            lw = 0.01
            if seed == 0:
                plt.plot(t_u_cv_s_method[0],
                         (t_u_cv_s_method[1] - golden_u) / N,
                         styles.plot(method),
                         label=styles.title(method),
                         linewidth=lw)
            else:
                plt.plot(t_u_cv_s_method[0],
                         (t_u_cv_s_method[1] - golden_u) / N,
                         styles.plot(method),
                         linewidth=lw)
            toterr += du
            numseeds += 1
    if numseeds > 0:
        return toterr / numseeds / N
    return None
Beispiel #2
0
#arg Ns = [[500,1372,4000]]


# make figure with axes labeled using scientific notation
def sci_fig(handle):
    fig = plt.figure(handle)
    ax = fig.add_subplot(1, 1, 1)
    fmt = matplotlib.ticker.ScalarFormatter(useMathText=True)
    fmt.set_powerlimits((-2, 3))
    fmt.set_scientific(True)
    ax.yaxis.set_major_formatter(fmt)
    ax.xaxis.set_major_formatter(fmt)
    return fig, ax


fig_u, ax_u = sci_fig('u')
plt.title('Specific internal energy for $\lambda=%g$, $\eta=%g$' % (ww, ff))

for N in Ns:
    T, U, CV, S, minT = readandcompute.T_u_cv_s_minT(
        "data/mc/ww%.2f-ff%.2f-N%d" % (ww, ff, N))
    plt.semilogx(T, U / N, '-', label='$N=%d$' % N)

plt.xlabel('$kT/\epsilon$')
plt.ylabel('$U/N\epsilon$')
plt.legend(loc='best')
plt.tight_layout(pad=0.2)
plt.savefig("figs/energy-ww%02.0f-ff%02.0f.pdf" % (ww * 100, ff * 100))

plt.show()
Beispiel #3
0
                         styles.plot(method), linewidth=lw)
            toterr += du
            numseeds += 1
    if numseeds > 0:
        return toterr/numseeds/N
    return None

labels_added = set()

for golden_comp in all_goldens:
    bits = golden_comp.split('-')
    ww = float(bits[1][2:])
    ff = float(bits[2][2:])
    N = int(bits[3][1:])
    print('ww = %g, ff = %g, N = %d' % (ww, ff, N))
    t_u_cv_s = readandcompute.T_u_cv_s_minT(ww, ff, N, golden)
    if t_u_cv_s != None:
        plt.figure(2)
        plt.cla()
        plt.title(r'error in $U/N$ for $N=%d$ and $\eta=%g$ and $\lambda=%g$' % (N, ff, ww))
        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)
Beispiel #4
0
lenyz = float(sys.argv[4])
#arg lenyz = [10]

fig, axD = plt.subplots()
axT = plt.twinx()

for ff in ffs:
    basename = 'data/lv/ww%.2f-ff%.2f-%gx%g' % (ww, ff, lenx, lenyz)
    e, diff = readandcompute.e_diffusion_estimate(basename)
    N = readandcompute.read_N(basename)
    axD.plot(e, diff, label=r'$\eta = %g$' % ff)
    axD.axvline(-readandcompute.max_entropy_state(basename) / N, linestyle=':')
    axD.axvline(-readandcompute.min_important_energy(basename) / N,
                linestyle='--')

    T, u, cv, s, minT = readandcompute.T_u_cv_s_minT(basename)
    axT.plot(u / N, T, 'r-')
    axT.set_ylim(0, 3)
    axT.axhline(minT, color='r', linestyle=':')

    e, hist = readandcompute.e_hist(basename)
    axT.plot(e / N, 2.5 * hist / hist.max(), 'k:')

    e, init_hist = readandcompute.e_and_total_init_histogram(basename)
    for i in range(len(e)):
        print(e[i], (2.5 * init_hist / init_hist.max())[i])
    axT.plot(e, 2.5 * init_hist / init_hist.max(), 'c--')

axT.spines['right'].set_color('red')
axT.tick_params(axis='y', colors='red')
axT.yaxis.label.set_color('red')