예제 #1
0
파일: task3_oop.py 프로젝트: FSund/FY8904
        bottom=False,
        left=False,
        # top=False,
        labelbottom=False,
        labelleft=False,
        # length=0,
    )

P = np.zeros(len(bonds))
size = np.zeros(len(bonds))
s = np.zeros(len(bonds))
pvec = np.zeros(len(bonds))
j = 0
for i in range(nn):
    for bond in bonds[i * step:(i + 1) * step]:
        sites.activate([bond])
        P[j] = sites.giantComponent
        s[j] = sites.averageSquaredSize
        size[j] = sites.sizeOfLargestCluster
        pvec[j] = j / len(bonds)
        j += 1

    print("start: {}, stop: {}, index: {}".format(i * step, (i + 1) * step, i))

    image = sites.makeImage()
    ax.imshow(image,
              aspect="equal",
              origin="upper",
              vmin=0,
              vmax=1,
              cmap="Purples")
예제 #2
0
for L in [100, 200]:
    N = L*L
    nBonds = 2*N

    its = 100  # number of iterations
    P = np.zeros([nBonds, its])
    P2 = np.zeros([nBonds, its])  # P_inf**2
    size = np.zeros([nBonds, its])
    s = np.zeros([nBonds, its])
    p = np.zeros(nBonds)

    for j in range(its):
        sites = Sites(L, L)
        bonds = makeSquareLattice(L, L)
        bonds = shuffleList(bonds)

        for i in range(nBonds):
            sites.activate([bonds[i]])
            P[i, j] = sites.giantComponent
            P2[i, j] = pow(sites.giantComponent/N, 2)
            s[i, j] = sites.averageSquaredSize
            size[i, j] = sites.sizeOfLargestCluster
            p[i] = i/nBonds
            # p[i] = (N - np.sum(sites.sites == -1))/N

    P = np.mean(P, axis=1)
    P2 = np.mean(P2, axis=1)
    s = np.mean(s, axis=1)
    size = np.mean(size, axis=1)