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

Source Code for Module test_suite.unit_tests._lib._dispersion.test_mmq_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, ones, pi, zeros 
 25  from unittest import TestCase 
 26   
 27  # relax module imports. 
 28  from lib.dispersion.mmq_cr72 import r2eff_mmq_cr72 
 29   
 30   
31 -class Test_mmq_cr72(TestCase):
32 """Unit tests for the lib.dispersion.mmq_cr72 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.dwH = 0.5 42 self.kex = 1000.0 43 44 # Required data structures. 45 self.num_points = 6 46 self.ncyc = array([2, 4, 8, 10, 20, 40]) 47 relax_times = 0.04 48 self.cpmg_frqs = self.ncyc / relax_times 49 self.inv_relax_times = 1.0 / relax_times 50 self.tau_cpmg = 0.25 / self.cpmg_frqs 51 self.R2eff = zeros(self.num_points, float64) 52 53 # The spin Larmor frequencies. 54 self.sfrq = 200. * 1E6
55 56
57 - def calc_r2eff(self):
58 """Calculate and check the R2eff values.""" 59 60 # Parameter conversions. 61 k_AB, k_BA, pB, dw_frq, dwH_frq = self.param_conversion(pA=self.pA, kex=self.kex, dw=self.dw, dwH=self.dwH, sfrq=self.sfrq) 62 63 a = ones(self.ncyc.shape) 64 65 # Calculate the R2eff values. 66 r2eff_mmq_cr72(r20=self.r20*a, pA=self.pA, dw=dw_frq*a, dwH=dwH_frq*a, kex=self.kex, cpmg_frqs=self.cpmg_frqs, inv_tcpmg=self.inv_relax_times, tcp=self.tau_cpmg, back_calc=self.R2eff) 67 68 # Check all R2eff values. 69 for i in range(self.num_points): 70 self.assertAlmostEqual(self.R2eff[i], self.r20)
71 72
73 - def param_conversion(self, pA=None, kex=None, dw=None, dwH=None, sfrq=None):
74 """Convert the parameters. 75 76 @keyword pA: The population of state A. 77 @type pA: float 78 @keyword kex: The rate of exchange. 79 @type kex: float 80 @keyword dw: The chemical exchange difference between states A and B in ppm. 81 @type dw: float 82 @keyword dwH: The proton chemical exchange difference between states A and B in ppm. 83 @type dwH: float 84 @keyword sfrq: The spin Larmor frequencies in Hz. 85 @type sfrq: float 86 @return: The parameters {k_AB, k_BA, pB, dw_frq}. 87 @rtype: tuple of float 88 """ 89 90 # Calculate pB. 91 pB = 1.0 - pA 92 93 # Exchange rates. 94 k_BA = pA * kex 95 k_AB = pB * kex 96 97 # Calculate spin Larmor frequencies in 2pi. 98 frqs = sfrq * 2 * pi 99 100 # Convert dw from ppm to rad/s. 101 dw_frq = dw * frqs / 1.e6 102 103 # Convert dwH from ppm to rad/s. 104 dwH_frq = dwH * frqs / 1.e6 105 106 # Return all values. 107 return k_AB, k_BA, pB, dw_frq, dwH_frq
108 109
110 - def test_mmq_cr72_no_rex1(self):
111 """Test the r2eff_mmq_cr72() function for no exchange when dw = 0.0 and dwH = 0.0.""" 112 113 # Parameter reset. 114 self.dw = 0.0 115 self.dwH = 0.0 116 117 # Calculate and check the R2eff values. 118 self.calc_r2eff()
119 120
121 - def test_mmq_cr72_no_rex2(self):
122 """Test the r2eff_mmq_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_mmq_cr72_no_rex3(self):
132 """Test the r2eff_mmq_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_mmq_cr72_no_rex4(self):
142 """Test the r2eff_mmq_cr72() function for no exchange when dw = 0.0, dwH = 0.0 and pA = 1.0.""" 143 144 # Parameter reset. 145 self.pA = 1.0 146 self.dw = 0.0 147 self.dwH = 0.0 148 149 # Calculate and check the R2eff values. 150 self.calc_r2eff()
151 152
153 - def test_mmq_cr72_no_rex5(self):
154 """Test the r2eff_mmq_cr72() function for no exchange when dw = 0.0, dwH = 0.0 and kex = 0.0.""" 155 156 # Parameter reset. 157 self.dw = 0.0 158 self.dwH = 0.0 159 self.kex = 0.0 160 161 # Calculate and check the R2eff values. 162 self.calc_r2eff()
163 164
165 - def test_mmq_cr72_no_rex6(self):
166 """Test the r2eff_mmq_cr72() function for no exchange when pA = 1.0 and kex = 0.0.""" 167 168 # Parameter reset. 169 self.pA = 1.0 170 self.kex = 0.0 171 172 # Calculate and check the R2eff values. 173 self.calc_r2eff()
174 175
176 - def test_mmq_cr72_no_rex7(self):
177 """Test the r2eff_mmq_cr72() function for no exchange when dw = 0.0, dwH = 0.0, pA = 1.0, and kex = 0.0.""" 178 179 # Parameter reset. 180 self.dw = 0.0 181 self.dwH = 0.0 182 self.pA = 1.0 183 self.kex = 0.0 184 185 # Calculate and check the R2eff values. 186 self.calc_r2eff()
187 188
189 - def test_mmq_cr72_no_rex8(self):
190 """Test the r2eff_mmq_cr72() function for no exchange when kex = 1e8.""" 191 192 # Parameter reset. 193 self.kex = 1e8 194 195 # Calculate and check the R2eff values. 196 self.calc_r2eff()
197