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

Source Code for Module lib.physical_constants

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2007-2015 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   
 33   
 34  # Misc. constants. 
 35  ################## 
 36   
 37  h = 6.62606876 * 1e-34 
 38  """Planck's constant.""" 
 39   
 40  h_bar = h / (2.0 * pi) 
 41  """Dirac's constant.""" 
 42   
 43  mu0 = 4.0 * pi * 1e-7 
 44  """The magnetic constant or the permeability of vacuum.""" 
 45   
 46  kB = 1.380650424 * 1e-23 
 47  """Boltzmann's constant in SI units of J.K^-1 (the last 2 digits of '24' are within the measured error limits).""" 
 48   
 49   
 50  # CSA and bond lengths. 
 51  ####################### 
 52   
 53  N15_CSA = -172 * 1e-6 
 54  """The 15N CSA in the NH bond (default value).""" 
 55   
 56  NH_BOND_LENGTH = 1.02 * 1e-10 
 57  """The length of the NH bond (default value).""" 
 58   
 59  NH_BOND_LENGTH_RDC = 1.041 * 1e-10 
 60  """The length of the NH bond for RDCs (from Ottiger, M. and Bax A., J. Am. Chem. Soc. (1998), 120, 12334-12341).""" 
 61   
 62  CA_HA_BOND_LENGTH_RDC = 1.118 * 1e-10 
 63  """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).""" 
 64   
 65  CA_C_BOND_LENGTH_RDC = 1.526 * 1e-10 
 66  """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).""" 
 67   
 68  C_N_BOND_LENGTH_RDC = 1.329 * 1e-10 
 69  """The length of the C_prime-N bond for RDCs (from Ottiger, M. and Bax A., J. Am. Chem. Soc. (1998), 120, 12334-12341).""" 
 70   
 71  C_HN_BOND_LENGTH_RDC = 2.067 * 1e-10 
 72  """The length of the C_prime-HN bond for RDCs (from Ottiger, M. and Bax A., J. Am. Chem. Soc. (1998), 120, 12334-12341).""" 
 73   
 74   
 75   
 76  # The dipolar constant. 
 77  ####################### 
 78   
79 -def dipolar_constant(gx, gh, r):
80 """Calculate the dipolar constant. 81 82 The dipolar constant is defined as:: 83 84 mu0 gI.gS.h_bar 85 d = - --- ----------- , 86 4pi r**3 87 88 where: 89 - mu0 is the permeability of free space, 90 - gI and gS are the gyromagnetic ratios of the I and S spins, 91 - h_bar is Dirac's constant which is equal to Planck's constant divided by 2pi, 92 - r is the distance between the two spins. 93 94 95 @param gx: The gyromagnetic ratio of the heteronucleus (or first spin). 96 @type gx: float 97 @param gh: The gyromagnetic ratio of the proton (or second spin). 98 @type gh: float 99 @param r: The distance between the two nuclei. 100 @type r: float 101 """ 102 103 # Catch zero bond lengths, returning NaN. 104 if r == 0: 105 return nan 106 107 # Calculate and return the value. 108 return - mu0 / (4.0*pi) * gx * gh * h_bar / r**3
109 110 111 # The pseudocontact shift constant. 112 ################################### 113
114 -def pcs_constant(T, Bo, r):
115 """Calculate the pseudocontact shift constant. 116 117 The pseudocontact shift constant is defined as:: 118 119 mu0 15kT 1 120 d = --- ----- ---- , 121 4pi Bo**2 r**3 122 123 where: 124 - mu0 is the permeability of free space, 125 - k is Boltzmann's constant, 126 - T is the absolute temperature, 127 - Bo is the magnetic field strength, 128 - r is the distance between the paramagnetic centre (electron spin) and the nuclear spin. 129 130 131 @param T: The temperature in kelvin. 132 @type T: float 133 @param Bo: The magnetic field strength. 134 @type Bo: float 135 @param r: The distance between the two nuclei. 136 @type r: float 137 """ 138 139 # Catch zero bond lengths, returning NaN. 140 if r == 0: 141 return nan 142 143 # Calculate and return the value. 144 return mu0 / (4.0*pi) * 15.0 * kB * T / Bo**2 / r**3
145 146 147 148 # Element info. 149 ############### 150
151 -def element_from_isotope(isotope):
152 """Determine and return the element name for the given isotope. 153 154 @param isotope: The isotope name, such as '1H', '15N'. 155 @type isotope: str 156 @return: The element name. 157 @rtype: str 158 """ 159 160 # Remove the digit characters. 161 return isotope.strip(digits)
162 163
164 -def number_from_isotope(isotope):
165 """Determine and return the isotope number for the given isotope. 166 167 @param isotope: The isotope name, such as '1H', '15N'. 168 @type isotope: str 169 @return: The isotope number. 170 @rtype: int 171 """ 172 173 # Remove the digit characters. 174 return int(isotope.strip(ascii_letters))
175