In [1]:
from pycalphad import Database, Model, variables as v
from pycalphad import equilibrium
import numpy as np

In [2]:
from pycalphad.tests.datasets import *
dbf = Database(ROSE_TDB)

In [3]:
eq2 = equilibrium(dbf, ['H', 'HE', 'LI'], ['TEST'],
                 {v.X('LI'): 0.3, v.MU('H'): -7385.549841,
                  v.T: 1273, v.P: 1e5}, verbose=True, calc_opts={'pdens': 10})
print(eq2)


Components: H HE LI
Phases: build_callables [N, P, T]
TEST 
[done]
build_callables [N, P, T]
('included_composition_indices', array([ 2, -1], dtype=int32))
('best_guess_simplex', array([1, 2], dtype=int32))
('trial_simplices', array([[1, 2],
       [1, 2]], dtype=int32))
('f_contig_trial', array([[ 0.,  1.],
       [ 1.,  1.]]))
('rhs', array([ 0.3,  1. ]))
('fractions', array([ 0.7,  0.3]))
('f_contig_trial', array([[ 0.,  1.],
       [ 1.,  1.]]))
('rhs', array([ 0.3,  1. ]))
('fractions', array([ 0.7,  0.3]))
('smallest_fractions', array([ 0.3,  0.3]))
('candidate_tieline', array([[ 1.,  0.],
       [ 0.,  1.]]))
('rhs', array([  1.00000000e+10,   1.00000000e+10]))
('candidate_potentials', array([  1.00000000e+10,   1.00000000e+10]))
('min_df', array(30))
('min_df_value', array(-10000007271.047592))
('f_contig_trial', array([[ 0.55555556,  1.        ],
       [ 1.        ,  1.        ]]))
('rhs', array([ 0.3,  1. ]))
('fractions', array([ 1.575, -0.575]))
('f_contig_trial', array([[ 0.        ,  0.55555556],
       [ 1.        ,  1.        ]]))
('rhs', array([ 0.3,  1. ]))
('fractions', array([ 0.46,  0.54]))
('smallest_fractions', array([-1.575, -0.54 ]))
('candidate_tieline', array([[ 1.        ,  0.        ],
       [ 0.44444444,  0.55555556]]))
('rhs', array([  1.00000000e+10,  -7.27104760e+03]))
('candidate_potentials', array([  1.00000000e+10,  -8.00001309e+09]))
('min_df', array(4))
('min_df_value', array(-9999999999.999973))
('f_contig_trial', array([[  1.00000000e-15,   5.55555556e-01],
       [  1.00000000e+00,   1.00000000e+00]]))
('rhs', array([ 0.3,  1. ]))
('fractions', array([ 0.46,  0.54]))
('f_contig_trial', array([[  0.00000000e+00,   1.00000000e-15],
       [  1.00000000e+00,   1.00000000e+00]]))
('rhs', array([ 0.3,  1. ]))
('fractions', array([ -3.00000000e+14,   3.00000000e+14]))
('smallest_fractions', array([  4.60000000e-01,  -3.00000000e+14]))
('candidate_tieline', array([[  1.00000000e+00,   1.00000000e-15],
       [  4.44444444e-01,   5.55555556e-01]]))
('rhs', array([ -7.47258030e-10,  -7.27104760e+03]))
('candidate_potentials', array([ -7.34170145e-10,  -1.30878857e+04]))
('min_df', array(9))
('min_df_value', array(-4275.244200561462))
('f_contig_trial', array([[  1.00000000e-15,   5.55555556e-01],
       [  1.00000000e+00,   1.00000000e+00]]))
('rhs', array([ 0.3,  1. ]))
('fractions', array([ 0.46,  0.54]))
('f_contig_trial', array([[  1.00000000e-15,   1.00000000e-15],
       [  1.00000000e+00,   1.00000000e+00]]))
('rhs', array([ 0.3,  1. ]))
('fractions', array([ -1.00000000e+19,  -1.00000000e+19]))
('smallest_fractions', array([  4.60000000e-01,  -1.00000000e+19]))
('candidate_tieline', array([[  6.66666667e-01,   1.00000000e-15],
       [  4.44444444e-01,   5.55555556e-01]]))
('rhs', array([-4275.24420056, -7271.04760243]))
('candidate_potentials', array([-6412.86630084, -7957.5926437 ]))
('min_df', array(10))
('min_df_value', array(-425.87750596329965))
('f_contig_trial', array([[  1.00000000e-15,   5.55555556e-01],
       [  1.00000000e+00,   1.00000000e+00]]))
('rhs', array([ 0.3,  1. ]))
('fractions', array([ 0.46,  0.54]))
('f_contig_trial', array([[  1.00000000e-15,   1.00000000e-15],
       [  1.00000000e+00,   1.00000000e+00]]))
('rhs', array([ 0.3,  1. ]))
('fractions', array([ -1.00000000e+19,  -1.00000000e+19]))
('smallest_fractions', array([  4.60000000e-01,  -1.00000000e+19]))
('candidate_tieline', array([[  5.55555556e-01,   1.00000000e-15],
       [  4.44444444e-01,   5.55555556e-01]]))
('rhs', array([-3988.58100643, -7271.04760243]))
('candidate_potentials', array([-7179.44581158, -7344.32903512]))
('min_df', array(31))
('min_df_value', array(-18.320358170944473))
('f_contig_trial', array([[ 0.44444444,  0.55555556],
       [ 1.        ,  1.        ]]))
('rhs', array([ 0.3,  1. ]))
('fractions', array([ 2.3, -1.3]))
('f_contig_trial', array([[  1.00000000e-15,   4.44444444e-01],
       [  1.00000000e+00,   1.00000000e+00]]))
('rhs', array([ 0.3,  1. ]))
('fractions', array([ 0.325,  0.675]))
('smallest_fractions', array([-1.3  ,  0.325]))
('candidate_tieline', array([[  5.55555556e-01,   1.00000000e-15],
       [  5.55555556e-01,   4.44444444e-01]]))
('rhs', array([-3988.58100643, -7271.04760243]))
('candidate_potentials', array([-7179.44581158, -7385.549841  ]))
('min_df', array(10))
('min_df_value', array(5.643395777030236e-13))
('Redundant phase:', CompositionSet(TEST, [  1.00000000e-15   5.55555556e-01   4.44444444e-01], NP=0.6749999999999997, GM=-7271.047602431603))
Removing CompositionSet(TEST, [  1.00000000e-15   5.55555556e-01   4.44444444e-01], NP=nan, GM=-7271.047602431603)
Trying to improve poor solution
Chemical Potentials [ -7385.54984098  -4188.6475501  -12142.35649515]
[ 0.  0.  0.  0.  0.  0.  0.]
[  1.00000000e+00   1.00000000e+05   1.27300000e+03   1.09005177e-02
   6.89099482e-01   3.00000000e-01   1.00000000e+00]
Status: 0 b'Algorithm terminated successfully at a locally optimal point, satisfying the convergence tolerances (can be specified by options).'
Adding CompositionSet(TEST, [  4.44444444e-01   5.55555556e-01   1.00000000e-15], NP=0.5, GM=-7271.047602431603) Driving force: 1661.5545897199527
Trying to improve poor solution
Chemical Potentials [-7385.54984144 -7385.53653288 -7385.53857956]
[  5.00000000e-13   5.00000000e-18   3.92772977e-16   1.03304504e-10
   1.00486359e-12   1.00486361e-12   1.00486363e-12   1.00486360e-12
   1.03304235e-10   8.34701242e-13   1.24694100e-12]
[  1.00000000e+00   1.00000000e+05   1.27300000e+03   4.84006000e-03
   4.97579974e-01   4.97579966e-01   4.97579957e-01   4.97579971e-01
   4.84007264e-03   5.99017720e-01   4.00982280e-01]
Status: 0 b'Algorithm terminated successfully at a locally optimal point, satisfying the convergence tolerances (can be specified by options).'
('Composition Sets', [CompositionSet(TEST, [ 0.00484006  0.49757997  0.49757997], NP=0.5990177196985614, GM=-7385.540390613181), CompositionSet(TEST, [ 0.49757996  0.49757997  0.00484007], NP=0.40098228030143857, GM=-7385.540390613311)])
<xarray.Dataset>
Dimensions:    (MU_H: 1, N: 1, P: 1, T: 1, X_LI: 1, component: 3, internal_dof: 3, vertex: 4)
Coordinates:
  * MU_H       (MU_H) float64 -7.386e+03
  * N          (N) float64 1.0
  * P          (P) float64 1e+05
  * T          (T) float64 1.273e+03
  * X_LI       (X_LI) float64 0.3
  * vertex     (vertex) int64 0 1 2 3
  * component  (component) <U2 'H' 'HE' 'LI'
Dimensions without coordinates: internal_dof
Data variables:
    Y          (N, P, T, MU_H, X_LI, vertex, internal_dof) float64 0.00484 ...
    Phase      (N, P, T, MU_H, X_LI, vertex) <U6 'TEST' 'TEST' '' ''
    GM         (N, P, T, MU_H, X_LI) float64 -7.386e+03
    MU         (N, P, T, MU_H, X_LI, component) float64 -7.386e+03 ...
    NP         (N, P, T, MU_H, X_LI, vertex) float64 0.599 0.401 nan nan
    X          (N, P, T, MU_H, X_LI, vertex, component) float64 0.00484 ...
Attributes:
    engine:   pycalphad 0.7.1.post2+87.gfb8869c.dirty
    created:  2019-02-21T23:34:57.294092

In [4]:
eq2.MU


Out[4]:
<xarray.DataArray 'MU' (N: 1, P: 1, T: 1, MU_H: 1, X_LI: 1, component: 3)>
array([[[[[[-7385.549841, -7385.536533, -7385.53858 ]]]]]])
Coordinates:
  * MU_H       (MU_H) float64 -7.386e+03
  * N          (N) float64 1.0
  * P          (P) float64 1e+05
  * T          (T) float64 1.273e+03
  * X_LI       (X_LI) float64 0.3
  * component  (component) <U2 'H' 'HE' 'LI'

In [5]:
%matplotlib inline
from pycalphad import calculate, Database
from pycalphad.plot.utils import phase_legend
import numpy as np
from pycalphad.tests.datasets import ISSUE43_TDB
import matplotlib.pyplot as plt

my_phases =  ['FCC_A1', 'GAMMA_PRIME']

legend_handles, colorlist = phase_legend(my_phases)

fig = plt.figure(figsize=(9,6))
ax = fig.gca()
for name in my_phases:
    result = calculate(dbf, ['AL', 'NI', 'CR', 'VA'], name,
                     T=1273, P=101325, pdens=500)
    gm = result.GM.isel(T=0,P=0) - np.sum([-140000, -47243.21708006, -90400.16978886] * result.X.isel(T=0,P=0), axis=1)
    ax.scatter(result.X.isel(T=0,P=0).sel(component='CR'), gm,
               marker='.', s=5, color=colorlist[name.upper()])
#ax.set_xlim((0.6, 1))
ax.set_ylim((-500, 1000))
#plt.plot([0,1], [0, 0])
ax.legend(handles=legend_handles, loc='center left', bbox_to_anchor=(1, 0.6))
plt.show()


---------------------------------------------------------------------------
ConditionError                            Traceback (most recent call last)
<ipython-input-5-ed5e3d0d8bdc> in <module>()
     14 for name in my_phases:
     15     result = calculate(dbf, ['AL', 'NI', 'CR', 'VA'], name,
---> 16                      T=1273, P=101325, pdens=500)
     17     gm = result.GM.isel(T=0,P=0) - np.sum([-140000, -47243.21708006, -90400.16978886] * result.X.isel(T=0,P=0), axis=1)
     18     ax.scatter(result.X.isel(T=0,P=0).sel(component='CR'), gm,

/home/rotis/git/pycalphad/pycalphad/core/calculate.py in calculate(dbf, comps, phases, mode, output, fake_points, broadcast, parameters, **kwargs)
    322     active_phases = {name: dbf.phases[name] for name in active_phases}
    323     if len(list_of_possible_phases) == 0:
--> 324         raise ConditionError('There are no phases in the Database that can be active with components {0}'.format(comps))
    325     if len(active_phases) == 0:
    326         raise ConditionError('None of the passed phases ({0}) are active. List of possible phases: {1}.'

ConditionError: There are no phases in the Database that can be active with components []

In [ ]: