Exemplo n.º 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(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
Exemplo n.º 2
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
Exemplo n.º 3
0
for method in [golden]+methods:

    U[method] = numpy.zeros(array_len)
    CV[method] = numpy.zeros(array_len)
    S[method] = numpy.zeros(array_len)
    for seed in seeds:
        u_cv_s = readandcompute.u_cv_s(ww, ff, N, method, seed)
        U[method] += u_cv_s[0] # internal energy
        CV[method] += u_cv_s[1] # heat capacity
        S[method] += u_cv_s[2] # entropy
    U[method] /= len(seeds)
    CV[method] /= len(seeds)
    S[method] /= len(seeds)

    plt.figure('u')
    plt.plot(T_range,U[method]/N, styles.plot(method), label=styles.title(method))

    if method != 'wang_landau':
        plt.figure('hc')
        plt.plot(T_range,CV[method]/N, styles.plot(method), label=styles.title(method))

    plt.figure('s')
    plt.plot(T_range,S[method]/N, styles.plot(method), label=styles.title(method))

methods.remove('wang_landau')

for method in methods:

    plt.figure('u_err')
    plt.plot(T_range,(U[method]-U[golden])/N, styles.plot(method),
             label=styles.title(method))
Exemplo n.º 4
0
                if method not in cv_errors:
                    cv_errors[method] = numpy.array([[N, dcv]])
                else:
                    cv_errors[method] = numpy.vstack([u_errors[method], [N, dcv]])
                ds = abs(u_cv_s_method[2]-u_cv_s[2]).max()
                if method not in s_errors:
                    s_errors[method] = numpy.array([[N, ds]])
                else:
                    s_errors[method] = numpy.vstack([u_errors[method], [N, ds]])

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

plt.figure()
for method in u_errors.keys():
    plt.semilogy(u_errors[method][:,0], u_errors[method][:,1],
                 '.'+styles.plot(method),label=styles.title(method))

plt.title('Maximum error with $\lambda=%g$, $\eta=%g$, and $T_{min}=%g$' % (ww, ff, min_T))
plt.xlabel('$N$')
plt.ylabel('$\\Delta U/N\epsilon$')
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-u_errors.pdf" % (ww*100, ff*100))

plt.figure()
for method in cv_errors.keys():
    plt.semilogy(cv_errors[method][:,0], cv_errors[method][:,1],
                 '.'+styles.plot(method),label=styles.title(method))

plt.title('Maximum error with $\lambda=%g$, $\eta=%g$, and $T_{min}=%g$' % (ww, ff, min_T))
plt.xlabel('$N$')
Exemplo n.º 5
0
                    cv_errors[method] = numpy.vstack(
                        [u_errors[method], [N, dcv]])
                ds = abs(u_cv_s_method[2] - u_cv_s[2]).max()
                if method not in s_errors:
                    s_errors[method] = numpy.array([[N, ds]])
                else:
                    s_errors[method] = numpy.vstack(
                        [u_errors[method], [N, ds]])

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

plt.figure()
for method in u_errors.keys():
    plt.semilogy(u_errors[method][:, 0],
                 u_errors[method][:, 1],
                 '.' + styles.plot(method),
                 label=styles.title(method))

plt.title('Maximum error with $\lambda=%g$, $\eta=%g$, and $T_{min}=%g$' %
          (ww, ff, min_T))
plt.xlabel('$N$')
plt.ylabel('$\\Delta U/N\epsilon$')
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-u_errors.pdf" %
            (ww * 100, ff * 100))

plt.figure()
for method in cv_errors.keys():
    plt.semilogy(cv_errors[method][:, 0],
                 cv_errors[method][:, 1],
Exemplo n.º 6
0
    Z_inf = sum(numpy.exp(ln_dos - ln_dos.max()))
    S_inf = sum(-numpy.exp(ln_dos - ln_dos.max())*(-ln_dos.max() - numpy.log(Z_inf))) / Z_inf

    for i in range(len(T_range)):
        ln_dos_boltz = ln_dos - energy/T_range[i]
        dos_boltz = numpy.exp(ln_dos_boltz - ln_dos_boltz.max())
        Z[i] = sum(dos_boltz)
        U[method][i] = sum(energy*dos_boltz)/Z[i]
        S[method][i] = sum(-dos_boltz*(-energy/T_range[i] - ln_dos_boltz.max() \
                                       - numpy.log(Z[i])))/Z[i]
        S[method][i] -= S_inf
        CV[method][i] = sum((energy/T_range[i])**2*dos_boltz)/Z[i] - \
                         (sum(energy/T_range[i]*dos_boltz)/Z[i])**2

    plt.figure('u')
    plt.plot(T_range,U[method]/N,styles.plot(method),label=styles.title(method))

    plt.figure('hc')
    plt.plot(T_range,CV[method]/N,styles.plot(method),label=styles.title(method))

    plt.figure('S')
    plt.plot(T_range,S[method]/N,styles.plot(method),label=styles.title(method))


plt.figure('dos')
plt.ylim(minlog, 0)
locs, labels = plt.yticks()
def tentothe(n):
    if n == 0:
        return '1'
    if n == 10:
Exemplo n.º 7
0
U = {}  # internal energy
CV = {}  # heat capacity
S = {}  # entropy

for method in set(methods + [golden]):

    u_cv_s = readandcompute.u_cv_s(ww, ff, N, method)
    if u_cv_s != None:
        U[method] = u_cv_s[0]  # internal energy
        CV[method] = u_cv_s[1]  # heat capacity
        S[method] = u_cv_s[2]  # entropy

    plt.figure('u')
    plt.plot(T_range,
             U[method] / N,
             styles.plot(method),
             label=styles.title(method))

    plt.figure('hc')
    plt.plot(T_range,
             CV[method] / N,
             styles.plot(method),
             label=styles.title(method))

    plt.figure('s')
    plt.plot(T_range,
             S[method] / N,
             styles.plot(method),
             label=styles.title(method))

for method in methods:
Exemplo n.º 8
0
            cv_errors[method][n] += dcv
            s_errors[method][n] += ds

        u_errors[method][n] /= len(seeds)
        cv_errors[method][n] /= len(seeds)
        s_errors[method][n] /= len(seeds)

os.chdir(thesis_dir)


### scaling figures
fig_size = (6,5)

plt.figure(figsize=fig_size)
for method in methods:
    plt.semilogy(Ns, u_errors[method],'.'+styles.plot(method),
                 label=styles.title(method))

plt.xlabel('$N$')
plt.ylabel('$\\Delta U/N\epsilon$')
plt.legend(loc='best')
plt.tight_layout(pad=0.2)
plt.savefig("figs/u-scaling.pdf")


plt.figure(figsize=fig_size)
for method in methods:
    plt.semilogy(Ns, cv_errors[method],'.'+styles.plot(method),
                 label=styles.title(method))

plt.xlabel('$N$')
Exemplo n.º 9
0
            cv_errors[method][n] += dcv
            s_errors[method][n] += ds

        u_errors[method][n] /= len(seeds)
        cv_errors[method][n] /= len(seeds)
        s_errors[method][n] /= len(seeds)

os.chdir(thesis_dir)


### scaling figures
fig_size = (6, 5)

plt.figure(figsize=fig_size)
for method in methods:
    plt.semilogy(Ns, u_errors[method], "." + styles.plot(method), label=styles.title(method))

plt.xlabel("$N$")
plt.ylabel("$\\Delta U/N\epsilon$")
plt.legend(loc="best")
plt.tight_layout(pad=0.2)
plt.savefig("figs/u-scaling.pdf")


plt.figure(figsize=fig_size)
for method in methods:
    plt.semilogy(Ns, cv_errors[method], "." + styles.plot(method), label=styles.title(method))

plt.xlabel("$N$")
plt.ylabel("$\\Delta C_V/N\epsilon$")
plt.legend(loc="best")
Exemplo n.º 10
0
#methods = eval(sys.argv[4])
methods = ["tmmc", "oetmmc"]
#arg methods = [["tmmc"]]

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

# input: ["../data/ww%04.2f-L%04.2f-N%i-%s.dat" % (ww, L, N, data) for data in ["E","lnw"]]

for method in set(methods):

    T, U, CV, S, min_T = readandcompute.T_u_cv_s_minT('../data/ww%04.2f-L%04.2f-N%03d' % (ww, L, N))

    plt.figure('u')
    plt.plot(T,U/N,styles.plot(method),label=styles.title(method))

    plt.figure('hc')
    plt.plot(T,CV/N,styles.plot(method),label=styles.title(method))

    plt.figure('s')
    plt.plot(T,S/N,styles.plot(method),label=styles.title(method))

plt.figure('u')
plt.title('Specific internal energy for $\lambda=%g$, $L=%g$, and $N=%i$' % (ww, L, N))
plt.xlabel('$kT/\epsilon$')
plt.ylabel('$U/N\epsilon$')
plt.legend(loc='best')
plt.axvline(min_T,linewidth=1,color='k',linestyle=':')
plt.tight_layout(pad=0.2)
plt.savefig("ww%02.0f-L%02.0f-N%i-u.pdf" % (ww*100, L, N))