Package lib :: Module physical_constants
[hide private]
[frames] | no frames]

Source Code for Module lib.physical_constants

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2007-2013 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program 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 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Module docstring. 
 23  """Module containing all physical constants used in relax, as well as all associated functions.""" 
 24   
 25   
 26  # Python module imports. 
 27  from math import pi 
 28  from string import ascii_letters, digits 
 29   
 30  # relax module imports. 
 31  from lib.float import nan 
 32  from lib.errors import RelaxError 
 33   
 34   
 35  # Misc. constants. 
 36  ################## 
 37   
 38  h = 6.62606876 * 1e-34 
 39  """Planck's constant.""" 
 40   
 41  h_bar = h / (2.0 * pi) 
 42  """Dirac's constant.""" 
 43   
 44  mu0 = 4.0 * pi * 1e-7 
 45  """The magnetic constant or the permeability of vacuum.""" 
 46   
 47  kB = 1.380650424 * 1e-23 
 48  """Boltzmann's constant in SI units of J.K^-1 (the last 2 digits of '24' are within the measured error limits).""" 
 49   
 50   
 51  # CSA and bond lengths. 
 52  ####################### 
 53   
 54  N15_CSA = -172 * 1e-6 
 55  """The 15N CSA in the NH bond (default value).""" 
 56   
 57  NH_BOND_LENGTH = 1.02 * 1e-10 
 58  """The length of the NH bond (default value).""" 
 59   
 60  NH_BOND_LENGTH_RDC = 1.041 * 1e-10 
 61  """The length of the NH bond for RDCs (from Ottiger, M. and Bax A., J. Am. Chem. Soc. (1998), 120, 12334-12341).""" 
 62   
 63  CA_HA_BOND_LENGTH_RDC = 1.118 * 1e-10 
 64  """The length of the C_alpha-H_alpha bond for RDCs (from Ottiger, M. and Bax A., J. Am. Chem. Soc. (1998), 120, 12334-12341).""" 
 65   
 66  CA_C_BOND_LENGTH_RDC = 1.526 * 1e-10 
 67  """The length of the C_alpha-C_prime bond for RDCs (from Ottiger, M. and Bax A., J. Am. Chem. Soc. (1998), 120, 12334-12341).""" 
 68   
 69  C_N_BOND_LENGTH_RDC = 1.329 * 1e-10 
 70  """The length of the C_prime-N bond for RDCs (from Ottiger, M. and Bax A., J. Am. Chem. Soc. (1998), 120, 12334-12341).""" 
 71   
 72  C_HN_BOND_LENGTH_RDC = 2.067 * 1e-10 
 73  """The length of the C_prime-HN bond for RDCs (from Ottiger, M. and Bax A., J. Am. Chem. Soc. (1998), 120, 12334-12341).""" 
 74   
 75   
 76   
 77  # The dipolar constant. 
 78  ####################### 
 79   
80 -def dipolar_constant(gx, gh, r):
81 """Calculate the dipolar constant. 82 83 The dipolar constant is defined as:: 84 85 mu0 gI.gS.h_bar 86 d = - --- ----------- , 87 4pi r**3 88 89 where: 90 - mu0 is the permeability of free space, 91 - gI and gS are the gyromagnetic ratios of the I and S spins, 92 - h_bar is Dirac's constant which is equal to Planck's constant divided by 2pi, 93 - r is the distance between the two spins. 94 95 96 @param gx: The gyromagnetic ratio of the heteronucleus (or first spin). 97 @type gx: float 98 @param gh: The gyromagnetic ratio of the proton (or second spin). 99 @type gh: float 100 @param r: The distance between the two nuclei. 101 @type r: float 102 """ 103 104 # Catch zero bond lengths, returning NaN. 105 if r == 0: 106 return nan 107 108 # Calculate and return the value. 109 return - mu0 / (4.0*pi) * gx * gh * h_bar / r**3
110 111 112 # The pseudocontact shift constant. 113 ################################### 114
115 -def pcs_constant(T, Bo, r):
116 """Calculate the pseudocontact shift constant. 117 118 The pseudocontact shift constant is defined as:: 119 120 mu0 15kT 1 121 d = --- ----- ---- , 122 4pi Bo**2 r**3 123 124 where: 125 - mu0 is the permeability of free space, 126 - k is Boltzmann's constant, 127 - T is the absolute temperature, 128 - Bo is the magnetic field strength, 129 - r is the distance between the paramagnetic centre (electron spin) and the nuclear spin. 130 131 132 @param T: The temperature in kelvin. 133 @type T: float 134 @param Bo: The magnetic field strength. 135 @type Bo: float 136 @param r: The distance between the two nuclei. 137 @type r: float 138 """ 139 140 # Catch zero bond lengths, returning NaN. 141 if r == 0: 142 return nan 143 144 # Calculate and return the value. 145 return mu0 / (4.0*pi) * 15.0 * kB * T / Bo**2 / r**3
146 147 148 149 # Gyromagnetic ratios. 150 ###################### 151 152 g13C = 6.728 * 1e7 153 """The 13C gyromagnetic ratio.""" 154 155 g1H = 26.7522212 * 1e7 156 """The 1H gyromagnetic ratio.""" 157 # Pales: 2.675198e+8 158 159 g15N = -2.7126 * 1e7 160 """The 15N gyromagnetic ratio.""" 161 # Pales: -2.7116e+7 162 163 g17O = -3.628 * 1e7 164 """The 17O gyromagnetic ratio.""" 165 166 g31P = 10.841 * 1e7 167 """The 31P gyromagnetic ratio.""" 168 169 # Function for returning the desired gyromagnetic ratio.
170 -def return_gyromagnetic_ratio(nucleus=None):
171 """Return the gyromagnetic ratio for the given nucleus type. 172 173 @keyword nucleus: The nucleus type. 174 @type nucleus: str 175 @raises RelaxError: If the nucleus type is unknown. 176 @returns: The desired gyromagnetic ratio. 177 @rtype: float 178 """ 179 180 # Matching loop. 181 if nucleus == '13C': 182 return g13C 183 elif nucleus == '1H': 184 return g1H 185 elif nucleus == '15N': 186 return g15N 187 elif nucleus == '17O': 188 return g17O 189 elif nucleus == '31P': 190 return g31P 191 else: 192 raise RelaxError("The nucleus type " + repr(nucleus) + " is unknown.")
193 194 195 # Relative atomic masses. 196 ######################### 197 198 ArH = 1.00794 199 """Proton atomic mass.""" 200 201 ArC = 12.0107 202 """Carbon atomic mass.""" 203 204 ArN = 14.0067 205 """Nitrogen atomic mass.""" 206 207 ArO = 15.9994 208 """Oxygen atomic mass.""" 209 210 ArS = 32.065 211 """Sulphur atomic mass.""" 212 213 ArCa = 40.078 214 """Calcium atomic mass.""" 215 216 217 # Function for returning the desired atomic mass.
218 -def return_atomic_mass(element=None):
219 """Return the atomic mass for the given element type. 220 221 @keyword element: The element type. 222 @type element: str 223 @raises RelaxError: If the element type is unknown. 224 @returns: The desired atomic mass. 225 @rtype: float 226 """ 227 228 # Protons, deuterons. 229 if element == 'H': 230 return ArH 231 if element == '1H': 232 return 1.0 233 if element == '2H': 234 return 2.0 235 236 # Carbons. 237 if element == 'C': 238 return ArC 239 if element == '12C': 240 return 12.0 241 if element == '13C': 242 return 13.0 243 244 # Nitrogens. 245 if element == 'N': 246 return ArN 247 if element == '14N': 248 return 14.0 249 if element == '15N': 250 return 15.0 251 252 # Oxygens. 253 if element == 'O': 254 return ArO 255 if element == '16O': 256 return 16.0 257 if element == '17O': 258 return 17.0 259 260 # Sulphurs. 261 if element == 'S': 262 return ArS 263 264 # Calcium. 265 if element.upper() == 'CA': 266 return ArCa 267 268 # Unknown mass. 269 raise RelaxError("The mass of the element " + repr(element) + " has not yet been programmed into relax.")
270 271 272 273 # Element info. 274 ############### 275
276 -def element_from_isotope(isotope):
277 """Determine and return the element name for the given isotope. 278 279 @param isotope: The isotope name, such as '1H', '15N'. 280 @type isotope: str 281 @return: The element name. 282 @rtype: str 283 """ 284 285 # Remove the digit characters. 286 return isotope.strip(digits)
287 288
289 -def number_from_isotope(isotope):
290 """Determine and return the isotope number for the given isotope. 291 292 @param isotope: The isotope name, such as '1H', '15N'. 293 @type isotope: str 294 @return: The isotope number. 295 @rtype: int 296 """ 297 298 # Remove the digit characters. 299 return int(isotope.strip(ascii_letters))
300