Commit 7e025abd authored by Martin Bauer's avatar Martin Bauer
Browse files

Adaptations to changes in pystencils (renaming of stencil plots)

parent deb77a1c
[flake8]
max-line-length=120
exclude=lbmpy/plot2d.py
exclude=lbmpy/plot.py
lbmpy/session.py
ignore = W293 W503 W291
......@@ -361,7 +361,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
"version": "3.6.8"
}
},
"nbformat": 4,
......
This diff is collapsed.
This diff is collapsed.
......@@ -4,7 +4,7 @@ from pystencils import TypedSymbol, create_indexed_kernel, Assignment
from pystencils.backends.cbackend import CustomCodeNode
from pystencils.boundaries import BoundaryHandling
from pystencils.boundaries.boundaryhandling import BoundaryOffsetInfo
from pystencils.stencils import inverse_direction
from pystencils.stencil import inverse_direction
class LatticeBoltzmannBoundaryHandling(BoundaryHandling):
......
......@@ -181,7 +181,7 @@ from lbmpy.methods.entropic_eq_srt import create_srt_entropic
from lbmpy.relaxationrates import relaxation_rate_from_magic_number
from lbmpy.stencils import get_stencil
from pystencils.simp import add_subexpressions_for_field_reads
from pystencils.stencils import stencils_have_same_entries
from pystencils.stencil import have_same_entries
import lbmpy.forcemodels as forcemodels
from lbmpy.simplificationfactory import create_simplification_strategy
from lbmpy.fieldaccess import StreamPullTwoFieldsAccessor, PeriodicTwoFieldsAccessor, CollideOnlyInplaceAccessor
......@@ -391,9 +391,9 @@ def create_lb_method(**params):
elif method_name.lower() == 'mrt3':
method = create_mrt3(stencil_entries, relaxation_rates, **common_params)
elif method_name.lower().startswith('trt-kbc-n'):
if stencils_have_same_entries(stencil_entries, get_stencil("D2Q9")):
if have_same_entries(stencil_entries, get_stencil("D2Q9")):
dim = 2
elif stencils_have_same_entries(stencil_entries, get_stencil("D3Q27")):
elif have_same_entries(stencil_entries, get_stencil("D3Q27")):
dim = 3
else:
raise NotImplementedError("KBC type TRT methods can only be constructed for D2Q9 and D3Q27 stencils")
......
import sympy as sp
import abc
from pystencils.stencils import inverse_direction
from pystencils.stencil import inverse_direction
from pystencils import Field
......@@ -169,7 +169,7 @@ class EsoTwistEvenTimeStepAccessor(PdfFieldAccessor):
def visualize_field_mapping(axes, stencil, field_mapping, color='b'):
from lbmpy.plot2d import LbGrid
from lbmpy.plot import LbGrid
grid = LbGrid(3, 3)
grid.fill_with_default_arrows()
for field_access, direction in zip(field_mapping, stencil):
......
......@@ -8,7 +8,7 @@ import itertools
from lbmpy.methods.cumulantbased import CumulantBasedLbMethod
from lbmpy.methods.momentbased import MomentBasedLbMethod
from lbmpy.stencils import get_stencil
from pystencils.stencils import stencils_have_same_entries
from pystencils.stencil import have_same_entries
from lbmpy.moments import is_even, gram_schmidt, get_default_moment_set_for_stencil, MOMENT_SYMBOLS, \
exponents_to_polynomial_representations, moments_of_order, moments_up_to_component_order, \
sort_moments_into_groups_of_same_order, get_order, discrete_moment
......@@ -380,12 +380,12 @@ def create_mrt_orthogonal(stencil, relaxation_rate_getter=None, maxwellian_momen
one = sp.Rational(1, 1)
moment_to_relaxation_rate_dict = OrderedDict()
if stencils_have_same_entries(stencil, get_stencil("D2Q9")):
if have_same_entries(stencil, get_stencil("D2Q9")):
moments = get_default_moment_set_for_stencil(stencil)
orthogonal_moments = gram_schmidt(moments, stencil)
orthogonal_moments_scaled = [e * common_denominator(e) for e in orthogonal_moments]
nested_moments = list(sort_moments_into_groups_of_same_order(orthogonal_moments_scaled).values())
elif stencils_have_same_entries(stencil, get_stencil("D3Q15")):
elif have_same_entries(stencil, get_stencil("D3Q15")):
sq = x ** 2 + y ** 2 + z ** 2
nested_moments = [
[one, x, y, z], # [0, 3, 5, 7]
......@@ -395,7 +395,7 @@ def create_mrt_orthogonal(stencil, relaxation_rate_getter=None, maxwellian_momen
[3 * x ** 2 - sq, y ** 2 - z ** 2, x * y, y * z, x * z], # [9, 10, 11, 12, 13]
[x * y * z]
]
elif stencils_have_same_entries(stencil, get_stencil("D3Q19")):
elif have_same_entries(stencil, get_stencil("D3Q19")):
# This MRT variant mentioned in the dissertation of Ulf Schiller
# "Thermal fluctuations and boundary conditions in the lattice Boltzmann method" (2008), p. 24ff
# There are some typos in the moment matrix on p.27
......@@ -417,7 +417,7 @@ def create_mrt_orthogonal(stencil, relaxation_rate_getter=None, maxwellian_momen
[(2 * sq - 3) * (3 * x ** 2 - sq), (2 * sq - 3) * (y ** 2 - z ** 2)], # [10, 12]
[(y ** 2 - z ** 2) * x, (z ** 2 - x ** 2) * y, (x ** 2 - y ** 2) * z] # [16, 17, 18]
]
elif stencils_have_same_entries(stencil, get_stencil("D3Q27")):
elif have_same_entries(stencil, get_stencil("D3Q27")):
xsq, ysq, zsq = x ** 2, y ** 2, z ** 2
all_moments = [
sp.Rational(1, 1), # 0
......
......@@ -387,21 +387,21 @@ def get_default_moment_set_for_stencil(stencil):
Returns a sequence of moments that are commonly used to construct a LBM equilibrium for the given stencil
"""
from lbmpy.stencils import get_stencil
from pystencils.stencils import stencils_have_same_entries
from pystencils.stencil import have_same_entries
to_poly = exponents_to_polynomial_representations
if stencils_have_same_entries(stencil, get_stencil("D2Q9")):
if have_same_entries(stencil, get_stencil("D2Q9")):
return sorted(to_poly(moments_up_to_component_order(2, dim=2)), key=moment_sort_key)
all27_moments = moments_up_to_component_order(2, dim=3)
if stencils_have_same_entries(stencil, get_stencil("D3Q27")):
if have_same_entries(stencil, get_stencil("D3Q27")):
return to_poly(all27_moments)
if stencils_have_same_entries(stencil, get_stencil("D3Q19")):
if have_same_entries(stencil, get_stencil("D3Q19")):
non_matched_moments = [(1, 2, 2), (1, 1, 2), (2, 2, 2), (1, 1, 1)]
moments19 = set(all27_moments) - set(extend_moments_with_permutations(non_matched_moments))
return sorted(to_poly(moments19), key=moment_sort_key)
if stencils_have_same_entries(stencil, get_stencil("D3Q15")):
if have_same_entries(stencil, get_stencil("D3Q15")):
x, y, z = MOMENT_SYMBOLS
non_matched_moments = [(1, 2, 0), (2, 2, 0), (1, 1, 2), (1, 2, 2), (2, 2, 2)]
additional_moments = (6 * (x ** 2 * y ** 2 + x ** 2 * z ** 2 + y ** 2 * z ** 2),
......
......@@ -6,7 +6,7 @@ from pystencils.fd import Diff
def plot_status(phase_field_step, from_x=None, to_x=None):
import lbmpy.plot2d as plt
import lbmpy.plot as plt
domain_size = phase_field_step.data_handling.shape
assert len(domain_size) == 2 and domain_size[1] == 1, "Not a 1D scenario"
......@@ -38,7 +38,7 @@ def plot_status(phase_field_step, from_x=None, to_x=None):
def plot_free_energy_bulk_contours(free_energy, order_parameters, phase0=0, phase1=1,
x_range=(-0.2, 1.2), y_range=(-0.2, 1.2), **kwargs):
import lbmpy.plot2d as plt
import lbmpy.plot as plt
x = np.linspace(x_range[0], x_range[1], 100)
y = np.linspace(y_range[0], y_range[1], 100)
......@@ -109,7 +109,7 @@ def tanh_test(pf_step, phase0, phase1, expected_interface_width=1, time_steps=10
Returns:
deviation of simulated profile from analytical solution as average(abs(simulation-analytic))
"""
import lbmpy.plot2d as plt
import lbmpy.plot as plt
from lbmpy.phasefield.analytical import analytic_interface_profile
domain_size = pf_step.data_handling.shape
......@@ -151,7 +151,7 @@ def galilean_invariance_test(pf_step, velocity=0.05, rounds=3, phase0=0, phase1=
Returns:
change in velocity
"""
import lbmpy.plot2d as plt
import lbmpy.plot as plt
from lbmpy.phasefield.analytical import analytic_interface_profile
domain_size = pf_step.data_handling.shape
......
......@@ -7,7 +7,7 @@ from pystencils import make_slice
def write_phase_field_picture_sequence(sc, filename='two_drops_%05d.png',
time_steps_between_frames=25, total_steps=9000):
import lbmpy.plot2d as plt
import lbmpy.plot as plt
outer_iterations = total_steps // time_steps_between_frames
for i in range(outer_iterations):
plt.figure(figsize=(14, 7))
......@@ -20,7 +20,7 @@ def write_phase_field_picture_sequence(sc, filename='two_drops_%05d.png',
def write_phase_velocity_picture_sequence(sc, filename='falling_drop_%05d.png',
time_steps_between_frames=25, total_steps=9000):
import lbmpy.plot2d as plt
import lbmpy.plot as plt
outer_iterations = total_steps // time_steps_between_frames
for i in range(outer_iterations):
plt.figure(figsize=(14, 10))
......
import matplotlib.patches as patches
from pystencils import make_slice
from pystencils.plot2d import *
from pystencils.plot import *
def boundary_handling(boundary_handling_obj, slice_obj=None, boundary_name_to_color=None, show_legend=True):
......
......@@ -10,5 +10,5 @@ from lbmpy.postprocessing import *
from lbmpy.lbstep import LatticeBoltzmannStep
from lbmpy.geometry import *
from lbmpy.parameterization import ScalingWidget
import lbmpy.plot2d as plt
from pystencils.jupytersetup import *
import lbmpy.plot as plt
from pystencils.jupyter import *
......@@ -139,7 +139,7 @@ def long_run(steady=True, **kwargs):
sc.run(10000)
res = evaluate_static_quantities(sc)
print(res)
import lbmpy.plot2d as plt
import lbmpy.plot as plt
plt.vector_field_magnitude(sc.velocity[:, :])
plt.show()
......
......@@ -181,7 +181,7 @@ def run(convergence_check_interval=1000, convergence_threshold=1e-12, plot_resul
last_vel_field = np.copy(vel)
if plot_result:
import lbmpy.plot2d as plt
import lbmpy.plot as plt
vel_profile = vel[1, params['domain_size'][1] // 2, :, 0]
plt.subplot(1, 2, 1)
plt.plot(vel_profile)
......
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