LBM module


This module is deprecated and about to be replaced by the native Python module lbmpy

Creation Functions

makeLatticeModel(stencil, collisionModel, forceModel, compressible, equilibriumAccuracyOrder=2)

Creates a new lattice model. A lattice model encapsulates all information about the lattice Boltzmann method.

  • stencil – a string describing the stencil in DxQy notation e.g. ‘D2Q9’, ‘D3Q19’, ‘D3Q27’
  • collisionModel – an instance of a collision model
  • forceModel – an instance of a force model
  • compressible – choose either a compressible or incompressible LBM scheme
  • equilibriumAccuracyOrder – order of the equilibrium distribution. Valid values are 1 and 2. If not sure use 2 here.


The collision model and force model object are copied into the lattice model object. Changes to the passed force or collision model do not affect the state of the lattice model. Similarly after a sweep was created with a lattice model, the sweep itself is not changed when the lattice model it was created with was changed.

addPdfFieldToStorage(blocks, name, latticeModel, initialVelocity=(0, 0, 0), initialDensity=1.0, ghostlayers=1, layout=field.zyxf, densityAdaptor="", velocityAdaptor="")

Adds a PDFField to the provided blockstorage and optionally a density and velocity adaptor.

  • blocks – blockstorage where the pdf field should be added to
  • name – block data id (string) of the new pdf field
  • latticeModel – see makeLatticeModel() . The lattice model is copied into the pdf field. Later changes to the provided object do not affect the pdf field. To change parameters of the lattice model later, one has to iterate over all blocks, get the pdf field and retrieve a lattice model reference from it.
  • initialVelocity – lattice velocity the field is initialized with
  • initialDensity – density the field is initialized with
  • ghostlayers – number of ghost layers, has to be at least one
  • layout – memory layout of the field, ( see documentation of field module )
  • densityAdaptor – if a nonempty string is passed a FieldAdaptor for the density is created with a blockdataID of the given name
  • velocityAdaptor – if a nonempty string is passed a FieldAdaptor for the velocity is created with a blockdataID of the given name
makeCellwiseSweep(blocks, pdfFieldID, flagFieldID="", flagList=[], velocityFieldID="")

Creates a new LBM sweep.

  • blocks – block storage where pdf field ( and if used, the flag field ) are stored
  • pdfFieldID – string identifier of the pdf field
  • flagFieldID – string identifier of the flag field. If empty string is passed, the LBM sweep is executed on all cells.
  • flagList – Only necessary when a flagFieldID was specified. Pass a list of flag identifiers here, describing the flags where the sweep should be executed
  • velocityFieldID – optional velocity field ( field of fSize=3 and type=float) where the calculated velocity is written to.
class PdfField(field.GhostLayerField)
setDensityAndVelocity(slice, velocity, density)
setToEquilibrium(slice, velocity, density)
getDensity(x, y, z)
getDensitySI(x, y, z, rho_SI)
getMomentumDensity(x, y, z)
getEquilibriumMomentumDensity(x, y, z)
getVelocity(x, y, z)
getVelocitySI(x, y, z. dx_SI, dt_SI)
getEquilibriumVelocity(x, y, z)
getPressureTensor(x, y, z)

Boundary Handling

class BoundaryHandling
isEmpty(x, y, z)
isNearBoundary(x, y, z)
isBoundary(x, y, z)
isDomain(x, y, z)
setDomain(x, y, z | slice)
forceDomain(x, y, z | slice)
fillWithDomain(x, y, z | slice | nrOfGhostLayersToInclude)
setBoundary(name, x, y, z | name, slice)
forceBoundary(name, x, y, z | name, slice)
removeDomain(x, y, z | slice | nrOfGhostLayersToInclude)
removeBoundary(x, y, z | slice | nrOfGhostLayersToInclude)
clear(x, y, z | slice | nrOfGhostLayersToInclude)

Collision Models

class collisionModels.SRT

Single Relaxation Time (BGK) lattice model

__init__(omega, level=0)

Relaxation parameter ( = 1/tau )

reset(omega, level=0)

Sets a new relaxation parameter for the given level

class collisionModels.SRTField(SRT)
__init__(omegaFieldID, level=0)
Parameters:omegaFieldID – this blockdata has to point to a floating point field of f-size=1 where for each cell a different omega value is stored.
class collisionModels.TRT
__init__(lambda_e, lambda_d, level=0)
static constructWithMagicNumber(omega, magicNumber=3.0/16.0, level=0)
reset(lambda_e, lambda_d, level=0)
resetWithMagicNumber(omega, magicNumber=3.0/16.0, level=0)
class collisionModels.D3Q19MRT
__init__(s1, s2, s4, s9, s10, s16, level=0)
static constructTRTWithMagicNumber(omega, magicNumber=3.0/16.0, level=0)
static constructTRT(lambda_e, lambda_d, level=0)
static constructPanWithMagicNumber(omega, magicNumber=3.0/16.0, level=0)
static constructPan(lambda_e, lambda_d, level=0)

Force Models

class forceModels.NoForce
class forceModels.SimpleConstant
__init__(force, level=0)
class forceModels.EDMField
class forceModels.LuoConstant
__init__(force, level=0)
class forceModels.LuoField
class forceModels.GuoConstant
__init__(force, level=0)
class forceModels.Correction

Lattice Models

class LatticeModel

Lattice models are created with the function makeLatticeModel() and encapsulate information about stencil, collision operator and force model. This information can be accessed through the following read-only attributes.


a copy of the collision model


a copy of the force model


boolean signaling a compressible model


a string describing the stencil in DxQy notation


name of stencil that should be used for communication. In most cases this is the same as stencilName


a list of tuples containing the directions of the stencil. e.g. (0,0,0) for center, (1,0,0) for east etc. For a DxQy stencil the list as y entries, the tuples are of length x.