|
1 | 1 | import matplotlib
|
2 | 2 | matplotlib.rc('text', usetex=True)
|
3 |
| -import pylab |
| 3 | +import matplotlib.pyplot as plt |
4 | 4 | import numpy as np
|
5 | 5 |
|
6 | 6 | # interface tracking profiles
|
7 | 7 | N = 500
|
8 | 8 | delta = 0.6
|
9 | 9 | X = np.linspace(-1, 1, N)
|
10 |
| -pylab.plot(X, (1 - np.tanh(4.*X/delta))/2, # phase field tanh profiles |
| 10 | +plt.plot(X, (1 - np.tanh(4.*X/delta))/2, # phase field tanh profiles |
11 | 11 | X, (X + 1)/2, # level set distance function
|
12 | 12 | X, (1.4 + np.tanh(4.*X/delta))/4, # composition profile
|
13 | 13 | X, X < 0, 'k--', # sharp interface
|
14 | 14 | linewidth=5)
|
15 | 15 |
|
16 | 16 | # legend
|
17 |
| -pylab.legend((r'phase field', r'level set', r'composition', r'sharp interface'), shadow=True, loc=(0.01, 0.55)) |
| 17 | +plt.legend(('phase field', 'level set', 'composition', 'sharp interface'), shadow=True, loc=(0.01, 0.55)) |
18 | 18 |
|
19 |
| -ltext = pylab.gca().get_legend().get_texts() |
20 |
| -pylab.setp(ltext[0], fontsize=20, color='b') |
21 |
| -pylab.setp(ltext[1], fontsize=20, color='g') |
22 |
| -pylab.setp(ltext[2], fontsize=20, color='r') |
23 |
| -pylab.setp(ltext[3], fontsize=20, color='k') |
| 19 | +ltext = plt.gca().get_legend().get_texts() |
| 20 | +plt.setp(ltext[0], fontsize=20, color='b') |
| 21 | +plt.setp(ltext[1], fontsize=20, color='g') |
| 22 | +plt.setp(ltext[2], fontsize=20, color='r') |
| 23 | +plt.setp(ltext[3], fontsize=20, color='k') |
24 | 24 |
|
25 | 25 | # the arrow
|
26 | 26 | height = 0.1
|
27 | 27 | offset = 0.02
|
28 |
| -pylab.plot((-delta / 2., delta / 2), (height, height), 'k', linewidth=2) |
29 |
| -pylab.plot((-delta / 2, -delta / 2 + offset * 2), (height, height - offset), 'k', linewidth=2) |
30 |
| -pylab.plot((-delta / 2, -delta / 2 + offset * 2), (height, height + offset), 'k', linewidth=2) |
31 |
| -pylab.plot((delta / 2, delta / 2 - offset * 2), (height, height - offset), 'k', linewidth=2) |
32 |
| -pylab.plot((delta / 2, delta / 2 - offset * 2), (height, height + offset), 'k', linewidth=2) |
33 |
| -pylab.text(-0.06, height - 0.06, r'$\delta$', {'color': 'k', 'fontsize': 24}) |
| 28 | +plt.plot((-delta / 2., delta / 2), (height, height), 'k', linewidth=2) |
| 29 | +plt.plot((-delta / 2, -delta / 2 + offset * 2), (height, height - offset), 'k', linewidth=2) |
| 30 | +plt.plot((-delta / 2, -delta / 2 + offset * 2), (height, height + offset), 'k', linewidth=2) |
| 31 | +plt.plot((delta / 2, delta / 2 - offset * 2), (height, height - offset), 'k', linewidth=2) |
| 32 | +plt.plot((delta / 2, delta / 2 - offset * 2), (height, height + offset), 'k', linewidth=2) |
| 33 | +plt.text(-0.06, height - 0.06, r'$\delta$', {'color': 'k', 'fontsize': 24}) |
34 | 34 |
|
35 | 35 | # X-axis label
|
36 |
| -pylab.xticks((-1, 0, 1), ('-1', '0', '1'), color='k', size=20) |
| 36 | +plt.xticks((-1, 0, 1), ('-1', '0', '1'), color='k', size=20) |
37 | 37 |
|
38 | 38 | # Left Y-axis labels
|
39 |
| -pylab.ylabel(r'\bf{phase field} $\phi$', {'color': 'b', |
| 39 | +plt.ylabel(r'\bf{phase field} $\phi$', {'color': 'b', |
40 | 40 | 'fontsize': 20})
|
41 |
| -pylab.yticks((0, 0.5, 1), ('0', '.5', '1'), color='k', size=20) |
| 41 | +plt.yticks((0, 0.5, 1), ('0', '.5', '1'), color='k', size=20) |
42 | 42 |
|
43 | 43 | # Right Y-axis labels
|
44 |
| -pylab.text(1.05, 0.5, r"\bf{level set} $\phi$", {'color': 'g', 'fontsize': 20}, |
| 44 | +plt.text(1.05, 0.5, r"\bf{level set} $\phi$", {'color': 'g', 'fontsize': 20}, |
45 | 45 | horizontalalignment='left',
|
46 | 46 | verticalalignment='center',
|
47 | 47 | rotation=90,
|
48 | 48 | clip_on=False)
|
49 |
| -pylab.text(1.01, -0.02, "-1", {'color': 'k', 'fontsize': 20}) |
50 |
| -pylab.text(1.01, 0.98, "1", {'color': 'k', 'fontsize': 20}) |
51 |
| -pylab.text(1.01, 0.48, "0", {'color': 'k', 'fontsize': 20}) |
| 49 | +plt.text(1.01, -0.02, "-1", {'color': 'k', 'fontsize': 20}) |
| 50 | +plt.text(1.01, 0.98, "1", {'color': 'k', 'fontsize': 20}) |
| 51 | +plt.text(1.01, 0.48, "0", {'color': 'k', 'fontsize': 20}) |
52 | 52 |
|
53 | 53 | # level set equations
|
54 |
| -pylab.text(0.1, 0.85, |
| 54 | +plt.text(0.1, 0.85, |
55 | 55 | r'$|\nabla\phi| = 1,$ \newline $ \frac{\partial \phi}{\partial t}'
|
56 | 56 | r'+ U|\nabla \phi| = 0$',
|
57 | 57 | {'color': 'g', 'fontsize': 20})
|
58 | 58 |
|
59 | 59 | # phase field equations
|
60 |
| -pylab.text(0.2, 0.15, |
| 60 | +plt.text(0.2, 0.15, |
61 | 61 | r'$\mathcal{F} = \int f\left( \phi, c \right) dV,$ \newline '
|
62 | 62 | r'$ \frac{ \partial \phi } { \partial t } = -M_{ \phi } '
|
63 | 63 | r'\frac{ \delta \mathcal{F} } { \delta \phi }$',
|
64 | 64 | {'color': 'b', 'fontsize': 20})
|
65 | 65 |
|
66 | 66 | # these went wrong in pdf in a previous version
|
67 |
| -pylab.text(-.9, .42, r'gamma: $\gamma$', {'color': 'r', 'fontsize': 20}) |
68 |
| -pylab.text(-.9, .36, r'Omega: $\Omega$', {'color': 'b', 'fontsize': 20}) |
| 67 | +plt.text(-.9, .42, r'gamma: $\gamma$', {'color': 'r', 'fontsize': 20}) |
| 68 | +plt.text(-.9, .36, r'Omega: $\Omega$', {'color': 'b', 'fontsize': 20}) |
69 | 69 |
|
70 |
| -pylab.show() |
| 70 | +plt.show() |
0 commit comments