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, int16, 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 # Calculate the R2eff values. 59 R2eff = r2eff_LM63(r20=self.r20, phi_ex=phi_ex_scaled, kex=self.kex, cpmg_frqs=self.cpmg_frqs, back_calc=self.R2eff, num_points=self.num_points) 60 61 # Check all R2eff values. 62 if self.kex > 1.e5: 63 for i in range(self.num_points): 64 self.assertAlmostEqual(self.R2eff[i], self.r20, 2) 65 else: 66 for i in range(self.num_points): 67 self.assertAlmostEqual(self.R2eff[i], self.r20)
68 69
70 - def param_conversion(self, pA=None, dw=None, sfrq=None):
71 """Convert the parameters. 72 73 @keyword pA: The population of state A. 74 @type pA: float 75 @keyword dw: The chemical exchange difference between states A and B in ppm. 76 @type dw: float 77 @keyword sfrq: The spin Larmor frequencies in Hz. 78 @type sfrq: float 79 @return: The parameters phi_ex_scaled 80 @rtype: float 81 """ 82 83 # Calculate pB. 84 pB = 1.0 - pA 85 86 # Calculate spin Larmor frequencies in 2pi. 87 frqs = sfrq * 2 * pi 88 89 # The phi_ex parameter value (pA * pB * delta_omega^2). 90 phi_ex = pA * pB * (dw / 1.e6)**2 91 92 # Convert phi_ex from ppm^2 to (rad/s)^2. 93 phi_ex_scaled = phi_ex * frqs**2 94 95 # Return all values. 96 return phi_ex_scaled
97 98
99 - def test_lm63_no_rex1(self):
100 """Test the r2eff_lm63() function for no exchange when dw = 0.0.""" 101 102 # Parameter reset. 103 self.dw = 0.0 104 105 # Calculate and check the R2eff values. 106 self.calc_r2eff()
107 108
109 - def test_lm63_no_rex2(self):
110 """Test the r2eff_lm63() function for no exchange when pA = 1.0.""" 111 112 # Parameter reset. 113 self.pA = 1.0 114 115 # Calculate and check the R2eff values. 116 self.calc_r2eff()
117 118
119 - def test_lm63_no_rex3(self):
120 """Test the r2eff_lm63() function for no exchange when kex = 0.0.""" 121 122 # Parameter reset. 123 self.kex = 0.0 124 125 # Calculate and check the R2eff values. 126 self.calc_r2eff()
127 128
129 - def test_lm63_no_rex4(self):
130 """Test the r2eff_lm63() function for no exchange when dw = 0.0 and pA = 1.0.""" 131 132 # Parameter reset. 133 self.pA = 1.0 134 self.dw = 0.0 135 136 # Calculate and check the R2eff values. 137 self.calc_r2eff()
138 139
140 - def test_lm63_no_rex5(self):
141 """Test the r2eff_lm63() function for no exchange when dw = 0.0 and kex = 0.0.""" 142 143 # Parameter reset. 144 self.dw = 0.0 145 self.kex = 0.0 146 147 # Calculate and check the R2eff values. 148 self.calc_r2eff()
149 150
151 - def test_lm63_no_rex6(self):
152 """Test the r2eff_lm63() function for no exchange when pA = 1.0 and kex = 0.0.""" 153 154 # Parameter reset. 155 self.pA = 1.0 156 self.kex = 0.0 157 158 # Calculate and check the R2eff values. 159 self.calc_r2eff()
160 161
162 - def test_lm63_no_rex7(self):
163 """Test the r2eff_lm63() function for no exchange when dw = 0.0, pA = 1.0, and kex = 0.0.""" 164 165 # Parameter reset. 166 self.dw = 0.0 167 self.kex = 0.0 168 169 # Calculate and check the R2eff values. 170 self.calc_r2eff()
171 172
173 - def test_lm63_no_rex8(self):
174 """Test the r2eff_lm63() function for no exchange when kex = 1e20.""" 175 176 # Parameter reset. 177 self.kex = 1e20 178 179 # Calculate and check the R2eff values. 180 self.calc_r2eff()
181