Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1from ase import Atoms 

2from icet import ClusterExpansion 

3from mchammer.observers.base_observer import BaseObserver 

4 

5 

6class ClusterExpansionObserver(BaseObserver): 

7 """ 

8 This class represents a cluster expansion (CE) observer. 

9 

10 A CE observer allows to compute a property described by a CE along the 

11 trajectory sampled by a Monte Carlo (MC) simulation. In general this CE 

12 differs from the CE that is used to generate the trajectory. For example in 

13 a canonical MC simulation the latter would usually represent an energy 

14 (total or mixing energy) whereas the former CE(s) could map lattice 

15 constant or band gap. 

16 

17 Parameters 

18 ---------- 

19 cluster_expansion : :class:`icet.ClusterExpansion` cluster expansion model 

20 to be used for observation 

21 tag : str 

22 human readable observer name (default: `ClusterExpansionObserver`) 

23 interval : int 

24 observation interval during the Monte Carlo simulation 

25 

26 Attributes 

27 ---------- 

28 tag : str 

29 name of observer 

30 interval : int 

31 the observation interval, defaults to None meaning that if the 

32 observer is used in a Monte Carlo simulation, then the Ensemble object 

33 will set the interval. 

34 """ 

35 

36 def __init__(self, cluster_expansion: ClusterExpansion, 

37 interval: int = None, 

38 tag: str = 'ClusterExpansionObserver') -> None: 

39 super().__init__(interval=interval, return_type=float, tag=tag) 

40 self._cluster_expansion = cluster_expansion 

41 

42 def get_observable(self, structure: Atoms) -> float: 

43 """ 

44 Returns the value of the property from a cluster expansion model 

45 for a given atomic configuration. 

46 

47 Parameters 

48 ---------- 

49 structure 

50 input atomic structure. 

51 """ 

52 return self._cluster_expansion.predict(structure)