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  #                                                                             # 
  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, int16, pi, zeros 
 24  from unittest import TestCase 
 25   
 26  # relax module imports. 
 27  from lib.dispersion.mmq_cr72 import r2eff_mmq_cr72 
 28   
 29   
30 -class Test_mmq_cr72(TestCase):
31 """Unit tests for the lib.dispersion.mmq_cr72 relax module.""" 32
33 - def setUp(self):
34 """Set up for all unit tests.""" 35 36 # Default parameter values. 37 self.r20 = 2.0 38 self.pA = 0.95 39 self.dw = 2.0 40 self.dwH = 0.5 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]) 46 relax_times = 0.04 47 self.cpmg_frqs = self.ncyc / relax_times 48 self.inv_relax_times = 1.0 / relax_times 49 self.tau_cpmg = 0.25 / self.cpmg_frqs 50 self.R2eff = zeros(self.num_points, float64) 51 52 # The spin Larmor frequencies. 53 self.sfrq = 200. * 1E6
54 55
56 - def calc_r2eff(self):
57 """Calculate and check the R2eff values.""" 58 59 # Parameter conversions. 60 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) 61 62 # Calculate the R2eff values. 63 r2eff_mmq_cr72(r20=self.r20, pA=self.pA, pB=pB, dw=dw_frq, dwH=dwH_frq, kex=self.kex, k_AB=k_AB, k_BA=k_BA, cpmg_frqs=self.cpmg_frqs, inv_tcpmg=self.inv_relax_times, tcp=self.tau_cpmg, back_calc=self.R2eff, num_points=self.num_points, power=self.ncyc) 64 65 # Check all R2eff values. 66 for i in range(self.num_points): 67 self.assertAlmostEqual(self.R2eff[i], self.r20)
68 69
70 - def param_conversion(self, pA=None, kex=None, dw=None, dwH=None, sfrq=None):
71 """Convert the parameters. 72 73 @keyword pA: The population of state A. 74 @type pA: float 75 @keyword kex: The rate of exchange. 76 @type kex: float 77 @keyword dw: The chemical exchange difference between states A and B in ppm. 78 @type dw: float 79 @keyword dwH: The proton chemical exchange difference between states A and B in ppm. 80 @type dwH: float 81 @keyword sfrq: The spin Larmor frequencies in Hz. 82 @type sfrq: float 83 @return: The parameters {k_AB, k_BA, pB, dw_frq}. 84 @rtype: tuple of float 85 """ 86 87 # Calculate pB. 88 pB = 1.0 - pA 89 90 # Exchange rates. 91 k_BA = pA * kex 92 k_AB = pB * kex 93 94 # Calculate spin Larmor frequencies in 2pi. 95 frqs = sfrq * 2 * pi 96 97 # Convert dw from ppm to rad/s. 98 dw_frq = dw * frqs / 1.e6 99 100 # Convert dwH from ppm to rad/s. 101 dwH_frq = dwH * frqs / 1.e6 102 103 # Return all values. 104 return k_AB, k_BA, pB, dw_frq, dwH_frq
105 106
107 - def test_mmq_cr72_no_rex1(self):
108 """Test the r2eff_mmq_cr72() function for no exchange when dw = 0.0 and dwH = 0.0.""" 109 110 # Parameter reset. 111 self.dw = 0.0 112 self.dwH = 0.0 113 114 # Calculate and check the R2eff values. 115 self.calc_r2eff()
116 117
118 - def test_mmq_cr72_no_rex2(self):
119 """Test the r2eff_mmq_cr72() 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_mmq_cr72_no_rex3(self):
129 """Test the r2eff_mmq_cr72() 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_mmq_cr72_no_rex4(self):
139 """Test the r2eff_mmq_cr72() function for no exchange when dw = 0.0, dwH = 0.0 and pA = 1.0.""" 140 141 # Parameter reset. 142 self.pA = 1.0 143 self.dw = 0.0 144 self.dwH = 0.0 145 146 # Calculate and check the R2eff values. 147 self.calc_r2eff()
148 149
150 - def test_mmq_cr72_no_rex5(self):
151 """Test the r2eff_mmq_cr72() function for no exchange when dw = 0.0, dwH = 0.0 and kex = 0.0.""" 152 153 # Parameter reset. 154 self.dw = 0.0 155 self.dwH = 0.0 156 self.kex = 0.0 157 158 # Calculate and check the R2eff values. 159 self.calc_r2eff()
160 161
162 - def test_mmq_cr72_no_rex6(self):
163 """Test the r2eff_mmq_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_mmq_cr72_no_rex7(self):
174 """Test the r2eff_mmq_cr72() function for no exchange when dw = 0.0, dwH = 0.0, pA = 1.0, and kex = 0.0.""" 175 176 # Parameter reset. 177 self.dw = 0.0 178 self.dwH = 0.0 179 self.pA = 1.0 180 self.kex = 0.0 181 182 # Calculate and check the R2eff values. 183 self.calc_r2eff()
184 185
186 - def test_mmq_cr72_no_rex8(self):
187 """Test the r2eff_mmq_cr72() function for no exchange when kex = 1e5.""" 188 189 # Parameter reset. 190 self.kex = 1e5 191 192 # Calculate and check the R2eff values. 193 self.calc_r2eff()
194