pycalphad
pycalphad copied to clipboard
Mapping improvements
This pull request makes some improvements in the mapping code based off some of the issues/observations I've been seeing after a lot of usage:
- Simplifies the metastable node detection in
TernaryStrategy
to just performing a global min check, then removing the ZPF line if it fails, which appears to avoid false negatives of detecting stable nodes as metastable. It's the exact same strategy as done inBinaryStrategy
, so we're one step closer to merging these strategies into a single tieline strategy - Sets default value for
GLOBAL_MIN_NUM_CANDIDATES
to 1000, which helps the global min detection, especially for phases with high internal degrees of freedom. Some crude performance testing for various values of this parameter seems to show that the performance isn't heavily affect by this (I assume it's because it only adds a few more single phase equilibrium calculations during the global minimum check) - Unaries can be computed now. Current code would run into an error during the global min check due to improper array shapes.
- Custom starting points for
BinaryStrategy
andTernaryStrategy
can handle cases for single, two or three phase equilibria.- Single phase -> no point is added and logs a warning
- Two phase -> point is added as an exit
- Three phase -> point is added as a node, which exits can be found from
- Plotting variables will go through
as_property
, which will allow plotting step diagrams such asv.T
vs'CPM'
. Jansson derivatives are also supported in plotting.- Note: there seems to be a jump in value when the Jansson derivative is computed at a node (where one of the composition sets are fixed). Not sure if this is inherent, considering that the derivative would likely be discontinuous at the node or if this is fixable.
TODOs
- [ ] When plotting, there should be a way to detect whether a property is specific to each phase or if the property corresponds to the entire system. For plotting properties such as
'CPM'
on a step diagram, there should be a single value at each point since we would be plotting the heat capacity of the system. Right now, the step plotting will loop through the phases and compute the property, which for phase dependent properties such asv.X('FCC_A1', 'AL')
orv.NP('FCC_A1')
, this is fine, but for'CPM'
, this would compute the same value (which is'CPM'
of the system) for each phase. Plotting-wise, this is okay visually, but we're just plotting multiple unnecessary lines on top of each other. - [ ] Starting points for
IsoplethStrategy
. Since the points have to be on a phase boundary with at least 1 composition set fixed as NP=0, I suppose the custom starting points would be to add a customStepStrategy
to extract starting points from
Notes (not the best place to bring this up, but this seems to be why some of the unit tests are failing right now)
- test_eqplot_binary and test_eqplot_ternary seems to be failing on 3.10, 3.11 and 3.12 with
DeprecationWarning: __array__ implementation doesn't accept a copy keyword, so passing copy=False failed. __array__ must implement 'dtype' and 'copy' keyword arguments.
when converting one of the equilibrium results to an array (i.e.eq['component'] = np.array(eq['component'], dtype='U')
). This suspect this might be coming from xarray and related to pydata/xarray#9400. Seems like they have a fix but it might not be in the release version of xarray yet.