Package test_suite :: Package unit_tests :: Package _lib :: Package _dispersion :: Module test_it99
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._lib._dispersion.test_it99

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2014 Edward d'Auvergne                                        # 
  4  # Copyright (C) 2014 Troels E. Linnet                                         # 
  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  # Python module imports. 
 24  from numpy import array, float64, ones, pi, zeros 
 25  from unittest import TestCase 
 26   
 27  # relax module imports. 
 28  from lib.dispersion.it99 import r2eff_IT99 
 29   
 30   
31 -class Test_it99(TestCase):
32 """Unit tests for the lib.dispersion.it99 relax module.""" 33
34 - def setUp(self):
35 """Set up for all unit tests.""" 36 37 # Default parameter values. 38 self.r20 = 2.0 39 self.pA = 0.95 40 self.dw = 2.0 41 self.kex = 1000.0 42 43 # Required data structures. 44 self.num_points = 7 45 self.ncyc = array([2, 4, 8, 10, 20, 40, 500]) 46 relax_times = 0.04 47 self.cpmg_frqs = self.ncyc / relax_times 48 self.R2eff = zeros(self.num_points, float64) 49 50 # The spin Larmor frequencies. 51 self.sfrq = 200. * 1E6
52 53
54 - def calc_r2eff(self):
55 """Calculate and check the R2eff values.""" 56 57 # Parameter conversions. 58 pB, dw_frq, tex = self.param_conversion(pA=self.pA, kex=self.kex, dw=self.dw, sfrq=self.sfrq) 59 60 a = ones([self.num_points]) 61 62 # Calculate the R2eff values. 63 r2eff_IT99(r20=self.r20*a, pA=self.pA, dw=dw_frq*a, dw_orig=dw_frq*a, tex=tex, cpmg_frqs=self.cpmg_frqs, back_calc=self.R2eff) 64 65 # Check all R2eff values. 66 if self.kex > 1.e5: 67 for i in range(self.num_points): 68 self.assertAlmostEqual(self.R2eff[i], self.r20, 2) 69 else: 70 for i in range(self.num_points): 71 self.assertAlmostEqual(self.R2eff[i], self.r20)
72 73
74 - def param_conversion(self, pA=None, kex=None, dw=None, sfrq=None):
75 """Convert the parameters. 76 77 @keyword pA: The population of state A. 78 @type pA: float 79 @keyword kex: The rate of exchange. 80 @type kex: float 81 @keyword dw: The chemical exchange difference between states A and B in ppm. 82 @type dw: float 83 @keyword sfrq: The spin Larmor frequencies in Hz. 84 @type sfrq: float 85 @return: The parameters {pB, dw_frq, tex}. 86 @rtype: tuple of float 87 """ 88 89 # Calculate pB. 90 pB = 1.0 - pA 91 92 # Calculate spin Larmor frequencies in 2pi. 93 frqs = sfrq * 2 * pi 94 95 # Convert dw from ppm to rad/s. 96 dw_frq = dw * frqs / 1.e6 97 98 # Time of exchange: 1/(2*kex) 99 if kex == 0.0: 100 tex = 0.0 101 else: 102 tex = 1 / (2*kex) 103 104 # Return all values. 105 return pB, dw_frq, tex
106 107
108 - def test_it99_no_rex1(self):
109 """Test the r2eff_it99() function for no exchange when dw = 0.0.""" 110 111 # Parameter reset. 112 self.dw = 0.0 113 114 # Calculate and check the R2eff values. 115 self.calc_r2eff()
116 117
118 - def test_it99_no_rex2(self):
119 """Test the r2eff_it99() function for no exchange when pA = 1.0.""" 120 121 # Parameter reset. 122 self.pA = 1.0 123 124 # Calculate and check the R2eff values. 125 self.calc_r2eff()
126 127
128 - def test_it99_no_rex3(self):
129 """Test the r2eff_it99() function for no exchange when kex = 0.0.""" 130 131 # Parameter reset. 132 self.kex = 0.0 133 134 # Calculate and check the R2eff values. 135 self.calc_r2eff()
136 137
138 - def test_it99_no_rex4(self):
139 """Test the r2eff_it99() function for no exchange when dw = 0.0 and pA = 1.0.""" 140 141 # Parameter reset. 142 self.pA = 1.0 143 self.dw = 0.0 144 145 # Calculate and check the R2eff values. 146 self.calc_r2eff()
147 148
149 - def test_it99_no_rex5(self):
150 """Test the r2eff_it99() function for no exchange when dw = 0.0 and kex = 0.0.""" 151 152 # Parameter reset. 153 self.dw = 0.0 154 self.kex = 0.0 155 156 # Calculate and check the R2eff values. 157 self.calc_r2eff()
158 159
160 - def test_it99_no_rex6(self):
161 """Test the r2eff_it99() function for no exchange when pA = 1.0 and kex = 0.0.""" 162 163 # Parameter reset. 164 self.pA = 1.0 165 self.kex = 0.0 166 167 # Calculate and check the R2eff values. 168 self.calc_r2eff()
169 170
171 - def test_it99_no_rex7(self):
172 """Test the r2eff_it99() function for no exchange when dw = 0.0, pA = 1.0, and kex = 0.0.""" 173 174 # Parameter reset. 175 self.dw = 0.0 176 self.kex = 0.0 177 178 # Calculate and check the R2eff values. 179 self.calc_r2eff()
180 181
182 - def test_it99_no_rex8(self):
183 """Test the r2eff_cr72() function for no exchange when kex = 1e19.""" 184 185 # Parameter reset. 186 self.kex = 1e19 187 188 # Calculate and check the R2eff values. 189 self.calc_r2eff()
190