Ejemplo n.º 1
0
def fill_the_void(roundOfInfilling, totalvolume, occupation, ideal_volume,
                  roundRadius, rangeRadius, maximum):

    gridnum = list(range(0, gridnumbers1))

    #remove the fully filled cells
    _remove_grid.remove_cells(roundRadius, Circles, w1, grid1, cols1, rows1)

    # the loop will stop if the mass of this round of infilling reaches the target or it runs out of void grids
    # the size of divided grids is 5, which can normally covers all round of infilling
    while totalvolume < ideal_volume and len(gridnum) > 0:
        #randomly select a void grid and try to add particles
        q = np.random.randint(len(gridnum))

        # decide the particle radius
        if roundRadius != maximum:
            n = _radii.radii(gridnum[q], roundRadius, rangeRadius, maximum,
                             Circles, cols1, w1, width, height)
        else:
            n = _single_radius.single_radius(gridnum[q], roundRadius,
                                             rangeRadius, maximum, Circles,
                                             cols1, w1, width, height)

        # insert the particle in the canvas
        if n is False:
            gridnum.remove(gridnum[q])
        else:
            grid1[q] = 1
            totalvolume = totalvolume + math.floor(3.1415926 * n * n)
            occupation = occupation + 1
            gridnum.remove(gridnum[q])

    if len(gridnum) == 0:
        print('round of infilling:', roundOfInfilling, 'infilling and add:',
              occupation, totalvolume, ideal_volume)
        fill_the_void(roundOfInfilling, totalvolume, occupation, ideal_volume,
                      roundRadius, rangeRadius, maximum)

    # adjust the volume of particles
    print(
        maximum > roundRadius,
        totalvolume > ideal_volume * 1.02, not _mini_radius.particles_mini(
            maximums[roundOfInfilling], roundRadius, Circles))
    if maximum > roundRadius and totalvolume > ideal_volume * 1.02 and not _mini_radius.particles_mini(
            maximums[roundOfInfilling], roundRadius, Circles):
        maximum -= 1
        _adjustment.remove_particles(maximums[roundOfInfilling], roundRadius,
                                     Circles)
        print('volume surpasses the target by 2%', 'round of infilling:',
              roundOfInfilling, 'infilling and add:', occupation, totalvolume,
              ideal_volume)
        fill_the_void(roundOfInfilling, 0, 0, ideal_volume, roundRadius,
                      rangeRadius, maximum)

    print('round of infilling:', roundOfInfilling, 'infilling and add:',
          occupation, totalvolume, ideal_volume)
Ejemplo n.º 2
0
def fill_the_void(roundOfInfilling, totalvolume, occupation, ideal_volume,
                  roundRadius, rangeRadius, maximum):

    gridnum = list(range(0, gridnumbers1))

    # remove the fully filled cells
    _remove_grid.remove_cells(roundRadius, Circles, w1, grid1, cols1, rows1,
                              depths1)

    while totalvolume < ideal_volume and len(gridnum) > 0:
        #randomly select a void grid and try to add particles
        q = np.random.randint(len(gridnum))

        # decide the particle radius
        if roundRadius != maximum:
            n = _radii.radii(gridnum[q], roundRadius, rangeRadius, maximum,
                             Circles, cols1, depths1, w1, width, height, depth)
        else:
            n = _single_radius.single_radius(gridnum[q], roundRadius,
                                             rangeRadius, maximum, Circles,
                                             cols1, depths1, w1, width, height,
                                             depth)

        # insert the particle in the canvas
        if n is False:
            gridnum.remove(gridnum[q])
        else:
            grid1[q] = 1
            totalvolume = totalvolume + math.floor((4 / 3) * pi * n**3)
            occupation = occupation + 1
            gridnum.remove(gridnum[q])

    if len(gridnum) == 0:
        print('round of infilling:', roundOfInfilling, 'infilling and add:',
              occupation, totalvolume, ideal_volume)
        fill_the_void(roundOfInfilling, totalvolume, occupation, ideal_volume,
                      roundRadius, rangeRadius, maximum)

    # adjust the volume of particles
    if maximum > roundRadius and totalvolume > ideal_volume * 1.02 and not _mini_radius.particles_mini(
            maximums[roundOfInfilling], roundRadius, Circles):
        maximum -= 1
        _adjustment.remove_particles(maximums[roundOfInfilling], roundRadius,
                                     Circles)
        print('volume surpasses the target by 2%', 'round of infilling:',
              roundOfInfilling, 'infilling and add:', occupation, totalvolume,
              ideal_volume)
        fill_the_void(roundOfInfilling, 0, 0, ideal_volume, roundRadius,
                      rangeRadius, maximum)

    print('round of infilling:', roundOfInfilling, 'infilling and add:',
          occupation, totalvolume, ideal_volume)