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

""" 

This module provides a Python interface to the NeighborList class 

with supplementary functions. 

""" 

 

from typing import List, Union 

from _icet import NeighborList 

from ase import Atoms 

from .structure import Structure 

 

 

def get_neighbor_lists(structure: Union[Atoms, Structure], 

cutoffs: List[float] = None) -> List[NeighborList]: 

""" 

Returns a list of icet neighbor lists given a configuration and cutoffs. 

 

Parameters 

---------- 

structure 

atomic configuration 

cutoffs 

positive floats indicating the cutoffs for the various clusters 

""" 

 

# deal with different types of structure objects 

26 ↛ 27line 26 didn't jump to line 27, because the condition on line 26 was never true if isinstance(structure, Atoms): 

structure = Structure.from_atoms(structure) 

28 ↛ 29line 28 didn't jump to line 29, because the condition on line 28 was never true elif not isinstance(structure, Structure): 

msg = ['Unknown structure format'] 

msg += ['{} (ClusterSpace)'.format(type(structure))] 

raise Exception(' '.join(msg)) 

 

neighbor_lists = [] 

if cutoffs is None: 

raise Exception('Both n and cutoffs is None in count clusters') 

else: 

for cutoff in cutoffs: 

nl = NeighborList(cutoff) 

neighbor_lists.append(nl) 

 

# build the neighbor_lists 

for nl in neighbor_lists: 

nl.build(structure) 

 

return neighbor_lists