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 arctan2, array, cos, float64, int16, pi, sin, zeros
25 from unittest import TestCase
26
27
28 from lib.dispersion.tap03 import r1rho_TAP03
29
30
32 """Unit tests for the lib.dispersion.tap03 relax module."""
33
35 """Set up for all unit tests."""
36
37
38
39
40
41 self.r1rho_prime = 5.0
42
43 self.omega = -35670.44192
44
45 self.offset = -35040.3526693
46
47
48 self.pA = 0.95
49
50 self.dw = 0.5
51 self.kex = 1000.0
52
53 self.r1 = 1.0
54
55 self.spin_lock_nu1 = array([ 1000., 1500., 2000., 2500., 3000., 3500., 4000., 4500., 5000., 5500., 6000.])
56
57
58 self.sfrq = 599.8908617*1E6
59
60
61 self.num_points = 11
62 self.R1rho = zeros(self.num_points, float64)
63
64
66 """Calculate and check the R1rho values."""
67
68
69 pB, dw_frq, spin_lock_omega1, spin_lock_omega1_squared = self.param_conversion(pA=self.pA, dw=self.dw, sfrq=self.sfrq, spin_lock_nu1=self.spin_lock_nu1)
70
71
72 r1rho_TAP03(r1rho_prime=self.r1rho_prime, omega=self.omega, offset=self.offset, pA=self.pA, pB=pB, dw=dw_frq, kex=self.kex, R1=self.r1, spin_lock_fields=spin_lock_omega1, spin_lock_fields2=spin_lock_omega1_squared, back_calc=self.R1rho, num_points=self.num_points)
73
74
75
76 Wa = self.omega
77
78
79 Wb = self.omega + dw_frq
80
81
82 W = self.pA * Wa + pB * Wb
83
84
85 d = W - self.offset
86
87
88 theta = arctan2(spin_lock_omega1, d)
89 r1rho_no_rex = self.r1 * cos(theta)**2 + self.r1rho_prime * sin(theta)**2
90
91
92 for i in range(self.num_points):
93 self.assertAlmostEqual(self.R1rho[i], r1rho_no_rex[i])
94
95
97 """Convert the parameters.
98
99 @keyword pA: The population of state A.
100 @type pA: float
101 @keyword dw: The chemical exchange difference between states A and B in ppm.
102 @type dw: float
103 @keyword sfrq: The spin Larmor frequencies in Hz.
104 @type sfrq: float
105 @keyword spin_lock_nu1: The spin-lock field strengths in Hertz.
106 @type spin_lock_nu1: float
107 @return: The parameters {pB, dw_frq, spin_lock_omega1, spin_lock_omega1_squared}.
108 @rtype: tuple of float
109 """
110
111
112 pB = 1.0 - pA
113
114
115 frqs = sfrq * 2 * pi
116
117
118 dw_frq = dw * frqs / 1.e6
119
120
121 spin_lock_omega1 = (2. * pi * spin_lock_nu1)
122
123
124 spin_lock_omega1_squared = spin_lock_omega1**2
125
126
127 return pB, dw_frq, spin_lock_omega1, spin_lock_omega1_squared
128
129
131 """Test the r1rho_tap03() function for no exchange when dw = 0.0."""
132
133
134 self.dw = 0.0
135
136
137 self.calc_r1rho()
138
139
141 """Test the r1rho_tap03() function for no exchange when pA = 1.0."""
142
143
144 self.pA = 1.0
145
146
147 self.calc_r1rho()
148
149
151 """Test the r1rho_tap03() function for no exchange when kex = 0.0."""
152
153
154 self.kex = 0.0
155
156
157 self.calc_r1rho()
158
159
161 """Test the r1rho_tap03() function for no exchange when dw = 0.0 and pA = 1.0."""
162
163
164 self.pA = 1.0
165 self.dw = 0.0
166
167
168 self.calc_r1rho()
169
170
172 """Test the r1rho_tap03() function for no exchange when dw = 0.0 and kex = 0.0."""
173
174
175 self.dw = 0.0
176 self.kex = 0.0
177
178
179 self.calc_r1rho()
180
181
183 """Test the r1rho_tap03() function for no exchange when pA = 1.0 and kex = 0.0."""
184
185
186 self.pA = 1.0
187 self.kex = 0.0
188
189
190 self.calc_r1rho()
191
192
194 """Test the r1rho_tap03() function for no exchange when dw = 0.0, pA = 1.0, and kex = 0.0."""
195
196
197 self.dw = 0.0
198 self.kex = 0.0
199
200
201 self.calc_r1rho()
202
203
205 """Test the r1rho_tap03() function for no exchange when kex = 1e20."""
206
207
208 self.kex = 1e20
209
210
211 self.calc_r1rho()
212