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

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

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