コード例 #1
0
    def test_domain_with_fluid_rectangle(self):
        fname = 'fluid_rectangle.npz'
        dom2d = copy.deepcopy(self.dom2d)
        dom2d['elements'] = [
            pyLBM.Parallelogram([0., 0.], [1., 0], [0., 2.], label=20),
            pyLBM.Parallelogram([0.23, 0.73], [0.5, 0], [0., .5],
                                label=10,
                                isfluid=True)
        ]
        dom = pyLBM.Domain(dom2d)

        check_from_file(dom, fname)
コード例 #2
0
from __future__ import print_function
from __future__ import division
# Authors:
#     Loic Gouarin <*****@*****.**>
#     Benjamin Graille <*****@*****.**>
#
# License: BSD 3 clause

"""
Example of a 2D geometry: the backward facing step
"""
import pyLBM
dgeom = {
    'box':{'x': [0, 3], 'y': [0, 1], 'label':[0, 1, 2, 3]},
    'elements':[pyLBM.Parallelogram((0.,0.), (.5,0.), (0., .5), label = [4,5,6,7])],
}
geom = pyLBM.Geometry(dgeom)
geom.visualize(viewlabel=True)
コード例 #3
0
def run(dx,
        Tf,
        generator=pyLBM.generator.CythonGenerator,
        sorder=None,
        withPlot=True):
    """
    Parameters
    ----------

    dx: double
        spatial step

    Tf: double
        final time

    generator: pyLBM generator

    sorder: list
        storage order

    withPlot: boolean
        if True plot the solution otherwise just compute the solution

    """
    # parameters
    xmin, xmax, ymin, ymax = 0., 1., 0., 1
    rayon = 0.25 * (xmax - xmin)
    la = 1.  # velocity of the scheme
    rhoo = 1.
    uo = 0.05
    mu = 2.5e-5  #0.00185
    zeta = 10 * mu
    dummy = 3.0 / (la * rhoo * dx)
    s3 = 1.0 / (0.5 + zeta * dummy)
    s4 = s3
    s5 = s4
    s6 = s4
    s7 = 1.0 / (0.5 + mu * dummy)
    s8 = s7
    s = [0., 0., 0., s3, s4, s5, s6, s7, s8]
    dummy = 1. / (LA**2 * rhoo)
    qx2 = dummy * qx**2
    qy2 = dummy * qy**2
    q2 = qx2 + qy2
    qxy = dummy * qx * qy
    xc = xmin + 0.75 * (xmax - xmin)
    yc = ymin + 0.75 * (ymax - ymin)

    dico = {
        'box': {
            'x': [xmin, xmax],
            'y': [ymin, ymax],
            'label': [2, 0, 1, 0]
        },
        'elements':
        [pyLBM.Parallelogram((xmin, ymin), (xc, ymin), (xmin, yc), label=0)],
        'scheme_velocity':
        la,
        'space_step':
        dx,
        'schemes': [{
            'velocities':
            list(range(9)),
            'polynomials': [
                1, X, Y, 3 * (X**2 + Y**2) - 4,
                0.5 * (9 * (X**2 + Y**2)**2 - 21 * (X**2 + Y**2) + 8),
                3 * X * (X**2 + Y**2) - 5 * X, 3 * Y * (X**2 + Y**2) - 5 * Y,
                X**2 - Y**2, X * Y
            ],
            'relaxation_parameters':
            s,
            'equilibrium': [
                rho, qx, qy, -2 * rho + 3 * q2, rho - 3 * q2, -qx, -qy,
                qx2 - qy2, qxy
            ],
            'conserved_moments': [rho, qx, qy],
            'init': {
                rho: rhoo,
                qx: 0.,
                qy: 0.
            },
        }],
        'boundary_conditions': {
            0: {
                'method': {
                    0: pyLBM.bc.Bouzidi_bounce_back
                }
            },
            1: {
                'method': {
                    0: pyLBM.bc.Neumann_y
                }
            },
            2: {
                'method': {
                    0: pyLBM.bc.Bouzidi_bounce_back
                },
                'value': (bc_in, (rhoo, uo, ymin, ymax))
            }
        },
        'generator':
        generator,
        'parameters': {
            'LA': la
        },
    }

    sol = pyLBM.Simulation(dico, sorder=sorder)

    if withPlot:
        # init viewer
        viewer = pyLBM.viewer.matplotlibViewer
        fig = viewer.Fig()
        ax = fig[0]
        image = ax.image(norme_q, (sol, ), cmap='jet', clim=[0, uo**2])
        ax.polygon([[xmin / dx, ymin / dx], [xmin / dx, yc / dx],
                    [xc / dx, yc / dx], [xc / dx, ymin / dx]], 'k')

        def update(iframe):
            nrep = 64
            for i in range(nrep):
                sol.one_time_step()
            image.set_data(norme_q(sol))
            ax.title = "Solution t={0:f}".format(sol.t)

        # run the simulation
        fig.animate(update, interval=1)
        fig.show()
    else:
        while sol.t < Tf:
            sol.one_time_step()

    return sol
コード例 #4
0
# Authors:
#     Loic Gouarin <*****@*****.**>
#     Benjamin Graille <*****@*****.**>
#
# License: BSD 3 clause
"""
Example of the backward facing step in 2D with a D2Q9
"""
from six.moves import range
import pyLBM
dico = {
    'box': {
        'x': [0, 3],
        'y': [0, 1],
        'label': 0
    },
    'elements': [pyLBM.Parallelogram((0., 0.), (.5, 0.), (0., .5), label=1)],
    'space_step': 0.125,
    'schemes': [{
        'velocities': list(range(9))
    }],
}
dom = pyLBM.Domain(dico)
dom.visualize()
dom.visualize(view_distance=True, label=1)
コード例 #5
0
# Authors:
#     Loic Gouarin <*****@*****.**>
#     Benjamin Graille <*****@*****.**>
#
# License: BSD 3 clause
"""
Example of a complex geometry in 2D
"""
import pyLBM
square = pyLBM.Parallelogram((.1, .1), (.8, 0), (0, .8), isfluid=False)
strip = pyLBM.Parallelogram((0, .4), (1, 0), (0, .2), isfluid=True)
circle = pyLBM.Circle((.5, .5), .25, isfluid=True)
inner_square = pyLBM.Parallelogram((.4, .5), (.1, .1), (.1, -.1),
                                   isfluid=False)
d = {
    'box': {
        'x': [0, 1],
        'y': [0, 1],
        'label': 0
    },
    'elements': [square, strip, circle, inner_square],
}
g = pyLBM.Geometry(d)
g.visualize()
# rounded inner angles
g.add_elem(pyLBM.Parallelogram((0.1, 0.9), (0.05, 0), (0, -0.05),
                               isfluid=True))
g.add_elem(pyLBM.Circle((0.15, 0.85), 0.05, isfluid=False))
g.add_elem(pyLBM.Parallelogram((0.1, 0.1), (0.05, 0), (0, 0.05), isfluid=True))
g.add_elem(pyLBM.Circle((0.15, 0.15), 0.05, isfluid=False))
g.add_elem(