From 6cf5eab3af58851ddafacfd4f04d1789762f0e1b Mon Sep 17 00:00:00 2001 From: Martin Bauer <martin.bauer@fau.de> Date: Fri, 26 Jul 2019 09:01:07 +0200 Subject: [PATCH] Added documentation --- lbmpy/continuous_distribution_measures.py | 14 ++++++++------ lbmpy/cumulants.py | 2 +- lbmpy/maxwellian_equilibrium.py | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/lbmpy/continuous_distribution_measures.py b/lbmpy/continuous_distribution_measures.py index 3edee60..c89960f 100644 --- a/lbmpy/continuous_distribution_measures.py +++ b/lbmpy/continuous_distribution_measures.py @@ -69,9 +69,10 @@ def multi_differentiation(generating_function, index, symbols): Computes moment from moment-generating function or cumulant from cumulant-generating function, by differentiating the generating function, as specified by index and evaluating the derivative at symbols=0 - :param generating_function: function with is differentiated - :param index: the i'th index specifies how often to differentiate w.r.t. to symbols[i] - :param symbols: symbol to differentiate + Args: + generating_function: function with is differentiated + index: the i'th index specifies how often to differentiate w.r.t. to symbols[i] + symbols: symbol to differentiate """ assert len(index) == len(symbols), "Length of index and length of symbols has to match" @@ -119,9 +120,10 @@ def __continuous_moment_or_cumulant(func, moment, symbols, generating_function): def continuous_moment(func, moment, symbols=None): """Computes moment of given function. - :param func: function to compute moments of - :param moment: tuple or polynomial describing the moment - :param symbols: if moment is given as polynomial, pass the moment symbols, i.e. the dof of the polynomial + Args: + func: function to compute moments of + moment: tuple or polynomial describing the moment + symbols: if moment is given as polynomial, pass the moment symbols, i.e. the dof of the polynomial """ return __continuous_moment_or_cumulant(func, moment, symbols, moment_generating_function) diff --git a/lbmpy/cumulants.py b/lbmpy/cumulants.py index c7629ad..9544636 100644 --- a/lbmpy/cumulants.py +++ b/lbmpy/cumulants.py @@ -43,7 +43,7 @@ def __partition(collection): def __cumulant_raw_moment_transform(index, dependent_var_dict, outer_function, default_prefix, centralized): - """Function to express cumulants as function of moments as vice versa. + """Function to express cumulants as function of moments and vice versa. Uses multivariate version of Faa di Bruno's formula. diff --git a/lbmpy/maxwellian_equilibrium.py b/lbmpy/maxwellian_equilibrium.py index 25a5779..98b73d8 100644 --- a/lbmpy/maxwellian_equilibrium.py +++ b/lbmpy/maxwellian_equilibrium.py @@ -199,6 +199,24 @@ def get_moments_of_discrete_maxwellian_equilibrium(stencil, moments, def 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 + + Args: + term: compressible equilibrium value + rho: symbol for density + u: symbol for velocity + + Returns: + incompressible equilibrium value + """ term = sp.sympify(term) term = term.expand() if term.func != sp.Add: -- GitLab