J_shape = [] old_vfrac = 0. J = 0 # counter for the number of particles placed in the mesh try: while vol_placed_frac < vol_frac: # Keep attempting to add particles until the required volume fraction is achieved 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'
nmax = n-1 # max integer generated xcoords = [] ycoords = [] radii = [] I_shape = [] J_shape = [] old_vfrac = 0. try: while vol_placed_frac<vol_frac: # Keep attempting to add particles until the required volume fraction is achieved if J == 0: # FIRST PARTICLE must ALWAYS be randomly placed I = random.randint(nmin,nmax) # Generate a random number to randomly select one of the generated shapes, to be tried for this loop 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) elif vol_placed_frac < vfraclimit*vol_frac: #elif J%2 == 0: 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 fail = 1 while fail == 1: