Scenario setup

This module contains functions to set up pre-defined scenarios like a lid-driven cavity or channel flows. It is a good starting point if you are new to lbmpy. >>> from lbmpy.enums import Method >>> scenario = create_channel(domain_size=(20, 10), force=1e-5, … method=Method.SRT, relaxation_rate=1.9) >>> scenario.run(100)

All scenarios can be modified, for example you can create a simple channel first, then place an object in it:

>>> from lbmpy.boundaries import NoSlip
>>> from pystencils.slicing import make_slice
>>> flag = scenario.boundary_handling.set_boundary(NoSlip(), make_slice[0.3:0.4, 0.0:0.3])

Functions for scenario setup:

All of the following scenario creation functions take keyword arguments specifying which LBM method should be used and a optimization dictionary, defining performance related options. These parameters are documented at lbmpy.creationfunctions. The only mandatory keyword parameter is relaxation_rate, that defines the viscosity of the fluid (valid values being between 0 and 2).

create_fully_periodic_flow(initial_velocity, periodicity_in_kernel=False, lbm_kernel=None, data_handling=None, parallel=False, **kwargs)

Creates a fully periodic setup with prescribed velocity field.

Parameters:
  • initial_velocity – numpy array that defines an initial velocity for each cell. The shape of this array determines the domain size.

  • periodicity_in_kernel – don’t use boundary handling for periodicity, but directly generate the kernel periodic

  • lbm_kernel – an LBM function, which would otherwise automatically created

  • data_handling – data handling instance that is used to create the necessary fields. If a data handling is passed the periodicity and parallel arguments are ignored.

  • parallel – True for distributed memory parallelization with waLBerla

  • kwargs – other parameters are passed on to the method, see lbmpy.creationfunctions

Returns:

instance of Scenario

create_lid_driven_cavity(domain_size=None, lid_velocity=0.005, lbm_kernel=None, parallel=False, data_handling=None, **kwargs)

Creates a lid driven cavity scenario.

Parameters:
  • domain_size – tuple specifying the number of cells in each dimension

  • lid_velocity – x velocity of lid in lattice coordinates.

  • lbm_kernel – an LBM function, which would otherwise automatically created

  • kwargs – other parameters are passed on to the method, see lbmpy.creationfunctions

  • parallel – True for distributed memory parallelization with waLBerla

  • data_handling – see documentation of create_fully_periodic_flow()

Returns:

instance of Scenario

create_channel(domain_size=None, force=None, pressure_difference=None, u_max=None, diameter_callback=None, duct=False, wall_boundary=<lbmpy.boundaries.boundaryconditions.NoSlip object>, parallel=False, data_handling=None, **kwargs)

Create a channel scenario (2D or 3D).

The channel can be driven either by force, velocity inflow or pressure difference. Choose one and pass exactly one of the parameters ‘force’, ‘pressure_difference’ or ‘u_max’.

Parameters:
  • domain_size – size of the simulation domain. First coordinate is the flow direction.

  • force – Periodic channel, driven by a body force. Pass force in flow direction in lattice units here.

  • pressure_difference – Inflow and outflow are fixed pressure conditions, with the given pressure difference.

  • u_max – Parabolic velocity profile prescribed at inflow, pressure boundary =1.0 at outflow.

  • diameter_callback – optional callback for channel with varying diameters. Only valid if duct=False. The callback receives x coordinate array and domain_size and returns a an array of diameters of the same shape

  • duct – if true the channel has rectangular instead of circular cross section

  • wall_boundary – instance of boundary class that should be set at the channel walls

  • parallel – True for distributed memory parallelization with walberla

  • data_handling – see documentation of create_fully_periodic_flow()

  • kwargs – all other keyword parameters are passed directly to scenario class.