In [10]:
%matplotlib inline
from pycalphad import Database, energy_surf, isotherm
from pycalphad.variables import *

db = Database('AlTiV.tdb')
my_phases = list(set(db.phases.keys()) - set(['BCC_A2', 'FCC_A1'])) # get all phases in database
%time sys_df = energy_surf(db, ['V', 'AL', 'TI', 'VA'] , my_phases, T=1600.0, pdens=10000)


CPU times: user 26.7 s, sys: 66 ms, total: 26.8 s
Wall time: 25.8 s

In [11]:
%time isotherm(sys_df, 'X(V)','X(AL)', T=1600.0)


CPU times: user 8.94 s, sys: 64 ms, total: 9 s
Wall time: 8.99 s

In [19]:
# Perform some setup for phase-specific coloring of points
import numpy as np
colorlist = {}

# colors from Junwei Huang, March 21 2013
ColorValues=["FF0000", "00FF00", "0000FF", "FFFF00", "FF00FF", "00FFFF", "000000", 
        "800000", "008000", "000080", "808000", "800080", "008080", "808080", 
        "C00000", "00C000", "0000C0", "C0C000", "C000C0", "00C0C0", "C0C0C0", 
        "400000", "004000", "000040", "404000", "400040", "004040", "404040", 
        "200000", "002000", "000020", "202000", "200020", "002020", "202020", 
        "600000", "006000", "000060", "606000", "600060", "006060", "606060", 
        "A00000", "00A000", "0000A0", "A0A000", "A000A0", "00A0A0", "A0A0A0", 
        "E00000", "00E000", "0000E0", "E0E000", "E000E0", "00E0E0", "E0E0E0"]
M=len(ColorValues)

phasecount = 0
for phase in my_phases:
	colorlist[phase] = "#"+ColorValues[np.mod(phasecount,M)]
	phasecount = phasecount + 1

# Get the configured plot colors
plotcolors = list(map(lambda x: colorlist[x], sys_df['Phase'].values))

In [20]:
# Final plotting setup
import numpy as np
import matplotlib.pyplot as plt
import scipy.spatial
x_variable = 'X(V)'
y_variable = 'X(AL)'
hull = scipy.spatial.ConvexHull(
    sys_df[['X(V)', 'X(AL)', 'GM']].values
)
fig = plt.figure(dpi=600,figsize=(9,9))
ax = fig.gca(projection="triangular") # use ternary axes
ax.tick_params(axis='both', which='major', labelsize=14)
ax.grid(True)
plt.xlim([-0.01,1])
plt.ylim([-0.01,1])
plt.gca().set_aspect('equal')

ax.text(0.3, 0.8, 'T = '+str(sys_df['T'][0])+ ' K',
        verticalalignment='bottom', horizontalalignment='left',
        color='black', fontsize=20)

stable_df = sys_df.ix[np.unique(np.ravel(hull.vertices))]
for phase in my_phases:
    # Plot each phase separately so we can mark the legend properly
    phase_frame = stable_df[(stable_df.Phase == phase)]
    if (len(phase_frame) > 0):
        ax.scatter(phase_frame[x_variable], phase_frame[y_variable], c=colorlist[phase],
                       marker='o',
                       label=phase,
                       zorder=2, alpha=0.4)
        ax.legend(loc=0, fontsize=15)
plt.title('Energy Surface',fontsize=25, x=0.5, y=0.9)
ax.set_xlabel(x_variable, labelpad=15,fontsize=20)
ax.set_ylabel(y_variable,rotation=60,fontsize=20,labelpad=-120)
plt.show()



In [12]: