Esempio n. 1
0
    def create_particles(self):
        dx = self.dx
        fluid = self._create_fluid()
        solid = self._create_solid()
        G.remove_overlap_particles(fluid, solid, dx, dim=2)
        outlet = self._create_outlet()
        inlet = self._create_inlet()
        wall = self._create_wall()

        ghost_inlet = self.iom.create_ghost(inlet, inlet=True)
        ghost_outlet = self.iom.create_ghost(outlet, inlet=False)

        particles = [fluid, inlet, outlet, solid, wall]
        if ghost_inlet:
            particles.append(ghost_inlet)
        if ghost_outlet:
            particles.append(ghost_outlet)

        self.scheme.setup_properties(particles)
        self._set_wall_normal(wall)

        if self.io_method == 'hybrid':
            fluid.uag[:] = 1.0
            fluid.uta[:] = 1.0
            outlet.uta[:] = 1.0

        return particles
Esempio n. 2
0
def get_wavespaddle_geometry(hdx=1.,
                             dx_f=0.02,
                             dx_s=0.02,
                             r_f=100.,
                             r_s=100.,
                             length=13.,
                             height=0.8,
                             flat_l=1.48,
                             h_fluid=0.43,
                             angle=2.8624):
    x1, y1, x2, y2 = get_beach_geometry_2d(dx_s, length, height, flat_l, angle,
                                           3)
    theta = np.pi * angle / 180.0
    p1x = flat_l - 9.605
    p1y = 0.40625
    p2x = flat_l - 10.065
    p2y = 0.6085
    theta1 = np.arctan((p2y - p1y) / (p2x - p1x))
    p3x = flat_l - 10.28
    p3y = 0.6085
    theta2 = np.arctan((p3y - p2y) / (p3x - p2x))
    p4x = flat_l - 10.62
    p4y = 0.457
    theta3 = np.arctan((p4y - p3y) / (p4x - p3x))
    obs_x1 = np.arange(p2x, p1x, dx_s / 2.0)
    obs_y1 = p1y + (obs_x1 - p1x) * np.tan(theta1)
    obs_x2 = np.arange(p3x, p2x, dx_s / 2.0)
    obs_y2 = p2y + (obs_x2 - p2x) * np.tan(-theta2)
    obs_x3 = np.arange(p4x, p3x, dx_s / 2.0)
    obs_y3 = p3y + (obs_x3 - p3x) * np.tan(theta3)
    x1 = np.concatenate([x1, obs_x1, obs_x2, obs_x3])
    y1 = np.concatenate([y1, obs_y1, obs_y2, obs_y3])
    r1 = np.ones_like(x1) * r_s
    m1 = r1 * dx_s * dx_s
    h1 = np.ones_like(x1) * hdx * dx_s
    wall = get_particle_array(name='wall', x=x1, y=y1, rho=r1, m=m1, h=h1)
    r2 = np.ones_like(x2) * r_s
    m2 = r2 * dx_s * dx_s
    h2 = np.ones_like(x2) * hdx * dx_s
    paddle = get_particle_array(name='paddle', x=x2, y=y2, rho=r2, m=m2, h=h2)
    fluid_center = np.array([flat_l - length / 2.0, h_fluid / 2.0])
    x_fluid, y_fluid = get_2d_block(dx_f, length, h_fluid, fluid_center)
    x3 = []
    y3 = []
    for i, xi in enumerate(x_fluid):
        if y_fluid[i] >= np.tan(-theta) * xi:
            x3.append(xi)
            y3.append(y_fluid[i])
    x3 = np.array(x3)
    y3 = np.array(y3)
    r3 = np.ones_like(x3) * r_f
    m3 = r3 * dx_f * dx_f
    h3 = np.ones_like(x3) * hdx * dx_f
    fluid = get_particle_array(name='fluid', x=x3, y=y3, rho=r3, m=m3, h=h3)
    remove_overlap_particles(fluid, wall, dx_s, 2)
    remove_overlap_particles(fluid, paddle, dx_s, 2)
    return fluid, wall, paddle
Esempio n. 3
0
def get_geometry(dx_s=0.03, dx_f=0.03, hdx=1.3, r_f=100.0, r_s=100.0,
                 wall_l=4.0, wall_h=2.0, fluid_l=1., fluid_h=2., cube_s=0.25):
    wall_y1 = np.arange(dx_s, wall_h, dx_s)
    wall_xlayer = np.ones_like(wall_y1) * 2.0
    wall_x1 = []
    wall_x2 = []
    num_layers = 3
    for i in range(num_layers):
        wall_x1.append(wall_xlayer + i * dx_s)
        wall_x2.append(wall_xlayer - i * dx_s + wall_l / 4.0)
    wall_x1, wall_x2 = np.ravel(wall_x1), np.ravel(wall_x2)
    wall_y1 = np.tile(wall_y1, num_layers)
    wall_y2 = wall_y1
    w_center = np.array([wall_l / 2.0, 0.0])
    wall_x3, wall_y3 = get_2d_wall(dx_s, w_center, wall_l, num_layers, False)
    w_center = np.array([2.5, wall_h + dx_s / 2.0])
    wall_x4, wall_y4 = get_2d_wall(dx_s, w_center, 1.0, num_layers)
    wall_x = np.concatenate([wall_x1, wall_x2, wall_x3, wall_x4])
    wall_y = np.concatenate([wall_y1, wall_y2, wall_y3, wall_y4])
    r1 = np.ones_like(wall_x) * r_s
    m1 = r1 * dx_s * dx_s
    h1 = np.ones_like(wall_x) * dx_s * hdx
    cs1 = np.zeros_like(wall_x)
    rad1 = np.ones_like(wall_x) * dx_s
    wall = get_particle_array(name='wall', x=wall_x, y=wall_y, h=h1, rho=r1,
                              m=m1, cs=cs1, rad_s=rad1)
    f_center = np.array([3.0 * wall_l / 8.0, wall_h / 2.0])
    x2, y2 = get_2d_block(dx_f, fluid_l, fluid_h, f_center)
    r2 = np.ones_like(x2) * r_f
    m2 = r2 * dx_f * dx_f
    h2 = np.ones_like(x2) * dx_f * hdx
    cs2 = np.zeros_like(x2)
    rad2 = np.ones_like(x2) * dx_f
    fluid = get_particle_array(name='fluid', x=x2, y=y2, h=h2, rho=r2, m=m2,
                               cs=cs2, rad_s=rad2)
    center1 = np.array([wall_l / 8.0 + cube_s / 2.0,
                        wall_h / 4.0 + cube_s / 2.0])
    cube1_x, cube1_y = get_2d_block(dx_s, cube_s, cube_s, center1)
    b1 = np.zeros_like(cube1_x, dtype=int)
    center2 = np.array([3.0 * wall_l / 4.0 + cube_s / 2.0 + 3.0 * dx_s,
                        wall_h + cube_s / 2.0 + (num_layers + 1) * dx_s])
    cube2_x, cube2_y = get_2d_block(dx_s, cube_s, cube_s, center2)
    b2 = np.ones_like(cube2_x, dtype=int)
    b = np.concatenate([b1, b2])
    x3 = np.concatenate([cube1_x, cube2_x])
    y3 = np.concatenate([cube1_y, cube2_y])
    r3 = np.ones_like(x3) * r_s * 0.5
    m3 = r3 * dx_s * dx_s
    h3 = np.ones_like(x3) * dx_s * hdx
    cs3 = np.zeros_like(x3)
    rad3 = np.ones_like(x3) * dx_s
    cube = get_particle_array_rigid_body(
        name='cube', x=x3, y=y3, h=h3, cs=cs3, rho=r3, m=m3, rad_s=rad3,
        body_id=b)
    remove_overlap_particles(fluid, wall, dx_s, 2)
    return fluid, wall, cube
Esempio n. 4
0
    def create_particles(self):
        fluid = self._create_fluid()
        solid = self._create_solid()
        outlet = self._create_outlet()
        inlet = self._create_inlet()
        wall = self._create_wall()
        G.remove_overlap_particles(fluid, solid, dx_solid=self.dx, dim=2)

        particles = [fluid, inlet, outlet, solid, wall]

        self._set_wall_normal(wall)
        self.scheme.setup_properties(particles)

        return particles
Esempio n. 5
0
def get_tsunami_geometry(dx_solid=0.01, dx_fluid=0.01, r_solid=100.0,
                         r_fluid=100.0, hdx=1.3, l_wall=9.5, h_wall=4.0,
                         angle=26.565051, h_fluid=3.5, l_obstacle=0.91,
                         flat_l=2.25):
    x1, y1, x2, y2 = get_beach_geometry_2d(dx_solid, l_wall, h_wall, flat_l,
                                           angle, 4)
    wall_x = np.concatenate([x1, x2])
    wall_y = np.concatenate([y1, y2])
    r_wall = np.ones_like(wall_x) * r_solid
    m_wall = r_wall * dx_solid * dx_solid
    h_w = np.ones_like(wall_x) * dx_solid * hdx
    wall = get_particle_array(name='wall', x=wall_x, y=wall_y, h=h_w,
                              rho=r_wall, m=m_wall)
    theta = np.pi * angle / 180.0
    h_obstacle = l_obstacle * np.tan(theta)
    obstacle_x1, obstacle_y1 = get_2d_block(dx_solid, l_obstacle, h_obstacle)
    obstacle_x = []
    obstacle_y = []
    for x, y in zip(obstacle_x1, obstacle_y1):
        if (y >= (-x * np.tan(theta))):
            obstacle_x.append(x)
            obstacle_y.append(y)
    x_translate = (l_wall - flat_l) * 0.8
    y_translate = x_translate * np.tan(theta)
    obstacle_x = np.asarray(obstacle_x) - x_translate
    obstacle_y = np.asarray(obstacle_y) + y_translate + dx_solid
    h_obstacle = np.ones_like(obstacle_x) * dx_solid * hdx
    r_obstacle = np.ones_like(obstacle_x) * r_solid
    m_obstacle = r_obstacle * dx_solid * dx_solid
    obstacle = get_particle_array(name='obstacle', x=obstacle_x,
                                  y=obstacle_y, rho=r_obstacle,
                                  m=m_obstacle, h=h_obstacle)
    fluid_center = np.array([flat_l - l_wall / 2.0, h_fluid / 2.0])
    x_fluid, y_fluid = get_2d_block(dx_fluid, l_wall, h_fluid, fluid_center)
    x3 = []
    y3 = []
    for i, xi in enumerate(x_fluid):
        if y_fluid[i] >= np.tan(-theta) * xi:
            x3.append(xi)
            y3.append(y_fluid[i])
    fluid_x = np.array(x3)
    fluid_y = np.array(y3)
    h_f = np.ones_like(fluid_x) * dx_fluid * hdx
    r_f = np.ones_like(fluid_x) * r_fluid
    m_f = r_f * dx_fluid * dx_fluid
    fluid = get_particle_array(name='fluid', x=fluid_x, y=fluid_y,
                               h=h_f, m=m_f, rho=r_f)
    remove_overlap_particles(fluid, obstacle, dx_solid * 1.1, 2)
    remove_overlap_particles(fluid, wall, dx_solid * 1.1, 2)
    return fluid, wall, obstacle
Esempio n. 6
0
    def create_particles(self):
        fluid_x, fluid_y = get_2d_block(
            dx=dx, length=Lx, height=Ly, center=np.array([0., 0.]))
        rho_fluid = np.ones_like(fluid_x) * rho0
        m_fluid = rho_fluid * volume
        h_fluid = np.ones_like(fluid_x) * h0
        cs_fluid = np.ones_like(fluid_x) * c0
        wall_x, wall_y = get_2d_block(
            dx=dx, length=Lx+6*dx, height=Ly+6*dx, center=np.array([0., 0.]))
        rho_wall = np.ones_like(wall_x) * rho0
        m_wall = rho_wall * volume
        h_wall = np.ones_like(wall_x) * h0
        cs_wall = np.ones_like(wall_x) * c0
        additional_props = ['V', 'color', 'scolor', 'cx', 'cy', 'cz',
                            'cx2', 'cy2', 'cz2', 'nx', 'ny', 'nz', 'ddelta',
                            'uhat', 'vhat', 'what', 'auhat', 'avhat', 'awhat',
                            'ax', 'ay', 'az', 'wij', 'vmag2', 'N', 'wij_sum',
                            'rho0', 'u0', 'v0', 'w0', 'x0', 'y0', 'z0',
                            'kappa', 'arho', 'nu', 'wg', 'ug', 'vg',
                            'pi00', 'pi01', 'pi10', 'pi11', 'alpha']
        consts = {'max_ddelta': np.zeros(1, dtype=float)}
        fluid = get_particle_array(
            name='fluid', x=fluid_x, y=fluid_y, h=h_fluid, m=m_fluid,
            rho=rho_fluid, cs=cs_fluid, additional_props=additional_props)
        for i in range(len(fluid.x)):
            if (fluid.x[i]*fluid.x[i] + fluid.y[i]*fluid.y[i]) < 0.04:
                fluid.color[i] = 1.0
            else:
                fluid.color[i] = 0.0
        fluid.alpha[:] = sigma
        wall = get_particle_array(
            name='wall', x=wall_x, y=wall_y, h=h_wall, m=m_wall,
            rho=rho_wall, cs=cs_wall, additional_props=additional_props)
        wall.color[:] = 0.0
        remove_overlap_particles(wall, fluid, dx_solid=dx, dim=2)
        fluid.add_output_arrays(['V', 'color', 'cx', 'cy', 'nx', 'ny', 'ddelta',
                                 'kappa', 'N', 'scolor', 'p'])
        wall.add_output_arrays(['V', 'color', 'cx', 'cy', 'nx', 'ny', 'ddelta',
                                'kappa', 'N', 'scolor', 'p'])
        for i in range(len(fluid.x)):
            R = sqrt(r(fluid.x[i], fluid.y[i]) + 0.0001*fluid.h[i]*fluid.h[i])
            fluid.u[i] = v0*fluid.x[i] * \
                (1.0 - (fluid.y[i]*fluid.y[i])/(r0*R))*np.exp(-R/r0)/r0
            fluid.v[i] = -v0*fluid.y[i] * \
                (1.0 - (fluid.x[i]*fluid.x[i])/(r0*R))*np.exp(-R/r0)/r0
        fluid.nu[:] = nu0

        return [fluid, wall]
Esempio n. 7
0
def get_dam_geometry(dx_tank=0.03,
                     dx_fluid=0.03,
                     r_tank=100.0,
                     h_f=2.0,
                     l_f=1.0,
                     r_fluid=100.0,
                     hdx=1.5,
                     l_tank=4.0,
                     h_tank=4.0,
                     h_f2=1.0):
    tank_x, tank_y = get_2d_tank(dx_tank,
                                 length=l_tank,
                                 height=h_tank,
                                 num_layers=4)
    rho_tank = np.ones_like(tank_x) * r_tank
    m_tank = rho_tank * dx_tank * dx_tank
    h_t = np.ones_like(tank_x) * dx_tank * hdx
    tank = get_particle_array(name='dam',
                              x=tank_x,
                              y=tank_y,
                              h=h_t,
                              rho=rho_tank,
                              m=m_tank)
    center = np.array([(l_f - l_tank) / 2.0, h_f / 2.0])
    fluid_x1, fluid_y1 = get_2d_block(dx_fluid, l_f, h_f, center)
    center = np.array([l_f / 2.0, h_f2 / 2.0])
    fluid_x2, fluid_y2 = get_2d_block(dx_fluid, l_tank - l_f - 2.0 * dx_fluid,
                                      h_f2, center)
    fluid_x = np.concatenate([fluid_x1, fluid_x2])
    fluid_y = np.concatenate([fluid_y1, fluid_y2])
    h_fluid = np.ones_like(fluid_x) * dx_fluid * hdx
    r_f = np.ones_like(fluid_x) * r_fluid
    m_f = r_f * dx_fluid * dx_fluid
    fluid = get_particle_array(name='fluid',
                               x=fluid_x,
                               y=fluid_y,
                               h=h_fluid,
                               rho=r_f,
                               m=m_f)
    remove_overlap_particles(fluid, tank, dx_tank, 2)
    return fluid, tank
Esempio n. 8
0
    def create_particles(self):
        dx = self.dx
        [fluid, boundary, obstacle] = self.geom.create_particles()

        # Thin sheet of water of height 1 cm
        x_sheet, y_sheet, z_sheet = np.mgrid[0.4:1.6:dx, -0.31:0.31:dx,
                                             dx:dx + 0.01:dx]
        x_sheet = x_sheet.ravel()
        y_sheet = y_sheet.ravel()
        z_sheet = z_sheet.ravel()
        sheet = get_particle_array(x=x_sheet,
                                   y=y_sheet,
                                   z=z_sheet,
                                   h=self.h0,
                                   rho=ro,
                                   m=ro * dx * dx * dx)

        remove_overlap_particles(sheet, obstacle, dx_solid=dx)
        remove_overlap_particles(sheet, boundary, dx_solid=dx)
        remove_overlap_particles(sheet, fluid, dx_solid=dx)
        fluid.append_parray(sheet)

        particles = [fluid, boundary, obstacle]
        self.scheme.setup_properties(particles)
        return particles
Esempio n. 9
0
def get_wavespaddle_geometry(hdx=1.5,
                             dx_f=0.1,
                             dx_s=0.1,
                             r_f=100.,
                             r_s=100.,
                             length=3.75,
                             height=0.3,
                             flat_l=1.,
                             angle=4.2364,
                             h_fluid=0.2):
    x1, y1, x2, y2 = get_beach_geometry_2d(dx_s, length, height, flat_l, angle,
                                           5)
    r1 = np.ones_like(x1) * r_s
    m1 = r1 * dx_s * dx_s
    h1 = np.ones_like(x1) * hdx * dx_s
    wall = get_particle_array(name='wall', x=x1, y=y1, rho=r1, m=m1, h=h1)
    r2 = np.ones_like(x2) * r_s
    m2 = r2 * dx_s * dx_s
    h2 = np.ones_like(x2) * hdx * dx_s
    paddle = get_particle_array(name='paddle', x=x2, y=y2, rho=r2, m=m2, h=h2)
    fluid_center = np.array([flat_l - length / 2.0, h_fluid / 2.0])
    x_fluid, y_fluid = get_2d_block(dx_f, length, h_fluid, fluid_center)
    x3 = []
    y3 = []
    theta = np.pi * angle / 180.0
    for i, xi in enumerate(x_fluid):
        if y_fluid[i] >= np.tan(-theta) * xi:
            x3.append(xi)
            y3.append(y_fluid[i])
    x3 = np.array(x3)
    y3 = np.array(y3)
    r3 = np.ones_like(x3) * r_f
    m3 = r3 * dx_f * dx_f
    h3 = np.ones_like(x3) * hdx * dx_f
    fluid = get_particle_array(name='fluid', x=x3, y=y3, rho=r3, m=m3, h=h3)
    remove_overlap_particles(fluid, wall, dx_s, 2)
    remove_overlap_particles(fluid, paddle, dx_s, 2)
    return fluid, wall, paddle
Esempio n. 10
0
 def test_remove_overlap_particles(self):
     dx_1 = 0.1
     dx_2 = 0.15
     length = 4.5
     height = 3.0
     radius = 2.0
     x1, y1 = G.get_2d_block(dx_1, length, height)
     x2, y2 = G.get_2d_circle(dx_2, radius)
     r1 = np.ones_like(x1) * 100.0
     m1 = r1 * dx_1 * dx_1
     h1 = np.ones_like(x1) * dx_1 * 1.5
     fluid = get_particle_array(name='fluid',
                                x=x1,
                                y=y1,
                                h=h1,
                                rho=r1,
                                m=m1)
     r2 = np.ones_like(x2) * 100.0
     m2 = r2 * dx_2 * dx_2
     h2 = np.ones_like(x2) * dx_2 * 1.5
     solid = get_particle_array(name='solid',
                                x=x2,
                                y=y2,
                                h=h2,
                                rho=r2,
                                m=m2)
     G.remove_overlap_particles(fluid, solid, dx_2, 2)
     x1 = fluid.x
     y1 = fluid.y
     count = 0
     for i in range(len(x1)):
         point = np.array([x1[i], y1[i]])
         dist = G.distance_2d(point)
         if dist <= radius:
             count += 1
     assert count == 0
Esempio n. 11
0
 def test_remove_overlap_particles(self):
     dx_1 = (10)**(np.random.randint(-2, -1))
     dx_2 = (10)**(np.random.randint(-2, -1))
     length = np.random.randint(20, 40) * dx_1
     height = np.random.randint(20, 40) * dx_1
     radius = np.random.randint(20, 40) * dx_2
     x1, y1 = get_2d_block(dx_1, length, height)
     x2, y2 = get_2d_circle(dx_2, radius)
     r1 = np.ones_like(x1) * 100.0
     m1 = r1 * dx_1 * dx_1
     h1 = np.ones_like(x1) * dx_1 * 1.5
     fluid = get_particle_array(name='fluid',
                                x=x1,
                                y=y1,
                                h=h1,
                                rho=r1,
                                m=m1)
     r2 = np.ones_like(x2) * 100.0
     m2 = r2 * dx_2 * dx_2
     h2 = np.ones_like(x2) * dx_2 * 1.5
     solid = get_particle_array(name='solid',
                                x=x2,
                                y=y2,
                                h=h2,
                                rho=r2,
                                m=m2)
     remove_overlap_particles(fluid, solid, dx_2, 2)
     x1 = fluid.x
     y1 = fluid.y
     count = 0
     for i in range(len(x1)):
         point = np.array([x1[i], y1[i]])
         dist = distance_2d(point)
         if dist <= radius:
             count += 1
     assert count == 0
Esempio n. 12
0
    def create_particles(self):
        fluid_x, fluid_y = get_2d_block(dx=dx,
                                        length=Lx,
                                        height=Ly,
                                        center=np.array([0., 0.]))
        rho_fluid = np.ones_like(fluid_x) * rho2
        m_fluid = rho_fluid * volume
        h_fluid = np.ones_like(fluid_x) * h0
        cs_fluid = np.ones_like(fluid_x) * c0
        circle_x, circle_y = get_2d_circle(dx=dx,
                                           r=0.2,
                                           center=np.array([0.0, 0.0]))
        rho_circle = np.ones_like(circle_x) * rho1
        m_circle = rho_circle * volume
        h_circle = np.ones_like(circle_x) * h0
        cs_circle = np.ones_like(circle_x) * c0
        wall_x, wall_y = get_2d_block(dx=dx,
                                      length=Lx + 6 * dx,
                                      height=Ly + 6 * dx,
                                      center=np.array([0., 0.]))
        rho_wall = np.ones_like(wall_x) * rho2
        m_wall = rho_wall * volume
        h_wall = np.ones_like(wall_x) * h0
        cs_wall = np.ones_like(wall_x) * c0
        additional_props = [
            'V', 'color', 'scolor', 'cx', 'cy', 'cz', 'cx2', 'cy2', 'cz2',
            'nx', 'ny', 'nz', 'ddelta', 'uhat', 'vhat', 'what', 'auhat',
            'avhat', 'awhat', 'ax', 'ay', 'az', 'wij', 'vmag2', 'N', 'wij_sum',
            'rho0', 'u0', 'v0', 'w0', 'x0', 'y0', 'z0', 'kappa', 'arho', 'nu',
            'wg', 'ug', 'vg', 'pi00', 'pi01', 'pi10', 'pi11'
        ]
        consts = {'max_ddelta': np.zeros(1, dtype=float)}
        gas = get_particle_array(name='gas',
                                 x=fluid_x,
                                 y=fluid_y,
                                 h=h_fluid,
                                 m=m_fluid,
                                 rho=rho_fluid,
                                 cs=cs_fluid,
                                 additional_props=additional_props,
                                 constants=consts)
        gas.nu[:] = nu2
        gas.color[:] = 0.0
        liquid = get_particle_array(name='liquid',
                                    x=circle_x,
                                    y=circle_y,
                                    h=h_circle,
                                    m=m_circle,
                                    rho=rho_circle,
                                    cs=cs_circle,
                                    additional_props=additional_props,
                                    constants=consts)
        liquid.nu[:] = nu1
        liquid.color[:] = 1.0
        wall = get_particle_array(name='wall',
                                  x=wall_x,
                                  y=wall_y,
                                  h=h_wall,
                                  m=m_wall,
                                  rho=rho_wall,
                                  cs=cs_wall,
                                  additional_props=additional_props)
        wall.color[:] = 0.0
        remove_overlap_particles(wall, liquid, dx_solid=dx, dim=2)
        remove_overlap_particles(wall, gas, dx_solid=dx, dim=2)
        remove_overlap_particles(gas, liquid, dx_solid=dx, dim=2)
        gas.add_output_arrays([
            'V', 'color', 'cx', 'cy', 'nx', 'ny', 'ddelta', 'kappa', 'N',
            'scolor', 'p'
        ])
        liquid.add_output_arrays([
            'V', 'color', 'cx', 'cy', 'nx', 'ny', 'ddelta', 'kappa', 'N',
            'scolor', 'p'
        ])
        wall.add_output_arrays([
            'V', 'color', 'cx', 'cy', 'nx', 'ny', 'ddelta', 'kappa', 'N',
            'scolor', 'p'
        ])

        for i in range(len(gas.x)):
            R = sqrt(r(gas.x[i], gas.y[i]) + 0.0001 * gas.h[i] * gas.h[i])
            gas.u[i] = v0 * gas.x[i] * (1.0 - (gas.y[i] * gas.y[i]) /
                                        (r0 * R)) * np.exp(-R / r0) / r0
            gas.v[i] = -v0 * gas.y[i] * (1.0 - (gas.x[i] * gas.x[i]) /
                                         (r0 * R)) * np.exp(-R / r0) / r0
        for i in range(len(liquid.x)):
            R = sqrt(
                r(liquid.x[i], liquid.y[i]) +
                0.0001 * liquid.h[i] * liquid.h[i])
            liquid.u[i] = v0*liquid.x[i] * \
                (1.0 - (liquid.y[i]*liquid.y[i])/(r0*R))*np.exp(-R/r0)/r0
            liquid.v[i] = -v0*liquid.y[i] * \
                (1.0 - (liquid.x[i]*liquid.x[i])/(r0*R))*np.exp(-R/r0)/r0
        return [liquid, gas, wall]
Esempio n. 13
0
def get_wavespaddle_geometry(hdx=1.5,
                             dx_f=0.1,
                             dx_s=0.05,
                             r_f=100.,
                             r_s=100.,
                             length=3.75,
                             height=0.3,
                             flat_l=1.,
                             angle=4.2364,
                             h_fluid=0.2,
                             obstacle_side=0.06):
    x1, y1, x2, y2 = get_beach_geometry_2d(dx_s, length, height, flat_l, angle,
                                           3)
    r1 = np.ones_like(x1) * r_s
    m1 = r1 * dx_s * dx_s
    h1 = np.ones_like(x1) * hdx * dx_s
    cs1 = np.zeros_like(x1)
    rad1 = np.ones_like(x1) * dx_s
    wall = get_particle_array(name='wall',
                              x=x1,
                              y=y1,
                              rho=r1,
                              m=m1,
                              h=h1,
                              cs=cs1,
                              rad_s=rad1)
    r2 = np.ones_like(x2) * r_s
    m2 = r2 * dx_s * dx_s
    h2 = np.ones_like(x2) * hdx * dx_s
    paddle = get_particle_array(name='paddle', x=x2, y=y2, rho=r2, m=m2, h=h2)
    fluid_center = np.array([flat_l - length / 2.0, h_fluid / 2.0])
    x_fluid, y_fluid = get_2d_block(dx_f, length, h_fluid, fluid_center)
    x3 = []
    y3 = []
    theta = np.pi * angle / 180.0
    for i, xi in enumerate(x_fluid):
        if y_fluid[i] >= np.tan(-theta) * xi:
            x3.append(xi)
            y3.append(y_fluid[i])
    x3 = np.array(x3)
    y3 = np.array(y3)
    r3 = np.ones_like(x3) * r_f
    m3 = r3 * dx_f * dx_f
    h3 = np.ones_like(x3) * hdx * dx_f
    cs3 = np.zeros_like(x3)
    rad3 = np.ones_like(x3) * dx_f
    fluid = get_particle_array(name='fluid', x=x3, y=y3, rho=r3, m=m3, h=h3)
    square_center = np.array([-0.38, 0.16])
    x4, y4 = get_2d_block(dx_s, obstacle_side, obstacle_side, square_center)
    b1 = np.zeros_like(x4, dtype=int)
    square_center = np.array([-0.7, 0.16])
    x5, y5 = get_2d_block(dx_s, obstacle_side, obstacle_side, square_center)
    b2 = np.ones_like(x5, dtype=int)
    square_center = np.array([-1.56, 0.22])
    x6, y6 = get_2d_block(dx_s, obstacle_side, obstacle_side, square_center)
    b3 = np.ones_like(x5, dtype=int) * 2
    b = np.concatenate([b1, b2, b3])
    x4 = np.concatenate([x4, x5, x6])
    y4 = np.concatenate([y4, y5, y6])
    r4 = np.ones_like(x4) * r_s * 0.5
    m4 = r4 * dx_s * dx_s
    h4 = np.ones_like(x4) * hdx * dx_s
    cs4 = np.zeros_like(x4)
    rad4 = np.ones_like(x4) * dx_s
    obstacle = get_particle_array_rigid_body(name='obstacle',
                                             x=x4,
                                             y=y4,
                                             h=h4,
                                             rho=r4,
                                             m=m4,
                                             cs=cs4,
                                             rad_s=rad4,
                                             body_id=b)
    remove_overlap_particles(fluid, wall, dx_s, 2)
    remove_overlap_particles(fluid, paddle, dx_s, 2)
    remove_overlap_particles(fluid, obstacle, dx_s, 2)
    return fluid, wall, paddle, obstacle
Esempio n. 14
0
def windtunnel_airfoil_model(dx_wall=0.01,
                             dx_airfoil=0.01,
                             dx_fluid=0.01,
                             r_solid=100.0,
                             r_fluid=100.0,
                             airfoil='2412',
                             hdx=1.1,
                             chord=1.0,
                             h_tunnel=1.0,
                             l_tunnel=10.0):
    """
    Generates a geometry which can be used for wind tunnel like simulations.

    Parameters
    ----------
    dx_wall : a number which is the dx of the wind tunnel wall
    dx_airfoil : a number which is the dx of the airfoil used
    dx_fluid : a number which is the dx of the fluid used
    r_solid : a number which is the initial density of the solid particles
    r_fluid : a number which is the initial density of the fluid particles
    airfoil : 4 or 5 digit string which is the airfoil name
    hdx : a number which is the hdx for the particle arrays
    chord : a number which is the chord of the airfoil
    h_tunnel : a number which is the height of the wind tunnel
    l_tunnel : a number which is the length of the wind tunnel

    Returns
    -------
    wall : pysph wcsph particle array for the wind tunnel walls
    wing : pysph wcsph particle array for the airfoil
    fluid : pysph wcsph particle array for the fluid
    """

    wall_center_1 = np.array([0.0, h_tunnel / 2.])
    wall_center_2 = np.array([0.0, -h_tunnel / 2.])
    x_wall_1, y_wall_1 = get_2d_wall(dx_wall, wall_center_1, l_tunnel)
    x_wall_2, y_wall_2 = get_2d_wall(dx_wall, wall_center_2, l_tunnel)
    x_wall = np.concatenate([x_wall_1, x_wall_2])
    y_wall = np.concatenate([y_wall_1, y_wall_2])
    y_wall_1 = y_wall_1 + dx_wall
    y_wall_2 = y_wall_2 - dx_wall
    y_wall = np.concatenate([y_wall, y_wall_1, y_wall_2])
    y_wall_1 = y_wall_1 + dx_wall
    y_wall_2 = y_wall_2 - dx_wall
    y_wall = np.concatenate([y_wall, y_wall_1, y_wall_2])
    y_wall_1 = y_wall_1 + dx_wall
    y_wall_2 = y_wall_2 - dx_wall
    x_wall = np.concatenate([x_wall, x_wall, x_wall, x_wall])
    y_wall = np.concatenate([y_wall, y_wall_1, y_wall_2])
    h_wall = np.ones_like(x_wall) * dx_wall * hdx
    rho_wall = np.ones_like(x_wall) * r_solid
    mass_wall = rho_wall * dx_wall * dx_wall
    wall = get_particle_array_wcsph(name='wall',
                                    x=x_wall,
                                    y=y_wall,
                                    h=h_wall,
                                    rho=rho_wall,
                                    m=mass_wall)
    if len(airfoil) == 4:
        x_airfoil, y_airfoil = get_4digit_naca_airfoil(dx_airfoil, airfoil,
                                                       chord)
    else:
        x_airfoil, y_airfoil = get_5digit_naca_airfoil(dx_airfoil, airfoil,
                                                       chord)
    x_airfoil = x_airfoil - 0.5
    h_airfoil = np.ones_like(x_airfoil) * dx_airfoil * hdx
    rho_airfoil = np.ones_like(x_airfoil) * r_solid
    mass_airfoil = rho_airfoil * dx_airfoil * dx_airfoil
    wing = get_particle_array_wcsph(name='wing',
                                    x=x_airfoil,
                                    y=y_airfoil,
                                    h=h_airfoil,
                                    rho=rho_airfoil,
                                    m=mass_airfoil)
    x_fluid, y_fluid = get_2d_block(dx_fluid, 1.6, h_tunnel)
    h_fluid = np.ones_like(x_fluid) * dx_fluid * hdx
    rho_fluid = np.ones_like(x_fluid) * r_fluid
    mass_fluid = rho_fluid * dx_fluid * dx_fluid
    fluid = get_particle_array_wcsph(name='fluid',
                                     x=x_fluid,
                                     y=y_fluid,
                                     h=h_fluid,
                                     rho=rho_fluid,
                                     m=mass_fluid)
    remove_overlap_particles(fluid, wall, dx_wall, 2)
    remove_overlap_particles(fluid, wing, dx_airfoil, 2)
    return wall, wing, fluid
Esempio n. 15
0
    def create_particles(self):
        x, y = np.mgrid[dx:l_tunnel + dx / 4:dx, dx / 2:w_tunnel - dx / 4:dx]
        x, y = (np.ravel(t) for t in (x, y))
        one = np.ones_like(x)
        volume = dx * dx * one
        m = volume * rho
        fluid = get_particle_array(name='fluid',
                                   m=m,
                                   x=x,
                                   y=y,
                                   h=h0 * one,
                                   V=1.0 / volume,
                                   u=umax * one)

        xc, yc = center
        cond = (x - xc)**2 + (y - yc)**2 < 1.0
        one = np.ones_like(x[cond])
        volume = dx * dx * one
        solid = get_particle_array(name='solid',
                                   x=x[cond].ravel(),
                                   y=y[cond].ravel(),
                                   m=volume * rho,
                                   rho=one * rho,
                                   h=h0 * one,
                                   V=1.0 / volume)
        G.remove_overlap_particles(fluid, solid, dx, dim=2)

        x, y = np.mgrid[dx:n_outlet * dx:dx, dx / 2:w_tunnel - dx / 4:dx]
        x, y = (np.ravel(t) for t in (x, y))
        x += l_tunnel
        one = np.ones_like(x)
        volume = dx * dx * one
        m = volume * rho
        outlet = get_particle_array(name='outlet',
                                    x=x,
                                    y=y,
                                    m=m,
                                    h=h0 * one,
                                    V=1.0 / volume,
                                    u=umax * one)

        # Setup the inlet particle array with just the particles we need at the
        # exit plane which is replicated by the inlet.
        y = np.arange(dx / 2, w_tunnel - dx / 4.0, dx)
        x = np.zeros_like(y)
        one = np.ones_like(x)
        volume = one * dx * dx

        inlet = get_particle_array(name='inlet',
                                   x=x,
                                   y=y,
                                   m=volume * rho,
                                   h=h0 * one,
                                   u=umax * one,
                                   rho=rho * one,
                                   V=1.0 / volume)
        self.scheme.setup_properties([fluid, inlet, outlet, solid])
        for p in fluid.properties:
            if p not in outlet.properties:
                outlet.add_property(p)

        return [fluid, solid, inlet, outlet]