In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from pycalphad import Database, equilibrium
import pycalphad.variables as v

db = Database('Fe-C_Fei_Brosh_2014_09.TDB')

In [2]:
%time data = equilibrium(db, ['FE', 'C', 'VA'], 'FCC_A1', {v.X('C'): 1e-6, v.T: 600, v.P: np.logspace(5, 10, num=10)})


Components: C FE VA
Phases: FCC_A1 [done]
Computing initial grid [206 points, 150.1KB]
Computing convex hull [iteration 1]
progress 50755.0679471 [10 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 1 [FCC_A1]
Rebuilding grid [208 points, 151.5KB]
Computing convex hull [iteration 2]
progress 12322.8426547 [10 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 2 [FCC_A1]
Rebuilding grid [210 points, 153.0KB]
Computing convex hull [iteration 3]
progress 14324.8926141 [10 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 1 [FCC_A1]
Rebuilding grid [212 points, 154.5KB]
Computing convex hull [iteration 4]
progress 37.2542701839 [10 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [214 points, 155.9KB]
Computing convex hull [iteration 5]
progress 148.923772432 [10 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [216 points, 157.4KB]
Computing convex hull [iteration 6]
progress 451.185532662 [10 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [218 points, 158.8KB]
Computing convex hull [iteration 7]
progress 8364.91527512 [10 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [220 points, 160.3KB]
Computing convex hull [iteration 8]
progress 2171.20064234 [10 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [222 points, 161.7KB]
Computing convex hull [iteration 9]
progress 816.92902158 [10 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [224 points, 163.2KB]
Computing convex hull [iteration 10]
progress 299.861308611 [10 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [226 points, 164.6KB]
Computing convex hull [iteration 11]
progress 175.317754512 [10 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [228 points, 166.1KB]
Computing convex hull [iteration 12]
progress 81.1049777177 [10 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [230 points, 167.6KB]
Computing convex hull [iteration 13]
progress 41.2347894224 [10 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [232 points, 169.0KB]
Computing convex hull [iteration 14]
progress 21.024919076 [10 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [234 points, 170.5KB]
Computing convex hull [iteration 15]
progress 10.4693673679 [9 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [236 points, 171.9KB]
Computing convex hull [iteration 16]
progress 0.0824469776635 [9 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [238 points, 173.4KB]
Computing convex hull [iteration 17]
progress 0.081365446109 [9 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [240 points, 174.8KB]
Computing convex hull [iteration 18]
progress 0.00193254528858 [7 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [242 points, 176.3KB]
Computing convex hull [iteration 19]
progress 0.00153138704627 [8 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [244 points, 177.7KB]
Computing convex hull [iteration 20]
progress 0.00153947940998 [7 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [246 points, 179.2KB]
Computing convex hull [iteration 21]
progress 0.00127761557815 [8 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [248 points, 180.7KB]
Computing convex hull [iteration 22]
progress 0.00233615589968 [8 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [250 points, 182.1KB]
Computing convex hull [iteration 23]
progress 0.00186257286987 [9 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [252 points, 183.6KB]
Computing convex hull [iteration 24]
progress 0.00336849553423 [8 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [254 points, 185.0KB]
Computing convex hull [iteration 25]
progress 0.00450045372418 [8 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [256 points, 186.5KB]
Computing convex hull [iteration 26]
progress 0.00367625788931 [9 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [258 points, 187.9KB]
Computing convex hull [iteration 27]
progress 0.00294014819519 [7 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [260 points, 189.4KB]
Computing convex hull [iteration 28]
progress 0.0015698143834 [8 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [262 points, 190.9KB]
Computing convex hull [iteration 29]
progress 0.00222050707816 [9 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [264 points, 192.3KB]
Computing convex hull [iteration 30]
progress 0.00192057011009 [9 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [266 points, 193.8KB]
Computing convex hull [iteration 31]
progress 7.13013020352 [8 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [268 points, 195.2KB]
Computing convex hull [iteration 32]
progress 0.00180879293475 [8 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [270 points, 196.7KB]
Computing convex hull [iteration 33]
progress 0.00248296662903 [7 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [272 points, 198.1KB]
Computing convex hull [iteration 34]
progress 0.00289583539416 [8 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [274 points, 199.6KB]
Computing convex hull [iteration 35]
progress 0.00434186046186 [8 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [276 points, 201.0KB]
Computing convex hull [iteration 36]
progress 0.00192853721819 [7 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [278 points, 202.5KB]
Computing convex hull [iteration 37]
progress 0.00235502437135 [8 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [280 points, 204.0KB]
Computing convex hull [iteration 38]
progress 0.00376783922547 [8 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [282 points, 205.4KB]
Computing convex hull [iteration 39]
progress 0.00234944780095 [8 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [284 points, 206.9KB]
Computing convex hull [iteration 40]
progress 6.90983540387 [7 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [286 points, 208.3KB]
Computing convex hull [iteration 41]
progress 0.00266633637511 [7 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [288 points, 209.8KB]
Computing convex hull [iteration 42]
progress 8.68851824803 [7 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [290 points, 211.2KB]
Computing convex hull [iteration 43]
progress 7.15709162499 [4 conditions updated]
Refining convex hull
N-R convergence on mini-iteration 0 [FCC_A1]
Rebuilding grid [292 points, 212.7KB]
Computing convex hull [iteration 44]
progress 0.0 [0 conditions updated]
Convergence achieved
CPU times: user 41 s, sys: 91 ms, total: 41.1 s
Wall time: 40.9 s

In [3]:
data


Out[3]:
<xray.Dataset>
Dimensions:       (P: 10, T: 1, X_C: 1, component: 2, internal_dof: 3, vertex: 2)
Coordinates:
  * P             (P) float64 1e+05 3.594e+05 1.292e+06 4.642e+06 1.668e+07 ...
  * T             (T) float64 600.0
  * X_C           (X_C) float64 1e-06
  * vertex        (vertex) int64 0 1
  * component     (component) object 'C' 'FE'
  * internal_dof  (internal_dof) int64 0 1 2
Data variables:
    NP            (P, T, X_C, vertex) float64 0.1996 0.8004 0.003445 0.9966 ...
    MU            (P, T, X_C, component) float64 -4.069e+04 -1.669e+04 ...
    GM            (P, T, X_C) float64 -1.669e+04 -1.669e+04 -1.668e+04 ...
    X             (P, T, X_C, vertex, component) float64 1e-06 1.0 1e-06 1.0 ...
    Y             (P, T, X_C, vertex, internal_dof) float64 1.0 1e-06 1.0 ...
    Phase         (P, T, X_C, vertex) object u'FCC_A1' u'FCC_A1' u'FCC_A1' ...
Attributes:
    iterations: 44

In [4]:
fig = plt.gca()
fig.plot(data['P'], np.exp(data['MU'].sel(T=600, X_C=1e-6, component='C')/(8.3145*600)))
fig.set_title('Equilibrium for X(C)=1e-6 and T=600 K', fontsize=15)
fig.set_xlabel('P (Pa)', fontsize=15)
fig.set_ylabel('Carbon Activity', fontsize=15)
fig.set_yscale('log')
fig.set_xscale('log')



In [5]:
from_tc = np.array([
   [1.00000E+05, 2.87082E-04],
   [2.50098E+08, 3.43702E-04],
   [5.00095E+08, 4.11376E-04],
   [7.50092E+08, 4.92240E-04],
   [1.00009E+09, 5.88842E-04],
   [1.25009E+09, 7.04217E-04],
   [1.50008E+09, 8.41978E-04],
   [1.75008E+09, 1.00643E-03],
   [2.00008E+09, 1.20270E-03],
   [2.25008E+09, 1.43688E-03],
   [2.50008E+09, 1.71624E-03],
   [2.75007E+09, 2.04941E-03],
   [3.00007E+09, 2.44668E-03],
   [3.25007E+09, 2.92025E-03],
   [3.50006E+09, 3.48467E-03],
   [3.75006E+09, 4.15723E-03],
   [4.00006E+09, 4.95845E-03],
   [4.25006E+09, 5.91275E-03],
   [4.50006E+09, 7.04914E-03],
   [4.75005E+09, 8.40209E-03],
   [5.00005E+09, 1.00125E-02],
   [5.25005E+09, 1.19290E-02],
   [5.50004E+09, 1.42094E-02],
   [5.75004E+09, 1.69221E-02],
   [6.00004E+09, 2.01484E-02],
   [6.25004E+09, 2.39849E-02],
   [6.50004E+09, 2.85461E-02],
   [6.75003E+09, 3.39678E-02],
   [7.00003E+09, 4.04112E-02],
   [7.25003E+09, 4.80674E-02],
   [7.50002E+09, 5.71628E-02],
   [7.75002E+09, 6.79661E-02],
   [8.00002E+09, 8.07956E-02],
   [8.25002E+09, 9.60286E-02],
   [8.50002E+09, 1.14112E-01],
   [8.75001E+09, 1.35576E-01],
   [9.00001E+09, 1.61047E-01],
   [9.25001E+09, 1.91268E-01],
   [9.50000E+09, 2.27120E-01],
   [9.75000E+09, 2.69643E-01],
   [1.00000E+10, 3.20071E-01]
    ])
fig = plt.gca()
fig.plot(from_tc[:, 0], from_tc[:, 1])
fig.set_title('Equilibrium for X(C)=1e-6 and T=600 K', fontsize=15)
fig.set_xlabel('P (Pa)', fontsize=15)
fig.set_ylabel('Carbon Activity', fontsize=15)
fig.set_yscale('log')
fig.set_xscale('log')



In [ ]: