Ejemplo n.º 1
0
        # Build radius array:
        build = np.sort([2**x for x in range(20)]+[3*2**x for x in range(20)])
        radius = build[build <= L//2]

        #radius = np.arange(1,28)
        #radius = radius[ radius <= L//2 ]

        #two_point:
        result = np.zeros( (samples,len(radius)) )
        #result = 0

        ker,norm = randomsurf.kernel(L,alpha)
        start1 = time.time()
        for s in range(samples):
            #start=time.time()
            surface = ( randomsurf.gaussian_field(L, alpha,ker,norm) > h )*1
            #surface = randomsurf.percolation(L)
            #surface = randomsurf.berry(L)

            surface = hoshen.get_clusters( surface )
            #result += np.array(two_point_full(surface))

            result[s,:] = np.array([two_point(surface, r) for r in radius])/(2*L**2)

            #del surface #dump memory
        print(f'Total elapsed time = {round(time.time() - start1, 3)}')
        twopt = [np.mean(result[:,r]) for r in range(len(radius))]
        error = [np.std(result[:,r])/np.sqrt(samples) for r in range(len(radius))]

        #np.savetxt(f'data/two_point/L={L}-alpha={alpha}-s={samples}.txt',(radius,twopt,error), fmt='%1.4f',)
        #np.savetxt(f'data/two_point/L={L}-Percolation-s={samples}.txt',(radius,twopt,error), fmt='%1.4f',)
Ejemplo n.º 2
0
def fractal_dim_measurement(L, alpha, height, ker, norm):
    '''Gather here all the calculations of the fractal dimension of a surface'''
    surface = 1 * (randomsurf.gaussian_field(L, alpha, ker, norm) > height)
    masses = hoshen.get_masses(surface)
    return np.max(masses) * L**2
Ejemplo n.º 3
0
ax = plt.axes()

print(parameters)
for L in sizes:
    ker, ker_norm = randomsurf.kernel(L, alpha)
    data = []
    error = []

    for i, h in enumerate(parameters):
        print(
            f'Binder Cumulants: Size {L}, measure {i+1} of {len(parameters)}...'
        )
        m2 = np.zeros(samples)
        m4 = np.zeros(samples)
        for s in range(samples):
            surface = 1 * (randomsurf.gaussian_field(L, alpha, ker, ker_norm) >
                           h)
            #surface = randomsurf.percolation(L,p=h)
            m4[s], m2[s] = stats(surface)

        mean_m2 = np.mean(m2)
        mean_m4 = np.mean(m4)
        std_m2 = np.std(m2)
        std_m4 = np.std(m4)
        data.append(mean_m4 / mean_m2**2)
        error.append(
            (std_m4 / mean_m2**2 + 2 * mean_m4 * std_m2 / mean_m2**3) /
            np.sqrt(samples))

    #np.savetxt(f'data/binder/L={L}-alpha={alpha}-s={samples}.txt',(parameters,np.round(data, 5),np.round(error, 5)), fmt='%1.5f,')
    # plot results
Ejemplo n.º 4
0
@njit
def measure_field(field, radii):
    size = field.shape[0]
    ans = np.zeros(len(radii))
    for x in range(size // 2):
        for y in range(size // 2):
            ans += np.array([field[y, x] * field[y, x + r] for r in radii])
    return ans / (size * size / 4)


corrs = np.zeros((samples, len(radii)))

for i, alpha in enumerate(alphas):
    ker = randomsurf.kernel(L, alpha)
    for s in range(samples):
        surf = 1 * (randomsurf.gaussian_field(L, alpha, ker) > crit_level[i])
        corrs[s, :] = measure_field(surf, radii) - (np.sum(surf) / (L**2))**2

    result = [np.mean(corrs[:, i]) for i in range(len(radii))]
    error = [np.std(corrs[:, i]) / np.sqrt(samples) for i in range(len(radii))]

    plt.figure()
    # plot results
    ax = plt.axes()
    ax.set_title(f'Alpha = {alpha}')
    ax.set_xscale("log")
    ax.set_yscale("log")
    ax.errorbar(radii,
                result,
                yerr=error,
                capsize=2,
Ejemplo n.º 5
0
sample_set = [10**7,10**6,10**6,10**5,10**5,10**5,10**5,10**4,10**4]

start = time.time()
for i,alpha in enumerate(alphas):
    print(f'Alpha = {alpha}')
    Levels = []
    Err = []

    for j,L in enumerate(sizes):
        print(f'Currently on size {L}')
        samples = sample_set[j]
        ker = randomsurf.kernel(L, alpha)

        levels = []
        for _ in range(samples):
            rsurf = randomsurf.gaussian_field(L, alpha, ker)
            crit_level = find_critical(rsurf)
            levels.append(crit_level)

        Levels.append(np.mean(levels))
        Err.append(np.std(levels)/np.sqrt(samples))
        print(Levels[-1],Err[-1])

    print(Levels)
    print(Err)

    print(f'elapsed time = {time.time() - start}')
    plt.errorbar(
        x = sizes,
        y = Levels,
        yerr = Err,