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
- get_invariant_data(x: StateVariable, y: StateVariable)[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.
- Returns:
- A list where each dictionary contains the following keys:
”phases” (list of str): The list of phases.
”x” (list of float): The corresponding values for the x-axis.
”y” (list of float): The corresponding values for the y-axis.
The indices in “x” and “y” match the indices in “phases”.
- Return type:
list of dict
- get_tieline_data(x: StateVariable, y: StateVariable)[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.
- 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.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
- get_invariant_data(x: StateVariable, y: StateVariable)[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:
A list where each dictionary has the following structure:
{ "x": list of float, "y": list of float }
- Return type:
list of dict
- get_zpf_data(x: StateVariable, y: StateVariable)[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.
- Returns:
A dictionary with the following structure:
{ "data": [ { "phase": str, "x": list of float, "y": list of float } ], "xlim": list of float, "ylim": list of float } The "phase" in the "data" section refers to the fixed phase at zero-phase fraction.
- Return type:
dict
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
- get_data(x: StateVariable, y: StateVariable, x_is_global: bool = False, set_nan_to_zero=False)[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.
x_is_global (bool, optional) – Indicates whether x is a global or phase-local variable. For example, if plotting global composition (x) vs. phase fraction (y), then x is global.
set_nan_to_zero (bool, optional) – If True, NaN values will be set to zero in the data.
- Returns:
A dictionary with the following structure:
{ "data": { "<phase_name>": { "x": list of float, "y": list of float } }, "xlim": list of float, # min and max for all x values "ylim": list of float # min and max for all y values }
- Return type:
dict
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:
object
Base 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: 1).
- add_nodes_from_conditions(conditions: dict[StateVariable, float], direction: Direction | None = 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
- 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_utils module¶
Helper functions to grab data from tieline strategies (BinaryStrategy and TernaryStrategy) This is to avoid repeating get_XXX_data functions for the two strategies
- TODO: Once BinaryStrategy and TernaryStrategy are merged into a more general TielineStrategy,
these two functions can be moved into TieLineStrategy and strategy_utils.py as be removed
- pycalphad.mapping.strategy.strategy_utils.get_invariant_data_from_tieline_strategy(strategy, x: StateVariable, y: StateVariable)[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_utils.get_tieline_data_from_tieline_strategy(strategy, x: StateVariable, y: StateVariable)[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
- get_invariant_data(x: StateVariable, y: StateVariable)[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.
- Returns:
A list where each dictionary has the following structure:
{ "phases": list of str, "x": list of float, "y": list of float } The indices in `x` and `y` will match the indices in `phases`.
- Return type:
list of dict
- get_tieline_data(x: StateVariable, y: StateVariable)[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.
- 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 ZPF line.
- Return type:
list of dict