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