コード例 #1
0
def REMOVE_DC_FROM_DISCRETE_GRID(dcoord_vec, dCellNum, occupiedPositions):
    for p in range(3):
        p -= 1
        if (dcoord_vec[0] + p >= numPositions):
            break
        elif dcoord_vec[0] + p < 0:
            continue
        for q in range(3):
            q -= 1
            if dcoord_vec[1] + q >= numPositions:
                break
            elif dcoord_vec[1] + q < 0:
                continue
            for r in range(3):
                r -= 1
                if dcoord_vec[2] + r >= numPositions:
                    break
                elif dcoord_vec[2] + r < 0:
                    continue
                # now clear this particular dCellNum from the position in the occupiedPositions array
                nearbyDCs = occupiedPositions[threed_to_1d(
                    dcoord_vec + np.asarray([p, q, r]), numPositions)]
                nearbyDCs = np.delete(nearbyDCs,
                                      np.where(nearbyDCs == dCellNum))
                occupiedPositions[threed_to_1d(
                    dcoord_vec + np.asarray([p, q, r]),
                    numPositions)] = nearbyDCs
コード例 #2
0
def CHECK_CONTACT_WITH_DENDRITES_DC(posn_vec, inContact, dCellList,
                                    occupiedPositions):
    coord_vec = set_coordinates(posn_vec, radius, cellSide)
    nearbyDCs = occupiedPositions[threed_to_1d(coord_vec, numPositions)]
    if isinstance(nearbyDCs, float):
        pass
    else:
        for j in nearbyDCs:
            cell = dCellList[int(j)]
            dend_vec = cell.posn
            diff_vec = posn_vec - dend_vec
            if diff_vec.dot(diff_vec) <= contactRadius**2:
                inContact = 1
                break
    return inContact
コード例 #3
0
def PLACE_DC_ON_GRID(i, dCellList, occupiedPositions):
    cell = dCellList[i]
    cellStatus = False
    while (cellStatus == False):
        # let's generate potential coordinates
        posn_vec = np.random.uniform(-1, 1, 3) * radius
        if inside_sphere(posn_vec, radius):
            # we need to check it's not touching any other DCs now
            inContact = 0
            inContact = CHECK_CONTACT_WITH_DENDRITES_DC(
                posn_vec, inContact, dCellList, occupiedPositions)
            if inContact == 1:
                continue
            else:
                cell.posn = posn_vec
                cellStatus = True
        else:
            continue
    # better update the occupied positions list
    coord_vec = set_coordinates(posn_vec, radius, cellSide)
    if occupiedPositions[threed_to_1d(coord_vec, numPositions)] == 0.0:
        occupiedPositions[threed_to_1d(coord_vec, numPositions)] = [i]
    else:
        occupiedPositions[threed_to_1d(coord_vec, numPositions)].append(i)
コード例 #4
0
def GET_CONTACTING_DC_COORDS_AND_NUM(posn_vec, dCellList, tCellList, tCellNum,
                                     occupiedPositions):
    coord_vec = set_coordinates(posn_vec, radius, cellSide)
    nearbyDCs = occupiedPositions[threed_to_1d(coord_vec, numPositions)]
    if isinstance(nearbyDCs, float):
        pass
    else:
        for j in nearbyDCs:
            cell = dCellList[int(j)]
            if (HAS_CONTACTED_DC(tCellNum, j, tCellList)):
                continue
            dend_vec = cell.posn
            diff_vec = posn_vec - dend_vec
            if diff_vec.dot(diff_vec) <= contactRadius**2:
                cont_vec = dend_vec
                contNum = j
                break
    return [cont_vec, contNum]