Skip to content

Commit

Permalink
Merge 56d2821 into ac380f5
Browse files Browse the repository at this point in the history
  • Loading branch information
bocklund committed Dec 11, 2019
2 parents ac380f5 + 56d2821 commit b6d8b6c
Show file tree
Hide file tree
Showing 8 changed files with 335 additions and 18 deletions.
6 changes: 3 additions & 3 deletions pycalphad/core/equilibrium.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _adjust_conditions(conds):
for key, value in sorted(conds.items(), key=str):
if key == str(key):
key = getattr(v, key, key)
if isinstance(key, v.Composition):
if isinstance(key, v.MoleFraction):
new_conds[key] = [max(val, MIN_SITE_FRACTION*1000) for val in unpack_condition(value)]
else:
new_conds[key] = unpack_condition(value)
Expand Down Expand Up @@ -214,7 +214,7 @@ def equilibrium(dbf, comps, phases, conditions, output=None, model=None,
conds = _adjust_conditions(conditions)

for cond in conds.keys():
if isinstance(cond, (v.Composition, v.ChemicalPotential)) and cond.species not in comps:
if isinstance(cond, (v.MoleFraction, v.ChemicalPotential)) and cond.species not in comps:
raise ConditionError('{} refers to non-existent component'.format(cond))
state_variables = sorted(get_state_variables(models=models, conds=conds), key=str)
str_conds = OrderedDict((str(key), value) for key, value in conds.items())
Expand Down Expand Up @@ -244,7 +244,7 @@ def equilibrium(dbf, comps, phases, conditions, output=None, model=None,
if 'pdens' not in grid_opts:
grid_opts['pdens'] = 500
grid = calculate(dbf, comps, active_phases, model=models, fake_points=True,
callables=callables, output='GM', parameters=parameters,
callables=callables, output='GM', parameters=parameters,
to_xarray=False, **grid_opts)
coord_dict = str_conds.copy()
coord_dict['vertex'] = np.arange(len(pure_elements) + 1) # +1 is to accommodate the degenerate degree of freedom at the invariant reactions
Expand Down
2 changes: 1 addition & 1 deletion pycalphad/core/starting_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def global_min_is_possible(conditions, state_variables):
global_min = True
for cond in conditions.keys():
if cond in state_variables or \
isinstance(cond, v.Composition) or \
isinstance(cond, v.MoleFraction) or \
isinstance(cond, v.ChemicalPotential) or \
cond == v.N:
continue
Expand Down
2 changes: 1 addition & 1 deletion pycalphad/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def get_multiphase_constraints(self, conds):
for statevar in sorted(conds.keys(), key=str):
if not is_multiphase_constraint(statevar):
continue
if isinstance(statevar, v.Composition):
if isinstance(statevar, v.MoleFraction):
multiphase_constraints.append(Symbol('NP') * self.moles(statevar.species))
elif statevar == v.N:
multiphase_constraints.append(Symbol('NP') * (sum(self.moles(spec) for spec in self.nonvacant_elements)))
Expand Down
2 changes: 1 addition & 1 deletion pycalphad/plot/binary/compsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class BinaryCompset():
indep_comp : str
Name of the independent component
composition : float
Composition of the independent component
Mole fraction of the independent component
site_fracs : np.ndarray
Array of floats corresponding to the site fractions.
Expand Down
2 changes: 1 addition & 1 deletion pycalphad/plot/binary/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def map_binary(dbf, comps, phases, conds, eq_kwargs=None, calc_kwargs=None,
prxs = build_phase_records(dbf, species, phases, conds, models, output='GM',
parameters=parameters, build_gradients=True, build_hessians=True)

indep_comp = [key for key, value in conds.items() if isinstance(key, v.Composition) and len(np.atleast_1d(value)) > 1]
indep_comp = [key for key, value in conds.items() if isinstance(key, v.MoleFraction) and len(np.atleast_1d(value)) > 1]
indep_pot = [key for key, value in conds.items() if (type(key) is v.StateVariable) and len(np.atleast_1d(value)) > 1]
if (len(indep_comp) != 1) or (len(indep_pot) != 1):
raise ValueError('Binary map requires exactly one composition and one potential coordinate')
Expand Down
6 changes: 3 additions & 3 deletions pycalphad/plot/eqplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


def _axis_label(ax_var):
if isinstance(ax_var, v.Composition):
if isinstance(ax_var, v.MoleFraction):
return 'X({})'.format(ax_var.species.name)
elif isinstance(ax_var, v.StateVariable):
return _plot_labels[ax_var]
Expand Down Expand Up @@ -71,7 +71,7 @@ def eqplot(eq, ax=None, x=None, y=None, z=None, tielines=True, **kwargs):
conds = OrderedDict([(_map_coord_to_variable(key), unpack_condition(np.asarray(value)))
for key, value in sorted(eq.coords.items(), key=str)
if (key in ('T', 'P', 'N')) or (key.startswith('X_'))])
indep_comps = sorted([key for key, value in conds.items() if isinstance(key, v.Composition) and len(value) > 1], key=str)
indep_comps = sorted([key for key, value in conds.items() if isinstance(key, v.MoleFraction) and len(value) > 1], key=str)
indep_pots = [key for key, value in conds.items() if (type(key) is v.StateVariable) and len(value) > 1]

# determine what the type of plot will be
Expand Down Expand Up @@ -128,7 +128,7 @@ def eqplot(eq, ax=None, x=None, y=None, z=None, tielines=True, **kwargs):
# get tieline endpoint compositions
two_phase_x = eq.X.sel(component=x.species.name).values[two_phase_idx][..., :2]
# handle special case for potential
if isinstance(y, v.Composition):
if isinstance(y, v.MoleFraction):
two_phase_y = eq.X.sel(component=y.species.name).values[two_phase_idx][..., :2]
else:
# it's a StateVariable. This must be True
Expand Down
6 changes: 3 additions & 3 deletions pycalphad/plot/ternary.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ def ternplot(dbf, comps, phases, conds, x=None, y=None, eq_kwargs=None, **plot_k
conds : dict
Maps StateVariables to values and/or iterables of values.
For ternplot only one changing composition and one potential coordinate each is supported.
x : Composition
x : v.MoleFraction
instance of a pycalphad.variables.composition to plot on the x-axis.
Must correspond to an independent condition.
y : Composition
y : v.MoleFraction
instance of a pycalphad.variables.composition to plot on the y-axis.
Must correspond to an independent condition.
eq_kwargs : optional
Expand All @@ -44,7 +44,7 @@ def ternplot(dbf, comps, phases, conds, x=None, y=None, eq_kwargs=None, **plot_k
None yet.
"""
eq_kwargs = eq_kwargs if eq_kwargs is not None else dict()
indep_comps = [key for key, value in conds.items() if isinstance(key, v.Composition) and len(np.atleast_1d(value)) > 1]
indep_comps = [key for key, value in conds.items() if isinstance(key, v.MoleFraction) and len(np.atleast_1d(value)) > 1]
indep_pots = [key for key, value in conds.items() if (type(key) is v.StateVariable) and len(np.atleast_1d(value)) > 1]
if (len(indep_comps) != 2) or (len(indep_pots) != 0):
raise ValueError('ternplot() requires exactly two composition coordinates')
Expand Down

0 comments on commit b6d8b6c

Please sign in to comment.