Commit 5b7d9b52 authored by Markus Holzer's avatar Markus Holzer Committed by Helen Schottenhamml
Browse files

Adaption to new API

parent eb191dc1
......@@ -16,4 +16,7 @@ _local_tmp
doc/bibtex.json
/db
/lbmpy/phasefield/simplex_projection.*.so
/lbmpy/phasefield/simplex_projection.c
\ No newline at end of file
/lbmpy/phasefield/simplex_projection.c
# macOS
**/.DS_Store
\ No newline at end of file
......@@ -14,8 +14,7 @@ tests-and-coverage:
- $ENABLE_NIGHTLY_BUILDS
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
script:
- env
- pip list
# - pip install sympy --upgrade
- export NUM_CORES=$(nproc --all)
- mkdir -p ~/.config/matplotlib
- echo "backend:template" > ~/.config/matplotlib/matplotlibrc
......@@ -134,6 +133,22 @@ minimal-windows:
- python -c "import numpy"
- py.test -v -n $NUM_CORES -m "not (notebook or longrun)"
minimal-sympy-master:
stage: test
except:
variables:
- $ENABLE_NIGHTLY_BUILDS
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/minimal_conda
script:
- pip install git+https://gitlab-ci-token:${CI_JOB_TOKEN}@i10git.cs.fau.de/pycodegen/pystencils.git@master#egg=pystencils
- python -m pip install --upgrade git+https://github.com/sympy/sympy.git
- pip list
- python setup.py quicktest
allow_failure: true
tags:
- docker
- cuda
ubuntu:
stage: test
except:
......@@ -141,7 +156,7 @@ ubuntu:
- $ENABLE_NIGHTLY_BUILDS
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/ubuntu
before_script:
- apt-get -y remove python3-sympy
# - apt-get -y remove python3-sympy
- ln -s /usr/include/locale.h /usr/include/xlocale.h
# - pip3 install `grep -Eo 'sympy[>=]+[0-9\.]+' setup.py | sed 's/>/=/g'`
- pip3 install git+https://gitlab-ci-token:${CI_JOB_TOKEN}@i10git.cs.fau.de/pycodegen/pystencils.git@master#egg=pystencils
......@@ -199,7 +214,7 @@ pycodegen-integration:
build-documentation:
stage: test
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/documentation
script:
- export PYTHONPATH=`pwd`
- pip install git+https://gitlab-ci-token:${CI_JOB_TOKEN}@i10git.cs.fau.de/pycodegen/pystencils.git@master#egg=pystencils
......
......@@ -4,6 +4,9 @@ import tempfile
import runpy
import sys
import warnings
import nbformat
from nbconvert import PythonExporter
import sympy
# Trigger config file reading / creation once - to avoid race conditions when multiple instances are creating it
# at the same time
from pystencils.cpu import cpujit
......@@ -12,12 +15,12 @@ from pystencils.cpu import cpujit
# at the same time
try:
import pyximport
pyximport.install(language_level=3)
except ImportError:
pass
from lbmpy.phasefield.simplex_projection import simplex_projection_2d # NOQA
SCRIPT_FOLDER = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.abspath('lbmpy'))
......@@ -40,7 +43,6 @@ collect_ignore = [os.path.join(SCRIPT_FOLDER, "doc", "conf.py"),
add_path_to_ignore('pystencils_tests/benchmark')
add_path_to_ignore('_local_tmp')
try:
import pycuda
except ImportError:
......@@ -49,18 +51,17 @@ except ImportError:
try:
import waLBerla
except ImportError:
collect_ignore += [os.path.join(SCRIPT_FOLDER, "lbmpy_tests/test_serial_scenarios.py")]
collect_ignore += [os.path.join(SCRIPT_FOLDER, "lbmpy_tests/test_datahandling_parallel.py")]
try:
import blitzdb
except ImportError:
collect_ignore += [os.path.join(SCRIPT_FOLDER, "lbmpy_tests/benchmark"),
os.path.join(SCRIPT_FOLDER, "lbmpy_tests/full_scenarios/kida_vortex_flow/scenario_kida_vortex_flow.py")]
os.path.join(SCRIPT_FOLDER,
"lbmpy_tests/full_scenarios/kida_vortex_flow/scenario_kida_vortex_flow.py")]
import sympy
sver = sympy.__version__.split(".")
if (int(sver[0]) == 1 and int(sver[1]) < 2):
if int(sver[0]) == 1 and int(sver[1]) < 2:
add_path_to_ignore('lbmpy_tests/phasefield')
collect_ignore += [os.path.join(SCRIPT_FOLDER, "lbmpy_tests/test_n_phase_boyer_noncoupled.ipynb")]
......@@ -72,10 +73,6 @@ for root, sub_dirs, files in os.walk('.'):
collect_ignore.append(f)
import nbformat
from nbconvert import PythonExporter
class IPythonMockup:
def run_line_magic(self, *args, **kwargs):
pass
......
*********
Enums
*********
************
Enumerations
************
.. automodule:: lbmpy.enums
:members:
......@@ -85,13 +85,17 @@ year = {2018}
@article{Semprebon2016,
author = {Semprebon, Ciro and Kusumaatmaja, Halim},
doi = {10.1103/PhysRevE.93.033305},
keywords = {lbm,multiphase,phasefield},
mendeley-tags = {lbm,multiphase,phasefield},
pages = {1--11},
title = {{Ternary free-energy lattice Boltzmann model with tunable surface tensions and contact angles}},
year = {2016}
title = {Ternary free-energy lattice Boltzmann model with tunable surface tensions and contact angles},
author = {Semprebon, Ciro and Kr\"uger, Timm and Kusumaatmaja, Halim},
journal = {Phys. Rev. E},
volume = {93},
issue = {3},
pages = {033305},
numpages = {11},
year = {2016},
month = {Mar},
publisher = {American Physical Society},
doi = {10.1103/PhysRevE.93.033305},
}
@article{geier2015,
......@@ -169,4 +173,42 @@ keywords = {{Lattice Boltzmann} method, {BGK} collision operator, Steady-state f
publisher = {Springer International Publishing},
author = {Kr\"{u}ger, T. and Kusumaatmaja, H. and Kuzmin, A. and Shardt, O. and Silva, G. and Viggen, E. M.},
title = {The Lattice {Boltzmann} Method}
}
@article{Ansumali2003,
doi = {10.1209/epl/i2003-00496-6},
year = 2003,
month = {sep},
journal = {{IOP} Publishing},
volume = {63},
number = {6},
pages = {798--804},
author = {S Ansumali and I. V Karlin and H. C Öttinger},
title = {Minimal entropic kinetic models for hydrodynamics},
abstract = {We derive minimal discrete models of the Boltzmann equation consistent with equilibrium thermodynamics, and which recover correct hydrodynamics in arbitrary dimensions. A new discrete velocity model is proposed for the simulation of the Navier-Stokes-Fourier equation and is tested in the setup of Taylor vortex flow. A simple analytical procedure for constructing the equilibrium for thermal hydrodynamics is established. For the lattice Boltzmann method of isothermal hydrodynamics, the explicit analytical form of the equilibrium distribution is presented. This results in an entropic version of the isothermal lattice Boltzmann method with the simplicity and computational efficiency of the standard lattice Boltzmann model.}
}
@article{raw_moments,
author = {D. D'Humières},
title = {Generalized lattice-{Boltzmann} equations},
journal = {Rarefied gas dynamics },
year = {1992}
}
@article{FAKHARI201722,
author = "Abbas Fakhari and Diogo Bolster and Li-Shi Luo",
title = "A weighted multiple-relaxation-time lattice {Boltzmann} method for multiphase flows and its application to partial coalescence cascades",
journal = "Journal of Computational Physics",
year = "2017",
doi = "10.1016/j.jcp.2017.03.062"
}
@article{TRT,
author = {Ginzburg Irina and Frederik Verhaeghe and D. D'Humières},
year = {2008},
month = {01},
pages = {427-478},
title = {Two-relaxation-time Lattice Boltzmann scheme: about parametrization, velocity, pressure and mixed boundary conditions},
volume = {3},
journal = {Communications in Computational Physics}
}
\ No newline at end of file
......@@ -6,6 +6,9 @@ Methods (lbmpy.methods)
LBM Method Interfaces
=====================
.. autoclass:: lbmpy.methods.LbmCollisionRule
:members:
.. autoclass:: lbmpy.methods.AbstractLbMethod
:members:
......@@ -77,3 +80,9 @@ Class
.. autoclass:: lbmpy.methods.centeredcumulant.CenteredCumulantBasedLbMethod
:members:
Default Moment sets
-------------------
.. autofunction:: lbmpy.methods.default_moment_sets.cascaded_moment_sets_literature
.. autofunction:: lbmpy.methods.default_moment_sets.mrt_orthogonal_modes_literature
......@@ -2,4 +2,4 @@ Bibliography
------------
.. bibliography:: lbmpy.bib
:cited:
\ No newline at end of file
:all:
\ No newline at end of file
......@@ -8,7 +8,7 @@ from .maxwellian_equilibrium import get_weights
from .relaxationrates import relaxation_rate_from_lattice_viscosity, lattice_viscosity_from_relaxation_rate,\
relaxation_rate_from_magic_number
from .scenarios import create_lid_driven_cavity, create_fully_periodic_flow
from .stencils import get_stencil, LBStencil
from .stencils import LBStencil
__all__ = ['create_lb_ast', 'create_lb_collision_rule', 'create_lb_function', 'create_lb_method',
......@@ -21,7 +21,7 @@ __all__ = ['create_lb_ast', 'create_lb_collision_rule', 'create_lb_function', 'c
'relaxation_rate_from_lattice_viscosity', 'lattice_viscosity_from_relaxation_rate',
'relaxation_rate_from_magic_number',
'create_lid_driven_cavity', 'create_fully_periodic_flow',
'get_stencil', 'LBStencil']
'LBStencil']
from ._version import get_versions
......
......@@ -3,7 +3,6 @@ from pystencils import Field, Assignment
from pystencils.slicing import shift_slice, get_slice_before_ghost_layer, normalize_slice
from lbmpy.advanced_streaming.utility import is_inplace, get_accessor, numeric_index, \
numeric_offsets, Timestep, get_timesteps
from lbmpy.stencils import get_stencil
from pystencils.datahandling import SerialDataHandling
from pystencils.enums import Target
from itertools import chain
......@@ -69,11 +68,10 @@ def get_communication_slices(
"""
dim = len(stencil[0])
if comm_stencil is None:
comm_stencil = itertools.product(*([-1, 0, 1] for _ in range(dim)))
comm_stencil = itertools.product(*([-1, 0, 1] for _ in range(stencil.D)))
pdfs = Field.create_generic('pdfs', spatial_dimensions=len(stencil[0]), index_shape=(len(stencil),))
pdfs = Field.create_generic('pdfs', spatial_dimensions=len(stencil[0]), index_shape=(stencil.Q,))
write_accesses = get_accessor(streaming_pattern, prev_timestep).write(pdfs, stencil)
slices_per_comm_direction = dict()
......@@ -169,11 +167,8 @@ class LBMPeriodicityHandling:
if not isinstance(data_handling, SerialDataHandling):
raise ValueError('Only serial data handling is supported!')
if isinstance(stencil, str):
stencil = get_stencil(stencil)
self.stencil = stencil
self.dim = len(stencil[0])
self.dim = stencil.D
self.dh = data_handling
target = data_handling.default_target
......
......@@ -5,7 +5,6 @@ import pystencils as ps
from pystencils.data_types import TypedSymbol, create_type
from pystencils.backends.cbackend import CustomCodeNode
from lbmpy.stencils import get_stencil
from lbmpy.advanced_streaming.utility import get_accessor, inverse_dir_index, is_inplace, Timestep
from itertools import product
......@@ -45,9 +44,6 @@ class BetweenTimestepsIndexing:
raise ValueError('Cannot create index arrays for both kinds of timesteps for inplace streaming pattern '
+ streaming_pattern)
if isinstance(stencil, str):
stencil = get_stencil(stencil)
prev_accessor = get_accessor(streaming_pattern, prev_timestep)
next_accessor = get_accessor(streaming_pattern, prev_timestep.next())
......@@ -58,8 +54,8 @@ class BetweenTimestepsIndexing:
self._pdf_field = pdf_field
self._stencil = stencil
self._dim = len(stencil[0])
self._q = len(stencil)
self._dim = stencil.D
self._q = stencil.Q
self._coordinate_names = ['x', 'y', 'z'][:self._dim]
self._index_dtype = create_type(index_dtype)
......
......@@ -94,7 +94,7 @@ class AccessPdfValues:
if streaming_dir not in ['in', 'out']:
raise ValueError('Invalid streaming direction.', streaming_dir)
pdf_field = ps.Field.create_generic('pdfs', len(stencil[0]), index_shape=(len(stencil),))
pdf_field = ps.Field.create_generic('pdfs', len(stencil[0]), index_shape=(stencil.Q,))
if accessor is None:
accessor = get_accessor(streaming_pattern, timestep)
......
import functools
import numpy as np
import sympy as sp
from lbmpy.chapman_enskog.chapman_enskog import (
......@@ -150,7 +151,8 @@ class SteadyStateChapmanEnskogAnalysis:
have_shape = hasattr(arg, 'shape') and hasattr(new_prod, 'shape')
if have_shape and arg.shape == new_prod.shape and arg.shape[1] == 1:
new_prod = sp.matrix_multiply_elementwise(new_prod, arg)
# since sympy 1.9 sp.matrix_multiply_elementwise does not work anymore in this case
new_prod = sp.Matrix(np.multiply(new_prod, arg))
else:
new_prod = arg * new_prod
if new_prod == 0:
......
This diff is collapsed.
......@@ -102,7 +102,7 @@ def __cumulant_raw_moment_transform(index, dependent_var_dict, outer_function, d
@memorycache(maxsize=16)
def __get_discrete_cumulant_generating_function(func, stencil, wave_numbers):
assert len(stencil) == len(func)
assert stencil.Q == len(func)
laplace_transformation = sum([factor * sp.exp(scalar_product(wave_numbers, e)) for factor, e in zip(func, stencil)])
return sp.ln(laplace_transformation)
......@@ -121,7 +121,7 @@ def discrete_cumulant(func, cumulant, stencil):
(similar to moment description)
stencil: sequence of directions
"""
assert len(stencil) == len(func)
assert stencil.Q == len(func)
dim = len(stencil[0])
wave_numbers = sp.symbols(f"Xi_:{dim}")
......@@ -157,9 +157,9 @@ def cumulants_from_pdfs(stencil, cumulant_indices=None, pdf_symbols=None):
dim = len(stencil[0])
if cumulant_indices is None:
cumulant_indices = moments_up_to_component_order(2, dim=dim)
assert len(stencil) == len(cumulant_indices), "Stencil has to have same length as cumulant_indices sequence"
assert stencil.Q == len(cumulant_indices), "Stencil has to have same length as cumulant_indices sequence"
if pdf_symbols is None:
pdf_symbols = __get_indexed_symbols(pdf_symbols, "f", range(len(stencil)))
pdf_symbols = __get_indexed_symbols(pdf_symbols, "f", range(stencil.Q))
return {idx: discrete_cumulant(tuple(pdf_symbols), idx, stencil) for idx in cumulant_indices}
......
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