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