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