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

Source Code for Module lib.physical_constants

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2007-2009,2011 Edward d'Auvergne                              # 
  4  # Copyright (C) 2008 Sebastien Morin                                          # 
  5  #                                                                             # 
  6  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  7  #                                                                             # 
  8  # This program is free software: you can redistribute it and/or modify        # 
  9  # it under the terms of the GNU General Public License as published by        # 
 10  # the Free Software Foundation, either version 3 of the License, or           # 
 11  # (at your option) any later version.                                         # 
 12  #                                                                             # 
 13  # This program is distributed in the hope that it will be useful,             # 
 14  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 16  # GNU General Public License for more details.                                # 
 17  #                                                                             # 
 18  # You should have received a copy of the GNU General Public License           # 
 19  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Module docstring. 
 24  """Module containing all physical constants used in relax, as well as all associated functions.""" 
 25   
 26   
 27  # Python module imports. 
 28  from math import pi 
 29  from string import ascii_letters, digits 
 30   
 31  # relax module imports. 
 32  from lib.float import nan 
 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 # Element info. 150 ############### 151
152 -def element_from_isotope(isotope):
153 """Determine and return the element name for the given isotope. 154 155 @param isotope: The isotope name, such as '1H', '15N'. 156 @type isotope: str 157 @return: The element name. 158 @rtype: str 159 """ 160 161 # Remove the digit characters. 162 return isotope.strip(digits)
163 164
165 -def number_from_isotope(isotope):
166 """Determine and return the isotope number for the given isotope. 167 168 @param isotope: The isotope name, such as '1H', '15N'. 169 @type isotope: str 170 @return: The isotope number. 171 @rtype: int 172 """ 173 174 # Remove the digit characters. 175 return int(isotope.strip(ascii_letters))
176