Esempio n. 1
0
        if J == 0 or (vol_placed_frac < vfraclimit * vol_frac
                      ):  # FIRST PARTICLE must ALWAYS be randomly placed
            I = random.randint(
                nmin, nmax
            )  # Generate a rrandom number to randomly select a particle from the 'library'
            fail = 1
            while fail == 1:  # Whilst fail = True continue to try to generate a coordinate
                x, y, fail = pss.gen_coord(pss.mesh_Shps[I, :, :])
            area = pss.insert_shape_into_mesh(pss.mesh_Shps[I, :, :], x, y)
            J += 1

        else:
            I = random.randint(
                nmin, nmax
            )  # Generate a random number to randomly select one of the generated shapes, to be tried for this loop
            x, y, area = pss.drop_shape_into_mesh(pss.mesh_Shps[I, :, :])
            J += 1

        placed_part_area.append(area)  # Save the area
        xcoords.append(x)  # Save the coords of that particle
        ycoords.append(y)
        radii.append(part_radii[I])  # Save the radii
        J_shape.append(J)  # Save the particle number
        I_shape.append(I)  # Save the number within the 'library'

        vol_placed_frac = np.sum(placed_part_area) / (pss.meshx * pss.meshy)
        # update the volume fraction
        if vol_placed_frac == old_vfrac:
            print '##########~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~##########'
            print '# volume fraction no longer increasing. Break here #'
            print '##########~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~##########'
Esempio n. 2
0
     fail = 1
     while fail == 1:
         x,y,fail = pss.gen_coord(pss.mesh_Shps[I,:,:])
     area = pss.insert_shape_into_mesh(pss.mesh_Shps[I,:,:],x,y)
     ii += 1
     J += 1                                # J is now the total number of particles inserted
     placed_part_area.append(area)                    # Update the list of areas
     xcoords.append(x)
     ycoords.append(y)
     radii.append(np.amax(part_radii[I]))
     I_shape.append(I)
     J_shape.append(J)
 else: 
     if ii >= MM: ii = 0
     I = random.randint(nmin,nmax)                    # Generate a random number to randomly select one of the generated shapes, to be tried for this loop
     x,y,area = pss.drop_shape_into_mesh(pss.mesh_Shps[I,:,:])
     J += 1
     ii+= 1
     placed_part_area.append(area)                    # Update the list of areas
     xcoords.append(x)
     ycoords.append(y)
     radii.append(np.amax(part_radii[I]))
     I_shape.append(I)
     J_shape.append(J)
 
 #print placed_part_area,np.sum(placed_part_area)# After it reaches 50%, the algorithm really slows, so output the results of each step to see progress
 vol_placed_frac = np.sum(placed_part_area)/(pss.meshx*pss.meshy)    # update the volume fraction
 if vol_placed_frac == old_vfrac: 
     print '##########~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~##########'
     print '# volume fraction no longer increasing. Break here #'
     print '##########~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~##########'