landau.calculate

Calculates phase diagrams from sets of Phases.

landau.calculate.calc_phase_diagram(phases, Ts, mu, refine=True, keep_unstable=False)[source]

Calculate phase diagram at given sampling points.

Parameters:
  • phases (Iterable[Phase])

  • Ts (Union[Iterable[float], float]) – sampling points in temperature

  • mu (Union[Iterable[float], float, int]) – sampling points in chemical potential; if a non-zero int, guess sampling points with guess_mu_range at max(Ts) (pass mu=0.0 for a fixed-mu temperature-only diagram)

  • refine (Union[bool, Sequence[Refiner]]) – add additional sampling points at exact phase transitions. True picks defaults based on which of T/mu are sampled, False skips refinement, and an explicit sequence of Refiner instances applies just those.

  • keep_unstable (bool) – if True, keep entries of all phases at all sampling points, otherwise only keep entries of stable phases

Returns:

dataframe of phase points; the locus column classifies each row as a Locus value ("interior", "boundary", "triple" or "congruent"); with keep_unstable=True the dphi column is phi minus the lowest phi among the rows at the same (T, mu), i.e. how far a phase sits above the stable one (0 for stable rows, NaN on the synthetic mu = +-inf edges; refined rows are zero up to the refiners’ numerical tolerance). The f_excess column is f relative to the chord between the lowest free energies of the pure components at each row’s T; it is left out when the phases do not reach both c = 0 and c = 1.

landau.calculate.cluster_T_c(dd, *, distance_threshold)[source]

Cluster points by (T, c) coordinates; used by cluster_phase.

Parameters:
  • dd – DataFrame with columns ‘T’ and ‘c’.

  • distance_threshold – Required. Agglomerative clustering cut-off in normalised (T, c) space. Smaller values split more aggressively; larger values merge more. Values of roughly 0.01-0.3 keep the test fixtures’ disconnected same-phase fields apart (see tests/regression/test_issue_456.py), while over-splitting of connected fields starts between 0.05 and 0.1. The user-facing default lives on cluster_phase() and get_polygons().

Return type:

Series

landau.calculate.cluster_T_c_mu(dd, *, distance_threshold)[source]

Cluster points by (T, c, mu); rows with mu=±inf get their own distinct labels.

Used by get_transitions. The mu=±inf rows are border edges from _border_edges and must not be fed to AgglomerativeClustering.

Parameters:
  • dd – DataFrame with columns ‘T’, ‘c’, and ‘mu’.

  • distance_threshold – Agglomerative clustering cut-off in normalised (T, c, mu) space. See cluster_T_c() for tuning guidance.

Return type:

Series

landau.calculate.get_transitions(df)[source]

Identify “continuous” two-phase transition lines in mu/T space, i.e. transitions between the same two phases and along which mu/T are continuous.

Useful for plotting below, but potentially also to augment the existing refining routines and acquire additional Free energies from calphy/etc. to improve the diagram.