Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
lbmpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pycodegen
lbmpy
Commits
9f29efa8
Commit
9f29efa8
authored
5 years ago
by
Michael Kuron
Browse files
Options
Downloads
Patches
Plain Diff
Add D2Q9 MRT from literature
parent
1ebe2216
No related branches found
No related tags found
1 merge request
!17
Use Gram-Schmidt for create_mrt_orthogonal
Pipeline
#20089
failed
5 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lbmpy/methods/creationfunctions.py
+10
-1
10 additions, 1 deletion
lbmpy/methods/creationfunctions.py
lbmpy/moments.py
+1
-1
1 addition, 1 deletion
lbmpy/moments.py
lbmpy_tests/test_momentbased_methods_equilibrium.py
+8
-11
8 additions, 11 deletions
lbmpy_tests/test_momentbased_methods_equilibrium.py
with
19 additions
and
13 deletions
lbmpy/methods/creationfunctions.py
+
10
−
1
View file @
9f29efa8
...
@@ -432,7 +432,16 @@ def mrt_orthogonal_modes_literature(stencil, is_weighted, is_cumulant):
...
@@ -432,7 +432,16 @@ def mrt_orthogonal_modes_literature(stencil, is_weighted, is_cumulant):
x
,
y
,
z
=
MOMENT_SYMBOLS
x
,
y
,
z
=
MOMENT_SYMBOLS
one
=
sp
.
Rational
(
1
,
1
)
one
=
sp
.
Rational
(
1
,
1
)
if
have_same_entries
(
stencil
,
get_stencil
(
"
D3Q15
"
))
and
is_weighted
:
if
have_same_entries
(
stencil
,
get_stencil
(
"
D2Q9
"
))
and
is_weighted
:
# Reference:
# Duenweg, B., Schiller, U. D., & Ladd, A. J. (2007). Statistical mechanics of the fluctuating
# lattice Boltzmann equation. Physical Review E, 76(3)
sq
=
x
**
2
+
y
**
2
all_moments
=
[
one
,
x
,
y
,
3
*
sq
-
2
,
2
*
x
**
2
-
sq
,
x
*
y
,
(
3
*
sq
-
4
)
*
x
,
(
3
*
sq
-
4
)
*
y
,
9
*
sq
**
2
-
15
*
sq
+
2
]
nested_moments
=
list
(
sort_moments_into_groups_of_same_order
(
all_moments
).
values
())
return
nested_moments
elif
have_same_entries
(
stencil
,
get_stencil
(
"
D3Q15
"
))
and
is_weighted
:
sq
=
x
**
2
+
y
**
2
+
z
**
2
sq
=
x
**
2
+
y
**
2
+
z
**
2
nested_moments
=
[
nested_moments
=
[
[
one
,
x
,
y
,
z
],
# [0, 3, 5, 7]
[
one
,
x
,
y
,
z
],
# [0, 3, 5, 7]
...
...
This diff is collapsed.
Click to expand it.
lbmpy/moments.py
+
1
−
1
View file @
9f29efa8
...
@@ -282,7 +282,7 @@ def is_bulk_moment(moment, dim):
...
@@ -282,7 +282,7 @@ def is_bulk_moment(moment, dim):
for
prefactor
,
monomial
in
moment
:
for
prefactor
,
monomial
in
moment
:
if
sum
(
monomial
)
==
2
:
if
sum
(
monomial
)
==
2
:
quadratic
=
True
quadratic
=
True
for
i
,
exponent
in
enumerate
(
monomial
):
for
i
,
exponent
in
enumerate
(
monomial
[:
dim
]
):
if
exponent
==
2
:
if
exponent
==
2
:
found
[
i
]
+=
prefactor
found
[
i
]
+=
prefactor
elif
sum
(
monomial
)
>
2
:
elif
sum
(
monomial
)
>
2
:
...
...
This diff is collapsed.
Click to expand it.
lbmpy_tests/test_momentbased_methods_equilibrium.py
+
8
−
11
View file @
9f29efa8
...
@@ -70,19 +70,12 @@ def test_relaxation_rate_setter():
...
@@ -70,19 +70,12 @@ def test_relaxation_rate_setter():
def
test_mrt_orthogonal
():
def
test_mrt_orthogonal
():
m
=
create_mrt_orthogonal
(
get_stencil
(
"
D2Q9
"
),
maxwellian_moments
=
True
,
weighted
=
False
)
m_ref
=
{}
assert
m
.
is_orthogonal
m
=
create_mrt_orthogonal
(
get_stencil
(
"
D2Q9
"
),
maxwellian_moments
=
True
,
weighted
=
True
)
assert
m
.
is_weighted_orthogonal
m
=
create_mrt_orthogonal
(
get_stencil
(
"
D3Q19
"
),
maxwellian_moments
=
True
,
weighted
=
False
)
assert
m
.
is_orthogonal
m
=
create_mrt_orthogonal
(
get_stencil
(
"
D3Q19
"
),
maxwellian_moments
=
True
,
weighted
=
True
)
moments
=
mrt_orthogonal_modes_literature
(
get_stencil
(
"
D2Q9
"
),
True
,
False
)
m
=
create_mrt_orthogonal
(
get_stencil
(
"
D2Q9
"
),
maxwellian_moments
=
True
,
nested_moments
=
moments
)
assert
m
.
is_weighted_orthogonal
assert
m
.
is_weighted_orthogonal
m_ref
[(
"
D2Q9
"
,
True
)]
=
m
m_ref
=
{}
moments
=
mrt_orthogonal_modes_literature
(
get_stencil
(
"
D3Q15
"
),
True
,
False
)
moments
=
mrt_orthogonal_modes_literature
(
get_stencil
(
"
D3Q15
"
),
True
,
False
)
m
=
create_mrt_orthogonal
(
get_stencil
(
"
D3Q15
"
),
maxwellian_moments
=
True
,
nested_moments
=
moments
)
m
=
create_mrt_orthogonal
(
get_stencil
(
"
D3Q15
"
),
maxwellian_moments
=
True
,
nested_moments
=
moments
)
...
@@ -102,6 +95,10 @@ def test_mrt_orthogonal():
...
@@ -102,6 +95,10 @@ def test_mrt_orthogonal():
for
weighted
in
[
True
,
False
]:
for
weighted
in
[
True
,
False
]:
for
stencil
in
[
"
D2Q9
"
,
"
D3Q15
"
,
"
D3Q19
"
,
"
D3Q27
"
]:
for
stencil
in
[
"
D2Q9
"
,
"
D3Q15
"
,
"
D3Q19
"
,
"
D3Q27
"
]:
m
=
create_mrt_orthogonal
(
get_stencil
(
stencil
),
maxwellian_moments
=
True
,
weighted
=
weighted
)
m
=
create_mrt_orthogonal
(
get_stencil
(
stencil
),
maxwellian_moments
=
True
,
weighted
=
weighted
)
if
weighted
:
assert
m
.
is_weighted_orthogonal
else
:
assert
m
.
is_orthogonal
bulk_moments
=
set
([
mom
for
mom
in
m
.
moments
if
is_bulk_moment
(
mom
,
m
.
dim
)])
bulk_moments
=
set
([
mom
for
mom
in
m
.
moments
if
is_bulk_moment
(
mom
,
m
.
dim
)])
shear_moments
=
set
([
mom
for
mom
in
m
.
moments
if
is_shear_moment
(
mom
,
m
.
dim
)])
shear_moments
=
set
([
mom
for
mom
in
m
.
moments
if
is_shear_moment
(
mom
,
m
.
dim
)])
assert
len
(
bulk_moments
)
==
1
assert
len
(
bulk_moments
)
==
1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment