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

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

  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.ns_cpmg_2site_3d import r2eff_ns_cpmg_2site_3D 
 28  from lib.dispersion.ns_matrices import r180x_3d 
 29   
 30   
31 -class Test_ns_cpmg_2site_3d(TestCase):
32 """Unit tests for the lib.dispersion.ns_cpmg_2site_3D 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 = 3.0 40 self.pA = 0.95 41 self.dw = 2.0 42 self.kex = 1000.0 43 44 # Required data structures. 45 # The 3D rotation matrix for an imperfect X-axis pi-pulse. 46 self.r180x = r180x_3d() 47 48 # This is a vector that contains the initial magnetizations corresponding to the A and B state transverse magnetizations. 49 self.M0 = zeros(7, float64) 50 self.M0[0] = 0.5 51 52 self.num_points = 7 53 self.ncyc = array([2, 4, 8, 10, 20, 40, 500]) 54 relax_times = 0.04 55 cpmg_frqs = self.ncyc / relax_times 56 self.inv_relax_times = 1.0 / relax_times 57 self.tau_cpmg = 0.25 / cpmg_frqs 58 self.R2eff = zeros(self.num_points, float64) 59 60 # The spin Larmor frequencies. 61 self.sfrq = 200. * 1E6
62 63
64 - def calc_r2eff(self):
65 """Calculate and check the R2eff values.""" 66 67 # Parameter conversions. 68 k_AB, k_BA, pB, dw_frq, M0 = self.param_conversion(pA=self.pA, kex=self.kex, dw=self.dw, sfrq=self.sfrq, M0=self.M0) 69 70 # Calculate the R2eff values. 71 r2eff_ns_cpmg_2site_3D(r180x=self.r180x, M0=M0, r20a=self.r20a, r20b=self.r20b, pA=self.pA, pB=pB, dw=dw_frq, k_AB=k_AB, k_BA=k_BA, inv_tcpmg=self.inv_relax_times, tcp=self.tau_cpmg, back_calc=self.R2eff, num_points=self.num_points, power=self.ncyc) 72 73 if self.kex >= 1.e5: 74 for i in range(self.num_points): 75 self.assertAlmostEqual(self.R2eff[i], self.r20a, 5) 76 else: 77 for i in range(self.num_points): 78 self.assertAlmostEqual(self.R2eff[i], self.r20a)
79 80
81 - def param_conversion(self, pA=None, kex=None, dw=None, sfrq=None, M0=None):
82 """Convert the parameters. 83 84 @keyword pA: The population of state A. 85 @type pA: float 86 @keyword kex: The rate of exchange. 87 @type kex: float 88 @keyword dw: The chemical exchange difference between states A and B in ppm. 89 @type dw: float 90 @keyword sfrq: The spin Larmor frequencies in Hz. 91 @type sfrq: float 92 @keyword M0: Vector that contains the initial magnetizations corresponding to the A and B state transverse magnetizations. 93 @type M0: numpy float64, rank-1, 7D array 94 @return: The parameters {k_AB, k_BA, pB, dw_frq, M0}. 95 @rtype: tuple of float 96 """ 97 98 # Calculate pB. 99 pB = 1.0 - pA 100 101 # This is a vector that contains the initial magnetizations corresponding to the A and B state transverse magnetizations. 102 M0[1] = pA 103 M0[4] = pB 104 105 # Exchange rates. 106 k_BA = pA * kex 107 k_AB = pB * kex 108 109 # Calculate spin Larmor frequencies in 2pi. 110 frqs = sfrq * 2 * pi 111 112 # Convert dw from ppm to rad/s. 113 dw_frq = dw * frqs / 1.e6 114 115 # Return all values. 116 return k_AB, k_BA, pB, dw_frq, M0
117 118
120 """Test the r2eff_ns_cpmg_2site_3D() function for no exchange when dw = 0.0.""" 121 122 # Parameter reset. 123 self.dw = 0.0 124 125 # Calculate and check the R2eff values. 126 self.calc_r2eff()
127 128
130 """Test the r2eff_ns_cpmg_2site_3D() function for no exchange when pA = 1.0.""" 131 132 # Parameter reset. 133 self.pA = 1.0 134 135 # Calculate and check the R2eff values. 136 self.calc_r2eff()
137 138
140 """Test the r2eff_ns_cpmg_2site_3D() function for no exchange when kex = 0.0.""" 141 142 # Parameter reset. 143 self.kex = 0.0 144 145 # Calculate and check the R2eff values. 146 self.calc_r2eff()
147 148
150 """Test the r2eff_ns_cpmg_2site_3D() function for no exchange when dw = 0.0 and pA = 1.0.""" 151 152 # Parameter reset. 153 self.pA = 1.0 154 self.dw = 0.0 155 156 # Calculate and check the R2eff values. 157 self.calc_r2eff()
158 159
161 """Test the r2eff_ns_cpmg_2site_3D() function for no exchange when dw = 0.0 and kex = 0.0.""" 162 163 # Parameter reset. 164 self.dw = 0.0 165 self.kex = 0.0 166 167 # Calculate and check the R2eff values. 168 self.calc_r2eff()
169 170
172 """Test the r2eff_ns_cpmg_2site_3D() function for no exchange when pA = 1.0 and kex = 0.0.""" 173 174 # Parameter reset. 175 self.pA = 1.0 176 self.kex = 0.0 177 178 # Calculate and check the R2eff values. 179 self.calc_r2eff()
180 181
183 """Test the r2eff_ns_cpmg_2site_3D() function for no exchange when dw = 0.0, pA = 1.0, and kex = 0.0.""" 184 185 # Parameter reset. 186 self.dw = 0.0 187 self.kex = 0.0 188 189 # Calculate and check the R2eff values. 190 self.calc_r2eff()
191