Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jonas Plewinski
pystencils
Commits
d01a0422
Commit
d01a0422
authored
Apr 28, 2019
by
Martin Bauer
Browse files
Moved phase field plotting functions from lbmpy to pystencils
parent
61d1bae6
Changes
1
Hide whitespace changes
Inline
Side-by-side
pystencils/plot2d.py
View file @
d01a0422
...
...
@@ -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):
colorbar
()
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
sympy_function
(
expr
,
x_values
=
None
,
**
kwargs
):
"""Plots the graph of a sympy term that depends on one symbol only.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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