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

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

  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, ones, pi, zeros 
 25  from unittest import TestCase 
 26   
 27  # relax module imports. 
 28  from lib.dispersion.lm63 import r2eff_LM63 
 29   
 30   
31 -class Test_lm63(TestCase):
32 """Unit tests for the lib.dispersion.lm63 relax module.""" 33
34 - def setUp(self):
35 """Set up for all unit tests.""" 36 37 # Default parameter values. 38 self.r20 = 2.0 39 self.pA = 0.95 40 self.dw = 0.5 41 self.kex = 100.0 42 43 # The spin Larmor frequencies. 44 self.sfrq = 599.8908617*1E6 45 46 # Required data structures. 47 self.num_points = 3 48 self.cpmg_frqs = array([2.5, 1.25, 0.83], float64) 49 self.R2eff = zeros(self.num_points, float64)
50 51
52 - def calc_r2eff(self):
53 """Calculate and check the R2eff values.""" 54 55 # Parameter conversions. 56 phi_ex_scaled = self.param_conversion(pA=self.pA, dw=self.dw, sfrq=self.sfrq) 57 58 a = ones([self.num_points]) 59 60 # Calculate the R2eff values. 61 R2eff = r2eff_LM63(r20=self.r20*a, phi_ex=phi_ex_scaled*a, kex=self.kex, cpmg_frqs=self.cpmg_frqs, back_calc=self.R2eff) 62 63 # Check all R2eff values. 64 if self.kex > 1.e5: 65 for i in range(self.num_points): 66 self.assertAlmostEqual(self.R2eff[i], self.r20, 2) 67 else: 68 for i in range(self.num_points): 69 self.assertAlmostEqual(self.R2eff[i], self.r20)
70 71
72 - def param_conversion(self, pA=None, dw=None, sfrq=None):
73 """Convert the parameters. 74 75 @keyword pA: The population of state A. 76 @type pA: float 77 @keyword dw: The chemical exchange difference between states A and B in ppm. 78 @type dw: float 79 @keyword sfrq: The spin Larmor frequencies in Hz. 80 @type sfrq: float 81 @return: The parameters phi_ex_scaled 82 @rtype: float 83 """ 84 85 # Calculate pB. 86 pB = 1.0 - pA 87 88 # Calculate spin Larmor frequencies in 2pi. 89 frqs = sfrq * 2 * pi 90 91 # The phi_ex parameter value (pA * pB * delta_omega^2). 92 phi_ex = pA * pB * (dw / 1.e6)**2 93 94 # Convert phi_ex from ppm^2 to (rad/s)^2. 95 phi_ex_scaled = phi_ex * frqs**2 96 97 # Return all values. 98 return phi_ex_scaled
99 100
101 - def test_lm63_no_rex1(self):
102 """Test the r2eff_lm63() function for no exchange when dw = 0.0.""" 103 104 # Parameter reset. 105 self.dw = 0.0 106 107 # Calculate and check the R2eff values. 108 self.calc_r2eff()
109 110
111 - def test_lm63_no_rex2(self):
112 """Test the r2eff_lm63() function for no exchange when pA = 1.0.""" 113 114 # Parameter reset. 115 self.pA = 1.0 116 117 # Calculate and check the R2eff values. 118 self.calc_r2eff()
119 120
121 - def test_lm63_no_rex3(self):
122 """Test the r2eff_lm63() function for no exchange when kex = 0.0.""" 123 124 # Parameter reset. 125 self.kex = 0.0 126 127 # Calculate and check the R2eff values. 128 self.calc_r2eff()
129 130
131 - def test_lm63_no_rex4(self):
132 """Test the r2eff_lm63() function for no exchange when dw = 0.0 and pA = 1.0.""" 133 134 # Parameter reset. 135 self.pA = 1.0 136 self.dw = 0.0 137 138 # Calculate and check the R2eff values. 139 self.calc_r2eff()
140 141
142 - def test_lm63_no_rex5(self):
143 """Test the r2eff_lm63() function for no exchange when dw = 0.0 and kex = 0.0.""" 144 145 # Parameter reset. 146 self.dw = 0.0 147 self.kex = 0.0 148 149 # Calculate and check the R2eff values. 150 self.calc_r2eff()
151 152
153 - def test_lm63_no_rex6(self):
154 """Test the r2eff_lm63() function for no exchange when pA = 1.0 and kex = 0.0.""" 155 156 # Parameter reset. 157 self.pA = 1.0 158 self.kex = 0.0 159 160 # Calculate and check the R2eff values. 161 self.calc_r2eff()
162 163
164 - def test_lm63_no_rex7(self):
165 """Test the r2eff_lm63() function for no exchange when dw = 0.0, pA = 1.0, and kex = 0.0.""" 166 167 # Parameter reset. 168 self.dw = 0.0 169 self.kex = 0.0 170 171 # Calculate and check the R2eff values. 172 self.calc_r2eff()
173 174
175 - def test_lm63_no_rex8(self):
176 """Test the r2eff_lm63() function for no exchange when kex = 1e20.""" 177 178 # Parameter reset. 179 self.kex = 1e20 180 181 # Calculate and check the R2eff values. 182 self.calc_r2eff()
183