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

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

  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, int16, pi, zeros 
 25  from unittest import TestCase 
 26   
 27  # relax module imports. 
 28  from lib.dispersion.m61b import r1rho_M61b 
 29   
 30   
31 -class Test_m61b(TestCase):
32 """Unit tests for the lib.dispersion.m61b relax module.""" 33
34 - def setUp(self):
35 """Set up for all unit tests.""" 36 37 # The R1rho_prime parameter value (R1rho with no exchange). 38 self.r1rho_prime = 2.5 39 # Population of ground state. 40 self.pA = 0.95 41 # The chemical exchange difference between states A and B in ppm. 42 self.dw = 0.5 43 self.kex = 1000.0 44 # The R1 relaxation rates. 45 self.r1 = 1.0 46 # The spin-lock field strengths in Hertz. 47 self.spin_lock_nu1 = array([ 1000., 1500., 2000., 2500., 3000., 3500., 4000., 4500., 5000., 5500., 6000.]) 48 # The rotating frame tilt angles for each dispersion point. 49 self.theta = array([1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966]) 50 51 # The spin Larmor frequencies. 52 self.sfrq = 599.8908617*1E6 53 54 # Required data structures. 55 self.num_points = 11 56 self.R1rho = zeros(self.num_points, float64)
57 58
59 - def calc_r1rho(self):
60 """Calculate and check the R1rho values.""" 61 62 # Parameter conversions. 63 phi_ex_scaled, dw_frq, spin_lock_omega1_squared = self.param_conversion(pA=self.pA, dw=self.dw, sfrq=self.sfrq, spin_lock_nu1=self.spin_lock_nu1) 64 65 # Calculate the R1rho values. 66 R1rho = r1rho_M61b(r1rho_prime=self.r1rho_prime, pA=self.pA, dw=dw_frq, kex=self.kex, spin_lock_fields2=spin_lock_omega1_squared, back_calc=self.R1rho, num_points=self.num_points) 67 68 69 # Check all R1rho values. 70 if self.kex > 1.e5: 71 for i in range(self.num_points): 72 self.assertAlmostEqual(self.R1rho[i], self.r1rho_prime, 2) 73 else: 74 for i in range(self.num_points): 75 self.assertAlmostEqual(self.R1rho[i], self.r1rho_prime)
76 77
78 - def param_conversion(self, pA=None, dw=None, sfrq=None, spin_lock_nu1=None):
79 """Convert the parameters. 80 81 @keyword pA: The population of state A. 82 @type pA: float 83 @keyword dw: The chemical exchange difference between states A and B in ppm. 84 @type dw: float 85 @keyword sfrq: The spin Larmor frequencies in Hz. 86 @type sfrq: float 87 @keyword spin_lock_nu1: The spin-lock field strengths in Hertz. 88 @type spin_lock_nu1: float 89 @return: The parameters {phi_ex_scaled, dw_frq, spin_lock_omega1_squared}. 90 @rtype: tuple of float 91 """ 92 93 # Calculate pB. 94 pB = 1.0 - pA 95 96 # Calculate spin Larmor frequencies in 2pi. 97 frqs = sfrq * 2 * pi 98 99 # Convert dw from ppm to rad/s. 100 dw_frq = dw * frqs / 1.e6 101 102 # The phi_ex parameter value (pA * pB * delta_omega^2). 103 phi_ex = pA * pB * (dw / 1.e6)**2 104 105 # Convert phi_ex from ppm^2 to (rad/s)^2. 106 phi_ex_scaled = phi_ex * frqs**2 107 108 # The R1rho spin-lock field strengths squared (in rad^2.s^-2). 109 spin_lock_omega1_squared = (2. * pi * spin_lock_nu1)**2 110 111 # Return all values. 112 return phi_ex_scaled, dw_frq, spin_lock_omega1_squared
113 114
115 - def test_m61b_no_rex1(self):
116 """Test the r1rho_m61b() function for no exchange when dw = 0.0.""" 117 118 # Parameter reset. 119 self.dw = 0.0 120 121 # Calculate and check the R1rho values. 122 self.calc_r1rho()
123 124
125 - def test_m61b_no_rex2(self):
126 """Test the r1rho_m61b() function for no exchange when pA = 1.0.""" 127 128 # Parameter reset. 129 self.pA = 1.0 130 131 # Calculate and check the R1rho values. 132 self.calc_r1rho()
133 134
135 - def test_m61b_no_rex3(self):
136 """Test the r1rho_m61b() function for no exchange when kex = 0.0.""" 137 138 # Parameter reset. 139 self.kex = 0.0 140 141 # Calculate and check the R1rho values. 142 self.calc_r1rho()
143 144
145 - def test_m61b_no_rex4(self):
146 """Test the r1rho_m61b() function for no exchange when dw = 0.0 and pA = 1.0.""" 147 148 # Parameter reset. 149 self.pA = 1.0 150 self.dw = 0.0 151 152 # Calculate and check the R1rho values. 153 self.calc_r1rho()
154 155
156 - def test_m61b_no_rex5(self):
157 """Test the r1rho_m61b() function for no exchange when dw = 0.0 and kex = 0.0.""" 158 159 # Parameter reset. 160 self.dw = 0.0 161 self.kex = 0.0 162 163 # Calculate and check the R1rho values. 164 self.calc_r1rho()
165 166
167 - def test_m61b_no_rex6(self):
168 """Test the r1rho_m61b() function for no exchange when pA = 1.0 and kex = 0.0.""" 169 170 # Parameter reset. 171 self.pA = 1.0 172 self.kex = 0.0 173 174 # Calculate and check the R1rho values. 175 self.calc_r1rho()
176 177
178 - def test_m61b_no_rex7(self):
179 """Test the r1rho_m61b() function for no exchange when dw = 0.0, pA = 1.0, and kex = 0.0.""" 180 181 # Parameter reset. 182 self.dw = 0.0 183 self.kex = 0.0 184 185 # Calculate and check the R1rho values. 186 self.calc_r1rho()
187 188
189 - def test_m61b_no_rex8(self):
190 """Test the r1rho_m61b() function for no exchange when kex = 1e20.""" 191 192 # Parameter reset. 193 self.kex = 1e20 194 195 # Calculate and check the R2eff values. 196 self.calc_r1rho()
197