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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Sebastian Bindgen
lbmpy
Commits
efb97424
Commit
efb97424
authored
4 years ago
by
Michael Kuron
Browse files
Options
Downloads
Patches
Plain Diff
Test the simple force model’s moments
parent
46415911
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lbmpy_tests/test_force.py
+35
-23
35 additions, 23 deletions
lbmpy_tests/test_force.py
with
35 additions
and
23 deletions
lbmpy_tests/test_force.py
+
35
−
23
View file @
efb97424
...
...
@@ -82,7 +82,8 @@ def test_total_momentum(method, force_model, omega):
@pytest.mark.parametrize
(
"
stencil
"
,
[
"
D2Q9
"
,
"
D3Q15
"
,
"
D3Q19
"
,
"
D3Q27
"
])
def
test_stress
(
stencil
):
@pytest.mark.parametrize
(
"
force_model
"
,
[
"
simple
"
,
"
schiller
"
])
def
test_modes
(
stencil
,
force_model
):
"""
check Schiller
'
s force term in mode space
"""
stencil
=
get_stencil
(
stencil
)
dim
=
len
(
stencil
[
0
])
...
...
@@ -98,31 +99,42 @@ def test_stress(stencil):
stencil
=
stencil
,
relaxation_rates
=
[
omega_s
,
omega_b
,
omega_o
,
omega_e
,
omega_o
,
omega_e
],
compressible
=
True
,
force_model
=
"
schiller
"
,
force_model
=
force_model
,
force
=
F
)
force_moments
=
sp
.
simplify
(
method
.
moment_matrix
*
sp
.
Matrix
(
method
.
force_model
(
method
)))
# The m
omentum
mode
s
should
contain the force
assert
list
(
force_moments
[
1
:
dim
+
1
])
==
F
# The m
ass
mode should
be zero
assert
force_moments
[
0
]
==
0
# The stress modes should match eq. 47 from https://doi.org/10.1023/A:1010414013942
u
=
method
.
first_order_equilibrium_moment_symbols
def
traceless
(
m
):
tr
=
sp
.
simplify
(
sp
.
Trace
(
m
))
return
m
-
tr
/
m
.
shape
[
0
]
*
sp
.
eye
(
m
.
shape
[
0
])
C
=
sp
.
Rational
(
1
,
2
)
*
(
2
+
omega_s
)
*
(
traceless
(
sp
.
Matrix
(
u
)
*
sp
.
Matrix
(
F
).
transpose
())
+
\
traceless
(
sp
.
Matrix
(
F
)
*
sp
.
Matrix
(
u
).
transpose
()))
+
\
sp
.
Rational
(
1
,
3
)
*
(
2
+
omega_b
)
*
sp
.
Matrix
(
u
).
dot
(
F
)
*
sp
.
eye
(
method
.
dim
)
# The momentum moments should contain the force
assert
list
(
force_moments
[
1
:
dim
+
1
])
==
F
num_stresses
=
(
dim
*
dim
-
dim
)
//
2
+
dim
subs
=
{
sp
.
Symbol
(
chr
(
ord
(
"
x
"
)
+
i
))
*
sp
.
Symbol
(
chr
(
ord
(
"
x
"
)
+
j
))
:
C
[
i
,
j
]
for
i
in
range
(
dim
)
for
j
in
range
(
dim
)}
for
force_moment
,
moment
in
zip
(
force_moments
[
dim
+
1
:
dim
+
1
+
num_stresses
],
method
.
moments
[
dim
+
1
:
dim
+
1
+
num_stresses
]):
ref
=
moment
.
subs
(
subs
)
diff
=
sp
.
simplify
(
ref
-
force_moment
)
if
is_bulk_moment
(
moment
,
dim
):
assert
diff
==
0
or
isinstance
(
diff
,
sp
.
Rational
)
# difference should be zero or a constant
else
:
assert
diff
==
0
# difference should be zero
if
force_model
==
"
schiller
"
:
num_stresses
=
(
dim
*
dim
-
dim
)
//
2
+
dim
# The stress moments should match eq. 47 from https://doi.org/10.1023/A:1010414013942
u
=
method
.
first_order_equilibrium_moment_symbols
def
traceless
(
m
):
tr
=
sp
.
simplify
(
sp
.
Trace
(
m
))
return
m
-
tr
/
m
.
shape
[
0
]
*
sp
.
eye
(
m
.
shape
[
0
])
C
=
sp
.
Rational
(
1
,
2
)
*
(
2
+
omega_s
)
*
(
traceless
(
sp
.
Matrix
(
u
)
*
sp
.
Matrix
(
F
).
transpose
())
+
\
traceless
(
sp
.
Matrix
(
F
)
*
sp
.
Matrix
(
u
).
transpose
()))
+
\
sp
.
Rational
(
1
,
3
)
*
(
2
+
omega_b
)
*
sp
.
Matrix
(
u
).
dot
(
F
)
*
sp
.
eye
(
method
.
dim
)
subs
=
{
sp
.
Symbol
(
chr
(
ord
(
"
x
"
)
+
i
))
*
sp
.
Symbol
(
chr
(
ord
(
"
x
"
)
+
j
))
:
C
[
i
,
j
]
for
i
in
range
(
dim
)
for
j
in
range
(
dim
)}
for
force_moment
,
moment
in
zip
(
force_moments
[
dim
+
1
:
dim
+
1
+
num_stresses
],
method
.
moments
[
dim
+
1
:
dim
+
1
+
num_stresses
]):
ref
=
moment
.
subs
(
subs
)
diff
=
sp
.
simplify
(
ref
-
force_moment
)
if
is_bulk_moment
(
moment
,
dim
):
assert
diff
==
0
or
isinstance
(
diff
,
sp
.
Rational
)
# difference should be zero or a constant
else
:
assert
diff
==
0
# difference should be zero
# All other moments should be zero
assert
list
(
force_moments
[
dim
+
1
+
num_stresses
:])
==
[
0
]
*
(
len
(
stencil
)
-
(
dim
+
1
+
num_stresses
))
elif
force_model
==
"
simple
"
:
# All other moments should be zero
assert
list
(
force_moments
[
dim
+
1
:])
==
[
0
]
*
(
len
(
stencil
)
-
(
dim
+
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