Equilibrium Properties and Partial Ordering (Al-Fe and Al-Ni) ============================================================= .. code:: ipython3 # Only needed in a Jupyter Notebook %matplotlib inline # Optional plot styling import matplotlib matplotlib.style.use('bmh') .. code:: ipython3 import matplotlib.pyplot as plt from pycalphad import equilibrium from pycalphad import Database, Model import pycalphad.variables as v import numpy as np Al-Fe (Heat Capacity and Degree of Ordering) -------------------------------------------- Here we compute equilibrium thermodynamic properties in the Al-Fe system. We know that only B2 and liquid are stable in the temperature range of interest, but we just as easily could have included all the phases in the calculation using my_phases = list(db.phases.keys()). Notice that the syntax for specifying a range is (min, max, step). We can also directly specify a list of temperatures using the list syntax, e.g., [300, 400, 500, 1400]. We explicitly indicate that we want to compute equilibrium values of the heat_capacity and degree_of_ordering properties. These are both defined in the default Model class. For a complete list, see the documentation. equilibrium will always return the Gibbs energy, chemical potentials, phase fractions and site fractions, regardless of the value of output. .. code:: ipython3 db = Database('alfe_sei.TDB') my_phases = ['LIQUID', 'B2_BCC'] eq = equilibrium(db, ['AL', 'FE', 'VA'], my_phases, {v.X('AL'): 0.25, v.T: (300, 2000, 50), v.P: 101325}, output=['heat_capacity', 'degree_of_ordering']) print(eq) .. parsed-literal:: Dimensions: (P: 1, T: 34, X_AL: 1, component: 2, internal_dof: 5, vertex: 2) Coordinates: * P (P) float64 1.013e+05 * T (T) float64 300.0 350.0 400.0 450.0 500.0 550.0 ... * X_AL (X_AL) float64 0.25 * vertex (vertex) int64 0 1 * component (component) Dimensions: (P: 1, T: 1, X_AL: 100, component: 2, internal_dof: 5, vertex: 2) Coordinates: * P (P) float64 1.013e+05 * T (T) float64 700.0 * X_AL (X_AL) float64 1e-09 0.01 0.02 0.03 0.04 0.05 0.06 ... * vertex (vertex) int64 0 1 * component (component) Dimensions: (P: 1, T: 110, X_AL: 1, component: 2, internal_dof: 5, vertex: 2) Coordinates: * P (P) float64 1.013e+05 * T (T) float64 300.0 320.0 340.0 360.0 380.0 400.0 ... * X_AL (X_AL) float64 0.1 * vertex (vertex) int64 0 1 * component (component) .. image:: EquilibriumWithOrdering_files/EquilibriumWithOrdering_16_1.png In the plot below we see that the degree of ordering does not change at all in each phase. There is a very abrupt disappearance of the completely ordered gamma-prime phase, leaving the completely disordered gamma phase. This is a first-order phase transition. .. code:: ipython3 plt.gca().set_title('Al-Ni: Degree of fcc ordering vs T [X(AL)=0.1]') plt.gca().set_xlabel('Temperature (K)') plt.gca().set_ylabel('Degree of ordering') plt.gca().set_ylim((-0.1,1.1)) # Generate a list of all indices where FCC_L12 is stable and ordered L12_phase_indices = np.nonzero(np.logical_and((eq_alni.Phase.values == 'FCC_L12'), (eq_alni.degree_of_ordering.values > 0.01))) # Generate a list of all indices where FCC_L12 is stable and disordered fcc_phase_indices = np.nonzero(np.logical_and((eq_alni.Phase.values == 'FCC_L12'), (eq_alni.degree_of_ordering.values <= 0.01))) # phase_indices[1] refers to all temperature indices # We know this because pycalphad always returns indices in order like P, T, X's plt.plot(np.take(eq_alni['T'].values, L12_phase_indices[1]), eq_alni['degree_of_ordering'].values[L12_phase_indices], label='$\gamma\prime$ (ordered fcc)', color='red') plt.plot(np.take(eq_alni['T'].values, fcc_phase_indices[1]), eq_alni['degree_of_ordering'].values[fcc_phase_indices], label='$\gamma$ (disordered fcc)', color='blue') plt.legend() plt.show() .. image:: EquilibriumWithOrdering_files/EquilibriumWithOrdering_18_0.png