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

# coding: utf-8 

# Copyright (c) Pymatgen Development Team. 

# Distributed under the terms of the MIT License. 

 

from __future__ import division, unicode_literals 

 

""" 

This module contains the definition of some objects used in the chemenv package. 

""" 

 

__author__ = "David Waroquiers" 

__copyright__ = "Copyright 2012, The Materials Project" 

__credits__ = "Geoffroy Hautier" 

__version__ = "2.0" 

__maintainer__ = "David Waroquiers" 

__email__ = "david.waroquiers@gmail.com" 

__date__ = "Feb 20, 2016" 

 

 

from pymatgen.analysis.chemenv.utils.coordination_geometry_utils import is_anion_cation_bond 

 

 

class AdditionalConditions(): 

NO_ADDITIONAL_CONDITION = 0 

ONLY_ANION_CATION_BONDS = 1 

NO_ELEMENT_TO_SAME_ELEMENT_BONDS = 2 

ONLY_ANION_CATION_BONDS_AND_NO_ELEMENT_TO_SAME_ELEMENT_BONDS = 3 

ONLY_ELEMENT_TO_OXYGEN_BONDS = 4 

#Short versions 

NONE = NO_ADDITIONAL_CONDITION 

NO_AC = NO_ADDITIONAL_CONDITION 

ONLY_ACB = ONLY_ANION_CATION_BONDS 

NO_E2SEB = NO_ELEMENT_TO_SAME_ELEMENT_BONDS 

ONLY_ACB_AND_NO_E2SEB = ONLY_ANION_CATION_BONDS_AND_NO_ELEMENT_TO_SAME_ELEMENT_BONDS 

ONLY_E2OB = ONLY_ELEMENT_TO_OXYGEN_BONDS 

#Dictionary mapping of integer for the condition and its "description" 

CONDITION_DESCRIPTION = {NO_ADDITIONAL_CONDITION: 'No additional condition', 

ONLY_ANION_CATION_BONDS: 'Only anion-cation bonds', 

NO_ELEMENT_TO_SAME_ELEMENT_BONDS: 'No element-element bonds (same elements)', 

ONLY_ANION_CATION_BONDS_AND_NO_ELEMENT_TO_SAME_ELEMENT_BONDS: 'Only anion-cation bonds and' 

' no element-element bonds' 

' (same elements)', 

ONLY_ELEMENT_TO_OXYGEN_BONDS: 'Only element-oxygen bonds'} 

 

ALL = [NONE, ONLY_ACB, NO_E2SEB, ONLY_ACB_AND_NO_E2SEB, ONLY_E2OB] 

 

def check_condition(self, condition, structure, parameters): 

if condition == self.NONE: 

return True 

elif condition == self.ONLY_ACB: 

valences = parameters['valences'] 

ii = parameters['site_index'] 

jj = parameters['neighbor_index'] 

return is_anion_cation_bond(valences, ii, jj) 

elif condition == self.NO_E2SEB: 

ii = parameters['site_index'] 

jj = parameters['neighbor_index'] 

elmts_ii = [sp.symbol for sp in structure[ii].species_and_occu] 

elmts_jj = [sp.symbol for sp in structure[jj].species_and_occu] 

return len(set(elmts_ii) & set(elmts_jj)) == 0 

elif condition == self.ONLY_ACB_AND_NO_E2SEB: 

valences = parameters['valences'] 

ii = parameters['site_index'] 

jj = parameters['neighbor_index'] 

elmts_ii = [sp.symbol for sp in structure[ii].species_and_occu] 

elmts_jj = [sp.symbol for sp in structure[jj].species_and_occu] 

return len(set(elmts_ii) & set(elmts_jj)) == 0 and is_anion_cation_bond(valences, ii, jj) 

elif condition == self.ONLY_E2OB: 

ii = parameters['site_index'] 

jj = parameters['neighbor_index'] 

elmts_ii = [sp.symbol for sp in structure[ii].species_and_occu] 

elmts_jj = [sp.symbol for sp in structure[jj].species_and_occu] 

return ('O' in elmts_jj and 'O' not in elmts_ii) or ('O' in elmts_ii and 'O' not in elmts_jj)