Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Frederik Hennig
lbmpy
Commits
3fc22a69
Commit
3fc22a69
authored
Apr 06, 2022
by
Frederik Hennig
Browse files
Increasing the Coverage
parent
954aa5b8
Pipeline
#39006
failed with stages
in 83 minutes and 6 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lbmpy/equilibrium/generic_discrete_equilibrium.py
View file @
3fc22a69
...
...
@@ -19,7 +19,7 @@ def discrete_equilibrium_from_matching_moments(stencil, moment_constraints,
return
GenericDiscreteEquilibrium
(
stencil
,
pdfs
,
zeroth_order_moment_symbol
,
first_order_moment_symbols
,
deviation_only
=
deviation_only
)
except
sp
.
matrices
.
inverse
.
NonInvertibleMatrixError
as
e
:
raise
Exception
(
"Could not construct equilibrium from given moment constraints."
)
from
e
raise
ValueError
(
"Could not construct equilibrium from given moment constraints."
)
from
e
class
GenericDiscreteEquilibrium
(
AbstractEquilibrium
):
...
...
lbmpy_tests/test_hydro_maxwellian_class.py
View file @
3fc22a69
...
...
@@ -2,6 +2,8 @@ import pytest
import
sympy
as
sp
from
itertools
import
chain
from
pystencils.sympyextensions
import
remove_higher_order_terms
from
lbmpy.stencils
import
Stencil
,
LBStencil
from
lbmpy.equilibrium
import
ContinuousHydrodynamicMaxwellian
,
DiscreteHydrodynamicMaxwellian
from
lbmpy.moments
import
moments_up_to_component_order
,
moments_up_to_order
...
...
@@ -73,3 +75,51 @@ def test_continuous_discrete_moment_equivalence(stencil, compressible, deviation
subs
=
{
delta_rho
:
rho
-
rho_0
}
assert
(
cm
-
dm
).
subs
(
subs
).
expand
()
==
sp
.
Matrix
((
0
,)
*
len
(
moments
))
@
pytest
.
mark
.
parametrize
(
'stencil'
,
[
Stencil
.
D2Q9
,
Stencil
.
D3Q15
,
Stencil
.
D3Q19
,
Stencil
.
D3Q27
])
@
pytest
.
mark
.
parametrize
(
'compressible'
,
[
False
,
True
])
@
pytest
.
mark
.
parametrize
(
'deviation_only'
,
[
False
,
True
])
def
test_continuous_discrete_central_moment_equivalence
(
stencil
,
compressible
,
deviation_only
):
stencil
=
LBStencil
(
stencil
)
c_s_sq
=
sp
.
Rational
(
1
,
3
)
moments
=
tuple
(
moments_up_to_order
(
3
,
dim
=
stencil
.
D
,
include_permutations
=
False
))
cd
=
ContinuousHydrodynamicMaxwellian
(
dim
=
stencil
.
D
,
compressible
=
compressible
,
deviation_only
=
deviation_only
,
order
=
2
,
c_s_sq
=
c_s_sq
)
cm
=
sp
.
Matrix
(
cd
.
central_moments
(
moments
))
dd
=
DiscreteHydrodynamicMaxwellian
(
stencil
,
compressible
=
compressible
,
deviation_only
=
deviation_only
,
order
=
2
,
c_s_sq
=
c_s_sq
)
dm
=
sp
.
Matrix
(
dd
.
central_moments
(
moments
))
dm
=
sp
.
Matrix
([
remove_higher_order_terms
(
t
,
dd
.
velocity
,
order
=
2
)
for
t
in
dm
])
rho
=
cd
.
density
delta_rho
=
cd
.
density_deviation
rho_0
=
cd
.
background_density
subs
=
{
delta_rho
:
rho
-
rho_0
}
assert
(
cm
-
dm
).
subs
(
subs
).
expand
()
==
sp
.
Matrix
((
0
,)
*
len
(
moments
))
@
pytest
.
mark
.
parametrize
(
'stencil'
,
[
Stencil
.
D2Q9
,
Stencil
.
D3Q15
,
Stencil
.
D3Q19
,
Stencil
.
D3Q27
])
def
test_continuous_discrete_cumulant_equivalence
(
stencil
):
stencil
=
LBStencil
(
stencil
)
c_s_sq
=
sp
.
Rational
(
1
,
3
)
compressible
=
True
deviation_only
=
False
moments
=
tuple
(
moments_up_to_order
(
3
,
dim
=
stencil
.
D
,
include_permutations
=
False
))
cd
=
ContinuousHydrodynamicMaxwellian
(
dim
=
stencil
.
D
,
compressible
=
compressible
,
deviation_only
=
deviation_only
,
order
=
2
,
c_s_sq
=
c_s_sq
)
cm
=
sp
.
Matrix
(
cd
.
cumulants
(
moments
))
dd
=
DiscreteHydrodynamicMaxwellian
(
stencil
,
compressible
=
compressible
,
deviation_only
=
deviation_only
,
order
=
2
,
c_s_sq
=
c_s_sq
)
dm
=
sp
.
Matrix
(
dd
.
cumulants
(
moments
))
dm
=
sp
.
Matrix
([
remove_higher_order_terms
(
t
,
dd
.
velocity
,
order
=
2
)
for
t
in
dm
])
rho
=
cd
.
density
delta_rho
=
cd
.
density_deviation
rho_0
=
cd
.
background_density
subs
=
{
delta_rho
:
rho
-
rho_0
}
assert
(
cm
-
dm
).
subs
(
subs
).
expand
()
==
sp
.
Matrix
((
0
,)
*
len
(
moments
))
pytest.ini
View file @
3fc22a69
...
...
@@ -30,6 +30,7 @@ exclude_lines =
pragma:
no
cover
def
__repr__
def
_repr_html_
# Don't complain if tests don't hit defensive assertion code:
raise
AssertionError
...
...
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