1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 from numpy import array, float64, ones, pi, zeros
25 from unittest import TestCase
26
27
28 from lib.dispersion.tsmfk01 import r2eff_TSMFK01
29
30
32 """Unit tests for the lib.dispersion.tsmfk01 relax module."""
33
35 """Set up for all unit tests."""
36
37
38 self.r20a = 2.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.tau_cpmg = 0.25 / self.cpmg_frqs
49 self.R2eff = zeros(self.num_points, float64)
50
51
52 self.sfrq = 200. * 1E6
53
54
56 """Calculate and check the R2eff values."""
57
58
59 k_AB, k_BA, pB, dw_frq = self.param_conversion(pA=self.pA, kex=self.kex, dw=self.dw, sfrq=self.sfrq)
60
61 a = ones([self.num_points])
62
63
64 r2eff_TSMFK01(r20a=self.r20a*a, dw=dw_frq*a, dw_orig=dw_frq, k_AB=k_AB, tcp=self.cpmg_frqs, back_calc=self.R2eff)
65
66
67 for i in range(self.num_points):
68 self.assertAlmostEqual(self.R2eff[i], self.r20a)
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 {k_AB, k_BA, pB, dw_frq}.
83 @rtype: tuple of float
84 """
85
86
87 pB = 1.0 - pA
88
89
90 k_BA = pA * kex
91 k_AB = pB * kex
92
93
94 frqs = sfrq * 2 * pi
95
96
97 dw_frq = dw * frqs / 1.e6
98
99
100 return k_AB, k_BA, pB, dw_frq
101
102
104 """Test the r2eff_tsmfk01() function for no exchange when dw = 0.0."""
105
106
107 self.dw = 0.0
108
109
110 self.calc_r2eff()
111
112
114 """Test the r2eff_tsmfk01() function for no exchange when pA = 1.0."""
115
116
117 self.pA = 1.0
118
119
120 self.calc_r2eff()
121
122
124 """Test the r2eff_tsmfk01() function for no exchange when kex = 0.0."""
125
126
127 self.kex = 0.0
128
129
130 self.calc_r2eff()
131
132
134 """Test the r2eff_tsmfk01() function for no exchange when dw = 0.0 and pA = 1.0."""
135
136
137 self.pA = 1.0
138 self.dw = 0.0
139
140
141 self.calc_r2eff()
142
143
145 """Test the r2eff_tsmfk01() function for no exchange when dw = 0.0 and kex = 0.0."""
146
147
148 self.dw = 0.0
149 self.kex = 0.0
150
151
152 self.calc_r2eff()
153
154
156 """Test the r2eff_tsmfk01() function for no exchange when pA = 1.0 and kex = 0.0."""
157
158
159 self.pA = 1.0
160 self.kex = 0.0
161
162
163 self.calc_r2eff()
164
165
167 """Test the r2eff_tsmfk01() function for no exchange when dw = 0.0, pA = 1.0, and kex = 0.0."""
168
169
170 self.dw = 0.0
171 self.kex = 0.0
172
173
174 self.calc_r2eff()
175