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, int16, 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
66 r1rho_M61(r1rho_prime=self.r1rho_prime, phi_ex=phi_ex_scaled, kex=self.kex, spin_lock_fields2=spin_lock_omega1_squared, back_calc=self.R1rho, num_points=self.num_points)
67
68
69
70 if self.kex > 1.e5:
71 for i in range(self.num_points):
72 self.assertAlmostEqual(self.R1rho[i], self.r1rho_prime, 2)
73 else:
74 for i in range(self.num_points):
75 self.assertAlmostEqual(self.R1rho[i], self.r1rho_prime)
76
77
79 """Convert the parameters.
80
81 @keyword pA: The population of state A.
82 @type pA: float
83 @keyword dw: The chemical exchange difference between states A and B in ppm.
84 @type dw: float
85 @keyword sfrq: The spin Larmor frequencies in Hz.
86 @type sfrq: float
87 @keyword spin_lock_nu1: The spin-lock field strengths in Hertz.
88 @type spin_lock_nu1: float
89 @return: The parameters {phi_ex_scaled, k_BA}.
90 @rtype: tuple of float
91 """
92
93
94 pB = 1.0 - pA
95
96
97 frqs = sfrq * 2 * pi
98
99
100 phi_ex = pA * pB * (dw / 1.e6)**2
101
102
103 phi_ex_scaled = phi_ex * frqs**2
104
105
106 spin_lock_omega1_squared = (2. * pi * spin_lock_nu1)**2
107
108
109 return phi_ex_scaled, spin_lock_omega1_squared
110
111
113 """Test the r1rho_m61() function for no exchange when dw = 0.0."""
114
115
116 self.dw = 0.0
117
118
119 self.calc_r1rho()
120
121
123 """Test the r1rho_m61() function for no exchange when pA = 1.0."""
124
125
126 self.pA = 1.0
127
128
129 self.calc_r1rho()
130
131
133 """Test the r1rho_m61() function for no exchange when kex = 0.0."""
134
135
136 self.kex = 0.0
137
138
139 self.calc_r1rho()
140
141
143 """Test the r1rho_m61() function for no exchange when dw = 0.0 and pA = 1.0."""
144
145
146 self.pA = 1.0
147 self.dw = 0.0
148
149
150 self.calc_r1rho()
151
152
154 """Test the r1rho_m61() function for no exchange when dw = 0.0 and kex = 0.0."""
155
156
157 self.dw = 0.0
158 self.kex = 0.0
159
160
161 self.calc_r1rho()
162
163
165 """Test the r1rho_m61() function for no exchange when pA = 1.0 and kex = 0.0."""
166
167
168 self.pA = 1.0
169 self.kex = 0.0
170
171
172 self.calc_r1rho()
173
174
176 """Test the r1rho_m61() function for no exchange when dw = 0.0, pA = 1.0, and kex = 0.0."""
177
178
179 self.dw = 0.0
180 self.kex = 0.0
181
182
183 self.calc_r1rho()
184
185
187 """Test the r1rho_m61() function for no exchange when kex = 1e20."""
188
189
190 self.kex = 1e20
191
192
193 self.calc_r1rho()
194