Y_cells = 500 PR = 0. cppr = 8 vfraclimit = .495 # The changeover point from random to forced contacts. > 1.0 => least contacts; = 0. Max contacts x_length = 1.e-3 y_length = 1.e-3 GRIDSPC = x_length/X_cells mat_no = 5 pss.generate_mesh(X_cells,Y_cells,mat_no,cppr,PR,vol_frac) mats = pss.mats part_area = np.zeros((1)) cppr_range = pss.cppr_max - pss.cppr_min r = pss.cppr_mid pss.mesh_Shps[0,:,:],part_area[0] = pss.gen_circle(r) lx, ly = 35., 35. UC = pss.unit_cell(LX=lx,LY=ly) N = 5 UCX = np.array([0.,lx,lx,0.,lx/2.]) UCY = np.array([0.,0.,ly,ly,ly/2.]) MATS = np.array([1.,1.,1.,1.,1.]) RAD = np.array([8.,8.,8.,8.,8.]) for i in range(N): pss.place_shape(pss.mesh_Shps[0,:,:],UCY[i],UCX[i],MATS[i],UC,LX=lx,LY=ly) #pss.place_shape(pss.mesh_Shps[0,:,:],0,0,1,UC,LX=lx,LY=ly) #pss.place_shape(pss.mesh_Shps[0,:,:],48,32+16,2,UC,LX=lx,LY=ly) #pss.place_shape(pss.mesh_Shps[0,:,:],32,32-20,3,UC,LX=lx,LY=ly)
Y_cells = 500 PR = 0. cppr = 8 vfraclimit = .495 # The changeover point from random to forced contacts. > 1.0 => least contacts; = 0. Max contacts x_length = 1.e-3 y_length = 1.e-3 GRIDSPC = x_length / X_cells mat_no = 5 pss.generate_mesh(X_cells, Y_cells, mat_no, cppr, PR, vol_frac) mats = pss.mats part_area = np.zeros((1)) cppr_range = pss.cppr_max - pss.cppr_min r = pss.cppr_mid pss.mesh_Shps[0, :, :], part_area[0] = pss.gen_circle(r) lx, ly = 35., 35. UC = pss.unit_cell(LX=lx, LY=ly) N = 5 UCX = np.array([0., lx, lx, 0., lx / 2.]) UCY = np.array([0., 0., ly, ly, ly / 2.]) MATS = np.array([1., 1., 1., 1., 1.]) RAD = np.array([8., 8., 8., 8., 8.]) for i in range(N): pss.place_shape(pss.mesh_Shps[0, :, :], UCY[i], UCX[i], MATS[i], UC,
""" #################################################################################### """ """ ####### GENERATE n+1 Particles - to be placed in appropriate distribution ####### """ """ #################################################################################### """ n = pss.N # Particles can be placed MORE than once! part_area = np.zeros((n)) part_radii = [] 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*cppr_range/(n-1) # generate radii that are incrementally greater for each circle produced #pss.mesh_Shps[i,:,:] = pss.gen_polygon(6,r) #pss.mesh_Shps[i,:,:] = pss.gen_ellipse(r,random.random()*np.pi,np.sqrt(8./9.)) pss.mesh_Shps[i,:,:] = pss.gen_circle(r) part_area[i] = np.sum(pss.mesh_Shps[i,:,:]) part_radii.append(cppr) """ #################################################################################### """ """ ####### 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,:,:] part_area = part_area[::-1] # Sort shapes into same order as areas pss.mesh_Shps = pss.mesh_Shps[::-1,:,:] part_radii = part_radii[::-1] # Radii are not 'sorted' as they are created in size order already #print part_radii, part_area[0:n]
CPPR=cppr, pr=PR, VF=vol_frac, GridSpc=GRIDSPC) n = pss.N # n is the number of particles to generated for the 'library' which can be selected from this and placed into the mesh part_area = np.zeros( (n)) # N.B. particles can (and likely will) be placed more than once part_radii = np.linspace( pss.cppr_min, pss.cppr_max, n ) # part_area and part_radii are arrays to contain the area and radii of the 'library' particles # if PR is non-zero then a range of radii will be generated for i in range(n): pss.mesh_Shps[i, :, :] = pss.gen_circle( part_radii[i] ) # Generate a circle and store it in mesh_Shps (an array of meshes) part_area[i] = np.sum(pss.mesh_Shps[i, :, :]) # Record the shape's area A_ = [] # Generate empty lists to store the area xc = [] # x coord yc = [] # y coord I_ = [] # Library index J_ = [] # shape number of each placed particle vf_pld = 0 # Volume Fraction of material inserted into the mesh so far J = 0 old_vfrac = 0. try: # Begin loop placing grains in. while vf_pld < vol_frac: # Keep attempting to add particles until the required volume fraction is achieved I = random.randint( 0, n - 1
y_length = 1.e-3 # Longitudinal width of bed PR = 0. # Particle size range (as a fraction) cppr = 20 # Cells per particle radius GRIDSPC = x_length/X_cells # Physical distance/cell mat_no = 5 pss.generate_mesh(X=X_cells,Y=Y_cells,mat_no=mat_no,CPPR=cppr,pr=PR,VF=vol_frac,GridSpc=GRIDSPC) n = pss.N # n is the number of particles to generated for the 'library' which can be selected from this and placed into the mesh part_area = np.zeros((n)) # N.B. particles can (and likely will) be placed more than once part_radii = np.linspace(pss.cppr_min,pss.cppr_max,n) # part_area and part_radii are arrays to contain the area and radii of the 'library' particles # if PR is non-zero then a range of radii will be generated for i in range(n): pss.mesh_Shps[i,:,:] = pss.gen_circle(part_radii[i]) # Generate a circle and store it in mesh_Shps (an array of meshes) part_area[i] = np.sum(pss.mesh_Shps[i,:,:]) # Record the shape's area A_ = [] # Generate empty lists to store the area xc = [] # x coord yc = [] # y coord I_ = [] # Library index J_ = [] # shape number of each placed particle vf_pld = 0 # Volume Fraction of material inserted into the mesh so far J = 0 old_vfrac = 0. try: # Begin loop placing grains in. while vf_pld < vol_frac: # Keep attempting to add particles until the required volume fraction is achieved I = random.randint(0,n-1) # Generate a random index to randomly select a particle from the 'library' fail = 1
import scipy.spatial as scsp import scipy as sc import random import matplotlib.pyplot as plt import time L_cells = 234 # T - Transverse, L - Longitudinal T_cells = 407 r = 8 T_length = 25.4e-3 L_length = 14.6e-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