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

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

""" 

This module provides the OrbitList class. 

""" 

 

from typing import List 

 

import numpy as np 

 

from _icet import _OrbitList 

from ase import Atoms 

from icet.core.local_orbit_list_generator import LocalOrbitListGenerator 

from icet.core.neighbor_list import get_neighbor_lists 

from icet.core.permutation_matrix import (_get_lattice_site_permutation_matrix, 

permutation_matrix_from_structure) 

from icet.core.structure import Structure 

from icet.io.logging import logger 

 

logger = logger.getChild('orbit_list') 

 

 

class OrbitList(_OrbitList): 

""" 

The orbit list object handles an internal list of orbits. 

 

An orbit has a list of equivalent sites with the restriction 

that at least one site is in the cell of the primitive structure. 

 

Parameters 

---------- 

structure : Atoms 

This structure will be used to construct a primitive 

structure on which all the lattice sites in the orbits 

are based. 

cutoffs : list of float 

the i-th element of this list is the cutoff for orbits with 

order i+2 

""" 

 

def __init__(self, structure_in, cutoffs): 

40 ↛ 41line 40 didn't jump to line 41, because the condition on line 40 was never true if isinstance(structure_in, Structure): 

structure_in = structure_in.to_structure() 

structure = structure_in.copy() 

structure.wrap() 

max_cutoff = np.max(cutoffs) 

# Set up a permutation matrix 

permutation_matrix, prim_structure, _ \ 

= permutation_matrix_from_structure(structure, max_cutoff, find_prim=False) 

 

logger.info('Done getting permutation_matrix.') 

 

# Get a list of neighbor-lists 

neighbor_lists = get_neighbor_lists(prim_structure, cutoffs) 

 

logger.info('Done getting neighbor lists.') 

 

# Transform permutation_matrix to be in lattice site format 

pm_lattice_sites \ 

= _get_lattice_site_permutation_matrix(prim_structure, 

permutation_matrix, 

prune=True) 

 

logger.info('Transformation of permutation matrix to lattice neighbor' 

'format completed.') 

 

_OrbitList.__init__(self, prim_structure, 

pm_lattice_sites, neighbor_lists) 

self.sort() 

logger.info('Finished construction of orbit list.') 

 

@property 

def primitive_structure(self): 

""" 

Returns the primitive structure to which the lattice sites in 

the orbits are referenced to. 

""" 

return self._primitive_structure.copy() 

 

def __str__(self): 

"""String representation.""" 

nice_str = 'Number of orbits: {}'.format(len(self)) 

 

for i, orbit in enumerate(self.orbits): 

cluster_str = self.orbits[i].representative_cluster.__str__() 

nice_str += "\norbit {} - Multiplicity {} - Cluster: {}".format( 

i, len(orbit), cluster_str) 

return nice_str 

 

def get_supercell_orbit_list(self, structure: Atoms): 

""" 

Returns an orbit list for a supercell structure. 

 

Parameters 

---------- 

structure 

supercell atomic structure 

 

Returns 

------- 

An OrbitList object 

""" 

log = LocalOrbitListGenerator(self, Structure.from_atoms(structure)) 

 

supercell_orbit_list = log.generate_full_orbit_list() 

 

return supercell_orbit_list 

 

def remove_inactive_orbits(self, allowed_species: List[List[str]]) -> None: 

""" Removes orbits with inactive sites. 

 

Parameters 

---------- 

allowed_species 

the list of allowed species on each site in the primitive 

structure 

""" 

prim_structure = self.get_primitive_structure() 

number_of_allowed_species = [len(sym) for sym in allowed_species] 

prim_structure.set_number_of_allowed_species(number_of_allowed_species) 

self._remove_inactive_orbits(prim_structure)