示例#1
0
def event(step):  #what happens to cell in time step

    print(step)

    if chk_vol():
        for elem in c_ary.keys():  #keys()cause new created cells do nothing
            if threeD:
                cvol = 4 * np.pi * c_ary[elem].radius**3
            else:
                cvol = np.pi * c_ary[elem].radius**2

            if cvol > maxvolume - 1.0E-6:  #cell_r big enough -> division#

                divide(elem)

            else:
                growth(elem)  #growfunc determines if grow or shrink#

    cgrad = cl.C_grad(len(c_ary), x, n, place, C_on, K, feedback, c_ary,
                      threeD)

    for i in range(ita):
        thres = move()
        if thres <= 0.1:
            break

    C_true = cgrad.calc_cval(step, C_t)  #actual c of cells

    #gridprint(step, C_true)

    C_i, state = cgrad.switch()
    switch_cary(state)

    state_t.append(list(state))
    C_t.append(list(C_i))
示例#2
0
def initialize():                                       #creats grid on which cells are placed by chance

    if not threeD:
        ce = 0
        for row in range(x):                     #grid saved in a dic#
            for col in range(x):
                pos[ce] = [x_c[col], y_c[row]]
                ce += 1
    else:
        ce = 0
        for wth in range(x):
            for row in range(x):                 #grid saved in a dic#
                for col in range(x):

                    pos[ce] = [x_c[col], y_c[row],z_c[wth]]
                    ce += 1

    if not threeD:
        c_num = 0
        start= 0
        stop = len(pos)-1
        step=1

        print start,stop
        for cc in range(start,stop,step):                        #cells being placed#

            bla = rd.random()
            if cc==stop:                                    #only one horizontal row used#
                break

            if bla >= n:
                continue
            if border(cc):                                  #checks for outofbounds around edges#
                 if checkneighbor(cc):                       #check if cell can be placed#
                    put = rd.randint(0, 1)
                    if put == 0:
                        c_ary[c_num] = cl.Cell(c_num, 'alpha', radius, stategamble(), pos[cc][0], pos[cc][1], maxrad, seite)
                        occupy(cc,c_num)
                        c_num += 1

                    elif put == 1:
                        c_ary[c_num] = cl.Cell(c_num, 'a', radius, stategamble(), pos[cc][0], pos[cc][1], maxrad, seite)
                        occupy(cc, c_num)
                        c_num += 1

    else:
        setcells()

    cgrad = cl.C_grad(len(c_ary), x, n, place, K, feedback, c_ary, True)
    C_i, state = cgrad.ini_cell_c()

    C_t.append(list(C_i))
    state_t.append(list(state))

    global fx
    global fy
    global fz
    fx = np.zeros(len(c_ary))
    fy = np.zeros(len(c_ary))
    fz = np.zeros(len(c_ary))