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, int16, 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
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
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
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
84 pB = 1.0 - pA
85
86
87 frqs = sfrq * 2 * pi
88
89
90 phi_ex = pA * pB * (dw / 1.e6)**2
91
92
93 phi_ex_scaled = phi_ex * frqs**2
94
95
96 return phi_ex_scaled
97
98
100 """Test the r2eff_lm63() function for no exchange when dw = 0.0."""
101
102
103 self.dw = 0.0
104
105
106 self.calc_r2eff()
107
108
110 """Test the r2eff_lm63() function for no exchange when pA = 1.0."""
111
112
113 self.pA = 1.0
114
115
116 self.calc_r2eff()
117
118
120 """Test the r2eff_lm63() function for no exchange when kex = 0.0."""
121
122
123 self.kex = 0.0
124
125
126 self.calc_r2eff()
127
128
130 """Test the r2eff_lm63() function for no exchange when dw = 0.0 and pA = 1.0."""
131
132
133 self.pA = 1.0
134 self.dw = 0.0
135
136
137 self.calc_r2eff()
138
139
141 """Test the r2eff_lm63() function for no exchange when dw = 0.0 and kex = 0.0."""
142
143
144 self.dw = 0.0
145 self.kex = 0.0
146
147
148 self.calc_r2eff()
149
150
152 """Test the r2eff_lm63() function for no exchange when pA = 1.0 and kex = 0.0."""
153
154
155 self.pA = 1.0
156 self.kex = 0.0
157
158
159 self.calc_r2eff()
160
161
163 """Test the r2eff_lm63() function for no exchange when dw = 0.0, pA = 1.0, and kex = 0.0."""
164
165
166 self.dw = 0.0
167 self.kex = 0.0
168
169
170 self.calc_r2eff()
171
172
174 """Test the r2eff_lm63() function for no exchange when kex = 1e20."""
175
176
177 self.kex = 1e20
178
179
180 self.calc_r2eff()
181