Calculators

ClusterExpansionCalculator

class mchammer.calculators.ClusterExpansionCalculator(structure, cluster_expansion, name='Cluster Expansion Calculator', scaling=None, use_local_energy_calculator=True)[source]

A ClusterExpansionCalculator object enables the efficient calculation of properties described by a cluster expansion. It is specific for a particular (supercell) structure and commonly employed when setting up a Monte Carlo simulation, see Ensembles.

Cluster expansions, e.g., of the energy, typically yield property values per site. When running a Monte Carlo simulation one, however, considers changes in the total energy of the system. The default behavior is therefore to multiply the output of the cluster expansion by the number of sites. This behavior can be changed via the scaling keyword parameter.

Parameters:
  • structure (Atoms) – Structure for which to set up the calculator.

  • cluster_expansion (ClusterExpansion) – Cluster expansion from which to build calculator.

  • name (str) – Human-readable identifier for this calculator.

  • scaling (Union[float, int, None]) – Scaling factor applied to the property value predicted by the cluster expansion.

  • use_local_energy_calculator (bool) – Evaluate energy changes using only the local environment; this method is generally much faster. Unless you know what you are doing do not set this option to False.

accept_change()

Some calculators depend on the state of the occupdations, in which they need to be informed if the occupations change.

calculate_change(*, sites, current_occupations, new_site_occupations)[source]

Calculates and returns the sum of the contributions to the property due to the sites specified in sites.

Parameters:
  • sites (List[int]) – Indices of sites at which occupations will be changed.

  • current_occupations (List[int]) – Entire occupation vector (atomic numbers) before change.

  • new_site_occupations (List[int]) – Atomic numbers after change at the sites defined by sites.

Return type:

float

calculate_total(*, occupations)[source]

Calculates and returns the total property value of the current configuration.

Parameters:

occupations (List[int]) – The entire occupation vector (i.e., list of atomic species).

Return type:

float

property cluster_expansion: ClusterExpansion

Cluster expansion from which calculator was set up.

property sublattices: Sublattices

Sublattices of the calculator structure.

ConstituentStrainCalculator

class mchammer.calculators.ConstituentStrainCalculator(constituent_strain, cluster_expansion, name='Constituent Strain Calculator', scaling=None)[source]

Calculator for handling cluster expansions with strain.

Parameters:
  • constituent_strain (ConstituentStrain) – ConstituentStrain object defining the strain energy properties of the system. The supercell used to create this object should correspond to the one used when running Monte Carlo simulations with this calculator

  • cluster_expansion (ClusterExpansion) – Cluster expansion based on which to set up ClusterExpansionCalculator.

  • name (str) – Human-readable identifier for this calculator.

  • scaling (Union[float, int, None]) – Scaling factor applied to the property value predicted by the cluster expansion.

accept_change()[source]

Informs the ConstituentStrain object that the most recent change was accepted, such that the new structure factor can be stored.

calculate_change(*, sites, current_occupations, new_site_occupations)[source]

Calculates and returns the sum of the contributions to the property due to the sites specified in sites.

Parameters:
  • sites (List[int]) – Indices of sites at which occupations will be changed.

  • current_occupations (List[int]) – Entire occupation vector (atomic numbers) before change.

  • new_site_occupations (List[int]) – Atomic numbers after change at the sites defined by sites.

Return type:

float

calculate_total(*, occupations)[source]

Calculates and returns the total property value of the current configuration.

Parameters:

occupations (ndarray) – The entire occupation vector (i.e., an array of atomic numbers as integers).

Return type:

float

property cluster_expansion: ClusterExpansion

Cluster expansion from which calculator was set up.

property sublattices: Sublattices

Sublattices of the calculator structure.

TargetVectorCalculator

class mchammer.calculators.TargetVectorCalculator(structure, cluster_space, target_vector, weights=None, optimality_weight=1.0, optimality_tol=1e-05, name='Target vector calculator')[source]

A TargetVectorCalculator enables evaluation of the similarity between a structure and a target cluster vector. Such a comparison can be carried out in many ways, and this implementation follows the measure proposed by van de Walle et al. in Calphad 42, 13 (2013) [WalTiwJon13]. Specifically, the objective function \(Q\) is calculated as

\[Q = - \omega L + \sum_{\alpha} \left||\Gamma_{\alpha} - \Gamma^{\text{target}}_{\alpha}\right||.\]

Here, \(\Gamma_{\alpha}\) are components in the cluster vector and \(\Gamma^\text{target}_{\alpha}\) the corresponding target values. The factor \(\omega\) is the radius of the largest pair cluster such that all clusters with the same or smaller radii have \(\Gamma_{\alpha} - \Gamma^\text{target}_{\alpha} = 0\).

Parameters:
  • structure (Atoms) – Structure for which to set up calculator.

  • cluster_space (ClusterSpace) – Cluster space from which to build calculator.

  • target_vector (List[float]) – Vector to which any vector will be compared.

  • weights (Optional[List[float]]) – Weighting of each component in cluster vector comparison. By default set to 1.0 for all components.

  • optimality_weight (float) – Factor \(L\), a high value of which effectively favors a complete series of optimal cluster correlations for the smallest pairs (see above).

  • optimality_tol (float) – Tolerance for determining whether a perfect match has been achieved (used in conjunction with \(L\)).

  • name (str) – Human-readable identifier for this calculator.

accept_change()

Some calculators depend on the state of the occupdations, in which they need to be informed if the occupations change.

calculate_total(occupations)[source]

Calculates and returns the similarity value \(Q\) of the current configuration.

Parameters:

occupations (List[int]) – The entire occupation vector (i.e., list of atomic species).

Return type:

float

property sublattices: Sublattices

Sublattices of the calculators structure.

mchammer.calculators.compare_cluster_vectors(cv_1, cv_2, as_list, weights=None, optimality_weight=1.0, tol=1e-05)[source]

Calculate a quantity that measures similarity between two cluster vecors.

Parameters:
  • cv_1 (ndarray) – Cluster vector 1.

  • cv_2 (ndarray) – Cluster vector 2.

  • as_list (List[OrderedDict]) – Orbit data as obtained by ClusterSpace.as_list.

  • weights (Optional[List[float]]) – Weight assigned to each cluster vector element.

  • optimality_weight (float) – Wuantity \(L\) in [WalTiwJon13] (see mchammer.calculators.TargetVectorCalculator).

  • tol (float) – Numerical tolerance for determining whether two elements are equal.

Return type:

float