Maxwellian Equilibrium

This module contains the continuous Maxwell-Boltzmann equilibrium and its discrete polynomial approximation, often used to formulate lattice-Boltzmann methods for hydrodynamics. Additionally functions are provided to compute moments and cumulants of these distributions.

discrete_maxwellian_equilibrium(stencil, rho=rho, u=(u_0, u_1, u_2), order=2, c_s_sq=c_s ** 2, compressible=True)

Memoized version of discrete_maxwellian_equilibrium(stencil, rho=rho, u=(u_0, u_1, u_2), order=2, c_s_sq=c_s**2, compressible=True)

Returns the common discrete LBM equilibrium as a list of sympy expressions

Parameters
  • stencil – tuple of directions

  • rho – sympy symbol for the density

  • u – symbols for macroscopic velocity, only the first ‘dim’ entries are used

  • order – highest order of velocity terms (for hydrodynamics order 2 is sufficient)

  • c_s_sq – square of speed of sound

  • compressible – compressibility

generate_equilibrium_by_matching_moments(stencil, moments, rho=rho, u=(u_0, u_1, u_2), c_s_sq=c_s ** 2, order=None)

Memoized version of generate_equilibrium_by_matching_moments(stencil, moments, rho=rho, u=(u_0, u_1, u_2), c_s_sq=c_s**2, order=None)

Computes discrete equilibrium, by setting the discrete moments to values taken from the continuous Maxwellian. The number of moments has to match the number of directions in the stencil. For documentation of other parameters see get_equilibrium_values_of_maxwell_boltzmann_function()

continuous_maxwellian_equilibrium(dim=3, rho=rho, u=(u_0, u_1, u_2), v=(v_0, v_1, v_2), c_s_sq=c_s ** 2)

Memoized version of continuous_maxwellian_equilibrium(dim=3, rho=rho, u=(u_0, u_1, u_2), v=(v_0, v_1, v_2), c_s_sq=c_s**2)

Returns sympy expression of Maxwell Boltzmann distribution

Parameters
  • dim – number of space dimensions

  • rho – sympy symbol for the density

  • u – symbols for macroscopic velocity (expected value for velocity)

  • v – symbols for particle velocity

  • c_s_sq – symbol for speed of sound squared, defaults to symbol c_s**2

get_equilibrium_values_of_maxwell_boltzmann_function(moments, dim, rho=rho, u=(u_0, u_1, u_2), c_s_sq=c_s ** 2, order=None, space='moment')

Memoized version of get_equilibrium_values_of_maxwell_boltzmann_function(moments, dim, rho=rho, u=(u_0, u_1, u_2), c_s_sq=c_s**2, order=None, space=’moment’)

Computes equilibrium values from the continuous Maxwell Boltzmann equilibrium.

Parameters
  • moments – moments to compute, either in polynomial or exponent-tuple form

  • dim – dimension (2 or 3)

  • rho – symbol or value for the density

  • u – symbols or values for the macroscopic velocity

  • c_s_sq – symbol for speed of sound squared, defaults to symbol c_s**2

  • order – if this parameter is not None, terms that have a higher polynomial order in the macroscopic velocity are removed

  • space – function space of the equilibrium values. Either moment, central moment or cumulant space are supported.

>>> get_equilibrium_values_of_maxwell_boltzmann_function( ( (0,0,0), (1,0,0), (0,1,0), (0,0,1), (2,0,0) ), dim=3 )
[rho, rho*u_0, rho*u_1, rho*u_2, rho*(c_s**2 + u_0**2)]
get_moments_of_discrete_maxwellian_equilibrium(stencil, moments, rho=rho, u=(u_0, u_1, u_2), c_s_sq=c_s ** 2, order=None, compressible=True)

Memoized version of get_moments_of_discrete_maxwellian_equilibrium(stencil, moments, rho=rho, u=(u_0, u_1, u_2), c_s_sq=c_s**2, order=None, compressible=True)

Compute moments of discrete maxwellian equilibrium.

Parameters
  • stencil – stencil is required to compute moments of discrete function

  • moments – moments in polynomial or exponent-tuple form

  • rho – symbol or value for the density

  • u – symbols or values for the macroscopic velocity

  • c_s_sq – symbol for speed of sound squared, defaults to symbol c_s**2

  • order – highest order of u terms

  • compressible – compressible or incompressible form

compressible_to_incompressible_moment_value(term, rho, u)

Compressible to incompressible equilibrium moments

Transforms so-called compressible equilibrium moments (as obtained from the continuous Maxwellian) by removing the density factor in all monomials where velocity components are multiplied to the density.

Examples

>>> rho, *u = sp.symbols("rho u_:2")
>>> compressible_to_incompressible_moment_value(rho  + rho * u[0] + rho * u[0]*u[1], rho, u)
rho + u_0*u_1 + u_0
Parameters
  • term – compressible equilibrium value

  • rho – symbol for density

  • u – symbol for velocity

Returns

incompressible equilibrium value