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, ones, pi, zeros
25 from unittest import TestCase
26
27
28 from lib.dispersion.m61 import r1rho_M61
29
30
32 """Unit tests for the lib.dispersion.m61 relax module."""
33
35 """Set up for all unit tests."""
36
37
38 self.r1rho_prime = 2.5
39
40 self.pA = 0.95
41
42 self.dw = 0.5
43 self.kex = 1000.0
44
45 self.r1 = 1.0
46
47 self.spin_lock_nu1 = array([ 1000., 1500., 2000., 2500., 3000., 3500., 4000., 4500., 5000., 5500., 6000.])
48
49 self.theta = array([1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966])
50
51
52 self.sfrq = 599.8908617*1E6
53
54
55 self.num_points = 11
56 self.R1rho = zeros(self.num_points, float64)
57
58
60 """Calculate and check the R1rho values."""
61
62
63 phi_ex_scaled, spin_lock_omega1_squared = self.param_conversion(pA=self.pA, dw=self.dw, sfrq=self.sfrq, spin_lock_nu1=self.spin_lock_nu1)
64
65 a = ones([self.num_points])
66
67
68 r1rho_M61(r1rho_prime=self.r1rho_prime*a, phi_ex=phi_ex_scaled*a, kex=self.kex, spin_lock_fields2=spin_lock_omega1_squared, back_calc=self.R1rho)
69
70
71 if self.kex > 1.e5:
72 for i in range(self.num_points):
73 self.assertAlmostEqual(self.R1rho[i], self.r1rho_prime, 2)
74 else:
75 for i in range(self.num_points):
76 self.assertAlmostEqual(self.R1rho[i], self.r1rho_prime)
77
78
80 """Convert the parameters.
81
82 @keyword pA: The population of state A.
83 @type pA: float
84 @keyword dw: The chemical exchange difference between states A and B in ppm.
85 @type dw: float
86 @keyword sfrq: The spin Larmor frequencies in Hz.
87 @type sfrq: float
88 @keyword spin_lock_nu1: The spin-lock field strengths in Hertz.
89 @type spin_lock_nu1: float
90 @return: The parameters {phi_ex_scaled, k_BA}.
91 @rtype: tuple of float
92 """
93
94
95 pB = 1.0 - pA
96
97
98 frqs = sfrq * 2 * pi
99
100
101 phi_ex = pA * pB * (dw / 1.e6)**2
102
103
104 phi_ex_scaled = phi_ex * frqs**2
105
106
107 spin_lock_omega1_squared = (2. * pi * spin_lock_nu1)**2
108
109
110 return phi_ex_scaled, spin_lock_omega1_squared
111
112
114 """Test the r1rho_m61() function for no exchange when dw = 0.0."""
115
116
117 self.dw = 0.0
118
119
120 self.calc_r1rho()
121
122
124 """Test the r1rho_m61() function for no exchange when pA = 1.0."""
125
126
127 self.pA = 1.0
128
129
130 self.calc_r1rho()
131
132
134 """Test the r1rho_m61() function for no exchange when kex = 0.0."""
135
136
137 self.kex = 0.0
138
139
140 self.calc_r1rho()
141
142
144 """Test the r1rho_m61() function for no exchange when dw = 0.0 and pA = 1.0."""
145
146
147 self.pA = 1.0
148 self.dw = 0.0
149
150
151 self.calc_r1rho()
152
153
155 """Test the r1rho_m61() function for no exchange when dw = 0.0 and kex = 0.0."""
156
157
158 self.dw = 0.0
159 self.kex = 0.0
160
161
162 self.calc_r1rho()
163
164
166 """Test the r1rho_m61() function for no exchange when pA = 1.0 and kex = 0.0."""
167
168
169 self.pA = 1.0
170 self.kex = 0.0
171
172
173 self.calc_r1rho()
174
175
177 """Test the r1rho_m61() function for no exchange when dw = 0.0, pA = 1.0, and kex = 0.0."""
178
179
180 self.dw = 0.0
181 self.kex = 0.0
182
183
184 self.calc_r1rho()
185
186
188 """Test the r1rho_m61() function for no exchange when kex = 1e20."""
189
190
191 self.kex = 1e20
192
193
194 self.calc_r1rho()
195