Commit 3ac2bf38 authored by Michael Kuron's avatar Michael Kuron
Browse files

fix some tests

Problems related to unhashable lists, hard-coded vector instruction sets, and undeclared dependencies
parent 65b2fd79
...@@ -368,8 +368,8 @@ class CenteredCumulantBasedLbMethod(AbstractLbMethod): ...@@ -368,8 +368,8 @@ class CenteredCumulantBasedLbMethod(AbstractLbMethod):
lower_order_equilibrium = [info.equilibrium_value for info in lower_order_relaxation_infos] lower_order_equilibrium = [info.equilibrium_value for info in lower_order_relaxation_infos]
lower_order_moment_collision_eqs = relax_lower_order_central_moments( lower_order_moment_collision_eqs = relax_lower_order_central_moments(
lower_order_moments, lower_order_moment_symbols, lower_order_moments, tuple(lower_order_moment_symbols),
lower_order_relaxation_rates, lower_order_equilibrium) tuple(lower_order_relaxation_rates), tuple(lower_order_equilibrium))
# 5) Add relaxation rules for higher-order, polynomial cumulants # 5) Add relaxation rules for higher-order, polynomial cumulants
poly_relaxation_infos = [cumulant_to_relaxation_info_dict[c] for c in higher_order_polynomials] poly_relaxation_infos = [cumulant_to_relaxation_info_dict[c] for c in higher_order_polynomials]
...@@ -383,8 +383,8 @@ class CenteredCumulantBasedLbMethod(AbstractLbMethod): ...@@ -383,8 +383,8 @@ class CenteredCumulantBasedLbMethod(AbstractLbMethod):
galilean_correction_terms = None galilean_correction_terms = None
cumulant_collision_eqs = relax_polynomial_cumulants( cumulant_collision_eqs = relax_polynomial_cumulants(
monomial_cumulants, higher_order_polynomials, tuple(monomial_cumulants), tuple(higher_order_polynomials),
poly_relaxation_rates, poly_equilibrium, tuple(poly_relaxation_rates), tuple(poly_equilibrium),
pre_simplification, pre_simplification,
galilean_correction_terms=galilean_correction_terms) galilean_correction_terms=galilean_correction_terms)
......
...@@ -50,7 +50,7 @@ def test_equilibrium_pdfs(stencil_name, cm_transform): ...@@ -50,7 +50,7 @@ def test_equilibrium_pdfs(stencil_name, cm_transform):
if ref_equilibrium is None: if ref_equilibrium is None:
raw_moments = list(extract_monomials(c_lb_method.cumulants, dim=dim)) raw_moments = list(extract_monomials(c_lb_method.cumulants, dim=dim))
ref_equilibrium = generate_equilibrium_by_matching_moments( ref_equilibrium = generate_equilibrium_by_matching_moments(
stencil, raw_moments, rho=rho, u=u, c_s_sq=sp.Rational(1, 3), order=2*dim) stencil, tuple(raw_moments), rho=rho, u=u, c_s_sq=sp.Rational(1, 3), order=2*dim)
reference_equilibria[stencil_name] = ref_equilibrium reference_equilibria[stencil_name] = ref_equilibrium
for i in range(q): for i in range(q):
......
...@@ -8,7 +8,9 @@ a cylinder. In Flow simulation with high-performance computers II (pp. 547-566). ...@@ -8,7 +8,9 @@ a cylinder. In Flow simulation with high-performance computers II (pp. 547-566).
import warnings import warnings
import numpy as np import numpy as np
import pytest
from pystencils.backends.simd_instruction_sets import get_supported_instruction_sets
from lbmpy.boundaries.boundaryconditions import NoSlip from lbmpy.boundaries.boundaryconditions import NoSlip
from lbmpy.geometry import get_pipe_velocity_field from lbmpy.geometry import get_pipe_velocity_field
from lbmpy.relaxationrates import relaxation_rate_from_lattice_viscosity from lbmpy.relaxationrates import relaxation_rate_from_lattice_viscosity
...@@ -146,8 +148,9 @@ def long_run(steady=True, **kwargs): ...@@ -146,8 +148,9 @@ def long_run(steady=True, **kwargs):
plt.show() plt.show()
@pytest.mark.skipif(not get_supported_instruction_sets(), reason='cannot detect CPU instruction set')
def test_schaefer_turek(): def test_schaefer_turek():
opt = {'vectorization': {'instruction_set': 'avx', 'assume_aligned': True}, 'openmp': 2} opt = {'vectorization': {'instruction_set': get_supported_instruction_sets()[-1], 'assume_aligned': True}, 'openmp': 2}
sc_2d_1 = schaefer_turek_2d(30, max_lattice_velocity=0.08, optimization=opt) sc_2d_1 = schaefer_turek_2d(30, max_lattice_velocity=0.08, optimization=opt)
sc_2d_1.run(30000) sc_2d_1.run(30000)
result = evaluate_static_quantities(sc_2d_1) result = evaluate_static_quantities(sc_2d_1)
......
import os import os
import numpy as np import numpy as np
import pytest
from lbmpy.boundaries import NoSlip from lbmpy.boundaries import NoSlip
from lbmpy.geometry import add_black_and_white_image, add_pipe_walls from lbmpy.geometry import add_black_and_white_image, add_pipe_walls
...@@ -49,6 +50,7 @@ def get_test_image_path(): ...@@ -49,6 +50,7 @@ def get_test_image_path():
def test_image(): def test_image():
pytest.importorskip('scipy.ndimage')
sc = LatticeBoltzmannStep(domain_size=(50, 40), method='srt', relaxation_rate=1.9, sc = LatticeBoltzmannStep(domain_size=(50, 40), method='srt', relaxation_rate=1.9,
optimization={}) optimization={})
add_black_and_white_image(sc.boundary_handling, get_test_image_path(), keep_aspect_ratio=True) add_black_and_white_image(sc.boundary_handling, get_test_image_path(), keep_aspect_ratio=True)
......
import numpy as np import numpy as np
import pytest
from lbmpy.postprocessing import scalar_field_interpolator, vector_field_interpolator from lbmpy.postprocessing import scalar_field_interpolator, vector_field_interpolator
def test_interpolation(): def test_interpolation():
pytest.importorskip('scipy.ndimage')
scalar_arr = np.arange(0, 3*3).reshape(3, 3) scalar_arr = np.arange(0, 3*3).reshape(3, 3)
scalar_ip = scalar_field_interpolator(scalar_arr) scalar_ip = scalar_field_interpolator(scalar_arr)
np.testing.assert_equal(scalar_ip([[1, 1.5], [0.5, 1]]), [2.5, 0.5]) np.testing.assert_equal(scalar_ip([[1, 1.5], [0.5, 1]]), [2.5, 0.5])
......
import numpy as np import numpy as np
import pytest import pytest
from pystencils.backends.simd_instruction_sets import get_supported_instruction_sets
from lbmpy.scenarios import create_lid_driven_cavity from lbmpy.scenarios import create_lid_driven_cavity
@pytest.mark.skipif(not get_supported_instruction_sets(), reason='cannot detect CPU instruction set')
def test_lbm_vectorization_short(): def test_lbm_vectorization_short():
print("Computing reference solutions") print("Computing reference solutions")
size1 = (64, 32) size1 = (64, 32)
...@@ -13,7 +15,7 @@ def test_lbm_vectorization_short(): ...@@ -13,7 +15,7 @@ def test_lbm_vectorization_short():
ldc1_ref.run(10) ldc1_ref.run(10)
ldc1 = create_lid_driven_cavity(size1, relaxation_rate=relaxation_rate, ldc1 = create_lid_driven_cavity(size1, relaxation_rate=relaxation_rate,
optimization={'vectorization': {'instruction_set': 'avx', optimization={'vectorization': {'instruction_set': get_supported_instruction_sets()[-1],
'assume_aligned': True, 'assume_aligned': True,
'nontemporal': True, 'nontemporal': True,
'assume_inner_stride_one': True, 'assume_inner_stride_one': True,
...@@ -23,7 +25,7 @@ def test_lbm_vectorization_short(): ...@@ -23,7 +25,7 @@ def test_lbm_vectorization_short():
ldc1.run(10) ldc1.run(10)
@pytest.mark.parametrize('instruction_set', ['sse', 'avx']) @pytest.mark.parametrize('instruction_set', get_supported_instruction_sets())
@pytest.mark.parametrize('aligned_and_padding', [[False, False], [True, False], [True, True]]) @pytest.mark.parametrize('aligned_and_padding', [[False, False], [True, False], [True, True]])
@pytest.mark.parametrize('nontemporal', [False, True]) @pytest.mark.parametrize('nontemporal', [False, True])
@pytest.mark.parametrize('double_precision', [False, True]) @pytest.mark.parametrize('double_precision', [False, True])
......
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