pss.generate_mesh(L_cells,T_cells,CPPR=r,mat_no=5,GridSpc=GRIDSPC) mats = pss.mats mats = mats.astype(int) Cu2_T1 = 0.e-3 Cu2_T2 = 10.0e-3 Cu2_L1 = 1.3e-3 Cu2_L2 = 2.6e-3 pss.fill_sinusoid(Cu2_L1,Cu2_T1,func,Cu2_T2,mats[0],mixed=True) Cu1_T1 = 0. Cu1_T2 = 10.e-3 Cu1_L1 = 0. Cu1_L2 = 1.3e-3 pss.fill_rectangle(Cu1_L1,Cu1_T1,Cu1_L2,Cu1_T2,mats[0]) """ Al1_T1 = 6.55e-3 Al1_T2 = 7.7e-3 Al1_L1 = 1.3e-3 Al1_L2 = 13.5e-3 pss.fill_rectangle(Al1_L1,Al1_T1,Al1_L2,Al1_T2,mats[1]) Al2_T1 = 17.7e-3 Al2_T2 = 18.85e-3 Al2_L1 = 1.3e-3 Al2_L2 = 13.5e-3 pss.fill_rectangle(Al2_L1,Al2_T1,Al2_L2,Al2_T2,mats[1]) Al3_T1 = 18.85e-3
return y L_cells = 1000 # T - Transverse, L - Longitudinal T_cells = 300 # L_cells = 100 # T - Transverse, L - Longitudinal # T_cells = 407 r = 8 T_length = 3.0e-3 L_length = 10.0e-3 GRIDSPC = T_length / T_cells print GRIDSPC pss.generate_mesh(L_cells, T_cells, CPPR=r, mat_no=5, GridSpc=GRIDSPC) mats = pss.mats mats = mats.astype(int) """ Cu1_T1 = 0. Cu1_T2 = 10.e-3 Cu1_L1 = 0. Cu1_L2 = 1.3e-3 pss.fill_rectangle(Cu1_L1,Cu1_T1,Cu1_L2,Cu1_T2,mats[0]) Al1_T1 = 6.55e-3 Al1_T2 = 7.7e-3 Al1_L1 = 1.3e-3 Al1_L2 = 13.5e-3 pss.fill_rectangle(Al1_L1,Al1_T1,Al1_L2,Al1_T2,mats[1]) Al2_T1 = 17.7e-3 Al2_T2 = 18.85e-3
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) #plt.axis('equal') plt.xlim(0,pss.meshx)
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)
return y L_cells = 1000 # T - Transverse, L - Longitudinal T_cells = 300 #L_cells = 100 # T - Transverse, L - Longitudinal #T_cells = 407 r = 8 T_length = 3.e-3 L_length = 10.e-3 GRIDSPC = T_length/T_cells print GRIDSPC pss.generate_mesh(L_cells,T_cells,CPPR=r,mat_no=5,GridSpc=GRIDSPC) mats = pss.mats mats = mats.astype(int) """ Cu1_T1 = 0. Cu1_T2 = 10.e-3 Cu1_L1 = 0. Cu1_L2 = 1.3e-3 pss.fill_rectangle(Cu1_L1,Cu1_T1,Cu1_L2,Cu1_T2,mats[0]) Al1_T1 = 6.55e-3 Al1_T2 = 7.7e-3 Al1_L1 = 1.3e-3 Al1_L2 = 13.5e-3 pss.fill_rectangle(Al1_L1,Al1_T1,Al1_L2,Al1_T2,mats[1]) Al2_T1 = 17.7e-3 Al2_T2 = 18.85e-3
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()
GRIDSPC = L_length / L_cells print GRIDSPC pss.generate_mesh(L_cells, T_cells, CPPR=r, mat_no=5, GridSpc=GRIDSPC) mats = pss.mats pss.mesh_Shps[0, :, :] = 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) Cu1_T1 = 0. Cu1_T2 = 25.4e-3 Cu1_L1 = 0. Cu1_L2 = 1.3e-3 pss.fill_rectangle(Cu1_L1, Cu1_T1, Cu1_L2, Cu1_T2, mats[0]) Cu2_T1 = 7.7e-3 Cu2_T2 = 17.7e-3 Cu2_L1 = 1.3e-3 Cu2_L2 = 2.6e-3 pss.fill_rectangle(Cu2_L1, Cu2_T1, Cu2_L2, Cu2_T2, mats[0]) Al1_T1 = 6.55e-3 Al1_T2 = 7.7e-3 Al1_L1 = 1.3e-3 Al1_L2 = 13.5e-3 pss.fill_rectangle(Al1_L1, Al1_T1, Al1_L2, Al1_T2, mats[1]) Al2_T1 = 17.7e-3 Al2_T2 = 18.85e-3
GRIDSPC = L_length/L_cells print GRIDSPC pss.generate_mesh(L_cells,T_cells,CPPR=r,mat_no=5,GridSpc=GRIDSPC) mats = pss.mats pss.mesh_Shps[0,:,:] = 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) Cu1_T1 = 0. Cu1_T2 = 25.4e-3 Cu1_L1 = 0. Cu1_L2 = 1.3e-3 pss.fill_rectangle(Cu1_L1,Cu1_T1,Cu1_L2,Cu1_T2,mats[0]) Cu2_T1 = 7.7e-3 Cu2_T2 = 17.7e-3 Cu2_L1 = 1.3e-3 Cu2_L2 = 2.6e-3 pss.fill_rectangle(Cu2_L1,Cu2_T1,Cu2_L2,Cu2_T2,mats[0]) Al1_T1 = 6.55e-3 Al1_T2 = 7.7e-3 Al1_L1 = 1.3e-3 Al1_L2 = 13.5e-3 pss.fill_rectangle(Al1_L1,Al1_T1,Al1_L2,Al1_T2,mats[1]) Al2_T1 = 17.7e-3 Al2_T2 = 18.85e-3
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()