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 (ase.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 calculatorscaling (
Union
[float
,int
,None
]) – scaling factor applied to the property value predicted by the cluster expansionuse_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 local_indices
- Parameters:
sites (
List
[int
]) – index of sites at which occupations will be changedcurrent_occupations (
List
[int
]) – entire occupation vector (atomic numbers) before changenew_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 constructed
- property sublattices: Sublattices¶
Sublattices of the calculators 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 corresponding to the one used when running Monte Carlo simulations with this calculatorcluster_expansion (
ClusterExpansion
) – cluster expansion from which to build ClusterExpansionCalculatorname (
str
) – human-readable identifier for this calculatorscaling (
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 local_indices
- Parameters:
sites (
List
[int
]) – index of sites at which occupations will be changedcurrent_occupations (
List
[int
]) – entire occupation vector (atomic numbers) before changenew_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 constructed
- property sublattices: Sublattices¶
Sublattices of the calculators 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 calculatorcluster_space (
ClusterSpace
) – cluster space from which to build calculatortarget_vector (
List
[float
]) – vector to which any vector will be comparedweights (
Optional
[List
[float
]]) – weighting of each component in cluster vector comparison, by default 1.0 for all componentsoptimality_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, orbit_data, 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 1cv_2 (
ndarray
) – cluster vector 2orbit_data (
List
[OrderedDict
]) – orbit data as obtained byClusterSpace.orbit_data
weights (
Optional
[List
[float
]]) – Weight assigned to each cluster vector elementoptimality_weight (
float
) – quantity \(L\) in [WalTiwJon13] (seemchammer.calculators.TargetVectorCalculator
)tol (
float
) – numerical tolerance for determining whether two elements are exactly equal
- Return type:
float