Example #1
0
def timeplot(num_it=100000):
    ''' Plots the height of the pile against time..'''

    plt.figure()

    if load == 0:
        model = cp.oslo(16, num_it)
        plt.plot(model[2], model[3], label='L=16')

        model = cp.oslo(32, num_it)
        plt.plot(model[2], model[3], label='L=32')

        model = cp.oslo(64, num_it)
        plt.plot(model[2], model[3], label='L=64')

        model = cp.oslo(128, num_it)
        plt.plot(model[2], model[3], label='L=128')

        model = cp.oslo(256, num_it)
        plt.plot(model[2], model[3], label='L=256')

    else:
        plt.plot(d16[2], d16[3], label='L=16')
        plt.plot(d32[2], d32[3], label='L=32')
        plt.plot(d64[2], d64[3], label='L=64')
        plt.plot(d128[2], d128[3], label='L=128')
        plt.plot(d256[2], d256[3], label='L=256')
        plt.axis([-2540, 100000, 0, 455])

    plt.xlabel('Time (units of number of grains added)')
    plt.ylabel('Height of pile (number of grains)')
    plt.title('h(t;L) vs t for various system sizes')
    plt.legend(bbox_to_anchor=(0.26, 1))
Example #2
0
def smooth_data_collapse(num_it=100000):
    ''' Plots the data collapse of the processed height for the different 
    system sizes.'''

    plt.figure()

    if load == 0:
        m = cp.oslo(16, num_it)
        h_smooth = cp.moving_average(m[3], 25)
        t, h = cp.data_collapse(m[2], h_smooth, 16)
        plt.plot(t, h, label='L=16')

        m = cp.oslo(32, num_it)
        h_smooth = cp.moving_average(m[3], 25)
        t, h = cp.data_collapse(m[2], h_smooth, 32)
        plt.plot(t, h, label='L=32')

        m = cp.oslo(64, num_it)
        h_smooth = cp.moving_average(m[3], 25)
        t, h = cp.data_collapse(m[2], h_smooth, 64)
        plt.plot(t, h, label='L=64')

        m = cp.oslo(128, num_it)
        h_smooth = cp.moving_average(m[3], 25)
        t, h = cp.data_collapse(m[2], h_smooth, 128)
        plt.plot(t, h, label='L=128')

        m = cp.oslo(256, num_it)
        h_smooth = cp.moving_average(m[3], 25)
        t, h = cp.data_collapse(m[2], h_smooth, 256)
        plt.plot(t, h, label='L=256')

    else:
        h_smooth = cp.moving_average(d16[3], 25)
        t, h = cp.data_collapse(d16[2], h_smooth, 16)
        plt.plot(t, h, label='L=16')

        h_smooth = cp.moving_average(d32[3], 25)
        t, h = cp.data_collapse(d32[2], h_smooth, 32)
        plt.plot(t, h, label='L=32')

        h_smooth = cp.moving_average(d64[3], 25)
        t, h = cp.data_collapse(d64[2], h_smooth, 64)
        plt.plot(t, h, label='L=64')

        h_smooth = cp.moving_average(d128[3], 25)
        t, h = cp.data_collapse(d128[2], h_smooth, 128)
        plt.plot(t, h, label='L=128')

        h_smooth = cp.moving_average(d256[3], 25)
        t, h = cp.data_collapse(d256[2], h_smooth, 256)
        plt.plot(t, h, label='L=256')

    plt.xlabel(r't/$L^2$', fontsize='large')
    plt.ylabel(r'$\tilde{h}$/L', fontsize='large')
    plt.title(r'Data Collapse of $\tilde{h}$')
    plt.axis([-1, 1.3, 0.3, 1.9])
    plt.legend(bbox_to_anchor=(0.25, 1))
Example #3
0
def plot_height_probs(num_it=70000):
    '''Plots the height probability against height for each system size.'''
    plt.figure()

    if load == 0:

        m = cp.oslo(8, num_it)
        x, y = cp.height_prob(m[3])
        plt.plot(x, y, label='L=8')

        m = cp.oslo(16, num_it)
        x, y = cp.height_prob(m[3])
        plt.plot(x, y, label='L=16')

        m = cp.oslo(32, num_it)
        x, y = cp.height_prob(m[3])
        plt.plot(x, y, label='L=32')

        m = cp.oslo(64, num_it)
        x, y = cp.height_prob(m[3])
        plt.plot(x, y, label='L=64')

        m = cp.oslo(128, num_it)
        x, y = cp.height_prob(m[3])
        plt.plot(x, y, label='L=128')

        m = cp.oslo(256, num_it)
        x, y = cp.height_prob(m[3])
        plt.plot(x, y, label='L=256')

    else:

        x, y = cp.height_prob(d8[3])
        plt.plot(x, y, label='L=8')

        x, y = cp.height_prob(d16[3])
        plt.plot(x, y, label='L=16')

        x, y = cp.height_prob(d32[3])
        plt.plot(x, y, label='L=32')

        x, y = cp.height_prob(d64[3])
        plt.plot(x, y, label='L=64')

        x, y = cp.height_prob(d128[3])
        plt.plot(x, y, label='L=128')

        x, y = cp.height_prob(d256[3])
        plt.plot(x, y, label='L=256')

    plt.legend()
    plt.title('Height Probability P(h;L) against height', fontsize='large')
    plt.xlabel('Height, h', fontsize='large')
    plt.ylabel('P(h;L)', fontsize='large')
Example #4
0
def plot_avalanches():
    ''' Plots the avalanche size probability against s.'''

    model = cp.oslo(256, 2000000)
    x, y, z = cp.avalanche_prob(model[1], model[2], 256)

    plt.subplot(311)
    plt.loglog(x[:10000], y[:10000], 'x', label=r'N=$10^4$')
    plt.title('Avalanche Size Probability P(s;L) against s for L = 256')
    plt.legend()

    plt.subplot(312)
    plt.loglog(x[:100000], y[:100000], 'x', label=r'N=$10^5$')
    plt.ylabel('P(s;L)')
    plt.legend()

    plt.subplot(313)
    plt.loglog(x[:1000000], y[:1000000], 'x', label=r'N=$10^6$')
    plt.xlabel('Avalanche sizes, s')
    plt.legend()
Example #5
0
def plot_stdev(num_it=100000):
    ''' Plots the standard deviation of the system height in the recurrent stage
    against the system size.'''

    lengths = [8, 16, 32, 64, 128, 256]
    dev_list = []

    if load == 0:
        for L in lengths:
            m = cp.oslo(L, num_it)
            dev_list.append(cp.stdev(m[2], m[3], L))

    else:
        for d in data_set:
            dev_list.append(cp.stdev(d[2], d[3], lengths[data_set.index(d)]))

    plt.figure()
    print dev_list
    plt.plot(lengths, dev_list, 'x-')
    plt.title('Standard Deviation against system size')
    plt.xlabel('System size, L')
    plt.ylabel('Standard Deviation')
Example #6
0
def plot_avh(num_it=100000):
    ''' Plots the average height of the pile against system size.'''

    lengths = [8, 16, 32, 64, 128, 256]
    hlist = []

    if load == 0:
        for L in lengths:
            m = cp.oslo(L, num_it)
            hlist.append(cp.height_av(m[2], m[3], L))

    else:
        hlist.append(cp.height_av(d8[2], d8[3], lengths[0]))
        hlist.append(cp.height_av(d16[2], d16[3], lengths[1]))
        hlist.append(cp.height_av(d32[2], d32[3], lengths[2]))
        hlist.append(cp.height_av(d64[2], d64[3], lengths[3]))
        hlist.append(cp.height_av(d128[2], d128[3], lengths[4]))
        hlist.append(cp.height_av(d256[2], d256[3], lengths[5]))

    plt.figure()
    plt.plot(lengths, hlist, 'x-')
    plt.title('Average height vs system size')
    plt.xlabel('System size, L')
    plt.ylabel('Time-averaged height, <h>')
Example #7
0
import complexity_project as cp
import cPickle as pickle

d1 = cp.oslo(8, 1000000)
print "d1 done!"
d2 = cp.oslo(16, 1000000)
print "d2 done!"
d3 = cp.oslo(32, 1000000)
print "d3 done!"
d4 = cp.oslo(64, 1000000)
print "d4 done!"
d5 = cp.oslo(128, 1000000)
print "d5 done!"
d6 = cp.oslo(256, 1000000)
print "d6 done!"

oslo_data = [d1, d2, d3, d4, d5, d6]

pickle.dump(oslo_data, open("oslo_data_2.p", "wb"))
print "Dump successful!"