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
23402c65
Commit
23402c65
authored
Nov 28, 2019
by
Michael Kuron
Browse files
fix broken tests
parent
9f29efa8
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
doc/notebooks/05_tutorial_modifying_method_smagorinsky.ipynb
View file @
23402c65
This diff is collapsed.
Click to expand it.
lbmpy/creationfunctions.py
View file @
23402c65
...
...
@@ -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
),
...
...
lbmpy_tests/phasefield_allen_cahn/test_codegen_3D.py
View file @
23402c65
...
...
@@ -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
)
...
...
lbmpy_tests/test_fluctuating_lb.py
View file @
23402c65
...
...
@@ -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
)
lbmpy_tests/test_fluctuation.py
View file @
23402c65
...
...
@@ -4,9 +4,9 @@ from lbmpy.scenarios import create_channel
def
test_fluctuating_generation_pipeline
():
ch
=
create_channel
((
10
,
10
,
10
),
stencil
=
'D
3Q1
9'
,
method
=
'mrt'
,
relaxation_rates
=
[
1.5
]
*
7
,
force
=
1e-5
,
ch
=
create_channel
((
10
,
10
),
stencil
=
'D
2Q
9'
,
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
lbmpy_tests/test_momentbased_methods_equilibrium.py
View file @
23402c65
...
...
@@ -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"
)
...
...
lbmpy_tests/test_serial_scenarios.py
View file @
23402c65
...
...
@@ -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"
)
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