xcr *= GRIDSPC ycr *= GRIDSPC zcr *= GRIDSPC radii *= GRIDSPC MAT = pss.mat_assignment(mats,xcr,ycr) DMY = np.zeros_like(xcoords) A,B = pss.part_distance(xcr,ycr,radii,MAT,False) print "The Contacts Measure, A = {}".format(A) print "Avg Contacts Between the Same Materials, B = {}".format(B) print 'Total contacts between same materials = {}, Total particles = {}'.format(B*J,J) ALL = np.column_stack((MAT,xcr,ycr,radii)) pss.populate_materials(I_shape,XINT,YINT,MAT,J,TRACERS=True,ON=J_shape) # Now populate the materials meshes (NB these are different to the 'mesh' and are pss.save_spherical_parts(xcr,ycr,radii,MAT,A) print 'save to meso_A-{:3.4f}.iSALE'.format(A) pss.save_general_mesh(tracers=True) A2, contact_matrix = pss.discrete_contacts_number(I_shape,XINT,YINT,J,J_shape) print '\n' print "A and A2 are:", A, A2 print '\n' timestr = time.strftime('%d-%m-%Y_%H-%M-%S') #np.savetxt('{}cppr_{}vfrlim_A{:1.3f}_{}.iSALE'.format(cppr,vfraclimit,A,timestr),ALL) placed_part_area = np.array(placed_part_area) print "total particles placed: {}".format(J) vol_frac_calc = np.sum(placed_part_area)/(pss.meshx*pss.meshy)
except KeyboardInterrupt: pass I_shape = np.array( I_) # Convert the lists of index, shape number, and coordinates to arrays J_shape = np.array(J_) xcSI = np.array(xc) ycSI = np.array(yc) xcSI *= GRIDSPC # Turn the coordinates into physical units ycSI *= GRIDSPC MAT = pss.mat_assignment( pss.mats[1:], xcSI, ycSI ) # Assign materials to the particles. This returns an array that is the same shape as xc, # and contains the optimum corresponding material number for each particle pss.populate_materials( I_, xc, yc, MAT, J ) # Now populate the materials meshes (NB these are different to the 'mesh' and are # the ones used in the actual iSALE input file) pss.fill_rectangle(0, 0, pss.meshx * GRIDSPC, pss.meshy * GRIDSPC, pss.mats[0]) # pySALESetup prioritises material placed sooner. So later things will NOT overwrite previous ones pss.save_general_mesh() # Save the mesh as meso_m.iSALE (default) plt.figure() # plot the resulting mesh. Skip this bit if you do not need to. for KK in range(pss.Ms): matter = np.copy(pss.materials[KK, :, :]) * (KK + 1) matter = np.ma.masked_where(matter == 0., matter) plt.imshow(matter, cmap='viridis', vmin=0, vmax=pss.Ms,
xcr *= GRIDSPC ycr *= GRIDSPC zcr *= GRIDSPC radii *= GRIDSPC MAT = pss.mat_assignment(mats, xcr, ycr) DMY = np.zeros_like(xcoords) A, B = pss.part_distance(xcr, ycr, radii, MAT, False) print "The Contacts Measure, A = {}".format(A) print "Avg Contacts Between the Same Materials, B = {}".format(B) print 'Total contacts between same materials = {}, Total particles = {}'.format( B * J, J) ALL = np.column_stack((MAT, xcr, ycr, radii)) pss.populate_materials( I_shape, XINT, YINT, MAT, J, TRACERS=True, ON=J_shape ) # Now populate the materials meshes (NB these are different to the 'mesh' and are #pss.save_spherical_parts(xcr,ycr,radii,MAT,A) print 'save to meso_A-{:3.4f}.iSALE'.format(A) pss.save_general_mesh(tracers=True) A2, contact_matrix = pss.discrete_contacts_number(I_shape, XINT, YINT, J, J_shape) print '\n' print "A and A2 are:", A, A2 print '\n' timestr = time.strftime('%d-%m-%Y_%H-%M-%S') #np.savetxt('{}cppr_{}vfrlim_A{:1.3f}_{}.iSALE'.format(cppr,vfraclimit,A,timestr),ALL) placed_part_area = np.array(placed_part_area) print "total particles placed: {}".format(J) vol_frac_calc = np.sum(placed_part_area) / (pss.meshx * pss.meshy)
break old_vfrac = vf_pld print "volume fraction achieved so far: {:3.3f}%".format(vf_pld*100) except KeyboardInterrupt: pass I_shape = np.array(I_) # Convert the lists of index, shape number, and coordinates to arrays J_shape = np.array(J_) xcSI = np.array(xc) ycSI = np.array(yc) xcSI*= GRIDSPC # Turn the coordinates into physical units ycSI*= GRIDSPC MAT = pss.mat_assignment(pss.mats[1:],xcSI,ycSI) # Assign materials to the particles. This returns an array that is the same shape as xc, # and contains the optimum corresponding material number for each particle pss.populate_materials(I_,xc,yc,MAT,J) # Now populate the materials meshes (NB these are different to the 'mesh' and are # the ones used in the actual iSALE input file) pss.fill_rectangle(0,0,pss.meshx*GRIDSPC,pss.meshy*GRIDSPC,pss.mats[0]) # pySALESetup prioritises material placed sooner. So later things will NOT overwrite previous ones pss.save_general_mesh() # Save the mesh as meso_m.iSALE (default) plt.figure() # plot the resulting mesh. Skip this bit if you do not need to. for KK in range(pss.Ms): matter = np.copy(pss.materials[KK,:,:])*(KK+1) matter = np.ma.masked_where(matter==0.,matter) plt.imshow(matter, cmap='viridis',vmin=0,vmax=pss.Ms,interpolation='nearest') matter = np.copy(pss.materials[pss.Ms-1,:,:])*(pss.Ms) matter = np.ma.masked_where(matter==0.,matter)