Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Markus Holzer
lbmpy
Commits
f68761dc
Commit
f68761dc
authored
Aug 11, 2021
by
Frederik Hennig
Browse files
Renamed moment symbol bases
parent
84bfe3ac
Changes
8
Hide whitespace changes
Inline
Side-by-side
lbmpy/methods/centeredcumulant/centeredcumulantmethod.py
View file @
f68761dc
...
...
@@ -25,7 +25,7 @@ from .cumulant_transform import (
CentralMomentsToCumulantsByGeneratingFunc
)
from
lbmpy.moment_transforms
import
(
PRE_COLLISION_CENTRAL_MOMENT
,
POST_COLLISION_CENTRAL_MOMENT
,
PRE_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
,
POST_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
,
PdfsToCentralMomentsByShiftMatrix
)
from
lbmpy.methods.centeredcumulant.force_model
import
CenteredCumulantForceModel
...
...
@@ -53,7 +53,7 @@ def cached_backward_transform(transform_obj, *args, **kwargs):
@
disk_cache
def
relax_lower_order_central_moments
(
moment_indices
,
pre_collision_values
,
relaxation_rates
,
equilibrium_values
,
post_collision_base
=
POST_COLLISION_CENTRAL_MOMENT
):
post_collision_base
=
POST_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
):
post_collision_symbols
=
[
statistical_quantity_symbol
(
post_collision_base
,
i
)
for
i
in
moment_indices
]
equilibrium_vec
=
sp
.
Matrix
(
equilibrium_values
)
moment_vec
=
sp
.
Matrix
(
pre_collision_values
)
...
...
@@ -381,7 +381,7 @@ class CenteredCumulantBasedLbMethod(AbstractLbMethod):
# 4) Add relaxation rules for lower order moments
lower_order_moments
=
moments_up_to_order
(
1
,
dim
=
self
.
dim
)
lower_order_moment_symbols
=
[
statistical_quantity_symbol
(
PRE_COLLISION_CENTRAL_MOMENT
,
exp
)
lower_order_moment_symbols
=
[
statistical_quantity_symbol
(
PRE_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
,
exp
)
for
exp
in
lower_order_moments
]
lower_order_relaxation_infos
=
[
cumulant_to_relaxation_info_dict
[
exponent_to_polynomial_representation
(
e
)]
...
...
lbmpy/methods/centeredcumulant/cumulant_transform.py
View file @
f68761dc
...
...
@@ -12,7 +12,7 @@ from lbmpy.moments import (
from
itertools
import
product
,
chain
from
lbmpy.moment_transforms
import
(
AbstractMomentTransform
,
PRE_COLLISION_CENTRAL_MOMENT
,
POST_COLLISION_CENTRAL_MOMENT
AbstractMomentTransform
,
PRE_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
,
POST_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
)
# ======================= Central Moments <-> Cumulants ==============================================================
...
...
@@ -72,7 +72,7 @@ class CentralMomentsToCumulantsByGeneratingFunc(AbstractMomentTransform):
def
forward_transform
(
self
,
cumulant_base
=
PRE_COLLISION_CUMULANT
,
central_moment_base
=
PRE_COLLISION_CENTRAL_MOMENT
,
central_moment_base
=
PRE_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
,
simplification
=
True
,
subexpression_base
=
'sub_k_to_C'
):
simplification
=
self
.
_get_simp_strategy
(
simplification
)
...
...
@@ -92,7 +92,7 @@ class CentralMomentsToCumulantsByGeneratingFunc(AbstractMomentTransform):
def
backward_transform
(
self
,
cumulant_base
=
POST_COLLISION_CUMULANT
,
central_moment_base
=
POST_COLLISION_CENTRAL_MOMENT
,
central_moment_base
=
POST_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
,
simplification
=
True
,
omit_conserved_moments
=
False
,
subexpression_base
=
'sub_C_to_k'
):
...
...
lbmpy/methods/momentbased/centralmomentbasedmethod.py
View file @
f68761dc
...
...
@@ -7,7 +7,7 @@ from pystencils.sympyextensions import subs_additive
from
lbmpy.methods.abstractlbmethod
import
AbstractLbMethod
,
LbmCollisionRule
,
RelaxationInfo
from
lbmpy.methods.conservedquantitycomputation
import
AbstractConservedQuantityComputation
from
lbmpy.moment_transforms
import
(
FastCentralMomentTransform
,
PRE_COLLISION_CENTRAL_MOMENT
,
POST_COLLISION_CENTRAL_MOMENT
)
PRE_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
,
POST_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
)
from
lbmpy.moments
import
(
MOMENT_SYMBOLS
,
moment_matrix
,
set_up_shift_matrix
,
statistical_quantity_symbol
)
...
...
@@ -16,7 +16,7 @@ from lbmpy.moments import (MOMENT_SYMBOLS, moment_matrix, set_up_shift_matrix,
def
relax_central_moments
(
moment_indices
,
pre_collision_values
,
relaxation_rates
,
equilibrium_values
,
force_terms
,
post_collision_base
=
POST_COLLISION_CENTRAL_MOMENT
):
post_collision_base
=
POST_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
):
post_collision_symbols
=
[
sp
.
Symbol
(
f
'
{
post_collision_base
}
_
{
""
.
join
(
str
(
i
)
for
i
in
m
)
}
'
)
for
m
in
moment_indices
]
equilibrium_vec
=
sp
.
Matrix
(
equilibrium_values
)
moment_vec
=
sp
.
Matrix
(
pre_collision_values
)
...
...
@@ -271,7 +271,7 @@ class CentralMomentBasedLbMethod(AbstractLbMethod):
moments_as_exponents
=
pdfs_to_c_transform
.
moment_exponents
# 2) Collision
moment_symbols
=
[
statistical_quantity_symbol
(
PRE_COLLISION_CENTRAL_MOMENT
,
exp
)
moment_symbols
=
[
statistical_quantity_symbol
(
PRE_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
,
exp
)
for
exp
in
moments_as_exponents
]
relaxation_infos
=
[
moment_to_relaxation_info_dict
[
m
]
for
m
in
self
.
moments
]
...
...
lbmpy/moment_transforms/__init__.py
View file @
f68761dc
from
.abstractmomenttransform
import
(
PRE_COLLISION_RAW_MOMENT
,
POST_COLLISION_RAW_MOMENT
,
PRE_COLLISION_
MONOMIAL_
RAW_MOMENT
,
POST_COLLISION_
MONOMIAL_
RAW_MOMENT
,
PRE_COLLISION_MOMENT
,
POST_COLLISION_MOMENT
,
PRE_COLLISION_CENTRAL_MOMENT
,
POST_COLLISION_CENTRAL_MOMENT
PRE_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
,
POST_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
)
from
.abstractmomenttransform
import
AbstractMomentTransform
...
...
@@ -22,7 +22,7 @@ __all__ = [
"PdfsToCentralMomentsByMatrix"
,
"PdfsToCentralMomentsByShiftMatrix"
,
"FastCentralMomentTransform"
,
"PRE_COLLISION_RAW_MOMENT"
,
"POST_COLLISION_RAW_MOMENT"
,
"PRE_COLLISION_
MONOMIAL_
RAW_MOMENT"
,
"POST_COLLISION_
MONOMIAL_
RAW_MOMENT"
,
"PRE_COLLISION_MOMENT"
,
"POST_COLLISION_MOMENT"
,
"PRE_COLLISION_CENTRAL_MOMENT"
,
"POST_COLLISION_CENTRAL_MOMENT"
"PRE_COLLISION_
MONOMIAL_
CENTRAL_MOMENT"
,
"POST_COLLISION_
MONOMIAL_
CENTRAL_MOMENT"
]
lbmpy/moment_transforms/abstractmomenttransform.py
View file @
f68761dc
...
...
@@ -6,14 +6,14 @@ from lbmpy.moments import (
exponents_to_polynomial_representations
,
extract_monomials
,
exponent_tuple_sort_key
)
PRE_COLLISION_RAW_MOMENT
=
'm'
POST_COLLISION_RAW_MOMENT
=
'm_post'
PRE_COLLISION_
MONOMIAL_
RAW_MOMENT
=
'm'
POST_COLLISION_
MONOMIAL_
RAW_MOMENT
=
'm_post'
PRE_COLLISION_MOMENT
=
'M'
POST_COLLISION_MOMENT
=
'M_post'
PRE_COLLISION_CENTRAL_MOMENT
=
'kappa'
POST_COLLISION_CENTRAL_MOMENT
=
'kappa_post'
PRE_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
=
'kappa'
POST_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
=
'kappa_post'
class
AbstractMomentTransform
:
...
...
lbmpy/moment_transforms/centralmomenttransforms.py
View file @
f68761dc
...
...
@@ -12,7 +12,7 @@ from lbmpy.moments import statistical_quantity_symbol as sq_sym
from
.abstractmomenttransform
import
(
AbstractMomentTransform
,
PRE_COLLISION_CENTRAL_MOMENT
,
POST_COLLISION_CENTRAL_MOMENT
PRE_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
,
POST_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
)
from
.momenttransforms
import
PdfsToMomentsByChimeraTransform
...
...
@@ -23,8 +23,8 @@ class PdfsToCentralMomentsByMatrix(AbstractMomentTransform):
def
__init__
(
self
,
stencil
,
moment_polynomials
,
equilibrium_density
,
equilibrium_velocity
,
pre_collision_central_moment_base
=
PRE_COLLISION_CENTRAL_MOMENT
,
post_collision_central_moment_base
=
POST_COLLISION_CENTRAL_MOMENT
,
pre_collision_central_moment_base
=
PRE_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
,
post_collision_central_moment_base
=
POST_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
,
**
kwargs
):
assert
len
(
moment_polynomials
)
==
len
(
stencil
),
'Number of moments must match stencil'
...
...
@@ -100,8 +100,8 @@ class FastCentralMomentTransform(AbstractMomentTransform):
equilibrium_density
,
equilibrium_velocity
,
conserved_quantity_equations
=
None
,
pre_collision_central_moment_base
=
PRE_COLLISION_CENTRAL_MOMENT
,
post_collision_central_moment_base
=
POST_COLLISION_CENTRAL_MOMENT
,
pre_collision_central_moment_base
=
PRE_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
,
post_collision_central_moment_base
=
POST_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
,
**
kwargs
):
assert
len
(
moment_polynomials
)
==
len
(
stencil
),
'Number of moments must match stencil'
...
...
@@ -321,8 +321,8 @@ class PdfsToCentralMomentsByShiftMatrix(AbstractMomentTransform):
equilibrium_density
,
equilibrium_velocity
,
conserved_quantity_equations
=
None
,
pre_collision_central_moment_base
=
PRE_COLLISION_CENTRAL_MOMENT
,
post_collision_central_moment_base
=
POST_COLLISION_CENTRAL_MOMENT
,
pre_collision_central_moment_base
=
PRE_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
,
post_collision_central_moment_base
=
POST_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
,
**
kwargs
):
assert
len
(
moment_polynomials
)
==
len
(
stencil
),
'Number of moments must match stencil'
...
...
lbmpy/moment_transforms/momenttransforms.py
View file @
f68761dc
...
...
@@ -12,7 +12,7 @@ from lbmpy.moments import statistical_quantity_symbol as sq_sym
from
.abstractmomenttransform
import
(
AbstractMomentTransform
,
PRE_COLLISION_MOMENT
,
POST_COLLISION_MOMENT
,
PRE_COLLISION_RAW_MOMENT
,
POST_COLLISION_RAW_MOMENT
PRE_COLLISION_
MONOMIAL_
RAW_MOMENT
,
POST_COLLISION_
MONOMIAL_
RAW_MOMENT
)
...
...
@@ -157,8 +157,8 @@ class PdfsToMomentsByChimeraTransform(AbstractMomentTransform):
conserved_quantity_equations
=
None
,
pre_collision_moment_base
=
PRE_COLLISION_MOMENT
,
post_collision_moment_base
=
POST_COLLISION_MOMENT
,
pre_collision_raw_moment_base
=
PRE_COLLISION_RAW_MOMENT
,
post_collision_raw_moment_base
=
POST_COLLISION_RAW_MOMENT
,
pre_collision_raw_moment_base
=
PRE_COLLISION_
MONOMIAL_
RAW_MOMENT
,
post_collision_raw_moment_base
=
POST_COLLISION_
MONOMIAL_
RAW_MOMENT
,
**
kwargs
):
if
moment_polynomials
:
...
...
lbmpy_tests/centeredcumulant/test_central_moment_transform.py
View file @
f68761dc
...
...
@@ -7,7 +7,7 @@ import pytest
from
lbmpy.stencils
import
get_stencil
from
lbmpy.moment_transforms
import
(
PdfsToCentralMomentsByMatrix
,
FastCentralMomentTransform
,
PdfsToCentralMomentsByShiftMatrix
,
PRE_COLLISION_CENTRAL_MOMENT
,
POST_COLLISION_CENTRAL_MOMENT
PRE_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
,
POST_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
)
...
...
@@ -54,7 +54,7 @@ def test_forward_transform(type, stencil):
f_to_k_shift
=
f_to_k_shift
.
new_without_subexpressions
().
main_assignments_dict
for
e
in
moment_exponents
:
moment_symbol
=
statistical_quantity_symbol
(
PRE_COLLISION_CENTRAL_MOMENT
,
e
)
moment_symbol
=
statistical_quantity_symbol
(
PRE_COLLISION_
MONOMIAL_
CENTRAL_MOMENT
,
e
)
rhs_matrix
=
f_to_k_matrix
[
moment_symbol
].
expand
()
rhs_fast
=
f_to_k_fast
[
moment_symbol
].
expand
()
rhs_shift
=
f_to_k_shift
[
moment_symbol
].
expand
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment