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) if abs(vol_frac_calc - pss.vol_frac) <= 0.02: print "GREAT SUCCESS! Volume Fraction = {:3.3f}%".format(vol_frac_calc*100.) else:
pss.fill_rectangle(Sip_L1, Sip_T1, Sip_L2, Sip_T2, mats[2]) """ PMMA_T1 = 0.e-3 PMMA_T2 = 10.e-3 PMMA_L1 = 8.6e-3 PMMA_L2 = 10.e-3 pss.fill_rectangle(PMMA_L1,PMMA_T1,PMMA_L2,PMMA_T2,mats[3]) """ # pss.mesh_Shps[0,:,:],part_area = pss.gen_circle(r) i = np.where(abs(pss.yh - 12.7e-3) < pss.GS / 2.0) j = np.where(abs(pss.xh - 4.51e-3) < pss.GS / 2.0) I, J, M = i[0], j[0], mats[4] # pss.place_shape(pss.mesh_Shps[0,:,:],J,I,M) plt.figure() # plt.imshow(pss.mesh,interpolation='nearest',cmap='binary') view_mesh = np.zeros_like((pss.materials[0, :, :])) for item in mats: view_mesh += pss.materials[item - 1, :, :] * item plt.imshow(view_mesh, interpolation="nearest", cmap="viridis") # plt.imshow(pss.materials[0,:,:],interpolation='nearest',cmap='copper_r') # plt.imshow(pss.materials[1,:,:],interpolation='nearest',cmap='BuPu') # plt.imshow(pss.materials[2,:,:],interpolation='nearest',cmap='viridis') # plt.imshow(pss.materials[3,:,:],interpolation='nearest',cmap='binary') # plt.imshow(pss.materials[4,:,:],interpolation='nearest',cmap='Reds_r') plt.show() pss.save_general_mesh(mixed=True)
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) if abs(vol_frac_calc - pss.vol_frac) <= 0.02: print "GREAT SUCCESS! Volume Fraction = {:3.3f}%".format(vol_frac_calc * 100.)
Sip_L2 = 8.6e-3 pss.fill_rectangle(Sip_L1,Sip_T1,Sip_L2,Sip_T2,mats[2]) PMMA_T1 = 0.e-3 PMMA_T2 = 10.e-3 PMMA_L1 = 8.6e-3 PMMA_L2 = 10.e-3 pss.fill_rectangle(PMMA_L1,PMMA_T1,PMMA_L2,PMMA_T2,mats[3]) #pss.mesh_Shps[0,:,:],part_area = pss.gen_circle(r) i = np.where(abs(pss.yh-12.7e-3)<pss.GS/2.) j = np.where(abs(pss.xh-4.51e-3)<pss.GS/2.) I, J, M = i[0],j[0],mats[4] #pss.place_shape(pss.mesh_Shps[0,:,:],J,I,M) pss.save_general_mesh(mixed=True) plt.figure() #plt.imshow(pss.mesh,interpolation='nearest',cmap='binary') view_mesh = np.zeros_like((pss.materials[0,:,:])) for item in mats: view_mesh += pss.materials[item-1,:,:]*item plt.imshow(view_mesh,interpolation='nearest',cmap = 'Reds') #plt.imshow(pss.materials[0,:,:],interpolation='nearest',cmap='copper_r') #plt.imshow(pss.materials[1,:,:],interpolation='nearest',cmap='BuPu') #plt.imshow(pss.materials[2,:,:],interpolation='nearest',cmap='viridis') #plt.imshow(pss.materials[3,:,:],interpolation='nearest',cmap='binary') #plt.imshow(pss.materials[4,:,:],interpolation='nearest',cmap='Reds_r') plt.show()
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) #plt.axis('equal') plt.xlim(0,pss.meshx) plt.ylim(0,pss.meshy) plt.show()
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) #plt.axis('equal')
Y = np.append(Y1,Y2) Y += 37.5 assert np.size(X) == np.size(Y) p = 1. N = np.size(X) for i in range(N): if i%2==0: pass else: Y[i] += p*2.5 p *= -1. X = np.append(X,(X[-1],X[0])) Y = np.append(Y,([0.,0.])) X /= (GRIDSPC/1.e-6) Y /= (GRIDSPC/1.e-6) pss.fill_arbitrary_shape_p(Y,X,mats[0]) #pss.fill_plate(0.,300.,mats[1]) pss.save_general_mesh() fig, ax = plt.subplots() cax = ax.imshow(pss.mesh,cmap='Greys',interpolation='nearest',vmin=0,vmax=1) cbar = fig.colorbar(cax, orientation='horizontal') plt.show()
import numpy as np import scipy.spatial as scsp import scipy as sc import random import matplotlib.pyplot as plt import time T_length = .5e-3 L_length = 1.e-3 GRIDSPC = 2.e-5 T_cells = int(T_length / GRIDSPC) L_cells = int(L_length / GRIDSPC) # T - Transverse, L - Longitudinal pss.generate_mesh(L_cells, T_cells, mat_no=1, GS=GRIDSPC) pss.mesh_Shps[0, :, :], part_area = pss.gen_circle(r) mats = pss.mats l1 = 0.5 * L_length l2 = 0.9 * L_length t1 = 0.1 * T_length t2 = 0.9 * T_length pss.fill_rectangle(l1, t1, l2, t2, mats[0]) plt.figure() #plt.imshow(pss.mesh,interpolation='nearest',cmap='binary') plt.imshow(pss.materials[0, :, :], interpolation='nearest', cmap='binary') plt.show() pss.save_general_mesh()
Al4_L1 = 1.3e-3 Al4_L2 = 2.5e-3 pss.fill_rectangle(Al4_L1, Al4_T1, Al4_L2, Al4_T2, mats[1]) Sip_T1 = 7.7e-3 Sip_T2 = 17.7e-3 Sip_L1 = 2.6e-3 Sip_L2 = 8.6e-3 pss.fill_rectangle(Sip_L1, Sip_T1, Sip_L2, Sip_T2, mats[2]) PMMA_T1 = 7.7e-3 PMMA_T2 = 17.7e-3 PMMA_L1 = 8.6e-3 PMMA_L2 = 14.6e-3 pss.fill_rectangle(PMMA_L1, PMMA_T1, PMMA_L2, PMMA_T2, mats[3]) plt.figure() #plt.imshow(pss.mesh,interpolation='nearest',cmap='binary') view_mesh = np.zeros_like((pss.materials[0, :, :])) for item in mats: view_mesh += pss.materials[item - 1, :, :] * item plt.imshow(view_mesh, interpolation='nearest', cmap='Reds') #plt.imshow(pss.materials[0,:,:],interpolation='nearest',cmap='copper_r') #plt.imshow(pss.materials[1,:,:],interpolation='nearest',cmap='BuPu') #plt.imshow(pss.materials[2,:,:],interpolation='nearest',cmap='viridis') #plt.imshow(pss.materials[3,:,:],interpolation='nearest',cmap='binary') #plt.imshow(pss.materials[4,:,:],interpolation='nearest',cmap='Reds_r') plt.show() pss.save_general_mesh(mixed=False)
dX = 2*cppr*np.sin(ANG) dY = 2*cppr*np.cos(ANG) pss.place_shape(pss.mesh_Shps[0,:,:],16+dY,28+dX,2) pss.place_shape(pss.mesh_Shps[0,:,:],32+dY,28+dX,3) pss.place_shape(pss.mesh_Shps[0,:,:],32+dY,28+dX-16,4) #pss.place_shape(pss.mesh_Shps[0,:,:],50,25,3) #pss.place_shape(pss.mesh_Shps[0,:,:],50,41,4) #pss.place_shape(pss.mesh_Shps[0,:,:],50,9,2) plt.figure() plt.imshow(pss.materials[0,:,:],interpolation='nearest',cmap='binary') plt.imshow(pss.materials[1,:,:],interpolation='nearest',cmap='binary',alpha=.5) plt.imshow(pss.materials[2,:,:],interpolation='nearest',cmap='binary',alpha=.5) plt.imshow(pss.materials[3,:,:],interpolation='nearest',cmap='binary',alpha=.5) plt.imshow(pss.materials[4,:,:],interpolation='nearest',cmap='binary',alpha=.5) plt.show() #S = float(np.sum(UC)-4*3)#There are 4 particles and 3 cells overlap per particle #print "Approximate Volume Fraction = {:3.1f}".format(S/float(lx*ly)) pss.save_general_mesh(fname='meso_m_test-{:3.1f}.iSALE'.format(ANGLE),mixed=False)
Al4_L2 = 2.5e-3 pss.fill_rectangle(Al4_L1,Al4_T1,Al4_L2,Al4_T2,mats[1]) Sip_T1 = 7.7e-3 Sip_T2 = 17.7e-3 Sip_L1 = 2.6e-3 Sip_L2 = 8.6e-3 pss.fill_rectangle(Sip_L1,Sip_T1,Sip_L2,Sip_T2,mats[2]) PMMA_T1 = 7.7e-3 PMMA_T2 = 17.7e-3 PMMA_L1 = 8.6e-3 PMMA_L2 = 14.6e-3 pss.fill_rectangle(PMMA_L1,PMMA_T1,PMMA_L2,PMMA_T2,mats[3]) plt.figure() #plt.imshow(pss.mesh,interpolation='nearest',cmap='binary') view_mesh = np.zeros_like((pss.materials[0,:,:])) for item in mats: view_mesh += pss.materials[item-1,:,:]*item plt.imshow(view_mesh,interpolation='nearest',cmap = 'Reds') #plt.imshow(pss.materials[0,:,:],interpolation='nearest',cmap='copper_r') #plt.imshow(pss.materials[1,:,:],interpolation='nearest',cmap='BuPu') #plt.imshow(pss.materials[2,:,:],interpolation='nearest',cmap='viridis') #plt.imshow(pss.materials[3,:,:],interpolation='nearest',cmap='binary') #plt.imshow(pss.materials[4,:,:],interpolation='nearest',cmap='Reds_r') plt.show() pss.save_general_mesh(mixed=False)