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.lm63 import r2eff_LM63
29
30
32 """Unit tests for the lib.dispersion.lm63 relax module."""
33
35 """Set up for all unit tests."""
36
37
38 self.r20 = 2.0
39 self.pA = 0.95
40 self.dw = 0.5
41 self.kex = 100.0
42
43
44 self.sfrq = 599.8908617*1E6
45
46
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
53 """Calculate and check the R2eff values."""
54
55
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
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
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
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
86 pB = 1.0 - pA
87
88
89 frqs = sfrq * 2 * pi
90
91
92 phi_ex = pA * pB * (dw / 1.e6)**2
93
94
95 phi_ex_scaled = phi_ex * frqs**2
96
97
98 return phi_ex_scaled
99
100
102 """Test the r2eff_lm63() function for no exchange when dw = 0.0."""
103
104
105 self.dw = 0.0
106
107
108 self.calc_r2eff()
109
110
112 """Test the r2eff_lm63() function for no exchange when pA = 1.0."""
113
114
115 self.pA = 1.0
116
117
118 self.calc_r2eff()
119
120
122 """Test the r2eff_lm63() function for no exchange when kex = 0.0."""
123
124
125 self.kex = 0.0
126
127
128 self.calc_r2eff()
129
130
132 """Test the r2eff_lm63() function for no exchange when dw = 0.0 and pA = 1.0."""
133
134
135 self.pA = 1.0
136 self.dw = 0.0
137
138
139 self.calc_r2eff()
140
141
143 """Test the r2eff_lm63() function for no exchange when dw = 0.0 and kex = 0.0."""
144
145
146 self.dw = 0.0
147 self.kex = 0.0
148
149
150 self.calc_r2eff()
151
152
154 """Test the r2eff_lm63() function for no exchange when pA = 1.0 and kex = 0.0."""
155
156
157 self.pA = 1.0
158 self.kex = 0.0
159
160
161 self.calc_r2eff()
162
163
165 """Test the r2eff_lm63() function for no exchange when dw = 0.0, pA = 1.0, and kex = 0.0."""
166
167
168 self.dw = 0.0
169 self.kex = 0.0
170
171
172 self.calc_r2eff()
173
174
176 """Test the r2eff_lm63() function for no exchange when kex = 1e20."""
177
178
179 self.kex = 1e20
180
181
182 self.calc_r2eff()
183