pycalphad.mapping.strategy package¶
Submodules¶
pycalphad.mapping.strategy.binary_strategy module¶
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.
TielineStrategy: For phase diagrams with tie-lines in the plane of the axis variables (binary phase diagrams and ternary isothermal sections).
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 whatTielineStrategy.get_tieline_data,TielineStrategy.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.ternary_strategy module¶
pycalphad.mapping.strategy.tieline_strategy module¶
- class pycalphad.mapping.strategy.tieline_strategy.BinaryStrategy(**kwargs)[source]¶
Bases:
TielineStrategy
- class pycalphad.mapping.strategy.tieline_strategy.TernaryStrategy(**kwargs)[source]¶
Bases:
TielineStrategy
- class pycalphad.mapping.strategy.tieline_strategy.TielineStrategy(dbf: Database, components: list[str], phases: list[str], conditions: dict[StateVariable, float | tuple[float]], **kwargs)[source]¶
Bases:
MapStrategyMap strategy for phase diagrams with tie-lines in the plane of the two axis variables, e.g. binary phase diagrams and ternary isothermal sections
- add_starting_points_from_step(step: StepStrategy)[source]¶
Grabs starting points from a step calc
- When mapping with a potential axis:
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
When mapping with only composition axes, this is all 2-phase and 3-phase regions, with 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
- Returns:
list of PhaseRegionData, which stores of list of SinglePhaseData with
x, y coordinates for each phase in the invariant reaction
- 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
- Returns:
list of PhaseRegionData, which stores of list of SinglePhaseData with
x, y coordinates of the phase boundary for each phase