Commit d01a0422 authored by Martin Bauer's avatar Martin Bauer
Browse files

Moved phase field plotting functions from lbmpy to pystencils

parent 61d1bae6
Pipeline #15077 passed with stage
in 1 minute and 33 seconds
......@@ -4,6 +4,8 @@ simulation coordinate system (y-axis goes up), instead of the "image coordinate
matplotlib normally uses.
from matplotlib.pyplot import *
from itertools import cycle
from matplotlib.text import Text
def vector_field(array, step=2, **kwargs):
......@@ -135,6 +137,27 @@ def multiple_scalar_fields(array, **kwargs):
def phase_plot(phase_field: np.ndarray, linewidth=1.0, clip=True) -> None:
"""Plots a phase field array using the phase variables as alpha channel.
phase_field: array with len(shape) == 3, first two dimensions are spatial, the last one indexes the phase
linewidth: line width of the 0.5 contour lines that are drawn over the alpha blended phase images
clip: see scalar_field_alpha_value function
color_cycle = cycle(['#fe0002', '#00fe00', '#0000ff', '#ffa800', '#f600ff'])
assert len(phase_field.shape) == 3
with warnings.catch_warnings():
for i in range(phase_field.shape[-1]):
scalar_field_alpha_value(phase_field[..., i], next(color_cycle), clip=clip, interpolation='bilinear')
if linewidth:
for i in range(phase_field.shape[-1]):
scalar_field_contour(phase_field[..., i], levels=[0.5], colors='k', linewidths=[linewidth])
def sympy_function(expr, x_values=None, **kwargs):
"""Plots the graph of a sympy term that depends on one symbol only.
Supports Markdown
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