def create_particles(self): hcp = self.options.hcp # Initial distribution using Hexagonal close packing of particles # create all particles global dx if hcp: x, y, dx, dy, xmin, xmax, ymin, ymax = uniform_distribution.uniform_distribution_hcp2D( dx=dx, xmin=-ghost_extent, xmax=Lx + ghost_extent, ymin=-ghost_extent, ymax=Ly + ghost_extent) else: x, y, dx, dy, xmin, xmax, ymin, ymax = uniform_distribution.uniform_distribution_cubic2D( dx=dx, xmin=-ghost_extent, xmax=Lx + ghost_extent, ymin=-ghost_extent, ymax=Ly + ghost_extent) x = x.ravel() y = y.ravel() # create the basic particle array solid = get_particle_array(name='solid', x=x, y=y) # now sort out the interior from all particles indices = _get_interior(solid.x, solid.y) fluid = solid.extract_particles(indices) fluid.set_name('fluid') solid.remove_particles(indices) # sort out the obstacle from the interior indices = _get_obstacle(fluid.x, fluid.y) obstacle = fluid.extract_particles(indices) obstacle.set_name('obstacle') fluid.remove_particles(indices) print( "SPHERIC benchmark 6 :: Re = %d, nfluid = %d, nsolid=%d, nobstacle = %d, dt = %g" % (Re, fluid.get_number_of_particles(), solid.get_number_of_particles(), obstacle.get_number_of_particles(), dt)) # setup requisite particle properties and initial conditions if hcp: wij_sum = uniform_distribution.get_number_density_hcp( dx, dy, kernel, h0) volume = 1. / wij_sum else: volume = dx * dy particles = self._setup_particle_properties([fluid, solid, obstacle], volume=volume) return particles
def create_particles(hcp=False, **kwargs): "Initial distribution using Hexagonal close packing of particles" # create all particles global dx if hcp: x, y, dx, dy, xmin, xmax, ymin, ymax = uniform_distribution.uniform_distribution_hcp2D( dx=dx, xmin=-ghost_extent, xmax=Lx+ghost_extent, ymin=-ghost_extent, ymax=Ly+ghost_extent) else: x, y, dx, dy, xmin, xmax, ymin, ymax = uniform_distribution.uniform_distribution_cubic2D( dx=dx, xmin=-ghost_extent, xmax=Lx+ghost_extent, ymin=-ghost_extent, ymax=Ly+ghost_extent) x = x.ravel(); y = y.ravel() # create the basic particle array solid = get_particle_array(name='solid', x=x, y=y) # now sort out the interior from all particles indices = _get_interior(solid.x, solid.y) fluid = solid.extract_particles( indices ) fluid.set_name('fluid') solid.remove_particles( indices ) # sort out the obstacle from the interior indices = _get_obstacle(fluid.x, fluid.y) obstacle = fluid.extract_particles( indices ) obstacle.set_name('obstacle') fluid.remove_particles(indices) print "SPHERIC benchmark 6 :: Re = %d, nfluid = %d, nsolid=%d, nobstacle = %d, dt = %g"%( Re, fluid.get_number_of_particles(), solid.get_number_of_particles(), obstacle.get_number_of_particles(), dt) # setup requisite particle properties and initial conditions if hcp: wij_sum = uniform_distribution.get_number_density_hcp(dx, dy, kernel, h0) volume = 1./wij_sum else: volume = dx*dy particles = _setup_particle_properties([fluid, solid, obstacle], volume=volume) return particles
# NumPy import numpy # Python timer from time import time # particle spacings dx = 0.01; dxb2 = 0.5 * dx h0 = 1.3*dx # Uniform lattice distribution of particles #x, y, dx, dy, xmin, xmax, ymin, ymax = uniform_distribution_cubic2D( # dx, xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0) # Uniform hexagonal close packing arrangement of particles x, y, dx, dy, xmin, xmax, ymin, ymax = uniform_distribution_hcp2D( dx, xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0, adjust=True) # SPH kernel #k = CubicSpline(dim=2) #k = Gaussian(dim=2) #k = QuinticSpline(dim=2) k = WendlandQuintic(dim=2) # for the hexagonal particle spacing, dx*dy is only an approximate # expression for the particle volume. As far as the summation density # test is concerned, the value will be uniform but not equal to 1. To # reproduce a density profile of 1, we need to estimate the kernel sum # or number density of the distribution based on the kernel wij_sum_estimate = get_number_density_hcp(dx, dy, k, h0) volume = 1./wij_sum_estimate print 'Volume estimates :: dx^2 = %g, Number density = %g'%(dx*dy, volume)
# Python timer from time import time # particle spacings dx = 0.01 dxb2 = 0.5 * dx h0 = 1.3 * dx # Uniform lattice distribution of particles #x, y, dx, dy, xmin, xmax, ymin, ymax = uniform_distribution_cubic2D( # dx, xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0) # Uniform hexagonal close packing arrangement of particles x, y, dx, dy, xmin, xmax, ymin, ymax = uniform_distribution_hcp2D(dx, xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0, adjust=True) # SPH kernel #k = CubicSpline(dim=2) #k = Gaussian(dim=2) #k = QuinticSpline(dim=2) k = WendlandQuintic(dim=2) # for the hexagonal particle spacing, dx*dy is only an approximate # expression for the particle volume. As far as the summation density # test is concerned, the value will be uniform but not equal to 1. To # reproduce a density profile of 1, we need to estimate the kernel sum # or number density of the distribution based on the kernel wij_sum_estimate = get_number_density_hcp(dx, dy, k, h0)