Skip to content
Snippets Groups Projects
Commit 6cf5eab3 authored by Martin Bauer's avatar Martin Bauer
Browse files

Added documentation

parent eb7c6efb
No related merge requests found
...@@ -69,9 +69,10 @@ def multi_differentiation(generating_function, index, symbols): ...@@ -69,9 +69,10 @@ def multi_differentiation(generating_function, index, symbols):
Computes moment from moment-generating function or cumulant from cumulant-generating function, 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 by differentiating the generating function, as specified by index and evaluating the derivative at symbols=0
:param generating_function: function with is differentiated Args:
:param index: the i'th index specifies how often to differentiate w.r.t. to symbols[i] generating_function: function with is differentiated
:param symbols: symbol to differentiate 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" 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): ...@@ -119,9 +120,10 @@ def __continuous_moment_or_cumulant(func, moment, symbols, generating_function):
def continuous_moment(func, moment, symbols=None): def continuous_moment(func, moment, symbols=None):
"""Computes moment of given function. """Computes moment of given function.
:param func: function to compute moments of Args:
:param moment: tuple or polynomial describing the moment func: function to compute moments of
:param symbols: if moment is given as polynomial, pass the moment symbols, i.e. the dof of the polynomial 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) return __continuous_moment_or_cumulant(func, moment, symbols, moment_generating_function)
......
...@@ -43,7 +43,7 @@ def __partition(collection): ...@@ -43,7 +43,7 @@ def __partition(collection):
def __cumulant_raw_moment_transform(index, dependent_var_dict, outer_function, default_prefix, centralized): 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. Uses multivariate version of Faa di Bruno's formula.
......
...@@ -199,6 +199,24 @@ def get_moments_of_discrete_maxwellian_equilibrium(stencil, moments, ...@@ -199,6 +199,24 @@ def get_moments_of_discrete_maxwellian_equilibrium(stencil, moments,
def compressible_to_incompressible_moment_value(term, rho, u): 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 = sp.sympify(term)
term = term.expand() term = term.expand()
if term.func != sp.Add: if term.func != sp.Add:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment