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

# coding: utf-8 

# Copyright (c) Pymatgen Development Team. 

# Distributed under the terms of the MIT License. 

 

from __future__ import division, unicode_literals 

 

from collections import namedtuple 

from monty.json import MSONable 

 

""" 

A module to perform NMR data analysis/processing. 

""" 

 

 

__author__ = "Xiaohui Qu" 

__copyright__ = "Copyright 2016, The Materials Project" 

__version__ = "0.1" 

__maintainer__ = "Xiaohui Qu" 

__email__ = "xhqu1981@gmail.com" 

__date__ = "Apr 17, 2016" 

 

 

class NMRChemicalShiftNotation(MSONable): 

""" 

Helper class to convert between different chemical shift conventions 

internally using the Mehring notation. Note that this is different than the 

default notion adopted by VASP which is the Maryland notation. 

 

Three notations to describe chemical shift tensor (RK Harris; Magn. Reson. 

Chem. 2008, 46, 582–598; DOI: 10.1002/mrc.2225) are supported. 

 

Args: 

sigma_1 (float): chemical shift tensor principle component 1 

sigma_2 (float): chemical shift tensor principle component 2 

sigma_3 (float): chemical shift tensor principle component 3 

 

.. attribute:: sigma_11, simga_22, sigma33 

principle components in Mehring notation 

 

Authors: Xiaohui Qu 

""" 

 

HaeberlenNotation = namedtuple(typename="HaeberlenNotion", 

field_names="sigma_iso, delta_sigma, zeta, eta") 

MehringNotation = namedtuple(typename="MehringNotation", 

field_names="sigma_iso, sigma_11, sigma_22, sigma_33") 

MarylandNotation = namedtuple(typename="MarylandNotation", 

field_names="sigma_iso, omega, kappa") 

 

def __init__(self, sigma_1, sigma_2, sigma_3): 

sigmas = sorted([sigma_1, sigma_2, sigma_3]) 

self.sigma_11, self.sigma_22, self.sigma_33 = sigmas 

 

@property 

def haeberlen_values(self): 

""" 

Returns: the Chemical shift tensor in Haeberlen Notation 

""" 

sigma_iso = (self.sigma_11 + self.sigma_22 + self.sigma_33) / 3.0 

h_order_sigmas = sorted([self.sigma_11, self.sigma_22, self.sigma_33], 

key=lambda x: abs(x - sigma_iso), 

reverse=True) 

sigma_zz, sigma_xx, sigma_yy = h_order_sigmas 

delta_sigma = sigma_zz - 0.5 * (sigma_xx + sigma_yy) 

zeta = sigma_zz - sigma_iso 

assert abs(delta_sigma - 1.5 * zeta) < 1.0E-5 

eta = (sigma_yy - sigma_xx) / zeta 

return self.HaeberlenNotation(sigma_iso, delta_sigma, zeta, eta) 

 

@property 

def mehring_values(self): 

""" 

Returns: the Chemical shift tensor in Mehring Notation 

""" 

sigma_iso = (self.sigma_11 + self.sigma_22 + self.sigma_33) / 3.0 

return self.MehringNotation(sigma_iso, self.sigma_11, 

self.sigma_22, self.sigma_33) 

 

@property 

def maryland_values(self): 

""" 

Returns: the Chemical shift tensor in Maryland Notation 

""" 

sigma_iso = (self.sigma_11 + self.sigma_22 + self.sigma_33) / 3.0 

omega = self.sigma_33 - self.sigma_11 

# There is a typo in equation 20 from Magn. Reson. Chem. 2008, 46, 582–598, the sign is wrong. 

# There correct order is presented in Solid State Nucl. Magn. Reson. 1993, 2, 285-288. 

kappa = 3.0 * (self.sigma_22 - sigma_iso) / omega 

return self.MarylandNotation(sigma_iso, omega, kappa) 

 

@classmethod 

def from_maryland_notation(cls, sigma_iso, omega, kappa): 

sigma_22 = sigma_iso + kappa * omega / 3.0 

sigma_11 = (3.0 * sigma_iso - omega - sigma_22) / 2.0 

sigma_33 = 3.0 * sigma_iso - sigma_22 - sigma_11 

return cls(sigma_11, sigma_22, sigma_33) 

 

def as_dict(self): 

d = {"sigma_11": self.sigma_11, 

"sigma_22": self.sigma_22, 

"sigma_33": self.sigma_33} 

return d 

 

@classmethod 

def from_dict(cls, d): 

return cls(d["sigma_11"], d["sigma_22"], d["sigma_33"])