): ### generate a mesh_Shps array for each eccentricity and add it to mesh_Shps_list ### reset mesh shapes array, and the particle area/radius arrays: #pss.mesh_Shps = np.zeros((n,ns,ns)) # Here, you are re-defining mesh_Shps, it is already defined in pySALESetup and unnecessary. If you just wish to reset them, do this: pss.mesh_Shps *= 0. part_area *= 0. part_radii *= 0. #part_angle = np.zeros((n)) ### add in list of angles for i in range(n): theta = angles[i] ### use the already generated list of angles Rad = np.sqrt( axis_ratios[j] ) * cppr ### radius calculated so that area stays constant, where cppr is radius of perfect circle pss.mesh_Shps[i, :, :] = pss.gen_ellipse( Rad, theta, eccen_list[j] ) ### Generate an ellipse of radius: Rad, angled at theta, and with eccentricity taken from eccen_list part_area[i] = np.sum( pss.mesh_Shps[i, :, :]) # Record the shape's area part_radii[ i] = cppr # Record the shape's radius (semi-major radius in this case) ###need to change this? #part_angle[i] = theta #mesh_Shps_list.append(pss.mesh_Shps) ### append new mesh_Shps to mesh_Shps_list # try to avoid appending things as it's a very costly programming technique (computationally) mesh_Shps_array[j, :, :, :] = pss.mesh_Shps #part_area_list.append(part_area) #part_radii_list.append(part_radii) #part_angle_list.append(part_angle) ############################################################################################################################################################
#r = cppr #r = np.zeros((n,6))+cppr #+ cppr*np.random.randn(6)/4. #r = np.random.randn(n)*np.sqrt(cppr_range) + cppr #print r for i in range( n ): # n+1 as range starts at 0; i.e. you'll never get to i = n unless range goes to n+1! r = pss.cppr_min + (i**SFDslope) * cppr_range / ( (n - 1)**SFDslope ) # generate radii that are incrementally greater for each circle produced angle = np.random.random() * np.pi * 2. this_eccen = eccen + ER * (np.random.random() * 2. - 1.) #pss.mesh_Shps[i,:,:] = pss.gen_polygon(6,r) pss.mesh_Shps[i, :, :] = pss.gen_ellipse(r, angle, this_eccen) #pss.mesh_Shps[i,:,:] = pss.gen_circle(r) part_area[i] = np.sum(pss.mesh_Shps[i, :, :]) part_radii.append(r) part_angle.append(angle) part_eccen.append(this_eccen) part_angle = np.array(part_angle) part_eccen = np.array(part_eccen) """ #################################################################################### """ """ ####### sort particles into order of Large -> Small ####### """ """ #################################################################################### """ sort_indices = np.argsort(part_area) # Sort areas into smallest to largest part_area = part_area[sort_indices] # Arrange as appropriate pss.mesh_Shps = pss.mesh_Shps[sort_indices, :, :]
pss.generate_mesh(X_cells, Y_cells, mat_no, cppr, PR, vol_frac) # Generate & set up the mesh n = pss.N # n is the number of particles to generated as a 'library' to be placed into the mesh part_area = np.zeros( (n)) # N.B. particles can (and likely will) be placed more than once part_radii = np.zeros( (n) ) # part_area and part_radii are arrays to contain the area and radii of the 'library' particles for i in range(n): eccen = np.sqrt(8. / 9.) theta = random.random() * np.pi Rad = cppr pss.mesh_Shps[i, :, :] = pss.gen_ellipse( Rad, theta, eccen ) # Generate an ellipse of radius: Rad, angled at theta, and with eccentricity: eccen. part_area[i] = np.sum(pss.mesh_Shps[i, :, :]) # Record the shape's area part_radii[ i] = cppr # Record the shape's radius (semi-major radius in this case) vol_placed_frac = 0. placed_part_area = [] nmin = 0 # Max and min elements of the shape 'library' nmax = n - 1 xcoords = [ ] # Lists to record the coords, radii, 'library' number and particle number of each particle ycoords = [ ] # Start empty and append to them as we do not know how many particles will be generated
y_length = 1.e-3 GRIDSPC = x_length/X_cells # Physical distance/cell mat_no = 5 pss.generate_mesh(X_cells,Y_cells,mat_no,cppr,PR,vol_frac) # Generate & set up the mesh n = pss.N # n is the number of particles to generated as a 'library' to be placed into the mesh part_area = np.zeros((n)) # N.B. particles can (and likely will) be placed more than once part_radii = np.zeros((n)) # part_area and part_radii are arrays to contain the area and radii of the 'library' particles for i in range(n): eccen = np.sqrt(8./9.) theta = random.random()*np.pi Rad = cppr pss.mesh_Shps[i,:,:] = pss.gen_ellipse(Rad,theta,eccen) # Generate an ellipse of radius: Rad, angled at theta, and with eccentricity: eccen. part_area[i] = np.sum(pss.mesh_Shps[i,:,:]) # Record the shape's area part_radii[i] = cppr # Record the shape's radius (semi-major radius in this case) vol_placed_frac = 0. placed_part_area = [] nmin = 0 # Max and min elements of the shape 'library' nmax = n-1 xcoords = [] # Lists to record the coords, radii, 'library' number and particle number of each particle ycoords = [] # Start empty and append to them as we do not know how many particles will be generated radii = [] I_shape = [] J_shape = []
part_radii = [] part_angle = [] part_eccen = [] cppr_range = pss.cppr_max - pss.cppr_min #r = cppr #r = np.zeros((n,6))+cppr #+ cppr*np.random.randn(6)/4. #r = np.random.randn(n)*np.sqrt(cppr_range) + cppr #print r for i in range(n): # n+1 as range starts at 0; i.e. you'll never get to i = n unless range goes to n+1! r = pss.cppr_min + (i**SFDslope)*cppr_range/((n-1)**SFDslope) # generate radii that are incrementally greater for each circle produced angle = np.random.random() * np.pi * 2. this_eccen = eccen + ER * (np.random.random() * 2. - 1.) #pss.mesh_Shps[i,:,:] = pss.gen_polygon(6,r) pss.mesh_Shps[i,:,:] = pss.gen_ellipse(r,angle,this_eccen) #pss.mesh_Shps[i,:,:] = pss.gen_circle(r) part_area[i] = np.sum(pss.mesh_Shps[i,:,:]) part_radii.append(r) part_angle.append(angle) part_eccen.append(this_eccen) part_angle = np.array(part_angle) part_eccen = np.array(part_eccen) """ #################################################################################### """ """ ####### sort particles into order of Large -> Small ####### """ """ #################################################################################### """ sort_indices = np.argsort(part_area) # Sort areas into smallest to largest part_area = part_area[sort_indices] # Arrange as appropriate