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

1""" 

2Definition of the base observer class. 

3""" 

4 

5from abc import ABC, abstractmethod 

6from typing import Any 

7from ase import Atoms 

8 

9 

10class BaseObserver(ABC): 

11 """ 

12 Base observer class. 

13 

14 Parameters 

15 ---------- 

16 interval : int 

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

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

19 will set the interval. 

20 tag : str 

21 human readable tag used for identifying the observer 

22 

23 Attributes 

24 ---------- 

25 tag : str 

26 human readable tag used for identifying the observer 

27 interval : int 

28 the observation interval 

29 """ 

30 

31 def __init__(self, return_type: type, interval: int = None, tag: str = 'BaseObserver') -> None: 

32 self.tag = tag 

33 self.interval = interval 

34 self._return_type = return_type 

35 

36 @property 

37 def return_type(self) -> type: 

38 """Data type of the observed data.""" 

39 return self._return_type 

40 

41 @abstractmethod 

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

43 """ 

44 Method used for extracting data. 

45 

46 Returns 

47 ------- 

48 self.return_type() 

49 

50 When implementing this method use the following names for the 

51 following types of data: 

52 

53 ASE Atoms object : `structure`. 

54 list of chemical species : `species`. 

55 icet cluster expansion : `cluster_expansion`. 

56 mchammer calculator : `calculator`. 

57 """ 

58 raise NotImplementedError