Commit 23402c65 authored by Michael Kuron's avatar Michael Kuron
Browse files

fix broken tests

parent 9f29efa8
......@@ -509,6 +509,8 @@ def update_with_default_parameters(params, opt_params=None, fail_on_unknown_para
'compressible': False,
'equilibrium_order': 2,
'c_s_sq': sp.Rational(1, 3),
'weighted': None,
'nested_moments': None,
'force_model': 'none',
'force': (0, 0, 0),
......
......@@ -86,7 +86,8 @@ relaxation_rate = 1.0 / relaxation_time
method_phase = create_lb_method(stencil=stencil_phase, method='srt', relaxation_rate=w_c, compressible=True)
mrt = create_lb_method(method="mrt", stencil=stencil_hydro, relaxation_rates=[1, 1, relaxation_rate, 1, 1, 1, 1])
mrt = create_lb_method(method="mrt", weighted=False, stencil=stencil_hydro,
relaxation_rates=[1, 1, relaxation_rate, 1, 1, 1, 1])
rr_dict = OrderedDict(zip(mrt.moments, mrt.relaxation_rates))
method_hydro = create_with_discrete_maxwellian_eq_moments(stencil_hydro, rr_dict, compressible=False)
......
......@@ -30,12 +30,12 @@ def run_scenario(scenario, steps):
scenario.time_steps_run += steps
def create_scenario(domain_size, temperature=None, viscosity=None, seed=2, target='cpu', openmp=4, method=None, num_rel_rates=None):
def create_scenario(domain_size, temperature=None, viscosity=None, seed=2, target='cpu', openmp=4, num_rel_rates=None):
rr = [relaxation_rate_from_lattice_viscosity(viscosity)]
rr = rr*num_rel_rates
cr = create_lb_collision_rule(
stencil='D3Q19', compressible=True,
method=method, relaxation_rates=rr,
method='mrt', weighted=True, relaxation_rates=rr,
fluctuating={'temperature': temperature, 'seed': seed},
optimization={'cse_global': True, 'split': False,
'cse_pdfs': True, 'vectorization': True}
......@@ -43,8 +43,7 @@ def create_scenario(domain_size, temperature=None, viscosity=None, seed=2, targe
return LatticeBoltzmannStep(periodicity=(True, True, True), domain_size=domain_size, compressible=True, stencil='D3Q19', collision_rule=cr, optimization={'target': target, 'openmp': openmp})
def run_for_method(method, num_rel_rates):
print("Testing", method)
def test_fluctuating_mrt():
# Unit conversions (MD to lattice) for parameters known to work with Espresso
agrid = 1.
m = 1. # mass per node
......@@ -53,7 +52,7 @@ def run_for_method(method, num_rel_rates):
viscosity = 3. * tau / agrid**2
n = 8
sc = create_scenario((n, n, n), viscosity=viscosity, temperature=temperature,
target='cpu', openmp=4, method=method, num_rel_rates=num_rel_rates)
target='cpu', openmp=4, num_rel_rates=15)
assert np.average(sc.velocity[:, :, :]) == 0.
# Warmup
......@@ -89,6 +88,3 @@ def run_for_method(method, num_rel_rates):
np.testing.assert_allclose(
v_hist[remove:-remove], v_expected[remove:-remove], rtol=0.005)
def test_mrt():
run_for_method('mrt', 15)
......@@ -4,9 +4,9 @@ from lbmpy.scenarios import create_channel
def test_fluctuating_generation_pipeline():
ch = create_channel((10, 10, 10), stencil='D3Q19', method='mrt', relaxation_rates=[1.5] * 7, force=1e-5,
ch = create_channel((10, 10), stencil='D2Q9', method='mrt', weighted=True, relaxation_rates=[1.5] * 5, force=1e-5,
fluctuating={'temperature': 1e-9}, kernel_params={'time_step': 1, 'seed': 312},
optimization={'cse_global': True})
ch.run(10)
assert np.max(ch.velocity[:, :, :]) < 0.1
assert np.max(ch.velocity[:, :]) < 0.1
......@@ -20,7 +20,8 @@ def check_for_matching_equilibrium(method_name, stencil, compressibility):
elif method_name == 'trt':
method = create_trt(stencil, omega, omega, compressible=compressibility, equilibrium_order=2)
elif method_name == 'mrt':
method = create_mrt_orthogonal(stencil, lambda v: omega, compressible=compressibility, equilibrium_order=2)
method = create_mrt_orthogonal(stencil, lambda v: omega, weighted=False, compressible=compressibility,
equilibrium_order=2)
else:
raise ValueError("Unknown method")
......
......@@ -210,10 +210,13 @@ def test_ldc_trt(action='Testing', plot="off"):
def test_ldc_mrt(action='Testing', plot="off"):
from lbmpy.methods import mrt_orthogonal_modes_literature
from lbmpy.stencils import get_stencil
if action == 'Testing' or action == 'Regenerate':
print("%s LidDrivenCavity MRT, compressible 0" % action)
moments = mrt_orthogonal_modes_literature(get_stencil("D3Q19"), True, False)
compare_lid_driven_cavity(domain_size=(16, 17, 18), lid_velocity=0.005, stencil='D3Q19',
method='MRT', compressible=False, maxwellian_moments=False,
method='MRT', nested_moments=moments, compressible=False, maxwellian_moments=False,
relaxation_rates=[1, 1.3, 1.4, 1.5, 1.25, 1.36, 1.12], action=action, plot=plot)
else:
print("Possible Actions: Regenerate or Testing")
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