Skip to content
Snippets Groups Projects
Select Git revision
  • d3f62364cf512cd9d93a93d89170cfea1bb2b0a1
  • master default protected
  • suffa/cumulantfourth_order_correction_with_psm
  • mr_refactor_wfb
  • Sparse
  • WallLaw
  • improved_comm
  • release/1.3.7
  • release/1.3.6
  • release/1.3.5
  • release/1.3.4
  • release/1.3.3
  • release/1.3.2
  • release/1.3.1
  • release/1.3
  • release/1.2
  • release/1.1.1
  • release/1.1
  • release/1.0.1
  • release/1.0
  • release/0.4.4
  • release/0.4.3
  • release/0.4.2
  • release/0.4.1
  • release/0.4.0
  • release/0.3.4
  • release/0.3.3
27 results

07_tutorial_thermal_lbm.ipynb

Blame
  • test_weights.py 1.55 KiB
    import pytest
    from lbmpy.creationfunctions import create_lb_method, LBMConfig
    from lbmpy.enums import Method, Stencil
    from lbmpy.maxwellian_equilibrium import get_weights
    from lbmpy.stencils import LBStencil
    
    
    def compare_weights(method, zero_centered, continuous_equilibrium, stencil_name):
        stencil = LBStencil(stencil_name)
        hardcoded_weights = get_weights(stencil)
    
        method = create_lb_method(LBMConfig(stencil=stencil, method=method, zero_centered=zero_centered, 
                                            continuous_equilibrium=continuous_equilibrium))
        weights = method.weights
    
        for i in range(len(weights)):
            assert hardcoded_weights[i] == weights[i]
    
    
    @pytest.mark.parametrize('method', [Method.SRT, Method.TRT])
    @pytest.mark.parametrize('zero_centered', [False, True])
    @pytest.mark.parametrize('continuous_equilibrium', [False, True])
    @pytest.mark.parametrize('stencil_name', [Stencil.D2Q9, Stencil.D3Q7])
    def test_weight_calculation(method, zero_centered, continuous_equilibrium, stencil_name):
        compare_weights(method, zero_centered, continuous_equilibrium, stencil_name)
    
    
    @pytest.mark.parametrize('method', [Method.MRT, Method.CENTRAL_MOMENT])
    @pytest.mark.parametrize('continuous_equilibrium', [False, True])
    @pytest.mark.parametrize('zero_centered', [False, True])
    @pytest.mark.parametrize('stencil_name', [Stencil.D3Q15, Stencil.D3Q19, Stencil.D3Q27])
    @pytest.mark.longrun
    def test_weight_calculation_longrun(method, zero_centered, continuous_equilibrium, stencil_name):
        compare_weights(method, zero_centered, continuous_equilibrium, stencil_name)