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.cr72 import r2eff_CR72
28
29
31 """Unit tests for the lib.dispersion.cr72 relax module."""
32
34 """Set up for all unit tests."""
35
36
37 self.r20a = 2.0
38 self.r20b = 4.0
39 self.pA = 0.95
40 self.dw = 2.0
41 self.kex = 1000.0
42
43
44 self.num_points = 7
45 self.ncyc = array([2, 4, 8, 10, 20, 40, 500])
46 relax_times = 0.04
47 self.cpmg_frqs = self.ncyc / relax_times
48 self.R2eff = zeros(self.num_points, float64)
49
50
51 self.sfrq = 200. * 1E6
52
53
55 """Calculate and check the R2eff values."""
56
57
58 k_AB, k_BA, pB, dw_frq = self.param_conversion(pA=self.pA, kex=self.kex, dw=self.dw, sfrq=self.sfrq)
59
60
61 r2eff_CR72(r20a=self.r20a, r20b=self.r20b, pA=self.pA, dw=dw_frq, kex=self.kex, cpmg_frqs=self.cpmg_frqs, back_calc=self.R2eff, num_points=self.num_points)
62
63
64 for i in range(self.num_points):
65 self.assertAlmostEqual(self.R2eff[i], self.r20a)
66
67
69 """Convert the parameters.
70
71 @keyword pA: The population of state A.
72 @type pA: float
73 @keyword kex: The rate of exchange.
74 @type kex: 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 {k_AB, k_BA, pB, dw_frq}.
80 @rtype: tuple of float
81 """
82
83
84 pB = 1.0 - pA
85
86
87 k_BA = pA * kex
88 k_AB = pB * kex
89
90
91 frqs = sfrq * 2 * pi
92
93
94 dw_frq = dw * frqs / 1.e6
95
96
97 return k_AB, k_BA, pB, dw_frq
98
99
101 """Test the r2eff_cr72() function for no exchange when dw = 0.0."""
102
103
104 self.dw = 0.0
105
106
107 self.calc_r2eff()
108
109
111 """Test the r2eff_cr72() function for no exchange when pA = 1.0."""
112
113
114 self.pA = 1.0
115
116
117 self.calc_r2eff()
118
119
121 """Test the r2eff_cr72() function for no exchange when kex = 0.0."""
122
123
124 self.kex = 0.0
125
126
127 self.calc_r2eff()
128
129
131 """Test the r2eff_cr72() function for no exchange when dw = 0.0 and pA = 1.0."""
132
133
134 self.pA = 1.0
135 self.dw = 0.0
136
137
138 self.calc_r2eff()
139
140
142 """Test the r2eff_cr72() function for no exchange when dw = 0.0 and kex = 0.0."""
143
144
145 self.dw = 0.0
146 self.kex = 0.0
147
148
149 self.calc_r2eff()
150
151
153 """Test the r2eff_cr72() function for no exchange when pA = 1.0 and kex = 0.0."""
154
155
156 self.pA = 1.0
157 self.kex = 0.0
158
159
160 self.calc_r2eff()
161
162
164 """Test the r2eff_cr72() function for no exchange when dw = 0.0, pA = 1.0, and kex = 0.0."""
165
166
167 self.dw = 0.0
168 self.kex = 0.0
169
170
171 self.calc_r2eff()
172
173
175 """Test the r2eff_cr72() function for no exchange when kex = 1e5."""
176
177
178 self.kex = 1e5
179
180
181 self.calc_r2eff()
182