Skip to content

Commit

Permalink
remove stepplot and isoplethplot
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Ury committed Jul 14, 2024
1 parent a25b11f commit ea999fe
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 108 deletions.
8 changes: 4 additions & 4 deletions examples/TernaryExamples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 4,
"metadata": {
"execution": {
"iopub.execute_input": "2022-02-19T19:18:35.550927Z",
Expand All @@ -34,8 +34,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: total: 28.3 s\n",
"Wall time: 28.7 s\n"
"CPU times: total: 28.4 s\n",
"Wall time: 29.5 s\n"
]
},
{
Expand All @@ -44,7 +44,7 @@
"<TriangularAxes: title={'center': 'Al-Cu-Y'}, xlabel='X(Al)', ylabel='X(Y)'>"
]
},
"execution_count": 2,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
},
Expand Down
2 changes: 1 addition & 1 deletion pycalphad/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from pycalphad.core.workspace import Workspace
from pycalphad.plot.eqplot import eqplot
from pycalphad.property_framework import as_property
from pycalphad.mapping.compat_api import binplot, ternplot, isoplethplot, stepplot
from pycalphad.mapping.compat_api import binplot, ternplot

# Set the version of pycalphad
try:
Expand Down
98 changes: 0 additions & 98 deletions pycalphad/mapping/compat_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,104 +106,6 @@ def ternplot(dbf, comps, phases, conds, x=None, y=None, return_strategy=False, m
ax.set_xlim(0, 1)
ax.set_ylim(0, 1)

if return_strategy:
return ax, strategy
else:
return ax

def isoplethplot(database, components, phases, conditions, return_strategy = False, plot_kwargs=None, **map_kwargs):
"""
Calculates an isopleth phase diagram.
TODO: if we can confirm that isopleths work with 2 non-potential conditions, then remove the check at the beginning
Parameters
----------
database : Database
Thermodynamic database containing the relevant parameters.
components : Sequence[str]
Names of components to consider in the calculation.
phases : Sequence[str]
Names of phases to consider in the calculation.
conditions : Mapping[v.StateVariable, Union[float, Tuple[float, float, float]]]
Maps StateVariables to values and/or iterables of values.
For isopleth only one changing composition and one potential coordinate each is supported.
return_strategy : bool, optional
Return the IsoplethStrategy object in addition to the Axes. Defaults to False.
map_kwargs : dict, optional
Additional keyword arguments to IsoplethStrategy().
plot_kwargs : dict, optional
Keyword arguments to plot_isopleth().
Returns
-------
Axes
Matplotlib Axes of the phase diagram
(Axes, IsoplethStrategy)
If return_strategy is True.
"""
indep_comps = [key for key, value in conditions.items() if key not in STATEVARS and len(np.atleast_1d(value)) > 1]
indep_pots = [key for key, value in conditions.items() if key in STATEVARS and len(np.atleast_1d(value)) > 1]
if (len(indep_comps) != 1) or (len(indep_pots) != 1):
raise ValueError('isoplethplot() requires exactly one composition coordinate and one potential coordinate')

strategy = IsoplethStrategy(database, components, phases, conditions, **map_kwargs)
strategy.initialize()
strategy.do_map()

plot_kwargs = plot_kwargs if plot_kwargs is not None else dict()
ax = plot_isopleth(strategy, **plot_kwargs)
ax.grid(plot_kwargs.get("gridlines", False))

if return_strategy:
return ax, strategy
else:
return ax

def stepplot(database, components, phases, conditions, return_strategy = False, plot_kwargs=None, **map_kwargs):
"""
Calculates and plot a step diagram
Default axes will be axis variable vs. phase fraction
Parameters
----------
database : Database
Thermodynamic database containing the relevant parameters.
components : Sequence[str]
Names of components to consider in the calculation.
phases : Sequence[str]
Names of phases to consider in the calculation.
conditions : Mapping[v.StateVariable, Union[float, Tuple[float, float, float]]]
Maps StateVariables to values and/or iterables of values.
For isopleth only one changing composition and one potential coordinate each is supported.
return_strategy : bool, optional
Return the StepStrategy object in addition to the Axes. Defaults to False.
map_kwargs : dict, optional
Additional keyword arguments to StepStrategy().
plot_kwargs : dict, optional
Keyword arguments to plot_step().
Returns
-------
Axes
Matplotlib Axes of the phase diagram
(Axes, StepStrategy)
If return_strategy is True.
"""
indep_vars = [key for key, value in conditions.items() if len(np.atleast_1d(value)) > 1]
if len(indep_vars) != 1:
raise ValueError('stepplot() requires exactly one coordinate')

strategy = StepStrategy(database, components, phases, conditions, **map_kwargs)
strategy.initialize()
strategy.do_map()

plot_kwargs = plot_kwargs if plot_kwargs is not None else dict()
ax = plot_step(strategy, **plot_kwargs)
ax.grid(plot_kwargs.get("gridlines", False))

if return_strategy:
return ax, strategy
else:
Expand Down
22 changes: 17 additions & 5 deletions pycalphad/tests/test_mapping_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import numpy as np
import matplotlib.pyplot as plt

from pycalphad import binplot, ternplot, stepplot, isoplethplot, Database, variables as v
from pycalphad import binplot, ternplot, Database, variables as v
from pycalphad.mapping.strategy import StepStrategy, IsoplethStrategy
from pycalphad.mapping.plotting import plot_step, plot_isopleth
from pycalphad.tests.fixtures import select_database, load_database

import pycalphad.tests.databases
Expand Down Expand Up @@ -76,8 +78,13 @@ def test_step_strategy(load_database):
dbf = load_database()
#dbf = Database(str(files(pycalphad.tests.databases).joinpath('alcocrni.tdb')))

ax, strategy = stepplot(dbf, ["CR", "NI", "VA"], None, conditions={v.T: (1000, 2500, 40), v.X("CR"): 0.8, v.P: 101325}, return_strategy=True)

strategy = StepStrategy(dbf, ["CR", "NI", "VA"], None, conditions={v.T: (1000, 2500, 40), v.X("CR"): 0.8, v.P: 101325})
strategy.initialize()
strategy.do_map()

# Just check that plot_step runs without failing
plot_step(strategy)

# Two-phase regions intended to show up in the Cr-Ni system
desired_zpf_sets = [{"BCC_B2", "L12_FCC"}, {"BCC_B2"}, {"BCC_B2", "LIQUID"}, {"LIQUID"}]
desired_node_sets = [{"BCC_B2", "L12_FCC"}, {"BCC_B2", "LIQUID"}]
Expand All @@ -100,8 +107,13 @@ def test_isopleth_strategy(load_database):
dbf = load_database()
#dbf = Database(str(files(pycalphad.tests.databases).joinpath('crtiv_ghosh.tdb')))

ax, strategy = isoplethplot(dbf, ["CR", "TI", "V", "VA"], None, conditions={v.T: (1073, 2073, 20), v.X("TI"): (0, 0.8, 0.01), v.X("V"): 0.2, v.P: 101325}, return_strategy=True)

strategy = IsoplethStrategy(dbf, ["CR", "TI", "V", "VA"], None, conditions={v.T: (1073, 2073, 20), v.X("TI"): (0, 0.8, 0.01), v.X("V"): 0.2, v.P: 101325})
strategy.initialize()
strategy.do_map()

# Check that plot_isopleth runs without fail
plot_isopleth(strategy)

# Two-phase regions intended to show up in the Cr-Ni system
desired_zpf_sets = [{"BCC_A2", "LAVES_C15"}, {"BCC_A2", "LIQUID"}]

Expand Down

0 comments on commit ea999fe

Please sign in to comment.