コード例 #1
0
    def test_stokes(self):
        self.system.actors.clear()
        self.system.lbboundaries.clear()
        self.system.actors.add(self.lbf)
        # The temperature is zero.
        self.system.thermostat.set_lb(kT=0)

        # Setup walls
        walls = [None] * 4
        walls[0] = lbboundaries.LBBoundary(shape=shapes.Wall(
                                           normal=[-1, 0, 0], dist=-(1 + box_width)), velocity=v)
        walls[1] = lbboundaries.LBBoundary(
            shape=shapes.Wall(
                normal=[
                    1,
                    0,
                    0],
                dist=1),
            velocity=v)
        walls[2] = lbboundaries.LBBoundary(shape=shapes.Wall(
            normal=[0, -1, 0], dist=-(1 + box_width)), velocity=v)
        walls[3] = lbboundaries.LBBoundary(
            shape=shapes.Wall(
                normal=[
                    0,
                    1,
                    0],
                dist=1),
            velocity=v)

        for wall in walls:
            self.system.lbboundaries.add(wall)

        # setup sphere without slip in the middle
        sphere = lbboundaries.LBBoundary(shape=shapes.Sphere(
            radius=radius, center=[real_width / 2] * 2 + [box_length / 2], direction=1))

        self.system.lbboundaries.add(sphere)

        def size(vector):
            tmp = 0
            for k in vector:
                tmp += k * k
            return np.sqrt(tmp)

        self.system.integrator.run(800)

        stokes_force = 6 * np.pi * KVISC * radius * size(v)
        print("Stokes' Law says: f=%f" % stokes_force)

        # get force that is exerted on the sphere
        for i in range(4):
            self.system.integrator.run(200)
            force = sphere.get_force()
            print("Measured force: f=%f" % size(force))
            self.assertLess(abs(1.0 - size(force) / stokes_force), 0.06)
コード例 #2
0
    def test(self):
        self.system.actors.clear()
        self.system.lbboundaries.clear()
        self.system.actors.add(self.lbf)

        # Setup walls
        for i in range(3):
            n = np.zeros(3)
            n[i] = 1
            self.system.lbboundaries.add(
                lbboundaries.LBBoundary(shape=shapes.Wall(
                                        normal=-n, dist=-(self.system.box_l[i] - AGRID))))

            self.system.lbboundaries.add(lbboundaries.LBBoundary(
                                         shape=shapes.Wall(
                                             normal=n, dist=AGRID)))

        # setup sphere without slip in the middle
        sphere = lbboundaries.LBBoundary(shape=shapes.Sphere(
            radius=RADIUS, center=self.system.box_l / 2, direction=1))

        self.system.lbboundaries.add(sphere)

        sphere_volume = 4. / 3. * np.pi * RADIUS**3

        # Equilibration
        last_force = -999999
        self.system.integrator.run(100)
        while True:
            self.system.integrator.run(10)
            force = np.linalg.norm(sphere.get_force())
            if np.linalg.norm(force - last_force) < 0.01:
                break
            last_force = force

        # Check force balance
        boundary_force = np.zeros(3)
        for b in self.system.lbboundaries:
            boundary_force += b.get_force()

        fluid_nodes = count_fluid_nodes(self.lbf) 
        fluid_volume = fluid_nodes * AGRID**3
        applied_force = fluid_volume * np.array(LB_PARAMS['ext_force_density'])

        np.testing.assert_allclose(
            boundary_force,
            applied_force,
            atol=0.08 * np.linalg.norm(applied_force))

        # Check buoyancy force on the sphere
        expected_force = np.array(
            [0, -sphere_volume * DENS * G, 0])
        np.testing.assert_allclose(
            np.copy(sphere.get_force()), expected_force,
            atol=np.linalg.norm(expected_force) * 0.02)
コード例 #3
0
    def test_stokes(self):
        self.system.actors.clear()
        self.system.lbboundaries.clear()
        self.system.actors.add(self.lbf)
        self.system.thermostat.set_lb(LB_fluid=self.lbf, gamma=1.0)

        # Setup walls
        walls = [None] * 4
        walls[0] = lbboundaries.LBBoundary(shape=shapes.Wall(
            normal=[-1, 0, 0], dist=-(1 + box_width)),
                                           velocity=v)
        walls[1] = lbboundaries.LBBoundary(shape=shapes.Wall(normal=[1, 0, 0],
                                                             dist=1),
                                           velocity=v)
        walls[2] = lbboundaries.LBBoundary(shape=shapes.Wall(
            normal=[0, -1, 0], dist=-(1 + box_width)),
                                           velocity=v)
        walls[3] = lbboundaries.LBBoundary(shape=shapes.Wall(normal=[0, 1, 0],
                                                             dist=1),
                                           velocity=v)

        for wall in walls:
            self.system.lbboundaries.add(wall)

        # setup sphere without slip in the middle
        sphere = lbboundaries.LBBoundary(
            shape=shapes.Sphere(radius=radius,
                                center=[real_width / 2] * 2 + [box_length / 2],
                                direction=1))

        self.system.lbboundaries.add(sphere)

        def size(vector):
            tmp = 0
            for k in vector:
                tmp += k * k
            return np.sqrt(tmp)

        last_force = -1000.
        dynamic_viscosity = self.lbf.viscosity * self.lbf.density
        stokes_force = 6 * np.pi * dynamic_viscosity * radius * size(v)
        self.system.integrator.run(35)
        while True:
            self.system.integrator.run(5)
            force = np.linalg.norm(sphere.get_force())
            if np.abs(last_force - force) < 0.01 * stokes_force:
                break
            last_force = force

        force = np.copy(sphere.get_force())
        np.testing.assert_allclose(force, [0, 0, stokes_force],
                                   rtol=0.03,
                                   atol=stokes_force * 0.03)
コード例 #4
0
    def test_stokes(self):
        # System setup
        agrid = 1
        radius = 5.5
        box_width = 54
        real_width = box_width + 2 * agrid
        box_length = 54
        system = espressomd.System(box_l=[real_width, real_width, box_length])
        system.box_l = [real_width, real_width, box_length]
        system.time_step = 0.4
        system.cell_system.skin = 0.4

        # The temperature is zero.
        system.thermostat.set_lb(kT=0)

        # LB Parameters
        v = [0, 0, 0.01]  # The boundary slip
        kinematic_visc = 5.0

        # Invoke LB fluid
        lbf = lb.LBFluidGPU(visc=kinematic_visc,
                            dens=1,
                            agrid=agrid,
                            tau=system.time_step,
                            fric=1)
        system.actors.add(lbf)

        # Setup walls
        walls = [None] * 4
        walls[0] = lbboundaries.LBBoundary(shape=shapes.Wall(
            normal=[-1, 0, 0], dist=-(1 + box_width)),
                                           velocity=v)
        walls[1] = lbboundaries.LBBoundary(shape=shapes.Wall(normal=[1, 0, 0],
                                                             dist=1),
                                           velocity=v)
        walls[2] = lbboundaries.LBBoundary(shape=shapes.Wall(
            normal=[0, -1, 0], dist=-(1 + box_width)),
                                           velocity=v)
        walls[3] = lbboundaries.LBBoundary(shape=shapes.Wall(normal=[0, 1, 0],
                                                             dist=1),
                                           velocity=v)

        for wall in walls:
            system.lbboundaries.add(wall)

        # setup sphere without slip in the middle
        sphere = lbboundaries.LBBoundary(
            shape=shapes.Sphere(radius=radius,
                                center=[real_width / 2] * 2 + [box_length / 2],
                                direction=1))

        system.lbboundaries.add(sphere)

        def size(vector):
            tmp = 0
            for k in vector:
                tmp += k * k
            return np.sqrt(tmp)

        system.integrator.run(800)

        stokes_force = 6 * np.pi * kinematic_visc * radius * size(v)
        print("Stokes' Law says: f=%f" % stokes_force)

        # get force that is exerted on the sphere
        for i in range(5):
            system.integrator.run(200)
            force = sphere.get_force()
            print("Measured force: f=%f" % size(force))
            self.assertLess(abs(1.0 - size(force) / stokes_force), 0.06)
コード例 #5
0
walls = [None] * 4
walls[0] = lbboundaries.LBBoundary(shape=shapes.Wall(normal=[-1,0,0], 
                                   dist = -(1+box_width)), velocity=v)
walls[1] = lbboundaries.LBBoundary(shape=shapes.Wall(normal=[1,0,0], dist = 1),
                                 velocity=v)
walls[2] = lbboundaries.LBBoundary(shape=shapes.Wall(normal=[0,-1,0], 
                                   dist = -(1+box_width)), velocity=v)
walls[3] = lbboundaries.LBBoundary(shape=shapes.Wall(normal=[0,1,0], dist = 1),
                                   velocity=v)

for wall in walls:
    system.lbboundaries.add(wall)

# setup sphere without slip in the middle
sphere = lbboundaries.LBBoundary(shape=shapes.Sphere(radius=radius,
                                 center = [real_width/2] * 2 + [box_length/2],
                                 direction = 1))

system.lbboundaries.add(sphere)


lbf.print_vtk_boundary("./boundary.vtk")


def size(vector):
    tmp = 0
    for k in vector:
        tmp+=k*k
    return np.sqrt(tmp)

for i in range(40):