Observers¶
SiteOccupancyObserver¶

class
mchammer.observers.
SiteOccupancyObserver
(cluster_space, structure, sites, interval=None)[source]¶ This class represents a site occupation factor (SOF) observer.
A SOF observer allows to compute the site occupation factors along the trajectory sampled by a Monte Carlo (MC) simulation.
 Parameters
cluster_space (icet.ClusterSpace) – cluster space from which the allowed species are extracted
structure (ase.Atoms) – supercell consistent with primitive structure in cluster space; used to determine which species are allowed on each site
sites (dict(str, list(int))) – dictionary containing lists of sites that are to be considered; the keys will be taken as the names of the sites; the indices refer to the primitive structure associated with the cluster space
interval (int) – the observation interval, defaults to None meaning that if the observer is used in a Monte Carlo simulation, then the Ensemble object will set the interval.

tag
¶ name of observer
 Type
str

interval
¶ observation interval
 Type
int
Example
The following snippet illustrate how to use the site occupancy factor (SOF) observer in a Monte Carlo simulation of a surface slab. Here, the SOF observer is used to monitor the concentrations of different species at the surface, the first subsurface layer, and the remaining “bulk”. A minimal cluster expansion is used with slightly modified surface interactions in order to obtain an example that can be run without much ado. In practice, one should of course use a proper cluster expansion:
>>> from ase.build import fcc111 >>> from icet import ClusterExpansion, ClusterSpace >>> from mchammer.calculators import ClusterExpansionCalculator >>> from mchammer.ensembles import CanonicalEnsemble >>> from mchammer.observers import SiteOccupancyObserver >>> # prepare reference structure >>> prim = fcc111('Au', size=(1, 1, 10), vacuum=10.0) >>> prim.translate((0.1, 0.1, 0.0)) >>> prim.wrap() >>> prim.pbc = True # icet requires pbc in all directions >>> # prepare cluster expansion >>> cs = ClusterSpace(prim, cutoffs=[3.7], chemical_symbols=['Ag', 'Au']) >>> params = [0] + 5 * [0] + 10 * [0.1] >>> params[1] = 0.01 >>> params[6] = 0.12 >>> ce = ClusterExpansion(cs, params) >>> print(ce) >>> # prepare initial configuration based on a 2x2 supercell >>> structure = prim.repeat((2, 2, 1)) >>> for k in range(20): >>> structure[k].symbol = 'Ag' >>> # set up MC simulation >>> calc = ClusterExpansionCalculator(structure, ce) >>> mc = CanonicalEnsemble(structure=structure, calculator=calc, temperature=600, ... dc_filename='myrun_sof.dc') >>> # set up observer and attach it to the MC simulation >>> sites = {'surface': [0, 9], 'subsurface': [1, 8], ... 'bulk': list(range(2, 8))} >>> sof = SiteOccupancyObserver(cs, structure, sites, interval=len(structure)) >>> mc.attach_observer(sof) >>> # run 1000 trial steps >>> mc.run(1000)
After having run this snippet one can access the SOFs via the data container:
>>> print(mc.data_container.data)

get_observable
(structure)[source]¶ Returns the site occupation factors for a given atomic configuration.
 Parameters
structure (
Atoms
) – input atomic structure. Return type
Dict
[str
,List
[float
]]

property
return_type
¶ Data type of the observed data.
 Return type
type
BinaryShortRangeOrderObserver¶

class
mchammer.observers.
BinaryShortRangeOrderObserver
(cluster_space, structure, radius, interval=None)[source]¶ This class represents a short range order (SRO) observer for a binary system.
 Parameters
cluster_space (icet.ClusterSpace) – cluster space used for initialization
structure (ase.Atoms) – defines the lattice which the observer will work on
interval (int) – the observation interval, defaults to None meaning that if the observer is used in a Monte Carlo simulations, then the Ensemble object will set the interval.
radius (float) – the maximum radius for the neigbhor shells considered

tag
¶ human readable observer name (BinaryShortRangeOrderObserver)
 Type
str

interval
¶ observation interval
 Type
int
Example
The following snippet illustrate how to use the shortrange order (SRO) observer in a Monte Carlo simulation of a bulk supercell. Here, the parameters of the cluster expansion are set to emulate a simple Ising model in order to obtain an example that can be run without modification. In practice, one should of course use a proper cluster expansion:
>>> from ase.build import bulk >>> from icet import ClusterExpansion, ClusterSpace >>> from mchammer.calculators import ClusterExpansionCalculator >>> from mchammer.ensembles import CanonicalEnsemble >>> from mchammer.observers import BinaryShortRangeOrderObserver >>> # prepare cluster expansion >>> # the setup emulates a second nearestneighbor (NN) Ising model >>> # (zerolet and singlet ECIs are zero; only first and second neighbor >>> # pairs are included) >>> prim = bulk('Au') >>> cs = ClusterSpace(prim, cutoffs=[4.3], chemical_symbols=['Ag', 'Au']) >>> ce = ClusterExpansion(cs, [0, 0, 0.1, 0.02]) >>> # prepare initial configuration >>> nAg = 10 >>> structure = prim.repeat(3) >>> structure.set_chemical_symbols(nAg * ['Ag'] + (len(structure)  nAg) * ['Au']) >>> # set up MC simulation >>> calc = ClusterExpansionCalculator(structure, ce) >>> mc = CanonicalEnsemble(structure=structure, calculator=calc, temperature=600, ... dc_filename='myrun_sro.dc') # set up observer and attach it to the MC simulation sro = BinaryShortRangeOrderObserver(cs, structure, interval=len(structure), radius=4.3) mc.attach_observer(sro) # run 1000 trial steps mc.run(1000)
After having run this snippet one can access the SRO parameters via the data container:
print(mc.data_container.data)

get_observable
(structure)[source]¶ Returns the value of the property from a cluster expansion model for a given atomic configurations.
 Parameters
structure (
Atoms
) – input atomic structure Return type
Dict
[str
,float
]

property
return_type
¶ Data type of the observed data.
 Return type
type
ClusterCountObserver¶

class
mchammer.observers.
ClusterCountObserver
(cluster_space, structure, interval=None)[source]¶ This class represents a cluster count observer.
A cluster count observer enables one to keep track of the occupation of clusters along the trajectory sampled by a Monte Carlo (MC) simulation. For example, using this observer, several canonical MC simulations could be carried out at different temperatures and the temperature dependence of the number of nearest neigbhors of a particular species could be accessed with this observer.
 Parameters
cluster_space (icet.ClusterSpace) – cluster space to define the clusters to be counted
structure (ase.Atoms) – defines the lattice that the observer will work on
interval (int) – observation interval during the Monte Carlo simulation

tag
¶ human readable observer name
 Type
str

interval
¶ the observation interval, defaults to None meaning that if the observer is used in a Monte Carlo simulation, then the Ensemble object will set the interval.
 Type
int

get_observable
(structure)[source]¶ Returns the value of the property from a cluster expansion model for a given atomic configuration.
 Parameters
structure (
Atoms
) – input atomic structure Return type
dict

property
return_type
¶ Data type of the observed data.
 Return type
type
ClusterExpansionObserver¶

class
mchammer.observers.
ClusterExpansionObserver
(cluster_expansion, interval=None, tag='ClusterExpansionObserver')[source]¶ This class represents a cluster expansion (CE) observer.
A CE observer allows to compute a property described by a CE along the trajectory sampled by a Monte Carlo (MC) simulation. In general this CE differs from the CE that is used to generate the trajectory. For example in a canonical MC simulation the latter would usually represent an energy (total or mixing energy) whereas the former CE(s) could map lattice constant or band gap.
 Parameters
cluster_expansion (
icet.ClusterExpansion
cluster expansion model) – to be used for observationtag (str) – human readable observer name (default: ClusterExpansionObserver)
interval (int) – observation interval during the Monte Carlo simulation

tag
¶ name of observer
 Type
str

interval
¶ the observation interval, defaults to None meaning that if the observer is used in a Monte Carlo simulation, then the Ensemble object will set the interval.
 Type
int

get_observable
(structure)[source]¶ Returns the value of the property from a cluster expansion model for a given atomic configuration.
 Parameters
structure (
Atoms
) – input atomic structure. Return type
float

property
return_type
¶ Data type of the observed data.
 Return type
type