Package generic_fns :: Module nuclei
[hide private]
[frames] | no frames]

Source Code for Module generic_fns.nuclei

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003, 2004 Edward d'Auvergne                                  # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax is free software; you can redistribute it and/or modify               # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation; either version 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax is distributed in the hope that it will be useful,                    # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  from re import match 
 24   
 25   
26 -class Nuclei:
27 - def __init__(self, relax):
28 """Class containing the function to set the gyromagnetic ratio of the heteronucleus.""" 29 30 self.relax = relax
31 32
33 - def find_nucleus(self):
34 """Function for finding the nucleus corresponding to 'self.relax.data.gx'.""" 35 36 # Not set. 37 if not hasattr(self.relax.data, 'gx'): 38 return 39 40 # Nitrogen. 41 if self.relax.data.gx == self.gn(): 42 return 'N' 43 44 # Carbon 45 if self.relax.data.gx == self.gc(): 46 return 'C' 47 48 # Oxygen. 49 if self.relax.data.gx == self.go(): 50 return 'O' 51 52 # Phosphate. 53 if self.relax.data.gx == self.gp(): 54 return 'P'
55 56
57 - def gc(self):
58 """The 13C gyromagnetic ratio.""" 59 60 return 6.728e7
61 62
63 - def gh(self):
64 """The 1H gyromagnetic ratio.""" 65 66 # Old, low precision gyromagnetic ratio. 67 #return 26.7522e7 68 69 return 26.7522212e7
70 71
72 - def gn(self):
73 """The 15N gyromagnetic ratio.""" 74 75 return -2.7126e7
76 77
78 - def go(self):
79 """The 17O gyromagnetic ratio.""" 80 81 return -3.628e7
82 83
84 - def gp(self):
85 """The 31P gyromagnetic ratio.""" 86 87 return 1.0841e8
88 89
90 - def set_values(self, heteronuc):
91 """Function for setting the gyromagnetic ratio of the heteronucleus.""" 92 93 # Nitrogen. 94 if match('[Nn]', heteronuc): 95 self.relax.data.gx = self.gn() 96 97 # Carbon 98 elif match('[Cc]', heteronuc): 99 self.relax.data.gx = self.gc() 100 101 # Oxygen. 102 elif match('[Oo]', heteronuc): 103 self.relax.data.gx = self.go() 104 105 # Phosphate. 106 elif match('[Pp]', heteronuc): 107 self.relax.data.gx = self.gp() 108 109 # Incorrect arguement. 110 else: 111 raise RelaxInvalidError, ('heteronucleus', heteronuc) 112 113 # Set the proton gyromagnetic ratio. 114 self.relax.data.gh = self.gh() 115 116 # Calculate the ratio of the gyromagnetic ratios. 117 self.relax.data.g_ratio = self.relax.data.gh / self.relax.data.gx
118