def create_particles(self): data = ud.uniform_distribution_cubic2D(self.dx, self.xmin, self.xmax, self.ymin, self.ymax) x = data[0] y = data[1] box_indices = numpy.where((x > 0.25) & (x < 0.75) & (y > 0.25) & (y < 0.75))[0] rho = numpy.ones_like(x) * self.rho0 rho[box_indices] = self.rhoi e = self.p / ((self.gamma - 1) * rho) m = self.dx * self.dx * rho h = self.hdx * self.dx fluid = gpa(name='fluid', x=x, y=y, p=self.p, rho=rho, e=e, u=0., v=0., h=self.hdx * self.dx, m=m, h0=h) self.scheme.setup_properties([fluid]) return [fluid]
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(**kwargs): global dx data = ud.uniform_distribution_cubic2D(dx, xmin, xmax, ymin, ymax) x = data[0]; y = data[1] dx = data[2]; dy = data[3] # volume estimate volume = dx*dy # indices on either side of the initial discontinuity right_indices = numpy.where( x > 0.0 )[0] # density is uniform rho = numpy.ones_like(x) # pl = 100.0, pr = 0.1 p = numpy.ones_like(x) * 1000.0 p[right_indices] = 0.01 # const h and mass h = numpy.ones_like(x) * h0 m = numpy.ones_like(x) * volume * rho # thermal energy from the ideal gas EOS e = p/(gamma1*rho) fluid = gpa(name='fluid', x=x, y=y, rho=rho, p=p, e=e, h=h, m=m, h0=h.copy()) print "2D Shocktube with %d particles"%(fluid.get_number_of_particles()) return [fluid,]
def create_particles(self): data = ud.uniform_distribution_cubic2D(self.dx, xmin, xmax, ymin, ymax) x = data[0].ravel() y = data[1].ravel() y1 = numpy.where((y >= 0) & (y < 0.25))[0] y2 = numpy.where((y >= 0.25) & (y < 0.5))[0] y3 = numpy.where((y >= 0.5) & (y < 0.75))[0] y4 = numpy.where((y >= 0.75) & (y < 1.0))[0] rho1 = rhoi_1 - rhoi_m * numpy.exp((y[y1] - 0.25) / delta) rho2 = rhoi_2 + rhoi_m * numpy.exp((0.25 - y[y2]) / delta) rho3 = rhoi_2 + rhoi_m * numpy.exp((y[y3] - 0.75) / delta) rho4 = rhoi_1 - rhoi_m * numpy.exp((0.75 - y[y4]) / delta) u1 = v_i1 - v_im * numpy.exp((y[y1] - 0.25) / delta) u2 = v_i2 + v_im * numpy.exp((0.25 - y[y2]) / delta) u3 = v_i2 + v_im * numpy.exp((y[y3] - 0.75) / delta) u4 = v_i1 - v_im * numpy.exp((0.75 - y[y4]) / delta) v = dely * numpy.sin(2 * numpy.pi * x / wavelen) p = 2.5 rho = numpy.concatenate((rho1, rho2, rho3, rho4)) u = numpy.concatenate((u1, u2, u3, u4)) v = numpy.concatenate((v[y1], v[y2], v[y3], v[y4])) x = numpy.concatenate((x[y1], x[y2], x[y3], x[y4])) y = numpy.concatenate((y[y1], y[y2], y[y3], y[y4])) e = p / ((gamma - 1) * rho) m = self.dx * self.dx * rho h = self.dx * self.hdx fluid = gpa(name='fluid', x=x, y=y, u=u, v=v, rho=rho, p=p, e=e, m=m, h=h, h0=h) self.scheme.setup_properties([fluid]) return [fluid]
def create_particles(self): global dx data = ud.uniform_distribution_cubic2D(dx, xmin, xmax, ymin, ymax) x = data[0] y = data[1] dx = data[2] dy = data[3] # volume estimate volume = dx * dy # indices on either side of the initial discontinuity right_indices = numpy.where(x > x0)[0] # density is uniform rho = numpy.ones_like(x) * self.rhol rho[right_indices] = self.rhor # pl = 100.0, pr = 0.1 p = numpy.ones_like(x) * self.pl p[right_indices] = self.pr # const h and mass h = numpy.ones_like(x) * self.hdx * self.dx m = numpy.ones_like(x) * volume * rho # ul = ur = 0 u = numpy.ones_like(x) * self.ul u[right_indices] = self.ur # vl = vr = 0 v = numpy.ones_like(x) * self.vl v[right_indices] = self.vr # thermal energy from the ideal gas EOS e = p / (gamma1 * rho) fluid = gpa(name='fluid', x=x, y=y, rho=rho, p=p, e=e, h=h, m=m, h0=h.copy(), u=u, v=v) self.scheme.setup_properties([fluid]) print("2D Shocktube with %d particles" % (fluid.get_number_of_particles())) return [ fluid, ]
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
def create_particles(self): global dx data = ud.uniform_distribution_cubic2D(self.dx, xmin, xmax, ymin, ymax) x = data[0].ravel() y = data[1].ravel() dx = data[2] volume = dx * dx rho = 1 + 0.2 * numpy.sin(numpy.pi * (x + y)) p = numpy.ones_like(x) * self.p # const h and mass h = numpy.ones_like(x) * self.hdx * dx m = numpy.ones_like(x) * volume * rho # u = 1 u = numpy.ones_like(x) * self.u # v = -1 v = numpy.ones_like(x) * self.v # thermal energy from the ideal gas EOS e = p / (gamma1 * rho) fluid = gpa(name='fluid', x=x, y=y, rho=rho, p=p, e=e, h=h, m=m, h0=h.copy(), u=u, v=v) self.scheme.setup_properties([fluid]) print("2D Accuracy Test with %d particles" % (fluid.get_number_of_particles())) return [ fluid, ]
dx = 0.001; dxb2 = 0.5 * dx h0 = 2.*dx max = 1. min = 0. is2D = True if is2D: maxz = 0. minz = 0. else: maxz = max minz = min # Uniform lattice distribution of particles x, y, dx, dy, xmin, xmax, ymin, ymax = uniform_distribution_cubic2D( dx, xmin=min, xmax=max, ymin=min, ymax=max) # Uniform hexagonal close packing arrangement of particles #x, y, dx, dy, xmin, xmax, ymin, ymax = uniform_distribution_hcp2D( # dx, xmin=0.0, xmax=1., ymin=0.0, ymax=1., 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