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