Skip to content
Snippets Groups Projects
Commit 41c36e74 authored by Martin Bauer's avatar Martin Bauer
Browse files

Moved phase-field plotting functions to pystencils

parent 7846a2dc
No related merge requests found
from itertools import cycle
import matplotlib.patches as patches
from matplotlib.text import Text
from pystencils import make_slice
from pystencils.plot2d import *
......@@ -63,28 +61,6 @@ def boundary_handling(boundary_handling_obj, slice_obj=None, boundary_name_to_co
legend(handles=path_list, bbox_to_anchor=(1.02, 0.5), loc=2, borderaxespad=0.)
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.
Args:
phase_field: array with len(shape) == 3, first two dimensions are spatial, the last one indexes the phase
components.
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():
warnings.simplefilter("ignore")
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 phase_plot_for_step(phase_field_step, slice_obj=make_slice[:, :], **kwargs):
concentrations = phase_field_step.concentration[slice_obj]
phase_plot(concentrations, **kwargs)
......
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