pycalphad.mapping.strategy package¶
Submodules¶
pycalphad.mapping.strategy.binary_strategy module¶
- class pycalphad.mapping.strategy.binary_strategy.BinaryStrategy(dbf: Database, components: list[str], phases: list[str], conditions: dict[StateVariable, float | tuple[float]], **kwargs)[source]¶
Bases:
MapStrategy- add_starting_points_from_step(step: StepStrategy)[source]¶
- Grabs starting points from a step calc
For stepping in a state variable (T or P), this is all the nodes of the step calc
For stepping in composition, this is all the 2 phase regions
- NOTE: Grabbing starting points is different for whether the axis variable on the step calculation is a state variable or not
For stepping along a state variable where the composition is likely near an end point, the two-phase regions are usually too small to be resolved in the stepping resolution, thus, getting starting points from the node is more consistent. Only one starting point is added for each phase transition since for alpha->beta, the zpf line for alpha will end with the parent and the zpf line for beta will start with the node For stepping along a composition axis, just grab a single point from a zpf line.
- If we were to grab the nodes, there would be two nodes for every two-phase regions:
alpha -> alpha + beta - Node for beginning of alpha + beta zpf line alpha + beta -> beta - Node for beginning of beta zpf line
- generate_automatic_starting_points()[source]¶
Searches axis limits to find starting points
Here, we do a step mapping along the axis bounds and grab all the nodes The nodes of a step map is distinguished from starting points in that they have a parent
- get_invariant_data(x: StateVariable, y: StateVariable, global_x: bool = False, global_y: bool = False) list[StrategyData][source]¶
Create a dictionary of data for invariant plotting.
- Parameters:
x (v.StateVariable) – The state variable to be used for the x-axis.
y (v.StateVariable) – The state variable to be used for the y-axis.
global_x (bool) – Whether variable x applies to the global system
global_y (bool) – Whether variable y applies to the global system
- Return type:
list of Strategy pertaining to each invariant
- get_tieline_data(x: StateVariable, y: StateVariable, global_x: bool = False, global_y: bool = False) list[StrategyData][source]¶
Create a dictionary of data for plotting ZPF lines.
- Parameters:
x (v.StateVariable) – The state variable to be used for the x-axis.
y (v.StateVariable) – The state variable to be used for the y-axis.
global_x (bool) – Whether variable x applies to the global system
global_y (bool) – Whether variable y applies to the global system
- Return type:
list of Strategy pertaining to each tieline
pycalphad.mapping.strategy.isopleth_strategy module¶
- class pycalphad.mapping.strategy.isopleth_strategy.IsoplethStrategy(dbf: Database, components: list[str], phases: list[str], conditions: dict[StateVariable, float | tuple[float]], **kwargs)[source]¶
Bases:
MapStrategy- add_starting_points_from_step(step: StepStrategy)[source]¶
- generate_automatic_starting_points()[source]¶
Searches axis limits to find starting points
Here, we do a step mapping along the axis bounds and grab all the nodes The nodes of a step map is distinguished from starting points in that they have a parent
- get_invariant_data(x: StateVariable, y: StateVariable) list[StrategyData][source]¶
Create a dictionary of data for plotting invariants for isopleths.
The end points of the node are adjusted to be the intersection of the isopleth polytope on the node in n-composition space.
- Parameters:
x (v.StateVariable) – The state variable to be used for the x-axis.
y (v.StateVariable) – The state variable to be used for the y-axis.
- Returns:
- NOTE: the data in each StrategyData does not pertain to a single phase
but rather the p-2 phases where the p-2 phase region intersects with the fixed isopleth conditions
- Return type:
list of StrategyData each pertaining to an invariant
- get_zpf_data(x: StateVariable, y: StateVariable) StrategyData[source]¶
Create a dictionary of data for plotting ZPF lines for isopleths.
- Parameters:
x (v.StateVariable) – The state variable to be used for the x-axis.
y (v.StateVariable) – The state variable to be used for the y-axis.
- Return type:
StrategyData where the data pertains to each ZPF line
pycalphad.mapping.strategy.step_strategy module¶
- class pycalphad.mapping.strategy.step_strategy.StepStrategy(dbf: Database, components: list[str], phases: list[str], conditions: dict[StateVariable, float | tuple[float]], **kwargs)[source]¶
Bases:
MapStrategy- generate_automatic_starting_points()[source]¶
Adds initial starting point in middle of free condition
- get_data(x: StateVariable, y: StateVariable, global_x: bool = False, global_y: bool = False, set_nan_to_zero: bool = False) StrategyData[source]¶
Utility function to get data from StepStrategy for plotting.
- Parameters:
x (v.StateVariable) – The state variable to be used for the x-axis.
y (v.StateVariable) – The state variable to be used for the y-axis.
global_x (bool) – Whether variable x applies to the global system
global_y (bool) – Whether variable y applies to the global system
set_nan_to_zero (bool) – If True, NaN values will be set to zero in the data, defaults to false
- Returns:
If x and y are unique for the system, then the data in StrategyData will be labeled as “SYSTEM” otherwise, the data in StrategyData will be labeled for all stable phases Examples of unique variables:
State variables (N, P, T)
Values such as GM, HM, CPM
Phase specific variable (i.e. v.X(phase, component) or v.NP(phase)) This is in contrast to v.X(component) or v.NP where composition or phase fraction will be taken for all stable phases
- Return type:
pycalphad.mapping.strategy.strategy_base module¶
- class pycalphad.mapping.strategy.strategy_base.MapStrategy(dbf: Database, components: list[str], phases: list[str], conditions: dict[StateVariable, float | tuple[float]], **kwargs)[source]¶
Bases:
objectBase strategy class for phase diagram construction.
Derived Classes¶
SteppingStrategy: For single-axis diagrams.
BinaryStrategy: For binary phase diagrams (1 composition, 1 potential axis).
TernaryStrategy: For ternary phase diagrams (2 composition axes).
IsoplethStrategy: For isopleths (tested only for 1 composition, 1 potential axis so far).
Constants¶
- DELTA_SCALEfloat
Factor to scale down step size if a single step iteration was unsuccessful (default: 0.5).
- MIN_DELTA_RATIOfloat
Minimum step size (as ratio of default) before stopping ZPF line iteration (default: 0.1).
- GLOBAL_CHECK_INTERVALint
Number of iterations before global minimum check. Proceed with caution for any interval >1 (default: 1).
- GLOBAL_MIN_PDENSint
Sampling density for global minimum check (default: 500).
- GLOBAL_MIN_TOLfloat
Minimum driving force for a composition set to pass the global minimum check (default: 1e-4).
- GLOBAL_MIN_NUM_CANDIDATESint
Number of candidates to search through for finding the global minimum. Sometimes, the global minimum can be missed if the sampling is poor, so checking the n-best candidates can help (default: 1000). (NOTE: this is not actually how many candidates the global eq check will solve the driving force. This value represents the N number of samples with the lowest sampled driving forces, then the driving force is computed for all unique phases from the candidates (which in large databases, this might be as high as 10-20), So increasing it to a high value does not significantly degrade performance and mapping using models with high DOF may be better)
- add_nodes_from_conditions(conditions: dict[StateVariable, float], direction: Direction = None, force_add: bool = True)[source]¶
Computes equilibrium and creates a point from input conditions
If a direction is supplied, then we can just add the new point with the direction If not, then we add two points, for each direction
Since this is a starting point, we set the ExitHint to POINT_IS_EXIT since we assume the starting point is not a true node
Also by default, we force add the node to skip checking if the node is already in the node queue
- generate_automatic_starting_points()[source]¶
Automatically finds starting points based off input conditions Map strategies should be able to still run even without automatic starting point finding as long as there is another method to add starting points (which could be add_nodes_from_conditions)
- get_all_phases()[source]¶
Goes through ZPF lines to get all unique phases. For miscibility gaps, phases will have #n added to it
In some cases, there might be no ZPF lines (e.g. ternaries with all line compounds), in which case, we return an empty set. There should always be nodes in the node_queue since it includes starting points (even if they’re not nodes in the mapping sense)
pycalphad.mapping.strategy.strategy_data module¶
Data classes to hold outputs from map strategies
SinglePhaseData- holds x, y coordinates for a given phaseStrategyData- holds a list ofSinglePhaseDatawith some functions to loop over phases, x and y in eachSinglePhaseDataobject and to get x and y limitsPhaseRegionData- alias ofStrategyData. This is done to clarify whatBinaryStrategy.get_zpf_data,BinaryStrategy.get_invariant_dataTernaryStrategy.get_zpf_data,TernaryStrategy.get_invariant_dataandIsoplethStrategy.get_invariant_datadoes compared toStepStrategy.get_dataandIsoplethStrategy.get_zpf_data
- pycalphad.mapping.strategy.strategy_data.PhaseRegionData¶
alias of
StrategyData
- class pycalphad.mapping.strategy.strategy_data.SinglePhaseData(phase: str, x: float | list[float], y: float | list[float])[source]¶
Bases:
object- phase: str¶
- x: float | list[float]¶
- y: float | list[float]¶
- class pycalphad.mapping.strategy.strategy_data.StrategyData(data: list[pycalphad.mapping.strategy.strategy_data.SinglePhaseData])[source]¶
Bases:
object- data: list[SinglePhaseData]¶
- property phases¶
- property x¶
- xlim: list[float]¶
- property y¶
- ylim: list[float]¶
- pycalphad.mapping.strategy.strategy_data.get_invariant_data_from_tieline_strategy(strategy, x: StateVariable, y: StateVariable, global_x=False, global_y=False) list[StrategyData][source]¶
Create a dictionary of data for node plotting in binary and ternary plots.
- Parameters:
strategy (BinaryStrategy or TernaryStrategy) – The strategy used for generating the data.
x (v.StateVariable) – The state variable to be used for the x-axis.
y (v.StateVariable) – The state variable to be used for the y-axis.
- Returns:
A list where each dictionary contains the following structure:
{ "phases": list of str, "x": list of float, "y": list of float } The indices in `x` and `y` match the indices in `phases`.- Return type:
list of dict
- pycalphad.mapping.strategy.strategy_data.get_tieline_data_from_tieline_strategy(strategy, x: StateVariable, y: StateVariable, global_x=False, global_y=False) list[StrategyData][source]¶
Create a dictionary of data for plotting ZPF lines.
- Parameters:
strategy (BinaryStrategy or TernaryStrategy) – The strategy used for generating the data.
x (v.StateVariable) – The state variable to be used for the x-axis.
y (v.StateVariable) – The state variable to be used for the y-axis.
- Returns:
A list where each dictionary has the following structure:
{ "<phase_name>": { "x": list of float, "y": list of float } } The lengths of the "x" and "y" lists should be equal for each phase in a ZPFLine.
- Return type:
list of dict
pycalphad.mapping.strategy.ternary_strategy module¶
- class pycalphad.mapping.strategy.ternary_strategy.TernaryStrategy(dbf: Database, components: list[str], phases: list[str], conditions: dict[StateVariable, float | tuple[float]], **kwargs)[source]¶
Bases:
MapStrategy- add_starting_points_from_step(step: StepStrategy)[source]¶
Adds all 2-phase and 3-phase regions from step as starting points We also do a global min check to make sure these phase regions are truly the phases they say they are
- generate_automatic_starting_points()[source]¶
Searches axis limits to find starting points
Here, we do a step mapping along the axis bounds and grab all the nodes The nodes of a step map is distinguished from starting points in that they have a parent
- get_invariant_data(x: StateVariable, y: StateVariable, global_x: bool = False, global_y: bool = False) list[StrategyData][source]¶
Create a dictionary of data for invariant plotting.
- Parameters:
x (v.StateVariable) – The state variable to be used for the x-axis.
y (v.StateVariable) – The state variable to be used for the y-axis.
global_x (bool) – Whether variable x applies to the global system
global_y (bool) – Whether variable y applies to the global system
- Return type:
list of StrategyData pertaining to each invariant
- get_tieline_data(x: StateVariable, y: StateVariable, global_x: bool = False, global_y: bool = False) list[StrategyData][source]¶
Create a dictionary of data for plotting ZPF lines.
- Parameters:
x (v.StateVariable) – The state variable to be used for the x-axis.
y (v.StateVariable) – The state variable to be used for the y-axis.
global_x (bool) – Whether variable x applies to the global system
global_y (bool) – Whether variable y applies to the global system
- Return type:
list of Strategy pertaining to each tieline