Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itischler
lbmpy
Commits
5c70dd3a
Commit
5c70dd3a
authored
Feb 08, 2021
by
Michael Kuron
Browse files
Merge branch 'cumulant_test' into 'master'
Cumulant test See merge request
pycodegen/lbmpy!61
parents
2b635f90
16049ba9
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
doc/notebooks/04_tutorial_cumulant_LBM.ipynb
View file @
5c70dd3a
This diff is collapsed.
Click to expand it.
lbmpy_tests/centeredcumulant/test_flow_around_sphere.py
View file @
5c70dd3a
...
...
@@ -12,17 +12,11 @@ from lbmpy.stencils import get_stencil
from
pystencils
import
create_kernel
,
create_data_handling
,
Assignment
from
pystencils.slicing
import
slice_from_direction
,
get_slice_before_ghost_layer
@
pytest
.
mark
.
parametrize
(
'stencil'
,
[
'D2Q9'
,
'D3Q19'
,
'D3Q27'
])
@
pytest
.
mark
.
parametrize
(
'galilean_correction'
,
[
False
,
True
])
@
pytest
.
mark
.
longrun
def
test_flow_around_sphere
(
stencil
,
galilean_correction
):
def
flow_around_sphere
(
stencil
,
galilean_correction
,
L_LU
,
total_steps
):
if
galilean_correction
and
stencil
!=
'D3Q27'
:
return
True
pytest
.
importorskip
(
'pycuda'
)
stencil
=
get_stencil
(
stencil
)
dim
=
len
(
stencil
[
0
])
Q
=
len
(
stencil
)
...
...
@@ -31,16 +25,15 @@ def test_flow_around_sphere(stencil, galilean_correction):
streaming_pattern
=
'aa'
timesteps
=
get_timesteps
(
streaming_pattern
)
L_LU
=
20
u_max
=
0.05
Re
=
5000
Re
=
5000
00
kinematic_viscosity
=
(
L_LU
*
u_max
)
/
Re
initial_velocity
=
(
u_max
,
)
+
(
0
,
)
*
(
dim
-
1
)
omega_v
=
relaxation_rate_from_lattice_viscosity
(
kinematic_viscosity
)
channel_size
=
(
3
0
*
L_LU
,
)
+
(
100
,)
*
(
dim
-
1
)
channel_size
=
(
1
0
*
L_LU
,
)
+
(
5
*
L_LU
,)
*
(
dim
-
1
)
sphere_position
=
(
channel_size
[
0
]
//
3
,)
+
(
channel_size
[
1
]
//
2
,)
*
(
dim
-
1
)
sphere_radius
=
L_LU
//
2
...
...
@@ -130,7 +123,6 @@ def test_flow_around_sphere(stencil, galilean_correction):
dh
.
run_kernel
(
init_kernel
)
total_steps
=
5000
stability_check_frequency
=
1000
for
i
in
range
(
total_steps
):
...
...
@@ -142,3 +134,17 @@ def test_flow_around_sphere(stencil, galilean_correction):
if
i
%
stability_check_frequency
==
0
:
dh
.
to_cpu
(
u_field
.
name
)
assert
np
.
isfinite
(
dh
.
cpu_arrays
[
u_field
.
name
]).
all
()
@
pytest
.
mark
.
parametrize
(
'stencil'
,
[
'D2Q9'
,
'D3Q19'
,
'D3Q27'
])
@
pytest
.
mark
.
parametrize
(
'galilean_correction'
,
[
False
,
True
])
def
test_flow_around_sphere_short
(
stencil
,
galilean_correction
):
pytest
.
importorskip
(
'pycuda'
)
flow_around_sphere
(
stencil
,
galilean_correction
,
5
,
200
)
@
pytest
.
mark
.
parametrize
(
'stencil'
,
[
'D2Q9'
,
'D3Q19'
,
'D3Q27'
])
@
pytest
.
mark
.
parametrize
(
'galilean_correction'
,
[
False
,
True
])
@
pytest
.
mark
.
longrun
def
test_flow_around_sphere_long
(
stencil
,
galilean_correction
):
pytest
.
importorskip
(
'pycuda'
)
flow_around_sphere
(
stencil
,
galilean_correction
,
20
,
3000
)
\ No newline at end of file
lbmpy_tests/test_cumulant_methods.py
View file @
5c70dd3a
import
pytest
import
numpy
as
np
from
lbmpy.methods
import
create_srt
from
lbmpy.stencils
import
get_stencil
from
lbmpy.methods.creationfunctions
import
create_with_default_polynomial_cumulants
from
lbmpy.scenarios
import
create_lid_driven_cavity
@
pytest
.
mark
.
parametrize
(
'stencil_name'
,
[
'D2Q9'
,
'D3Q19'
,
'D3Q27'
])
def
test_weights
(
stencil_name
):
...
...
@@ -10,3 +12,16 @@ def test_weights(stencil_name):
cumulant_method
=
create_with_default_polynomial_cumulants
(
stencil
,
[
1
])
moment_method
=
create_srt
(
stencil
,
1
,
cumulant
=
False
,
compressible
=
True
,
maxwellian_moments
=
True
)
assert
cumulant_method
.
weights
==
moment_method
.
weights
def
test_cumulant_ldc
():
sc_cumulant
=
create_lid_driven_cavity
((
20
,
20
),
method
=
'cumulant'
,
relaxation_rate
=
1.999999
,
compressible
=
True
,
force
=
(
-
1e-10
,
0
))
sc_cumulant_3D
=
create_lid_driven_cavity
((
20
,
20
,
3
),
method
=
'cumulant'
,
relaxation_rate
=
1.999999
,
compressible
=
True
,
force
=
(
-
1e-10
,
0
,
0
),
galilean_correction
=
True
)
sc_cumulant
.
run
(
1000
)
sc_cumulant_3D
.
run
(
1000
)
assert
np
.
isfinite
(
np
.
max
(
sc_cumulant
.
velocity
[:,
:]))
assert
np
.
isfinite
(
np
.
max
(
sc_cumulant_3D
.
velocity
[:,
:,
:]))
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment