-
Notifications
You must be signed in to change notification settings - Fork 2
/
simplex.py
191 lines (165 loc) · 5.67 KB
/
simplex.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# -*- coding: utf-8 -*-
# Plot the bulk contributions (no gradients) for a selection of multiphase-field models.
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
import numpy as np
plt.rcParams['figure.figsize'] = (12.0, 8.0)
Titles = (u'Folch',u'Steinbach',u'Chen',u'Moelans',u'Tóth',u'Levitas')
nmodels = len(Titles)
# Folch and Plapp. Phys. Rev. E 72 (2005) 011602. Eqn. 3.14.
def binary_folch(a, b):
return np.power(a*(1.0-a),2) \
+ np.power(b*(1.0-b),2)
def ternary_folch(a, b, c):
return np.power(a*(1.0-a),2) \
+ np.power(b*(1.0-b),2) \
+ np.power(c*(1.0-c),2)
# Steinbach and Pezzolla. Physica D 134 (1999) 385-393. Eqn. 10.
def binary_steinbach(a, b):
return 0.5*np.abs(a)*np.abs(b)
def ternary_steinbach(a, b, c):
return 0.5*np.abs(a)*np.abs(b) \
+ 0.5*np.abs(a)*np.abs(c) \
+ 0.5*np.abs(b)*np.abs(c)
# Chen and Yang. Phys. Rev. B 50 (1994) 15752. Eqn. 1.
def binary_chen(a, b):
return (0.25*a**4 - 0.5*a**2) \
+ (0.25*b**4 - 0.5*b**2) \
+ 2.0*a**2*b**2
def ternary_chen(a, b, c):
return (0.25*a**4 - 0.5*a**2) \
+ (0.25*b**4 - 0.5*b**2) \
+ (0.25*c**4 - 0.5*c**2) \
+ 2.0*a**2*b**2 \
+ 2.0*a**2*c**2 \
+ 2.0*b**2*c**2
# Moelans, Blanpain, and Wollants. Pyhs. Rev. B 78 (2008) 024113. Eqn. 2.
def binary_moelans(a, b):
gamma = 1.5
return 1.0/4 + (0.25*a**4 - 0.5*a**2) \
+ (0.25*b**4 - 0.5*b**2) \
+ gamma*a**2*b**2
def ternary_moelans(a, b, c):
gamma = 1.5
return 1.0/4 + (0.25*a**4 - 0.5*a**2) \
+ (0.25*b**4 - 0.5*b**2) \
+ (0.25*c**4 - 0.5*c**2) \
+ gamma*(a**2*b**2 + a**2*c**2 + b**2+c**2)
# Toth, Pusztai, and Granasy. Phys. Rev. B 92 (2015) 184105. Eqn. 30.
def binary_toth(a, b):
return 1.0/12 + (0.25*a**4 - (1.0/3)*a**3) \
+ (0.25*b**4 - (1.0/3)*b**3) \
+ 0.5*a**2*b**2
def ternary_toth(a, b, c):
return 1.0/12 + (0.25*a**4 - (1.0/3)*a**3) \
+ (0.25*b**4 - (1.0/3)*b**3) \
+ (0.25*c**4 - (1.0/3)*c**3) \
+ 0.5*(a**2*b**2 + a**2*c**2 + b**2+c**2)
# Levitas and Roy. Phys. Rev. B 91 (2015) 174109. Eqn. 4.
def binary_levitas(a, b):
l=2
return (a + b - 1.0)**2*np.power(a,l)*np.power(b,l)
def ternary_levitas(a, b, c):
l=2
return (a + b - 1.0)**2*np.power(a,l)*np.power(b,l) \
+ (a + c - 1.0)**2*np.power(a,l)*np.power(c,l) \
+ (b + c - 1.0)**2*np.power(b,l)*np.power(c,l) \
+ 0.0625*a**2*b**2*c**2
# Binary system
span = (-1.05,1.05)
a = np.linspace(span[0],span[1],400)
b = np.linspace(span[0],span[1],400)
x = np.zeros(len(a)*len(b))
y = np.zeros(len(a)*len(b))
z = np.ndarray(shape=(nmodels,len(a)*len(b)), dtype=float)
zpath = np.zeros(len(a)*len(b))
sqx = np.array([0,1,1,0,0])
sqy = np.array([0,0,1,1,0])
n=0
for j in np.nditer(b):
for i in np.nditer(a):
x[n] = i
y[n] = j
zpath[n] = i+j
z[0][n] = binary_folch(i, j)
z[1][n] = binary_steinbach(i, j)
z[2][n] = binary_chen(i, j)
z[3][n] = binary_moelans(i, j)
z[4][n] = binary_toth(i, j)
z[5][n] = binary_levitas(i, j)
n+=1
f, axarr = plt.subplots(nrows=2, ncols=3, sharex='col', sharey='row')
f.suptitle("MPF Binary Potentials",fontsize=14)
n=0
for ax in axarr.reshape(-1):
ax.set_title(Titles[n],fontsize=10)
ax.axis('equal')
ax.set_xlim(span)
ax.set_ylim(span)
ax.axis('off')
confil = ax.tricontourf(x,y,z[n], 96, cmap=plt.cm.get_cmap('coolwarm'))
ax.tricontour(x,y,zpath, [1.0])
ax.plot(sqx,sqy, linestyle=':', color='w')
n+=1
plt.figtext(x=0.5, y=0.0625, ha='center', fontsize=8, \
s=r'White boxes enclose $x,y\in[0,1]$. Black pathways constrain $\phi_\alpha+\phi_\beta=1$.')
f.savefig('binary.png', dpi=400, bbox_inches='tight')
plt.close()
# Ternary system
npts = 200
span = (-0.05,1.05)
yspan = (-0.15,0.95)
x = np.linspace(span[0],span[1],npts)
y = np.linspace(yspan[0],yspan[1],npts)
z = np.ndarray(shape=(nmodels,len(x)*len(y)), dtype=float)
trix = np.array([0,1,0.5,0])
triy = np.array([0,0,np.sqrt(3)/2,0])
offx = 0.5*(trix - 1)
offy = 0.5*(triy - 1)
p = np.zeros(len(x)*len(y))
q = np.zeros(len(x)*len(y))
n=0
for j in np.nditer(y):
for i in np.nditer(x):
c = 2.0*j/np.sqrt(3.0)
b = (2.0*i-c)/2.0
a = 1.0 - b - c
p[n]=i
q[n]=j
z[0][n] = ternary_folch(a,b,c)
z[1][n] = ternary_steinbach(a,b,c)
z[2][n] = ternary_chen(a,b,c)
z[3][n] = np.min((ternary_moelans(a,b,c),ternary_moelans(b,a,c),ternary_moelans(b,c,a),
ternary_moelans(a,c,b),ternary_moelans(c,a,b),ternary_moelans(c,b,a)))
z[4][n] = np.min((ternary_toth(a,b,c),ternary_toth(b,a,c),ternary_toth(b,c,a),
ternary_toth(a,c,b),ternary_toth(c,a,b),ternary_toth(c,b,a)))
z[5][n] = ternary_levitas(a,b,c)
n+=1
f, axarr = plt.subplots(nrows=2, ncols=3, sharex='col', sharey='row')
f.suptitle("MPF Ternary Potentials",fontsize=14)
n=0
for ax in axarr.reshape(-1):
ax.set_title(Titles[n],fontsize=10)
ax.axis('equal')
ax.set_xlim(span)
ax.set_ylim(yspan)
ax.axis('off')
ax.tricontourf(p,q,z[n], 96, cmap=plt.cm.get_cmap('coolwarm'))
ax.plot(trix,triy, linestyle=':', color='w')
n+=1
plt.figtext(x=0.5, y=0.0625, ha='center', fontsize=8, \
s=r'White triangles enclose Gibbs simplex, $\phi_\alpha+\phi_\beta+\phi_\gamma=1$.')
f.savefig('ternary.png', dpi=400, bbox_inches='tight')
plt.close()
for n in range(len(z)):
plt.axis('equal')
plt.xlim(span)
plt.ylim(yspan)
plt.axis('off')
plt.tricontourf(p,q,z[n], 96, cmap=plt.cm.get_cmap('coolwarm'))
plt.plot(trix,triy, linestyle=':', color='w')
plt.margins(0,0)
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator())
plt.savefig(Titles[n]+"MPF.png", transparent=True, dpi=600, bbox_inches='tight', pad_inches=0)
plt.close()