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