Cluster expansion convergence check#

Convergence checks.

ce_converged(coefs_history, cv_history, cv_std_history, wrangler, convergence_options)[source]#

Check whether the ce workflow has converged.

Parameters:
  • coefs_history (list of lists of float) – CE coefficients from all past iterations.

  • cv_history (list of float) – Past cross validation errors.

  • cv_std_history (list of float) – Past cross validation standard deviations. The length of the first three arguments must be equal.

  • wrangler (CeDataWrangler) – A wrangler storing all past training data. Maximum recorded iteration index in wrangler must be equal to that of current iter_id - 1.

  • convergence_options (dict) – Pre-processed convergence criterion.

Returns:

Whether the cluster expansion has converged.

Return type:

bool

compare_fitted_coefs(cluster_subspace, coefs_prev, coefs_now)[source]#

Compare fitted coefficients for convergence.

Parameters:
  • cluster_subspace (ClusterSubspace) – The cluster subspace used in fitting.

  • coefs_prev (1D ArrayLike) – Cluster coefficients fitted in the previous iteration. They are not ECIs as they are not divided by multiplicity!

  • coefs_now (1D ArrayLike) – Cluster coefficients fitted in the latest iteration.

Returns:

\(|| J' - J ||_1 / ||J||_1\), where \(J\) represents the coefficients from the last iteration and \(J'\) represents coefficients from the current iteration.

Return type:

float

compare_min_energy_structures_by_composition(min_e1, min_e2, matcher=None)[source]#

Compare minimum energy and structure by composition for convergence check.

We will only compare keys that exist in both older and newer iterations. If one composition appears in the older one but not the newer one, we will not claim convergence.

Parameters:
  • min_e1 (defaultdict) – Minimum energies and structures from an earlier iteration.

  • min_e2 (defaultdict) – Minimum energies and structures from a later iteration. See documentation of WFacer.wrangling.

  • matcher (StructureMatcher) – optional A StructureMatcher used compare structures. wrangler.cluster_subspace._site_matcher is recommended.

Returns:

The maximum energy difference compared across compositions (unit: eV/site), and whether a new ground-state structure has appeared.

Return type:

float, bool