Commit 16049ba9 authored by Markus Holzer's avatar Markus Holzer Committed by Michael Kuron
Browse files

Cumulant test

parent 2b635f90
...@@ -12,17 +12,11 @@ from lbmpy.stencils import get_stencil ...@@ -12,17 +12,11 @@ from lbmpy.stencils import get_stencil
from pystencils import create_kernel, create_data_handling, Assignment from pystencils import create_kernel, create_data_handling, Assignment
from pystencils.slicing import slice_from_direction, get_slice_before_ghost_layer from pystencils.slicing import slice_from_direction, get_slice_before_ghost_layer
def flow_around_sphere(stencil, galilean_correction, L_LU, total_steps):
@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):
if galilean_correction and stencil != 'D3Q27': if galilean_correction and stencil != 'D3Q27':
return True return True
pytest.importorskip('pycuda')
stencil = get_stencil(stencil) stencil = get_stencil(stencil)
dim = len(stencil[0]) dim = len(stencil[0])
Q = len(stencil) Q = len(stencil)
...@@ -31,16 +25,15 @@ def test_flow_around_sphere(stencil, galilean_correction): ...@@ -31,16 +25,15 @@ def test_flow_around_sphere(stencil, galilean_correction):
streaming_pattern = 'aa' streaming_pattern = 'aa'
timesteps = get_timesteps(streaming_pattern) timesteps = get_timesteps(streaming_pattern)
L_LU = 20
u_max = 0.05 u_max = 0.05
Re = 5000 Re = 500000
kinematic_viscosity = (L_LU * u_max) / Re kinematic_viscosity = (L_LU * u_max) / Re
initial_velocity = (u_max, ) + (0, ) * (dim - 1) initial_velocity = (u_max, ) + (0, ) * (dim - 1)
omega_v = relaxation_rate_from_lattice_viscosity(kinematic_viscosity) omega_v = relaxation_rate_from_lattice_viscosity(kinematic_viscosity)
channel_size = (30 * L_LU, ) + (100,) * (dim - 1) channel_size = (10 * L_LU, ) + (5 * L_LU,) * (dim - 1)
sphere_position = (channel_size[0] // 3,) + (channel_size[1] // 2,) * (dim - 1) sphere_position = (channel_size[0] // 3,) + (channel_size[1] // 2,) * (dim - 1)
sphere_radius = L_LU // 2 sphere_radius = L_LU // 2
...@@ -130,7 +123,6 @@ def test_flow_around_sphere(stencil, galilean_correction): ...@@ -130,7 +123,6 @@ def test_flow_around_sphere(stencil, galilean_correction):
dh.run_kernel(init_kernel) dh.run_kernel(init_kernel)
total_steps = 5000
stability_check_frequency = 1000 stability_check_frequency = 1000
for i in range(total_steps): for i in range(total_steps):
...@@ -142,3 +134,17 @@ def test_flow_around_sphere(stencil, galilean_correction): ...@@ -142,3 +134,17 @@ def test_flow_around_sphere(stencil, galilean_correction):
if i % stability_check_frequency == 0: if i % stability_check_frequency == 0:
dh.to_cpu(u_field.name) dh.to_cpu(u_field.name)
assert np.isfinite(dh.cpu_arrays[u_field.name]).all() 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
import pytest import pytest
import numpy as np
from lbmpy.methods import create_srt from lbmpy.methods import create_srt
from lbmpy.stencils import get_stencil from lbmpy.stencils import get_stencil
from lbmpy.methods.creationfunctions import create_with_default_polynomial_cumulants 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']) @pytest.mark.parametrize('stencil_name', ['D2Q9', 'D3Q19', 'D3Q27'])
def test_weights(stencil_name): def test_weights(stencil_name):
...@@ -10,3 +12,16 @@ def test_weights(stencil_name): ...@@ -10,3 +12,16 @@ def test_weights(stencil_name):
cumulant_method = create_with_default_polynomial_cumulants(stencil, [1]) cumulant_method = create_with_default_polynomial_cumulants(stencil, [1])
moment_method = create_srt(stencil, 1, cumulant=False, compressible=True, maxwellian_moments=True) moment_method = create_srt(stencil, 1, cumulant=False, compressible=True, maxwellian_moments=True)
assert cumulant_method.weights == moment_method.weights 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[:, :, :]))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment