1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 from numpy import array, float64, int16, pi, zeros
24 from unittest import TestCase
25
26
27 from lib.dispersion.it99 import r2eff_IT99
28
29
31 """Unit tests for the lib.dispersion.it99 relax module."""
32
34 """Set up for all unit tests."""
35
36
37 self.r20 = 2.0
38 self.pA = 0.95
39 self.dw = 2.0
40 self.kex = 1000.0
41
42
43 self.num_points = 7
44 self.ncyc = array([2, 4, 8, 10, 20, 40, 500])
45 relax_times = 0.04
46 self.cpmg_frqs = self.ncyc / relax_times
47 self.R2eff = zeros(self.num_points, float64)
48
49
50 self.sfrq = 200. * 1E6
51
52
54 """Calculate and check the R2eff values."""
55
56
57 pB, dw_frq, tex = self.param_conversion(pA=self.pA, kex=self.kex, dw=self.dw, sfrq=self.sfrq)
58
59
60 r2eff_IT99(r20=self.r20, pA=self.pA, pB=pB, dw=dw_frq, tex=tex, cpmg_frqs=self.cpmg_frqs, back_calc=self.R2eff, num_points=self.num_points)
61
62
63 if self.kex > 1.e5:
64 for i in range(self.num_points):
65 self.assertAlmostEqual(self.R2eff[i], self.r20, 2)
66 else:
67 for i in range(self.num_points):
68 self.assertAlmostEqual(self.R2eff[i], self.r20)
69
70
72 """Convert the parameters.
73
74 @keyword pA: The population of state A.
75 @type pA: float
76 @keyword kex: The rate of exchange.
77 @type kex: float
78 @keyword dw: The chemical exchange difference between states A and B in ppm.
79 @type dw: float
80 @keyword sfrq: The spin Larmor frequencies in Hz.
81 @type sfrq: float
82 @return: The parameters {pB, dw_frq, tex}.
83 @rtype: tuple of float
84 """
85
86
87 pB = 1.0 - pA
88
89
90 frqs = sfrq * 2 * pi
91
92
93 dw_frq = dw * frqs / 1.e6
94
95
96 if kex == 0.0:
97 tex = 0.0
98 else:
99 tex = 1 / (2*kex)
100
101
102 return pB, dw_frq, tex
103
104
106 """Test the r2eff_it99() function for no exchange when dw = 0.0."""
107
108
109 self.dw = 0.0
110
111
112 self.calc_r2eff()
113
114
116 """Test the r2eff_it99() function for no exchange when pA = 1.0."""
117
118
119 self.pA = 1.0
120
121
122 self.calc_r2eff()
123
124
126 """Test the r2eff_it99() function for no exchange when kex = 0.0."""
127
128
129 self.kex = 0.0
130
131
132 self.calc_r2eff()
133
134
136 """Test the r2eff_it99() function for no exchange when dw = 0.0 and pA = 1.0."""
137
138
139 self.pA = 1.0
140 self.dw = 0.0
141
142
143 self.calc_r2eff()
144
145
147 """Test the r2eff_it99() function for no exchange when dw = 0.0 and kex = 0.0."""
148
149
150 self.dw = 0.0
151 self.kex = 0.0
152
153
154 self.calc_r2eff()
155
156
158 """Test the r2eff_it99() function for no exchange when pA = 1.0 and kex = 0.0."""
159
160
161 self.pA = 1.0
162 self.kex = 0.0
163
164
165 self.calc_r2eff()
166
167
169 """Test the r2eff_it99() function for no exchange when dw = 0.0, pA = 1.0, and kex = 0.0."""
170
171
172 self.dw = 0.0
173 self.kex = 0.0
174
175
176 self.calc_r2eff()
177
178
180 """Test the r2eff_cr72() function for no exchange when kex = 1e19."""
181
182
183 self.kex = 1e19
184
185
186 self.calc_r2eff()
187