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

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

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