Example #1
0
    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
Example #2
0
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
# 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
# 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)

x = x.ravel(); y = y.ravel()
h = numpy.ones_like(x) * h0
m = numpy.ones_like(x) * volume
wij = numpy.zeros_like(x)

# use the helper function get_particle_array to create a ParticleArray
pa = utils.get_particle_array(x=x,y=y,h=h,m=m,wij=wij)

# the simulation domain used to request periodicity
domain = DomainManager(
    xmin=min, xmax=max, ymin=min, ymax=max,periodic_in_x=False, periodic_in_y=False)
Example #4
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))

x = x.ravel()
y = y.ravel()
h = numpy.ones_like(x) * h0
m = numpy.ones_like(x) * volume
wij = numpy.zeros_like(x)

# use the helper function get_particle_array to create a ParticleArray
pa = utils.get_particle_array(x=x, y=y, h=h, m=m, wij=wij)

# the simulation domain used to request periodicity
domain = DomainManager(xmin=0.,
                       xmax=1.,