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

""" 

This module provides the Structure class. 

""" 

 

from ase import Atoms 

 

from _icet import Structure 

 

 

@classmethod 

def _structure_from_atoms(self, conf: Atoms): 

""" 

Returns the input configuration as an icet Structure object. 

 

Parameters 

---------- 

conf 

input configuration 

 

Returns 

------- 

atomic configuration 

""" 

return self(conf.positions, 

conf.get_chemical_symbols(), 

conf.cell, 

conf.pbc.tolist()) 

 

 

Structure.from_atoms = _structure_from_atoms 

 

 

def _structure_to_atoms(self) -> Atoms: 

""" 

Returns the structure as an ASE Atoms object. 

 

Returns 

------- 

atomic configuration 

""" 

import ase 

conf = ase.Atoms(pbc=self.pbc) 

conf.set_cell(self.cell) 

for symbol, position in zip(self.chemical_symbols, self.positions): 

conf.append(ase.Atom(symbol, position)) 

conf.set_positions(self.get_positions()) 

conf.set_chemical_symbols(self.get_chemical_symbols()) 

return conf 

 

 

Structure.to_atoms = _structure_to_atoms 

 

 

def _repr_function(self) -> str: 

s = ['Cell:'] 

s += ['{}\n'.format(self.cell)] 

s += ['Element and positions:'] 

for symbol, position in zip(self.chemical_symbols, self.positions): 

s += ['{} [{:} {:} {:}]'.format(symbol, *position)] 

return '\n'.join(s) 

 

 

Structure.__repr__ = _repr_function